/* =============================================================
   Public tracking: the search state, the not-found state and the
   Turnstile challenge (F4, TRACE-2026-10-18 §F4 and §11).

   Loaded after portal.css by every public page: templates/public/tracking.html
   (every state), challenge.html and invoice_verify.html. The search state and
   the challenge set body.trk-page (palette + full-width hero layout); the
   result, booking-only, /track/<box>/ and verify pages set body.trk-palette
   (palette only, portal.css layout kept). portal.css is shared with
   templates/portal/base.html and templates/depot/base.html and is NOT edited:
   - the design-system values below are COPIED from static/css/tokens.css
     (Maritime Editorial). Linking tokens.css itself would redefine
     portal.css's --radius / --radius-sm / --radius-md on :root and restyle its
     body, a and .btn. Keep these values in step with tokens.css;
   - portal.css's own custom properties are re-pointed under .trk-page and
     .trk-palette, so the shared nav, footer, cards and badges take
     ruby / ink / bone on the public site only.
   Every selector starts with .trk (core/tests/test_public_track_redesign.py).
   Radius ceiling 1px / 6px, as the design system rules.
   ============================================================= */

.trk-page, .trk-palette {
  --ink: #0E1E33;
  --ink-2: #1B2D49;
  --ink-soft: #5A6B86;
  --paper: #FBF8F1;
  --bone: #F2EDE2;
  --bone-rule: #DBD2BD;
  --slate-500: #6F6655;
  --ruby: #B8344A;
  --ruby-deep: #8B1F2F;
  --ruby-soft: #E8C5CB;
  --font-display: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* The shade over the photograph. At 0.72 alpha, bone (#F2EDE2) text keeps
     5.7:1 and paper (#FBF8F1) 6.3:1 even where the photo is pure white
     (composite rgb(81, 93, 108)), so contrast never depends on the image.
     core/tests/test_public_track_browser.py pins >= 4.5:1. */
  --trk-shade: rgba(14, 30, 51, 0.72);

  /* portal.css custom properties, re-pointed for these pages only. */
  --navy: var(--ink);
  --navy-mid: var(--ink-2);
  --navy-light: var(--ink-soft);
  --gold: var(--ruby);
  --gold-dark: var(--ruby-deep);
  /* invoice_verify's Grand Total (.finance-total) on the ink card: 10.6:1. */
  --gold-light: var(--ruby-soft);
  --surface: var(--paper);
  --surface-low: var(--bone);
  --white: var(--paper);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-soft);
  --text-muted: var(--slate-500);
  --border: var(--bone-rule);
}

/* Full-width hero: lift portal.css's max-width and padding on <main> for these
   pages only. Never 100vw, which adds a sideways scrollbar. */
.trk-page .portal-main { max-width: none; padding: 0; overflow: visible; }
.trk-page .portal-footer { margin-top: 0; }

.trk { font-family: var(--font-body); color: var(--ink); }
.trk-mono {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

/* Hero: one photograph under the ink shade. The photo is decoration, so it is
   a CSS background (no alt). The phone file is the default; from 900px the
   wide file replaces it, and a browser downloads only the one that applies. */
.trk-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: 480px;
  padding: 48px 0 32px;
  background: var(--ink) url("../img/track-hero-900.e36ec275c983.webp") center / cover no-repeat;
  color: var(--paper);
}
.trk-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--trk-shade);
}
.trk-hero__inner { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.trk-eyebrow {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone);
}
.trk-hero__title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.018em;
  color: var(--paper);
}
.trk-hero__lede {
  max-width: 34em;
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--bone);
}

.trk-form { max-width: 640px; margin-top: 24px; }
.trk-form__label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--bone);
}
.trk-form__row { display: flex; flex-direction: column; gap: 8px; }
.trk-form__input {
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--bone-rule);
  border-radius: 1px;
}
.trk-form__input::placeholder { color: var(--slate-500); }
.trk-btn {
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: var(--ruby);
  border: 1px solid var(--ruby);
  border-radius: 1px;
  cursor: pointer;
}
.trk-btn:hover { background: var(--ruby-deep); border-color: var(--ruby-deep); }
.trk-form__input:focus-visible,
.trk-btn:focus-visible,
.trk a:focus-visible { outline: 2px solid var(--ruby-soft); outline-offset: 2px; }

/* Not found: half the traffic (Stitch brief), so it is a designed card, not a
   red bar. Solid paper, so its contrast never depends on the photograph. */
.trk-miss {
  max-width: 640px;
  margin-top: 16px;
  padding: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ruby-soft);
  border-radius: 1px;
}
.trk-miss__head { font-size: 15px; }
.trk-miss__head strong { color: var(--ruby-deep); }
.trk-miss__hint { margin-top: 8px; font-size: 14px; }
.trk-miss__steps { margin-top: 12px; padding-left: 20px; font-size: 14px; line-height: 1.55; }
.trk-miss__steps li + li { margin-top: 4px; }
.trk-miss__contact { margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.trk-miss a { color: var(--ruby-deep); text-decoration: underline; }
/* On paper the light ruby ring is ~1.5:1; a focus ring needs >= 3:1. */
.trk-miss a:focus-visible { outline-color: var(--ruby-deep); }

/* Notices on the result and verify pages: a full hairline frame, never a side
   stripe (DESIGN.md "Shapes": structure is drawn with strokes). */
.trk-note {
  margin-bottom: 16px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid;
  border-radius: 1px;
}
.trk-note--info { padding: 12px 16px; line-height: inherit; background: rgba(15,31,61,0.06); border-color: var(--navy); }
.trk-note--warn { background: var(--warning-bg); border-color: var(--warning); color: #7C2D12; }
.trk-note--error { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.trk-note--ok { background: rgba(22,163,74,0.08); border-color: #16A34A; }

/* The four accepted formats, each with a fictitious worked example. */
.trk-formats { max-width: 1120px; margin: 0 auto; padding: 32px 16px 48px; }
.trk-formats__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}
.trk-formats__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
  list-style: none;
}
.trk-format {
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--bone-rule);
  border-radius: 6px;
}
.trk-format__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.trk-format__eg { margin-top: 6px; font-size: 18px; color: var(--ink); }
.trk-format__where { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.trk-formats__note { margin-top: 20px; font-size: 13px; color: var(--ink-soft); }

/* Challenge: the same hero, with the check on a paper card. */
.trk-hero--gate { align-items: center; min-height: 70vh; }
.trk-gate {
  max-width: 440px;
  margin: 0 auto;
  padding: 24px 12px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 1px;
  text-align: center;
}
.trk-gate__title {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}
.trk-gate__error { margin-top: 12px; font-weight: 600; color: var(--ruby-deep); }
/* Reserve the Turnstile widget's box (300 x 65) so the card does not jump when
   Cloudflare's script draws it. A 360px phone leaves 360 - 2*16 - 2*12 = 304px.
   Below 360px the gate drops the hero gutter and thins the card padding:
   320 - 2*0 - 2*10 = 300px, exactly the widget. */
.trk-gate .cf-turnstile {
  display: flex;
  justify-content: center;
  min-width: 300px;
  min-height: 65px;
  margin: 16px auto 0;
}
@media (max-width: 359px) {
  .trk-hero--gate .trk-hero__inner { padding: 0; }
  .trk-gate { padding: 24px 10px; }
}

/* Palette-only pages (result, booking-only, /track/<box>/, verify) keep
   portal.css's layout, with one exception on phones: the 3rem box number and
   the three meta cards are wider than a 360px screen, and portal.css's
   overflow-x:auto on <main> turns that into a sideways scroll inside the page.
   Pinned by test_public_track_browser.PublicResultPaletteBrowserTests. */
@media (max-width: 639px) {
  .trk-palette .tracking-container-id { font-size: 2rem; overflow-wrap: anywhere; }
  .trk-palette .tracking-meta-cards { grid-template-columns: 1fr; }
}

@media (min-width: 640px) {
  .trk-form__row { flex-direction: row; }
  .trk-form__input { flex: 1; }
  .trk-formats__grid { grid-template-columns: repeat(2, 1fr); }
  .trk-gate { padding: 32px; }
}
@media (min-width: 900px) {
  .trk-hero {
    min-height: 560px;
    padding: 80px 0 56px;
    background-image: url("../img/track-hero-1920.838f606ce7ed.webp");
  }
  .trk-hero__inner { padding: 0 32px; }
  .trk-hero__title { font-size: 52px; }
  .trk-hero__lede { font-size: 18px; }
  .trk-formats { padding: 48px 32px 64px; }
}
@media (min-width: 1100px) {
  .trk-formats__grid { grid-template-columns: repeat(4, 1fr); }
}
