/* ETM365 V0.4.7 – responsive desktop + mobile design.
   Requires approved V0.4.5 full-bleed styling. No change to trial or API logic.
   Rules intentionally cover public landing, driver/operator trial, and staff preview. */

/* General: protect against narrow-screen overflow without altering the desktop brand. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#app { min-width: 0; }
body { overflow-x: clip; }
button, .btn, .sidebtn { touch-action: manipulation; }
input, textarea, select { max-width: 100%; }
img, svg { max-width: 100%; }

/* HERO – desktop: whole approved banner is visible at 100% browser zoom.
   Keep the existing transparent edges and all background neon trails. */
@media (min-width: 741px) {
  body[data-view="public"]:has(.hero) .hero {
    width: min(calc(100% - 24px), 1240px);
    max-width: none;
    margin: 0 auto -17px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
  }
  @supports (height: 100svh) {
    body[data-view="public"]:has(.hero) .hero {
      /* Width constrained by the height of the browser's content viewport. */
      width: min(calc(100% - 24px), 1240px, max(340px, calc(166svh - 282px)));
    }
  }
  body[data-view="public"]:has(.hero) .hero img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    mix-blend-mode: screen;
  }
}

/* HTML mobile presentation is hidden on desktop; original final banner stays intact. */
.etm-mobile-offer { display: none; }

/* Tablet 741–1024: content cards with readable touch controls. */
@media (min-width: 741px) and (max-width: 1024px) {
  body[data-view="public"]:has(.hero) .landing-grid,
  body[data-view="public"]:has(.hero) .features {
    width: calc(100% - 36px);
  }
  .topbar { padding-left: 18px; padding-right: 18px; }
  .navright { flex-wrap: wrap; justify-content: flex-end; }
  .portal .sidebar { width: 205px; min-width: 205px; }
  .portal .content { padding: 18px; }
  .record { min-width: 0; }
}

/* True phone / small tablet support, not browser zoom tricks. */
@media (max-width: 740px) {
  body[data-view="public"]:has(.hero),
  body[data-view="staff"] {
    overflow-x: clip;
  }
  .topbar {
    min-height: 67px;
    height: auto;
    gap: 9px;
    padding: 10px 14px;
    align-items: center;
  }
  .brand {
    font-size: clamp(22px, 7vw, 28px);
    line-height: 1.05;
    min-width: 0;
    flex: 1 1 auto;
  }
  .brand small {
    max-width: 220px;
    font-size: 10px;
    letter-spacing: 0;
    line-height: 1.2;
    margin-top: 4px;
    overflow-wrap: anywhere;
  }
  .navright { display: flex; gap: 4px; flex: 0 0 auto; max-width: 39%; }
  .navright .pill { display: none; }
  .navright .pill:first-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1.18;
    text-align: center;
    max-width: 118px;
    padding: 7px 8px;
    overflow-wrap: anywhere;
  }
  /* The original artwork is still visible, but no rectangular frame or overflow. */
  body[data-view="public"]:has(.hero) .container {
    width: 100%;
    padding: 0 0 26px;
    overflow: visible;
  }
  body[data-view="public"]:has(.hero) .hero {
    width: 100%;
    max-width: 100%;
    margin: 0 0 0;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden;
    box-shadow: none !important;
  }
  body[data-view="public"]:has(.hero) .hero img {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    object-fit: contain;
    mix-blend-mode: screen;
    border: 0 !important;
    border-radius: 0 !important;
  }
  /* Readable marketing information: avoids relying on tiny text baked into a PNG. */
  body[data-view="public"]:has(.hero) .etm-mobile-offer {
    display: block;
    position: relative;
    width: calc(100% - 24px);
    max-width: 610px;
    margin: -3px auto 16px;
    padding: 17px 16px 15px;
    color: #f2faff;
    background: linear-gradient(155deg, rgba(2,32,60,.78), rgba(0,12,30,.84));
    border: 1px solid rgba(0,217,255,.65);
    border-radius: 17px;
    box-shadow: 0 0 20px rgba(0,214,255,.15), inset 0 -1px rgba(0,249,255,.36);
    backdrop-filter: blur(8px);
    text-align: center;
  }
  .etm-mobile-offer .m-eyebrow {
    font-size: 10px;
    color: #27e8fa;
    text-transform: uppercase;
    letter-spacing: .17em;
    font-weight: 800;
  }
  .etm-mobile-offer h1 {
    font-size: clamp(24px, 7vw, 36px);
    line-height: 1.05;
    letter-spacing: -.02em;
    margin: 8px 0 5px;
    font-style: italic;
  }
  .etm-mobile-offer .m-sub { margin: 0 0 12px; color: #cceaff; font-size: 14px; }
  .etm-mobile-offer .m-price {
    display: inline-block;
    width: auto;
    padding: 10px 19px;
    border-radius: 999px;
    background: linear-gradient(110deg, #00eff4, #04acd8);
    box-shadow: 0 0 22px #08defb73, inset 0 0 0 2px #75faff;
    color: #06182e;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(23px, 7vw, 34px);
    line-height: 1.1;
    white-space: nowrap;
  }
  .etm-mobile-offer .m-unlimited { font-size: clamp(14px, 4.4vw, 18px); font-weight: 800; margin: 13px 0; }
  .etm-mobile-offer .m-unlimited span { color: #00ecff; }
  .etm-mobile-offer .m-plan-grid { display: grid; grid-template-columns: 1fr; gap: 9px; text-align: left; }
  .etm-mobile-offer .m-plan {
    padding: 11px 13px;
    border: 1px solid rgba(27,226,255,.55);
    border-radius: 12px;
    background: rgba(3,38,67,.68);
    line-height: 1.38;
    font-size: 13px;
  }
  .etm-mobile-offer .m-plan strong { display: block; font-size: 14px; color: #fff; }
  .etm-mobile-offer .m-plan em { display: block; color: #12efff; font-weight: 850; font-style: normal; }
  .etm-mobile-offer .m-note { font-size: 11px; line-height: 1.42; color: #b4d8e9; margin: 11px 0 0; }

  body[data-view="public"]:has(.hero) .landing-grid,
  body[data-view="public"]:has(.hero) .features {
    width: calc(100% - 24px);
    max-width: 610px;
    margin-left: auto;
    margin-right: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }
  body[data-view="public"]:has(.hero) .landing-grid { margin-top: 0; }
  body[data-view="public"]:has(.hero) .features { margin-top: 13px; }
  body[data-view="public"]:has(.hero) .glass,
  body[data-view="public"]:has(.hero) .feature {
    min-width: 0;
    padding: 17px 15px;
    border-radius: 15px;
  }
  body[data-view="public"]:has(.hero) .glass h2 { font-size: clamp(21px, 6.5vw, 27px); }
  body[data-view="public"]:has(.hero) .footer { margin: 22px 13px 6px; padding: 18px 0; }
  body[data-view="public"]:has(.hero)::before { background-size: auto 100%; opacity: .68; }
  .muted { overflow-wrap: anywhere; }
  .btn, input, textarea, select { font-size: 16px; } /* prevents auto-zoom on iOS */
  .btn { min-height: 44px; }
  .landing-grid .btn, .glass > .btn { width: 100%; }
  .control { min-height: 44px; }
  .status { overflow-wrap: anywhere; }

  /* Trial portal: horizontal navigation scrolls inside nav, never the page. */
  .portal { display: block; width: 100%; min-width: 0; }
  .portal .sidebar {
    width: 100%; min-width: 0; max-width: 100vw;
    overflow-x: auto; overflow-y: hidden;
    padding: 8px 10px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .portal .sidebrand { display: none; }
  .portal .sidenav { display: flex; flex-direction: row; width: max-content; max-width: none; gap: 5px; }
  .portal .sidebtn { flex: 0 0 auto; min-height: 44px; padding: 10px 12px; font-size: 13px; white-space: nowrap; }
  .portal .content { width: 100%; min-width: 0; padding: 15px 12px 28px; }
  .dashhead { align-items: flex-start; flex-direction: column; gap: 10px; }
  .dashhead h1 { font-size: clamp(21px, 6vw, 28px); overflow-wrap: anywhere; }
  .toplinks { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .bannerlite { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 13px 14px; }
  .bannerlite > div { text-align: left !important; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .stat { padding: 12px; min-width: 0; }
  .stat b { font-size: 22px; }
  .two { display: grid; grid-template-columns: minmax(0,1fr); gap: 13px; }
  .two > .glass { margin: 0; min-width: 0; }
  .formgrid { display: grid; grid-template-columns: minmax(0,1fr); }
  .records, .record, .trialrow { min-width: 0; }
  .record { flex-direction: column; gap: 10px; }
  .record .btn { align-self: flex-start; }
  .trialrow { align-items: stretch; }
  .trialrow .actions, .actions { max-width: 100%; gap: 7px; }
  .trialrow .actions .btn { flex: 1 1 auto; }
  .smallselect { max-width: 100%; min-width: 0; width: 100%; }
  .links .linkrow { flex-wrap: wrap; }
  .links .linkrow input { min-width: 0; width: 100%; flex: 1 1 100%; }
  .footer { overflow-wrap: anywhere; }
  body[data-view="staff"] .container { padding: 15px 12px 30px; max-width: 100%; }
  body[data-view="staff"] .glass { max-width: 100% !important; margin: 22px auto !important; padding: 18px 15px; }
}

/* Very narrow phones (e.g. 320px width). */
@media (max-width: 360px) {
  .topbar { padding: 9px 10px; }
  .brand { font-size: 22px; }
  .brand small { font-size: 9px; max-width: 168px; }
  .navright .pill:first-child { font-size: 8px; padding: 5px; max-width: 101px; }
  .etm-mobile-offer .m-price { padding: 9px 15px; font-size: 22px; }
  .etm-mobile-offer .m-plan { font-size: 12px; }
  .stats { gap: 6px; }
}

/* Accessible focus visibility on desktop and mobile. */
:where(button, input, textarea, select, a):focus-visible {
  outline: 2px solid #19e6ff;
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
