/* Brand tokens lifted from apps/os2/src/app/globals.css (:root / .dark) in
   gw-os2-frontend-ui, so this standalone form matches the rest of the
   product — light AND dark — without pulling in Tailwind/the shared
   package. Icons below are Hugeicons' free "Stroke Rounded" set
   (@hugeicons/core-free-icons, MIT), matching what the React version uses
   via @hugeicons/react — inlined as raw SVG since there's no bundler here. */
:root {
  /* Which scheme the browser paints native control chrome in — checkbox and
     radio boxes, the date picker and its calendar, scrollbars. It has to be
     declared per theme *here* rather than left as "light dark", because
     "light dark" resolves off the OS preference, not off data-theme: a
     visitor whose OS is dark but who picked light on the toggle got a light
     card with dark-painted checkboxes and radios. color-scheme inherits, so
     every control picks this up; a control that declares its own opts back
     out of the toggle. */
  color-scheme: light;
  --font-sans: 'Google Sans', -apple-system, 'Segoe UI', sans-serif;
  --surface: #fcfefd;
  --card: #fcfefd;
  --accent: #03b155;
  --accent-dark: #029a49;
  --accent-light: #e6f2ec;
  --accent-line: rgba(3, 177, 85, 0.25);
  --accent-hover: rgba(3, 177, 85, 0.15);
  --text-primary: #0f1f18;
  --text-secondary: #4a6358;
  --border: #dfe7e3;
  --neutral: #f1f3f3;
  --red: #d94f3d;
  --red-light: #fdecea;
  --radius: 0.625rem;
  --card-shadow: 0 1px 2px rgba(15, 31, 24, 0.05);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a6358' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a6358' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
}

/* Theming has three states, driven by a `data-theme` attribute on <html>
   that js/theme.js sets:

     - data-theme="dark"   -> dark, whatever the OS says
     - data-theme="light"  -> light, whatever the OS says
     - attribute absent    -> follow prefers-color-scheme (the default)

   "System" is the *absence* of the attribute, not data-theme="system", which
   is what lets the OS preference resolve in pure CSS below — so a visitor who
   never touches the toggle gets the right theme with JavaScript disabled and
   with no flash of the wrong one. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #121a16;
    --card: #121a16;
    --accent: #1ec46b;
    --accent-dark: #16a34a;
    --accent-light: #16281f;
    --accent-line: rgba(30, 196, 107, 0.3);
    --accent-hover: rgba(30, 196, 107, 0.18);
    --text-primary: #e8f0ec;
    --text-secondary: #9db3a8;
    --border: #243029;
    --neutral: #1a231e;
    --red: #f0715e;
    --red-light: #2a1512;
    --card-shadow: none;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db3a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    --calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db3a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
  }
}

/* The same dark tokens again, for an explicit data-theme="dark" — i.e. the
   visitor chose dark while their OS is in light mode.

   This duplicates the block above because CSS cannot share one declaration
   block between a media query and a plain selector, and the two cases are
   genuinely different: above is "no choice made, OS says dark", this is
   "choice made". KEEP THE VALUES IN SYNC — a token added to one must be added
   to the other. (The reverse case needs nothing: an explicit
   data-theme="light" is excluded by the :not() above, so :root's own light
   values already win.) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --surface: #121a16;
    --card: #121a16;
    --accent: #1ec46b;
    --accent-dark: #16a34a;
    --accent-light: #16281f;
    --accent-line: rgba(30, 196, 107, 0.3);
    --accent-hover: rgba(30, 196, 107, 0.18);
    --text-primary: #e8f0ec;
    --text-secondary: #9db3a8;
    --border: #243029;
    --neutral: #1a231e;
    --red: #f0715e;
    --red-light: #2a1512;
    --card-shadow: none;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db3a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    --calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db3a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  font-variation-settings: "GRAD" 0;
}

body {
  background: var(--surface);
  color: var(--text-primary);
  min-height: 100vh;
}

.hidden { display: none !important; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 340px 1fr;
    grid-template-rows: 1fr;
  }
}

.brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Centres the mark in the mobile band, where the logo is the only child in
     flow (the rider is display: none below 1024px and absolute above it).
     Anchoring it to flex-start left it sitting above the band's optical
     centre. Desktop re-anchors to the top below. */
  justify-content: center;
  gap: 1.5rem;
  height: 6rem;
  background: var(--accent);
  padding: 0.5rem 1.5rem;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .brand-panel {
    height: auto;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 4rem 3.25rem;
  }
}

/* Sits in the brand panel, which is brand green in both themes — so the
   control is styled against that green (translucent white) rather than
   against the themed surface tokens. */
.theme-toggle {
  position: absolute;
  /* Shares the band's centreline with the logo on mobile — pinned to the top
     it sat on a different axis from a vertically centred mark, which is what
     made the short band read as misaligned. Desktop re-pins it to the corner,
     where the panel is tall and the logo is top-anchored anyway. */
  top: 50%;
  transform: translateY(-50%);
  /* Lines its right edge up with .brand-panel's own padding-inline, so the
     toggle and the logo sit in the same content box. At 0.75rem it hung
     0.75rem outside the box everything else in the panel respects. */
  right: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.1875rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

@media (min-width: 1024px) {
  .theme-toggle {
    top: 1.25rem;
    transform: none;
    right: 3.25rem;
  }
}

.theme-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-toggle__btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.theme-toggle__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* aria-pressed is the source of truth for which theme is active, so the
   active styling keys off it rather than a separate class. */
.theme-toggle__btn[aria-pressed="true"] {
  background: #fff;
  color: var(--accent-dark);
}

.theme-toggle__btn svg {
  width: 0.9375rem;
  height: 0.9375rem;
}

/* These sizes are the mark's own, not a box mostly full of empty canvas —
   logo.svg's viewBox is cropped to its artwork (see the comment in that
   file), so the values here are what the logo actually draws at.

   Mobile was 4.25rem of padded box, i.e. a 30px mark. Desktop asked for
   20rem but never got it: max-width below clamped the box to the panel's
   236px content width, drawing a 162px mark. Both are now sized on purpose:
   13rem draws a 208px mark in the 236px the desktop panel has to give,
   keeping ~28px clear of the padding edge before max-width would clamp it
   again, and mobile fills the band as below.

   Mobile is sized on width rather than height even though the band is a
   height budget, because the mark is centred while the toggle is absolutely
   positioned over the same row: the second term reserves the toggle's 96px
   plus an 8px gap on *each* side of centre (2 x 104px = 13rem, measured off
   the panel's content box), so the two can never meet however narrow the
   phone. Sizing on height and letting max-width clamp the overflow would
   squash the mark instead - a bound max-width on a replaced element with a
   specified height does not scale the height back. 8.25rem is a 132x65px
   mark, which is as much as the 6rem band holds. */
.brand-logo {
  width: min(8.25rem, calc(100% - 13rem));
  height: auto;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

@media (min-width: 1024px) {
  .brand-logo { height: auto; width: 13rem; }
}

.brand-rider {
  display: none;
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  width: 100%;
  height: 49%;
  object-fit: cover;
  object-position: bottom;
}

@media (min-width: 1024px) {
  .brand-rider { display: block; }
}

.form-area {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem 1rem;
}

@media (min-width: 1024px) {
  .form-area { align-items: center; padding: 3rem 2rem; }
}

.form-shell {
  width: 100%;
  max-width: 28rem;
}

@media (min-width: 1024px) {
  .form-shell { max-width: 32rem; }
}

.capture-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: calc(var(--radius) * 1.8);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

@media (min-width: 1024px) {
  .capture-card { padding: 2rem; }
}

.capture-card__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.step-icon {
  width: 2rem;
  height: 2rem;
  color: var(--accent);
  flex-shrink: 0;
}

.capture-card__header h1 { font-size: 1.125rem; font-weight: 700; }

.subtitle { font-size: 0.875rem; color: var(--text-secondary); }

.capture-card__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field { display: flex; flex-direction: column; gap: 0.375rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

label { font-size: 0.875rem; font-weight: 500; }

.required { color: var(--red); margin-left: 0.125rem; }

input, select {
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.8);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.1rem;
}

input::placeholder { color: var(--text-secondary); opacity: 0.8; }

/* The date fields' calendar glyph is drawn by the browser, which only knows
   how to invert it for the color-scheme — so under a dark OS it came out
   white-on-white and the icon simply vanished from a light card. Painting it
   from a token puts it under the same per-theme control as --chevron above,
   in the same Hugeicons stroke as the inline SVGs. Firefox draws its own and
   ignores this pseudo-element; color-scheme on :root is what fixes it there. */
input[type="date"]::-webkit-calendar-picker-indicator {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  padding: 0;
  background: var(--calendar) no-repeat center / contain;
  cursor: pointer;
  opacity: 0.85;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[aria-invalid="true"], select[aria-invalid="true"], input.invalid, select.invalid {
  border-color: var(--red);
}

.phone-row { display: flex; }

.phone-row input:first-child,
.phone-row select:first-child {
  width: 6rem;
  flex-shrink: 0;
  border-right: none;
  border-radius: calc(var(--radius) * 0.8) 0 0 calc(var(--radius) * 0.8);
  background-color: var(--neutral);
  color: var(--text-secondary);
  text-align: center;
}

.phone-row input:last-child,
.phone-row select:last-child {
  border-radius: 0 calc(var(--radius) * 0.8) calc(var(--radius) * 0.8) 0;
  flex: 1;
}

.field-error {
  font-size: 0.8125rem;
  color: var(--red);
  min-height: 0;
}

.field-error:empty { display: none; }

.form-error {
  font-size: 0.875rem;
  color: var(--red);
}

/* .field's default flex-direction: column already stacks the label row
   above the error text correctly — this used to force the whole block into
   a row, which shoved the error text beside the checkbox instead of below
   it. checkbox-field needs no override; only .checkbox-label itself (the
   checkbox + its text) should lay out as a row. */

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Checkboxes and radios are drawn here rather than left to the platform.
   Native ones take only accent-color, which paints the *checked* fill and
   nothing else — the unchecked box keeps the platform's own border and fill,
   which is what made them read as dark blobs on the light card. appearance:
   none hands us the whole control, so one 1px --border box with an --accent
   fill renders the same in both themes and on every browser. Grouped with the
   radio because the two only differ in shape and in what marks them checked;
   see also color-scheme on :root, which fixes the rest of the native chrome
   (the date picker, scrollbars) the same way. */
.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  /* Undoes the shared input rule above: its 2.25rem height and side padding
     are for text fields, and a padding box narrower than 0 would swallow the
     tick. */
  padding: 0;
  border: 1px solid var(--border);
  background-color: var(--card);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.checkbox-label input[type="checkbox"] {
  border-radius: 0.25rem;
  margin-top: 0.125rem;
}

.radio-label input[type="radio"] { border-radius: 50%; }

.checkbox-label input[type="checkbox"]:hover,
.radio-label input[type="radio"]:hover { border-color: var(--accent); }

.checkbox-label input[type="checkbox"]:checked,
.radio-label input[type="radio"]:checked {
  border-color: var(--accent);
  background-color: var(--accent);
}

/* An <input> can hold no children, so the tick has to be a background image —
   same rounded stroke as the inline Hugeicons elsewhere in the form, in white
   because it sits on --accent in both themes. */
.checkbox-label input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4.5 4.5L19 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.7rem;
}

/* And the radio's dot is an inset ring in the card colour biting into the
   accent fill, for the same reason. */
.radio-label input[type="radio"]:checked {
  box-shadow: inset 0 0 0 3px var(--card);
}

.checkbox-label input[type="checkbox"]:focus-visible,
.radio-label input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Outranks the box's own border above, which the shared
   input[aria-invalid="true"] rule no longer can. */
.checkbox-label input[type="checkbox"][aria-invalid="true"] {
  border-color: var(--red);
}

.checkbox-label a { color: var(--accent); text-decoration: underline; white-space: nowrap; }

.radio-field { border: none; }

.radio-field legend {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.radio-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
}


.fast-track-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--accent-line);
  background: var(--accent-light);
  border-radius: calc(var(--radius) * 1.4);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
}

.fast-track-banner:hover { background: var(--accent-hover); }

.fast-track-banner__icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--accent);
  flex-shrink: 0;
}

.fast-track-banner__chevron {
  width: 1rem;
  height: 1rem;
  color: var(--accent);
  flex-shrink: 0;
}

.fast-track-banner__text { display: flex; flex-direction: column; flex: 1; }

.fast-track-banner__text strong { font-size: 0.875rem; font-weight: 600; }

.fast-track-banner__text small { font-size: 0.75rem; color: var(--text-secondary); }

.btn {
  height: 2.5rem;
  width: 100%;
  border-radius: calc(var(--radius) * 0.8);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--neutral); }

/* Cloudflare Turnstile.

   Sits below whichever step card is showing (it's a sibling of them, not a
   child — see index.html), so it needs its own top gap rather than inheriting
   .capture-card__body's. Turnstile renders a fixed-size iframe it won't let
   us restyle, so all this can do is centre it and give it room; margin-inline
   auto rather than the parent centring everything, to keep .form-shell's
   layout untouched. */
.turnstile-widget {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  /* The widget is 65px tall once rendered; reserving it stops the card from
     jumping down when the challenge finishes loading. */
  min-height: 65px;
}
