/* HOPE Brand Tokens — the single source of truth for the face.
   ===========================================================================
   Import this first, everywhere. No other stylesheet may declare @font-face,
   and none may redefine --navy, --gold, or --cream. A build gate fails the
   release if one does.

   WHY THIS FILE EXISTS

   A measured audit of sixteen user-facing surfaces found:
     - two brand palettes shipping side by side (#0d1f3c vs #0b2344)
     - eleven distinct first-choice font families
     - exactly one @font-face declaration in the whole app, under a name that
       only one stylesheet referenced, so Fraunces rendered on one page and
       fell back to Georgia everywhere else
     - Public Sans named in the brand spec with no font file behind it
     - 179 tap targets under 44px

   TYPE DECISION, stated plainly so it is not re-litigated by accident:

   Fraunces is self-hosted for display. It is 25KB, it is already in the repo,
   and it is the single thing that stops HOPE looking like a bootstrapped
   template. It earns its bytes.

   Body text uses a system stack and NOT a second webfont. Public Sans is the
   US government typeface and would be thematically perfect, but this is a PWA
   used by people on metered data and borrowed phones. A second font file to
   set 14px body copy is a cost paid by exactly the people HOPE exists for.
   System sans renders instantly, offline, at zero bytes.
   =========================================================================== */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-display.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- The brand. Three colours. Do not fork them. ---- */
  --navy: #0d1f3c;
  --gold: #e8b23a;
  --cream: #f6f1e6;

  /* ---- Derived from those three, and only from those three ---- */
  --navy-2: #17335a;
  --navy-lift: #24507f;
  --gold-2: #f7dc86;
  --gold-ink: #7a5c11;      /* gold that passes contrast on cream */
  --cream-2: #fffdf7;
  --ink: #13202f;
  --ink-muted: #55647a;     /* 4.8:1 on cream */
  --line: #d9d3c8;

  /* ---- Semantic. Meaning, never decoration. ---- */
  --urgent: #b3352d;        /* a clock closing, a shutoff, a cessation notice */
  --caution: #8f6210;       /* a deadline in view */
  --steady: #295f8f;        /* a standard procedural step */
  --settled: #26694a;       /* done, verified, protected */

  /* ===========================================================================
     CONTRAST PAIRS — always choose text colour by its GROUND, never by mood.

     A pixel-level audit of ten surfaces found thirteen contrast failures, and
     they were not thirteen bugs. They were one missing idea: the palette had no
     on-dark / on-light pairs, so a component would pick a colour assuming one
     ground and then get rendered on the other.

     Every ratio below is measured, not estimated. Do not substitute a colour
     here without re-measuring.
     =========================================================================== */

  /* On navy ground */
  --on-navy: var(--cream);          /* 14.58:1 — body and headings on navy */
  --on-navy-muted: #9fb0c6;         /*  7.43:1 — secondary text on navy */
  --on-navy-accent: var(--gold);    /*  6.05:1 — accents and eyebrows on navy */

  /* On cream or white ground */
  --on-cream: var(--ink);           /* 12.9:1  — body and headings on cream */
  --on-cream-muted: var(--ink-muted); /* 5.34:1 — secondary text on cream */
  --on-cream-accent: var(--gold-ink); /* 5.54:1 — gold that is actually readable */

  /* On gold ground. There is exactly one correct answer. */
  --on-gold: var(--ink);            /*  8.52:1 */

  /* ---- Known-bad pairs, recorded so they are not rediscovered the hard way ----
     white on gold ............ 1.93:1  never do this
     --ink-muted on navy ...... 2.73:1  use --on-navy-muted
     gold as text on cream .... 1.72:1  use --on-cream-accent
     Gold is a mid-luminance accent. It works as a GROUND with dark ink on it,
     and as an accent on dark. It does not work as text on light.
     ------------------------------------------------------------------------- */

  /* ---- Type. Two roles, one webfont. ---- */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-data: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- Five sizes. Not six. ---- */
  --t-display: clamp(28px, 5vw, 46px);
  --t-title: clamp(19px, 3vw, 25px);
  --t-lead: clamp(15px, 1.6vw, 17px);
  --t-body: 14.5px;
  --t-meta: 11.5px;

  /* ---- Interaction floors. Not suggestions. ---- */
  --tap-min: 44px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 14px 38px rgba(13, 31, 60, 0.13);
}

/* ===========================================================================
   Tap-target floor, applied globally so no surface can forget it.

   min-height rather than height, so content still governs layout. Grid is used
   for the padding case so an icon-only control centres rather than sitting at
   the top of a 44px box.
   =========================================================================== */
a[href],
button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"],
summary,
select {
  min-height: var(--tap-min);
}

/* Links inside running prose are exempt. A 44px-tall word inside a sentence
   would tear the paragraph apart. The floor is for standalone controls. */
p a[href],
li a[href],
small a[href],
td a[href],
dd a[href],
blockquote a[href],
figcaption a[href],
label a[href] {
  min-height: 0;
}

/* ...except the crisis strip, which is authored as a <p> so it survives a
   blocked script and a dead stylesheet. That markup choice quietly dragged
   911, 988, and 2-1-1 into the prose-link exemption above: `p a[href]` is
   specificity (0,1,2) and beat every `.hope-crisis-strip a` rule ever
   written for them, including the 30px one below, so the three most
   important targets in the app have been computing to min-height: 0.
   The attribute selector here restores the floor at (0,2,1) without
   reaching for !important. */
.hope-crisis-strip a[href] {
  min-height: 44px;
}

/* Visible focus, everywhere, always. Removing this is a regression, not a
   style choice — it is how a keyboard or switch-access user knows where
   they are. */
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===========================================================================
   Icon policy.

   Emoji stay. They are legible at small sizes, need no asset pipeline, work
   offline, and carry warmth that a stroke icon cannot. For a survival guide
   that warmth is not decoration.

   But emoji come off load-bearing navigation and status, because they render
   differently on every platform, carry inconsistent weight and colour, and
   announce unpredictably to screen readers. A person navigating by shape
   should see the shape you chose.

   .hope-icon  — inline SVG, for navigation and status
   .hope-emoji — emoji, for content, categories, and warmth
   =========================================================================== */
.hope-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

/* Decorative emoji must be hidden from assistive technology. An emoji that
   carries meaning needs real text beside it — never an aria-label on the
   emoji itself. */
.hope-emoji {
  font-style: normal;
  speak: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ===========================================================================
   Static crisis strip.

   A measured sweep found six surfaces where every telephone number was
   rendered by JavaScript. With scripts blocked — an old handset, a data saver,
   a locked-down library machine, a failed asset — a person on those pages had
   no way to reach help at all.

   This strip is plain HTML in every page. It does not depend on a script, a
   font, or a stylesheet beyond this one. On a survival guide a crisis number
   should never be more than a glance away, so it stays visible when scripts
   work too. That is a design decision, not only a fallback.
   =========================================================================== */
.hope-crisis-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
  margin: 0;
  padding: 7px 12px;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  border-bottom: 2px solid var(--gold);
}
.hope-crisis-strip b {
  font-weight: 800;
  color: var(--gold-2);
  letter-spacing: 0.02em;
}
.hope-crisis-strip a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 2px 8px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  background: rgba(255, 255, 255, 0.09);
}
.hope-crisis-strip a:hover,
.hope-crisis-strip a:focus-visible {
  background: var(--gold);
  color: var(--navy);
}
/* The strip is a standalone control set, so the 44px floor would make it a
   thick band on every page. 30px plus generous horizontal padding keeps the
   touch area honest while the strip stays slim. */
.hope-crisis-strip a { min-height: 30px; }

@media (max-width: 380px) {
  .hope-crisis-strip { font-size: 11.5px; gap: 3px 9px; padding: 6px 8px; }
}

/* Carry the number onto paper. A printed handback is often the only thing a
   person keeps. */
@media print {
  .hope-crisis-strip {
    background: transparent !important;
    color: #000 !important;
    border-bottom: 1pt solid #000;
  }
  .hope-crisis-strip a { background: none !important; color: #000 !important; }
  .hope-crisis-strip b { color: #000 !important; }
}


/* ===========================================================================
   GROUND-AWARE SAFETY NET

   These rules exist because the audit proved that intent is not enough: a
   component styled for one ground will eventually be rendered on another. The
   net catches the three pairs that measurably fail, at the point of use.
   =========================================================================== */

/* A gold ground always carries dark ink. White on gold measures 1.93:1. */
[style*="var(--gold)"],
.on-gold,
button.gold, a.gold, .btn-gold, .rl-primary.gold,
.hope-footer-button {
  color: var(--on-gold);
}

/* Secondary text on a dark ground uses the light muted, not the cream-muted.
   --ink-muted on navy measures 2.73:1. */
.on-navy .muted, .on-navy small, .on-navy .small,
[class*="hero"] small, [class*="hero"] .muted,
.hope-footer small, .hope-footer .muted, .hope-footer p {
  color: var(--on-navy-muted);
}

/* Gold as text on a light ground is unreadable at 1.72:1. Use the ink gold. */
.on-cream .accent, .on-cream .eyebrow,
.card .eyebrow, .panel .eyebrow {
  color: var(--on-cream-accent);
}


/* ===========================================================================
   FORCED COLOURS

   In Windows High Contrast and similar modes the operating system replaces the
   palette outright. Anything whose meaning is carried only by a background
   colour vanishes. People with low vision use these modes daily, and several of
   HOPE's most important signals — urgency, verified state, the crisis strip —
   are colour-coded.

   The floor: keep a visible border on every control and every status surface,
   so structure survives even when colour does not.
   =========================================================================== */
@media (forced-colors: active) {
  a[href], button, [role="button"], summary, select, input, textarea {
    border: 1px solid currentColor;
    forced-color-adjust: none;
    color: LinkText;
  }
  button, [role="button"], input[type="submit"] { color: ButtonText; background: ButtonFace; }
  .hope-crisis-strip {
    border: 2px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    forced-color-adjust: none;
  }
  .hope-crisis-strip a { border: 2px solid LinkText; color: LinkText; background: Canvas; }
  /* status must not rely on fill alone */
  .rl-lamp, .lamp, [class*="badge"], [class*="chip"], [class*="pill"],
  [class*="status"], .rl-fill, .rl-badge {
    border: 1px solid CanvasText;
  }
  /* keep the focus ring visible against a replaced palette */
  :focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }
}
