/* Phone handoff page: the brand hero on top, each state in a sheet that rises from the bottom with the footer as its
   last block, and from 48rem the sheet as a floating panel. Fonts are self-hosted (font-src 'self'); sizes are in rem so
   the page reflows at 200 % zoom, and every touch target is at least 44 px tall. Tokens are the marketing site's brand
   palette, by the same names. */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Bebas Neue";
  src: url("fonts/bebas-neue-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --color-navy-900: #011627;
  --color-navy-800: #062236;
  --color-navy-700: #0f2e45;
  --color-navy-600: #1d3f58;
  --color-navy-500: #33536c;
  --color-navy-400: #5c7488;
  --color-navy-300: #8b9dac;
  --color-navy-200: #bcc7d0;
  --color-navy-100: #dee4e9;
  --color-cream-0: #fdfffc;
  --color-teal-500: #2ec4b6;
  --color-teal-400: #5cd3c8;
  --color-orange-500: #ff9f1c;
  --warn-text: #ffc27a; /* the mock's warning text; not a brand token */
  --shadow-focus: 0 0 0 3px rgba(46, 196, 182, 0.35);
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bebas Neue", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* 4 / 8 / 12 / 16 / 24 / 32 / 48 px. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --radius: 0.75rem;
  --radius-sheet: 1.5rem;
  --edge: var(--color-navy-400); /* 3.3:1 on the sheet, so field and control edges meet non-text contrast. */
  --hairline: var(--color-navy-600);
  --teal-line: rgba(92, 211, 200, 0.32);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--color-navy-900); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-navy-900);
  color: var(--color-cream-0);
  font: 1rem/1.5 var(--font-sans);
}
p { margin: 0; }
b { font-weight: 600; color: var(--color-cream-0); }
a { color: var(--color-teal-400); }
button { font: inherit; }

/* --- the page --- */

.page {
  --gutter: clamp(1.25rem, 6vw, 1.5rem);
  --inset-l: calc(var(--gutter) + env(safe-area-inset-left, 0px));
  --inset-r: calc(var(--gutter) + env(safe-area-inset-right, 0px));
  /* On wide phones and small tablets the sheet stays full width but its content keeps a readable column. */
  --pad-l: max(var(--inset-l), calc((100% - 30rem) / 2));
  --pad-r: max(var(--inset-r), calc((100% - 30rem) / 2));
  --hero-pad: clamp(1.75rem, 8.5vh, 4.5rem);
  --logo-h: 2.375rem;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 22rem at 50% 0%, rgba(46, 196, 182, 0.17), rgba(46, 196, 182, 0.05) 60%, rgba(46, 196, 182, 0) 100%),
    var(--color-navy-900);
  text-align: center;
}
@supports (height: 1svh) {
  .page { --hero-pad: clamp(1.75rem, 8.5svh, 4.5rem); }
}
/* The form needs its room: a shorter hero and a smaller logo while it shows. */
.page:has(#state-form:not([hidden])) { --hero-pad: clamp(1rem, 3vh, 1.5rem); --logo-h: 1.75rem; }

/* The signal motif: faint rings around the logo over scanlines, fading out before the sheet. */
.page::before {
  --ring-at: 50% calc(var(--hero-pad) + env(safe-area-inset-top, 0px) + var(--logo-h) / 2);
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 auto;
  height: 26rem;
  pointer-events: none;
  background:
    repeating-radial-gradient(circle at var(--ring-at),
      rgba(92, 211, 200, 0) 0, rgba(92, 211, 200, 0) 2.3rem, rgba(92, 211, 200, 0.1) 2.4rem, rgba(92, 211, 200, 0) 2.5rem),
    repeating-linear-gradient(180deg, rgba(253, 255, 252, 0.035) 0 1px, rgba(253, 255, 252, 0) 1px 4px);
  -webkit-mask-image: radial-gradient(75% 85% at 50% 0%, #000 35%, transparent 100%);
  mask-image: radial-gradient(75% 85% at 50% 0%, #000 35%, transparent 100%);
}

.frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.hero {
  display: flex;
  justify-content: center;
  padding: calc(var(--hero-pad) + env(safe-area-inset-top, 0px)) var(--inset-r) 0 var(--inset-l);
}
.hero svg {
  display: block;
  height: var(--logo-h);
  width: auto;
  max-width: 100%;
  fill: currentColor;
}
.hero .accent { fill: var(--color-orange-500); }

main { flex: 1 0 auto; display: flex; flex-direction: column; }
main > section { flex: 1 0 auto; display: flex; flex-direction: column; }

/* Each state's line under the logo. */
.lede {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3) var(--inset-r) var(--hero-pad) var(--inset-l);
}
.tagline {
  max-width: 22em;
  color: var(--color-navy-100);
  letter-spacing: 0.01em;
  text-wrap: balance;
}
/* On the form the line is the ticket, as wide as the sheet's content under it. */
.lede-form { align-items: stretch; padding: var(--space-6) var(--pad-r) var(--space-4) var(--pad-l); }

/* --- the ticket: the TV's code, the countdown as its stub, and the way out as its last row --- */

.pair {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "icon code timer" "swap swap swap";
  overflow: hidden;
  border: 1px solid var(--teal-line);
  border-radius: var(--space-4);
  background: rgba(1, 22, 39, 0.65);
  text-align: left;
}
.pair > span:first-child {
  grid-area: code;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.125rem;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3);
}
.pair b { font: 400 1.375rem/1.2 var(--font-mono); letter-spacing: 0.1em; }
.pair .label {
  color: var(--color-navy-300);
  font: 600 0.6875rem/1.3 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pair .tv {
  grid-area: icon;
  align-self: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0 var(--space-1) 0 var(--space-4);
  color: var(--color-teal-400);
  stroke-width: 1.8;
}
.pair .timer {
  grid-area: timer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.125rem;
  min-width: 4.75rem;
  padding: var(--space-3);
  border-left: 2px dashed rgba(92, 211, 200, 0.3);
  color: var(--color-navy-100);
  font: 400 1.125rem/1.3 var(--font-mono);
  text-align: center;
}
.pair .swap {
  grid-area: swap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border-top: 1px solid rgba(92, 211, 200, 0.2);
  background: rgba(92, 211, 200, 0.06);
  font: 600 0.8125rem/1.3 var(--font-sans);
  text-underline-offset: 0.2em;
  white-space: nowrap;
}
.pair .swap svg { width: 0.875rem; height: 0.875rem; }

/* --- the sheet --- */

.sheet {
  position: relative;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6) var(--pad-r) var(--space-6) var(--pad-l);
  background: var(--color-navy-800);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: 0 -1px 0 rgba(253, 255, 252, 0.08), 0 -18px 40px -16px rgba(0, 0, 0, 0.6);
}
/* The grab handle: decorative, so a pseudo-element, which assistive tech skips. */
.sheet::before {
  content: "";
  position: absolute;
  top: var(--space-3);
  left: 50%;
  width: 2.25rem;
  height: var(--space-1);
  margin-left: -1.125rem;
  border-radius: 999px;
  background: var(--color-navy-500);
}

h1 {
  margin: 0;
  font: 400 2.125rem/1.05 var(--font-display);
  letter-spacing: 0.03em;
  text-wrap: balance;
}
[data-heading]:focus { outline: none; }
.head { display: flex; flex-direction: column; gap: var(--space-2); }
.muted {
  max-width: 34em;
  margin-inline: auto;
  color: var(--color-navy-200);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Checking: an indeterminate bar under the status line. */
.status { color: var(--color-navy-100); font-size: 1.0625rem; }
.progress {
  position: relative;
  height: var(--space-1);
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-navy-700);
}
.progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  border-radius: inherit;
  background: var(--color-teal-500);
}

/* --- forms --- */

.stack { display: flex; flex-direction: column; gap: var(--space-5); margin: 0; }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font: 600 0.875rem/1.3 var(--font-sans); color: var(--color-navy-100); }
.field .optional { color: var(--color-navy-300); font-weight: 400; }
.field input {
  width: 100%;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0 var(--space-4);
  background: var(--color-navy-900);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  color: var(--color-cream-0);
  font: 1rem/1.25 var(--font-sans); /* 16 px keeps iOS from zooming into the field. */
  text-align: left; /* What a viewer types, such as a long URL, reads from the start. */
}
.field input::placeholder { color: var(--color-navy-300); opacity: 1; }
.field input[aria-invalid="true"] { border-color: var(--color-orange-500); }
.field input:focus-visible { outline: none; border-color: var(--color-teal-500); box-shadow: var(--shadow-focus); }
.field input.code {
  min-height: 3.75rem;
  font: 1.75rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.field .row { display: flex; gap: var(--space-2); }
.help { color: var(--color-navy-300); font-size: 0.8125rem; }
.error { color: var(--color-orange-500); font-size: 0.875rem; }
.warn {
  padding: var(--space-3) var(--space-4);
  border: 1px solid #ff9f1c80;
  border-radius: var(--radius);
  background: #ff9f1c1a;
  color: var(--warn-text);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* M3U / Xtream: a segmented control in a well. */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--edge);
  border-radius: calc(var(--radius) + var(--space-1));
  background: var(--color-navy-900);
}
.seg button {
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-1);
  border: 0;
  border-radius: var(--space-2);
  background: transparent;
  color: var(--color-navy-200);
  font: 600 0.9375rem var(--font-sans);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--color-teal-500); color: var(--color-navy-900); }
.seg button:focus-visible { outline-color: var(--color-cream-0); }

.toggle {
  min-height: 3.25rem;
  min-width: 4.5rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--color-navy-700);
  color: var(--color-navy-100);
  font: 600 0.875rem var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
}

/* The security and deletion facts, right above the button they're about. */
.fine {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: rgba(46, 196, 182, 0.07);
  color: var(--color-navy-200);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.fine svg { width: 1rem; height: 1rem; margin-top: 0.125rem; color: var(--color-teal-400); }

.btn {
  width: 100%;
  min-height: 3.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-cream-0);
  color: var(--color-navy-900);
  font: 700 1.0625rem var(--font-sans);
  letter-spacing: 0.01em;
  cursor: pointer;
}
.btn:active:not(:disabled) { background: var(--color-navy-100); }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* --- final states: a badge, the heading group, and a way back where one helps --- */

.badge {
  align-self: center;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--space-4);
  background: rgba(46, 196, 182, 0.14);
  color: var(--color-teal-400);
}
.badge.alert { background: rgba(255, 159, 28, 0.14); color: var(--color-orange-500); }
.badge svg { width: 1.75rem; height: 1.75rem; stroke-width: 2.2; }
.action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  color: var(--color-cream-0);
  font-weight: 600;
  text-decoration: none;
}
.action:active { background: var(--color-navy-700); }

/* --- footer: the sheet's last block --- */

.foot {
  position: relative; /* Paints after the positioned sheet, so it covers the sheet's shadow and its rise. */
  padding: 0 var(--pad-r) calc(var(--space-5) + env(safe-area-inset-bottom, 0px)) var(--pad-l);
  background: var(--color-navy-800);
  color: var(--color-navy-300);
  font-size: 0.75rem;
  line-height: 1.45;
}
.foot > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--hairline);
}
.site {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--color-navy-700);
  color: var(--color-navy-100);
  font: 600 0.875rem/1.2 var(--font-sans);
  text-decoration: none;
}
.site:active { background: var(--color-navy-600); }
.site .globe { width: 1.125rem; height: 1.125rem; color: var(--color-teal-400); stroke-width: 1.8; }
.site .external { width: 0.875rem; height: 0.875rem; color: var(--color-navy-300); }
.secure { text-wrap: balance; }
/* Inline, so the lock stays with the first word when the line wraps on narrow screens. */
.secure svg {
  display: inline-block;
  width: 0.9375rem;
  height: 0.9375rem;
  margin-right: var(--space-2);
  vertical-align: -0.1875rem;
  color: var(--color-teal-400);
}

/* Line icons: drawn in the colour of their context. */
.pair svg, .fine svg, .badge svg, .site svg, .secure svg {
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pair .swap svg, .fine svg, .site .external, .secure svg { stroke-width: 2; }

/* --- focus, hover, motion --- */

:focus-visible { outline: 2px solid var(--color-teal-400); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 3px; }
.btn, .seg button, .toggle, .site, .action, .swap { -webkit-tap-highlight-color: transparent; }

@media (hover: hover) {
  .site:hover { background: var(--color-navy-600); }
  .action:hover { background: var(--color-navy-700); }
  .toggle:hover { background: var(--color-navy-600); }
  .seg button[aria-pressed="false"]:hover { color: var(--color-cream-0); }
}

@media (prefers-reduced-motion: no-preference) {
  /* Each state's sheet rises into place when it appears; the footer holds still and covers the overlap. */
  .sheet { animation: rise 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
  .progress::after { animation: scan 1.2s ease-in-out infinite; }
  .btn, .seg button, .toggle, .site, .action { transition: background-color 0.15s, color 0.15s, opacity 0.15s; }
}
@keyframes rise {
  from { transform: translateY(1.5rem); }
  to { transform: none; }
}
@keyframes scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

/* --- from 48rem: the sheet floats as a panel over the hero, and the ticket takes the panel's width --- */

@media (min-width: 48rem) {
  .page {
    display: flex;
    flex-direction: column;
    padding: calc(var(--space-7) + env(safe-area-inset-top, 0px)) var(--space-5) calc(var(--space-7) + env(safe-area-inset-bottom, 0px));
    background:
      radial-gradient(70% 60% at 50% 0%, rgba(46, 196, 182, 0.16), rgba(46, 196, 182, 0.04) 60%, rgba(46, 196, 182, 0) 100%),
      radial-gradient(60% 50% at 50% 100%, rgba(15, 46, 69, 0.9), rgba(15, 46, 69, 0) 100%),
      var(--color-navy-900);
  }
  /* The rings now spread from behind the panel. */
  .page::before {
    --ring-at: 50% 45%;
    inset: 0;
    height: auto;
    opacity: 0.7;
    -webkit-mask-image: radial-gradient(60% 60% at 50% 45%, #000 30%, transparent 100%);
    mask-image: radial-gradient(60% 60% at 50% 45%, #000 30%, transparent 100%);
  }
  .frame {
    width: 100%;
    max-width: 28rem;
    min-height: 0;
    margin: auto; /* Centres when there's room and falls back to the top when there isn't, so nothing is cut off. */
    filter: drop-shadow(0 1.5rem 2.5rem rgba(0, 0, 0, 0.5));
  }
  .hero { padding: 0; }
  .page,
  .page:has(#state-form:not([hidden])) { --logo-h: 2.625rem; }
  main, main > section, .sheet { flex: none; }
  .lede { padding: var(--space-3) 0 var(--space-6); }
  .lede-form { padding: var(--space-6) 0 var(--space-4); }
  .pair { border-radius: var(--radius-sheet); }
  .sheet {
    padding: var(--space-6);
    border: 1px solid rgba(253, 255, 252, 0.07);
    border-bottom: 0;
    box-shadow: none;
  }
  .sheet::before { display: none; } /* A floating panel isn't dragged: no handle. */
  .foot {
    padding: 0 var(--space-6) var(--space-5);
    border: 1px solid rgba(253, 255, 252, 0.07);
    border-top: 0;
    border-radius: 0 0 var(--radius-sheet) var(--radius-sheet);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
