/* ── Evident ICU Core — Component Styles ──────────────────────────
   Layout, buttons, focus ring, reduced-motion. Token values
   are sourced from local tokens.css + package design tokens import.
   Do NOT redefine shared token primitives here.
   ──────────────────────────────────────────────────────────────── */

/* ── Skip Link (WCAG 2.4.1) ────────────────────────────────────── */
.skip-to-main {
  position: absolute;
  inset-inline-start: -100vw;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary, #1f3a99);
  color: #fff;
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--type-sm, 0.8125rem);
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm, 0.5rem) 0;
  z-index: 10000;
}

.skip-to-main:focus {
  inset-inline-start: 0;
  inset-block-start: 0;
  outline: 2px solid var(--color-accent, #c88c00);
  outline-offset: 2px;
}

/* ── Global box model reset ─────────────────────────────────────── */
/* critical.css was never wired to head.njk — put the canonical reset here
   so every element's padding + border is included in its declared width. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* clip (not hidden) prevents horizontal scroll without creating a BFC or
     suppressing the vertical scrollbar on iOS Safari. */
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-text, #1a2040);
  font-family: var(--font-sans, "Inter", system-ui, sans-serif);
  line-height: var(--line-height-normal, 1.6);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--surface-base, #0f1623);
  /* Institutional surfaces are stable. No animation, no atmospheric depth stack.
     The interface communicates trust through clarity, not theatrical light. */
}

img,
video,
iframe,
embed,
object,
svg {
  max-width: 100%;
  height: auto;
}

/* ── Orphan & Widow Prevention ──────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

p,
li,
blockquote,
figcaption {
  text-wrap: pretty;
}

/* ── Card Orphan Prevention ─────────────────────────────────────── */
.card,
[class*="__card"],
[class*="-card"] {
  break-inside: avoid;
}

/* ── Card Hover Elevation ───────────────────────────────────────── */
.card,
[class*="__card"],
[class*="-card"],
.ev-glass {
  transition:
    transform var(--duration-normal, 250ms) var(--ease-spring, cubic-bezier(0.22, 1, 0.36, 1)),
    box-shadow var(--duration-slow, 400ms) var(--ease-spring, cubic-bezier(0.22, 1, 0.36, 1)),
    border-color var(--duration-fast, 150ms) ease;
}

a:hover > .card,
a:hover > [class*="__card"],
a:hover > [class*="-card"],
a:hover > .ev-glass,
.card:hover,
[class*="__card"]:hover,
[class*="-card"]:hover,
.ev-glass:hover,
.card:focus-visible,
[class*="__card"]:focus-visible,
[class*="-card"]:focus-visible,
.ev-glass:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 8px 28px rgb(14 21 40 / 10%),
    0 0 0 1px var(--border-default);
  /* No color glow — elevation expressed through shadow depth, not colored light */
}

@media (prefers-reduced-motion: reduce) {
  .card,
  [class*="__card"],
  [class*="-card"],
  .ev-glass {
    transition: none;
  }

  a:hover > .card,
  a:hover > [class*="__card"],
  a:hover > [class*="-card"],
  a:hover > .ev-glass,
  .card:hover,
  [class*="__card"]:hover,
  [class*="-card"]:hover,
  .ev-glass:hover,
  .card:focus-visible,
  [class*="__card"]:focus-visible,
  [class*="-card"]:focus-visible,
  .ev-glass:focus-visible {
    transform: none;
  }
}

/* ── Grid Overflow Prevention ───────────────────────────────────── */

/* Prevent grid children from overflowing due to min-width: auto default */
* {
  min-width: 0;
}

a {
  color: inherit;
}

.site-container,
.container {
  width: min(100% - 2rem, var(--site-max-width));
  margin-inline: auto;
}

/* ── Section Eyebrow — gold authority bar ─────────────────────────── */
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding: 0.35rem 0.9rem 0.35rem 0;
  font-size: 0.72rem;
  font-weight: var(--font-weight-extrabold, 800);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent-contrast, #825a1e);
}

.section-eyebrow::before {
  content: "";
  width: 2rem;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--color-accent-contrast, #825a1e),
    color-mix(in srgb, var(--color-accent-contrast, #825a1e) 30%, transparent)
  );
  border-radius: var(--radius-full, 999px);
}

/* ── Primary CTA Button — deep sapphire authority ─────────────────── */
.btn-primary,
.btn-ghost,
.btn-lg,
.btn-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.875rem;
  padding: 0.9rem 1.35rem;
  border-radius: var(--radius-full, 999px);
  border: 1px solid transparent;
  font-weight: var(--font-weight-bold, 700);
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--duration-fast, 150ms) var(--ease-out),
    box-shadow var(--duration-normal, 250ms) var(--ease-out),
    border-color var(--duration-fast, 150ms) ease,
    background-color var(--duration-fast, 150ms) ease;
}

.btn-primary {
  color: var(--gem-sapphire-text, #d0dcff);
  background: var(--gem-sapphire, linear-gradient(135deg, #0a1a6e 0%, #1f3a99 35%, #3d64cc 60%, #128 100%));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--gem-sapphire-flat, #1f3a99) 20%, transparent);
}

.btn-primary:hover {
  box-shadow: 0 8px 24px color-mix(in srgb, var(--gem-sapphire-flat, #1f3a99) 24%, transparent);
}

.btn-ghost {
  color: var(--color-text, #1a2040);
  background: var(--surface-card);
  border-color: var(--border-default);
  /* No backdrop-filter — solid surface, legible at all times */
}

.btn-ghost:hover {
  border-color: var(--color-primary, #1f3a99);
  background: var(--surface-elevated);
}

.btn-lg {
  padding-inline: 1.65rem;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
}

.btn-primary:hover,
.btn-ghost:hover,
.site-header__btn:hover,
.flag-hero__cta:hover,
.replay-btn:hover {
  transform: translateY(-1px);
  /* Restrained lift — presence without theater */
}

.homepage-body section,
.app-page section {
  position: relative;
}

/* ── Focus Visible — WCAG 2.4.11 compliant focus indicator ──────────
   Gold outline at 3px offset, tight 3px ring. Precise, not decorative.
   The spread is 5px total (2px outline + 3px offset) — exceeds WCAG
   minimum of 3px perimeter at ≥3:1 contrast ratio.
   ──────────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent, #f7b32b);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px rgb(247 179 43 / 28%);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--color-accent, #f7b32b) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 3px rgb(247 179 43 / 28%) !important;
}

/* Remove glow on non-interactive focus (e.g. scroll containers) */
[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* ── Selection — branded highlight ────────────────────────────────── */
::selection {
  background: color-mix(in srgb, var(--color-primary, #1f3a99) 18%, transparent);
  color: var(--color-text, #1a2040);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  body {
    animation: none;
    background-attachment: scroll;
  }

  .btn-primary,
  .btn-ghost,
  .site-header__btn,
  .flag-hero__cta,
  .replay-btn {
    transition: none;
  }

  .btn-primary:hover,
  .btn-ghost:hover,
  .site-header__btn:hover,
  .flag-hero__cta:hover,
  .replay-btn:hover {
    transform: none;
  }
}
