/* ============================================================================
   AMERICA 250 — Shared Design System
   US Semiquincentennial (1776–2026)
   Vanilla CSS. No build step. No external libraries. Mobile-first.
   ----------------------------------------------------------------------------
   Load from a game: <link rel="stylesheet" href="../../shared/design.css">
   Load from the hub: <link rel="stylesheet" href="shared/design.css">
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. DESIGN TOKENS (CSS custom properties)
   Refined federal palette — deep, dignified, not garish.
   --------------------------------------------------------------------------- */
:root {
  /* Core palette */
  --c-navy:        #0A2342;   /* deep federal navy — primary ground */
  --c-navy-deep:   #061528;   /* darker navy for shadows/wells */
  --c-navy-soft:   #14365C;   /* raised navy panels */
  --c-red:         #B22234;   /* federal/Old Glory red */
  --c-red-deep:    #8E1B29;   /* pressed red */
  --c-cream:       #F7F3E8;   /* parchment / antique white */
  --c-cream-dim:   #E8E0CC;   /* muted parchment */
  --c-white:       #FFFFFF;
  --c-gold:        #C9A227;   /* federal gold accent */
  --c-gold-light:  #E4C95B;   /* gold highlight */
  --c-blue:        #3D5AFE;   /* bright federal blue (stars) */
  --c-ink:         #1A1A1A;   /* near-black text on light */

  /* Semantic surface tokens (default = on dark navy hub) */
  --bg:            var(--c-navy);
  --bg-deep:       var(--c-navy-deep);
  --surface:       var(--c-navy-soft);
  --surface-2:     #1B406A;
  --text:          var(--c-cream);
  --text-dim:      #B9C6D8;
  --text-invert:   var(--c-ink);
  --accent:        var(--c-gold);
  --accent-2:      var(--c-red);
  --line:          rgba(201, 162, 39, 0.28);   /* hairline gold */
  --line-soft:     rgba(247, 243, 232, 0.12);

  /* Type */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
                Georgia, "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
                Arial, "Helvetica Neue", sans-serif;

  /* Modular type scale (1.250 major third) */
  --t-xs:   0.75rem;
  --t-sm:   0.875rem;
  --t-base: 1rem;
  --t-md:   1.25rem;
  --t-lg:   1.563rem;
  --t-xl:   1.953rem;
  --t-2xl:  2.441rem;
  --t-3xl:  3.052rem;

  /* Spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  /* Radii & shadows */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-1: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-2: 0 6px 20px rgba(0,0,0,0.40);
  --shadow-glow: 0 0 0 1px var(--line), 0 8px 28px rgba(0,0,0,0.45);

  --maxw: 1100px;
  --header-h: 64px;
}

/* ---------------------------------------------------------------------------
   2. RESET / BASE
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  /* Subtle stitched-stripe + radial vignette ground */
  background-image:
    radial-gradient(120% 90% at 50% -10%, rgba(27,64,106,0.65) 0%, transparent 60%),
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.012) 0px,
      rgba(255,255,255,0.012) 2px,
      transparent 2px,
      transparent 28px
    );
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.15;
  margin: 0 0 var(--s-3);
  letter-spacing: 0.01em;
}
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }

p { margin: 0 0 var(--s-4); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--gold-light, var(--c-gold-light)); text-decoration: underline; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 3px solid var(--c-gold-light);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.usa-container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--s-4);
}

.usa-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   3. STAR / STRIPE MOTIF UTILITIES
   --------------------------------------------------------------------------- */

/* Thin tricolor rule: red / cream / navy band */
.usa-tricolor {
  height: 4px;
  width: 100%;
  background: linear-gradient(
    90deg,
    var(--c-red)   0%, var(--c-red)   33.33%,
    var(--c-cream) 33.33%, var(--c-cream) 66.66%,
    var(--c-navy-soft) 66.66%, var(--c-navy-soft) 100%
  );
}

/* A single CSS star (no asset). Use <span class="usa-star"></span> */
.usa-star {
  display: inline-block;
  width: 1em;
  height: 1em;
  background: var(--c-blue);
  vertical-align: -0.12em;
  clip-path: polygon(
    50% 0%, 61% 35%, 98% 35%, 68% 57%,
    79% 91%, 50% 70%, 21% 91%, 32% 57%,
    2% 35%, 39% 35%
  );
}
.usa-star.is-cream { background: var(--c-cream); }
.usa-star.is-red   { background: var(--c-red); }

/* Row of stars used as a decorative divider */
.usa-star-row {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  align-items: center;
  font-size: var(--t-md);
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   4. APP HEADER — "AMERICA 250 · 1776–2026"
   --------------------------------------------------------------------------- */
.usa-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--c-navy-deep), var(--c-navy));
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.usa-header__bar {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  justify-content: space-between;
  padding-block: var(--s-2);
}
.usa-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-decoration: none;
  color: var(--text);
}
.usa-brand:hover { text-decoration: none; }

/* Roundel seal: gold ring with a star, pure CSS */
.usa-brand__seal {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 40%, var(--c-navy-soft), var(--c-navy-deep));
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 2px rgba(201,162,39,0.25), var(--shadow-1);
}
.usa-brand__seal .usa-star { font-size: 18px; }

.usa-brand__text { display: flex; flex-direction: column; line-height: 1; }
.usa-brand__title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--t-md);
  letter-spacing: 0.06em;
  color: var(--c-cream);
}
.usa-brand__years {
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  letter-spacing: 0.32em;
  color: var(--accent);
  text-transform: uppercase;
  margin-top: 2px;
}
.usa-header__actions { display: flex; align-items: center; gap: var(--s-3); }

/* ---------------------------------------------------------------------------
   5. BUTTONS
   --------------------------------------------------------------------------- */
.usa-btn {
  --btn-bg: var(--c-red);
  --btn-fg: var(--c-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 0.7em 1.2em;
  min-height: 44px;          /* touch target */
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
  box-shadow: var(--shadow-1);
}
.usa-btn:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.usa-btn:active { transform: translateY(1px); }
.usa-btn:disabled, .usa-btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; box-shadow: none;
}

.usa-btn--primary { --btn-bg: var(--c-red); --btn-fg: #fff; }
.usa-btn--gold    { --btn-bg: var(--c-gold); --btn-fg: var(--c-navy-deep); }
.usa-btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--c-cream);
  border-color: var(--line);
  box-shadow: none;
}
.usa-btn--ghost:hover { background: rgba(247,243,232,0.06); }

.usa-btn--sm { font-size: var(--t-xs); min-height: 38px; padding: 0.55em 0.95em; }

/* Back-to-hub link */
.usa-back {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--t-sm);
  color: var(--text-dim);
  text-decoration: none;
}
.usa-back:hover { color: var(--c-cream); text-decoration: none; }
.usa-back::before { content: "\2190"; color: var(--accent); font-size: 1.1em; }

/* ---------------------------------------------------------------------------
   6. AUDIO TOGGLE BAR  (rendered by USA250Audio.mountToggleBar)
   Markup contract (audio.js emits exactly this):
     <div class="usa-audiobar" role="group" aria-label="Audio controls">
       <button class="usa-audiobar__btn" data-channel="master" aria-pressed="true">…</button>
       <button class="usa-audiobar__btn" data-channel="music"  aria-pressed="true">…</button>
       <button class="usa-audiobar__btn" data-channel="sfx"    aria-pressed="true">…</button>
     </div>
   .is-off is toggled by audio.js to reflect channel state.
   --------------------------------------------------------------------------- */
.usa-audiobar {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 4px;
  background: var(--c-navy-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}
.usa-audiobar__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-cream);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 8px 12px;
  min-height: 38px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, opacity .15s ease;
}
.usa-audiobar__btn:hover { background: rgba(247,243,232,0.07); }
.usa-audiobar__btn .usa-audiobar__icon { font-size: 1.05em; line-height: 1; }
/* ON state (default) shows a gold star pip */
.usa-audiobar__btn[aria-pressed="true"] {
  background: rgba(201,162,39,0.14);
  color: var(--c-gold-light);
}
/* OFF state */
.usa-audiobar__btn.is-off,
.usa-audiobar__btn[aria-pressed="false"] {
  color: var(--text-dim);
  opacity: 0.7;
}
.usa-audiobar__btn.is-off .usa-audiobar__icon { opacity: 0.5; }
/* Master, when off, dims the whole bar visually */
.usa-audiobar.is-muted { opacity: 0.85; }

/* ---------------------------------------------------------------------------
   7. HERO  (hub landing)
   --------------------------------------------------------------------------- */
.usa-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: var(--s-8) var(--s-4) var(--s-7);
  background:
    radial-gradient(80% 120% at 50% 0%, rgba(178,34,52,0.18), transparent 55%),
    linear-gradient(180deg, var(--c-navy-deep) 0%, var(--c-navy) 100%);
  border-bottom: 1px solid var(--line);
}
/* faint field-of-stars backdrop using radial dots */
.usa-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(247,243,232,0.10) 1.2px, transparent 1.6px);
  background-size: 38px 38px;
  background-position: 0 0;
  opacity: 0.5;
  pointer-events: none;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
}
.usa-hero > * { position: relative; z-index: 1; }
.usa-hero__title {
  font-size: var(--t-3xl);
  letter-spacing: 0.04em;
  margin-bottom: var(--s-2);
  color: var(--c-cream);
  text-shadow: 0 2px 18px rgba(0,0,0,0.5);
}
.usa-hero__title .num { color: var(--accent); }

/* Birthday-emblem hero image (Liberty Arcade) */
.usa-hero__emblem {
  display: block;
  width: min(640px, 86%);
  height: auto;
  margin: 0 auto var(--s-4);
  filter: drop-shadow(0 8px 28px rgba(0,0,0,0.55));
}
.usa-hero__sub {
  font-family: var(--font-sans);
  font-size: var(--t-md);
  color: var(--text-dim);
  max-width: 56ch;
  margin: 0 auto var(--s-5);
}
.usa-hero__years {
  font-family: var(--font-sans);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: var(--s-4);
}

/* ---------------------------------------------------------------------------
   8. GAME-CARD GRID
   --------------------------------------------------------------------------- */
.usa-section {
  padding-block: var(--s-7);
}
.usa-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.usa-section__title { margin: 0; color: var(--c-cream); }

/* Sub-section group label ("Arcade & Action", "Word & Puzzle") */
.usa-section__group {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-serif);
  font-size: var(--t-lg);
  color: var(--c-cream);
}
.usa-section__group::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Compact, image-forward grid: 2 cols on phones, up to 4 on wide desktop. */
.usa-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}
@media (min-width: 600px) {
  .usa-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 980px) {
  .usa-grid { grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
}

.usa-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform .14s ease, box-shadow .18s ease, border-color .18s ease;
}
.usa-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
  border-color: var(--line);
  text-decoration: none;
}
/* gold top edge accent */
.usa-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-red), var(--c-gold), var(--c-cream));
  opacity: 0.9;
}
/* IMAGE-FORWARD: the badge is the hero — square, fills the card width, on top. */
.usa-card__art {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(201,162,39,0.18), transparent 60%),
    var(--c-navy-deep);
  color: var(--accent);
  overflow: hidden;
}
/* Badge PNG fills the card-art frame — the prominent seller. */
.usa-card__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}
.usa-card:hover .usa-card__art img { transform: scale(1.05); }

/* Compact text block BELOW the image: title, then a small one-line desc, then PLAY. */
.usa-card__body {
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.usa-card__kicker {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.usa-card__title {
  font-family: var(--font-serif);
  font-size: var(--t-base);
  line-height: 1.15;
  margin: 1px 0 0;
  color: var(--c-cream);
}
/* SHORT one-line description: clamp to a single line, ellipsis if it runs long. */
.usa-card__desc {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-dim);
  margin: 2px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.usa-card__foot {
  margin-top: auto;
  padding-top: var(--s-2);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-gold-light);
}

/* "coming soon" / placeholder card */
.usa-card--soon {
  background: repeating-linear-gradient(
    135deg,
    var(--c-navy-soft) 0, var(--c-navy-soft) 12px,
    var(--c-navy-deep) 12px, var(--c-navy-deep) 24px
  );
  opacity: 0.75;
  cursor: default;
}
.usa-card--soon:hover { transform: none; box-shadow: var(--shadow-1); }

/* ---------------------------------------------------------------------------
   9. IN-GAME LAYOUT HELPERS
   --------------------------------------------------------------------------- */
.usa-gamebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding-block: var(--s-3);
}
.usa-instructions {
  background: rgba(247,243,232,0.05);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  font-size: var(--t-sm);
  color: var(--text-dim);
}
.usa-instructions strong { color: var(--c-cream); }

.usa-stage {
  background: var(--c-navy-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-2);
}

/* light "parchment" panel for occasional content on cream */
.usa-parchment {
  background: var(--c-cream);
  color: var(--text-invert);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.usa-parchment h1, .usa-parchment h2, .usa-parchment h3 { color: var(--c-navy); }

/* ---------------------------------------------------------------------------
   10. FOOTER
   --------------------------------------------------------------------------- */
.usa-footer {
  border-top: 1px solid var(--line);
  background: var(--c-navy-deep);
  padding-block: var(--s-6);
  text-align: center;
  color: var(--text-dim);
  font-size: var(--t-sm);
}
.usa-footer a { color: var(--accent); }

/* ---------------------------------------------------------------------------
   11. UTILITIES & MOTION
   --------------------------------------------------------------------------- */
.usa-center { text-align: center; }
.usa-stack > * + * { margin-top: var(--s-4); }
.usa-hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------------------
   12. WAVING-FLAG BACKGROUND HOOK  (flag-bg.js adds .usa250-flag-on to <html>)
   The fixed canvas (#usa250-flag-bg) is painted behind the page with its own
   built-in dark scrim, so legibility is guaranteed. Here we only unblock the
   body base color and let a few large grounds go slightly translucent so the
   flag reads "behind" the UI without ever fighting the foreground text.
   --------------------------------------------------------------------------- */
.usa250-flag-on body {
  /* Drop the opaque navy fill so the fixed flag canvas shows through.
     Keep the subtle stripe/vignette texture layered on top of the flag. */
  background-color: transparent;
  background-attachment: scroll, scroll;
}
/* Header & footer stay near-solid for crisp chrome, but let a hint through. */
.usa250-flag-on .usa-header {
  background: linear-gradient(180deg,
    rgba(6,21,40,0.94), rgba(10,35,66,0.90));
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.usa250-flag-on .usa-footer {
  background: rgba(6,21,40,0.82);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
/* Hero: let the waving flag glow through the navy gradient. */
.usa250-flag-on .usa-hero {
  background:
    radial-gradient(80% 120% at 50% 0%, rgba(178,34,52,0.18), transparent 55%),
    linear-gradient(180deg, rgba(6,21,40,0.55) 0%, rgba(10,35,66,0.45) 100%);
}
/* Section bodies / main get no extra fill — the flag shows in the gutters. */
/* Cards: translucent panels so the flag is sensed behind them, with a blur
   to keep title/desc text crisp. The scrim already darkened the flag. */
.usa250-flag-on .usa-card {
  background: linear-gradient(180deg,
    rgba(27,64,106,0.82), rgba(20,54,92,0.86));
  backdrop-filter: blur(3px) saturate(1.05);
  -webkit-backdrop-filter: blur(3px) saturate(1.05);
}
/* Game-stage / instruction panels stay readable over the flag too. */
.usa250-flag-on .usa-stage {
  background: rgba(6,21,40,0.86);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.usa250-flag-on .usa-instructions {
  background: rgba(247,243,232,0.06);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* If the user prefers reduced motion, flag-bg.js paints a single static frame;
   nothing animates. No additional CSS motion is introduced by this hook. */
