/* Antics portal — homepage (docs/00_DESIGN.md).
   Tokens from docs/06_SHARED_UI_BASELINE.md §1. The portal claims no accent of
   its own (§1): each card carries its game's accent, defined in the card
   accents block below. Adding a live game = adding one block there. */

:root,
:root[data-theme="light"] {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-raised: #F1EDE6;
  --ink: #232730;
  --ink-dim: #6B7280;
  --line: #DDD7CC;
  /* Chips are 12px/600 on --surface-raised, so they need the full 4.5:1 —
     --ink-dim only reaches 4.14:1 against that background. Darkened just
     enough to clear it (5.03:1) while still reading as secondary. */
  --chip-ink: #5E6572;
}

:root[data-theme="dark"] {
  --bg: #16181D;
  --surface: #1F232B;
  --surface-raised: #2A2F39;
  --ink: #E8E6E1;
  --ink-dim: #9AA0AB;
  --line: #333944;
  --chip-ink: #9AA0AB; /* 5.11:1 on --surface-raised — passes as-is */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181D;
    --surface: #1F232B;
    --surface-raised: #2A2F39;
    --ink: #E8E6E1;
    --ink-dim: #9AA0AB;
    --line: #333944;
    --chip-ink: #9AA0AB;
  }
}

/* Card accents — the game's own tokens, so a card matches the game it opens.
   Number Forge: ember, per its docs/02_UI.md §4 (light value darkened there
   for contrast; both are reproduced exactly). */
.card[data-accent="ember"] {
  --accent: #BC4217;
  /* Lightened from #F6E7DF: the New chip puts --accent text on this at 12px,
     which needed 4.5:1 and only had 4.43:1. Now 4.73:1. */
  --accent-soft: #FAEFE9;
}

:root[data-theme="dark"] .card[data-accent="ember"] {
  --accent: #FF6B35;
  --accent-soft: #33231C;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card[data-accent="ember"] {
    --accent: #FF6B35;
    --accent-soft: #33231C;
  }
}

/* Sudoku: lapis, per its docs/00_DESIGN.md §5 (same dark/light pair the game
   itself uses for entry numerals — the card matches the game exactly). */
.card[data-accent="lapis"] {
  --accent: #2451B3;
  --accent-soft: #E3EBFA;
}

:root[data-theme="dark"] .card[data-accent="lapis"] {
  --accent: #93BAF8;
  --accent-soft: #1E2A3B;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card[data-accent="lapis"] {
    --accent: #93BAF8;
    --accent-soft: #1E2A3B;
  }
}

/* Ant Colony Idle: leaf, per its docs/00_DESIGN.md §5 (the same dark/light
   pair the game itself uses — the card matches the game exactly). Both
   accent-on-soft pairings clear 4.5:1 (6.36 dark, 4.57 light) unmodified. */
.card[data-accent="leaf"] {
  --accent: #54761F;
  --accent-soft: #EAF2DC;
}

:root[data-theme="dark"] .card[data-accent="leaf"] {
  --accent: #8CBF4A;
  --accent-soft: #26301B;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card[data-accent="leaf"] {
    --accent: #8CBF4A;
    --accent-soft: #26301B;
  }
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, ui-rounded, sans-serif;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- header ------------------------------------------------------------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
}

.wordmark-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}

.mark {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.mark svg {
  width: 100%;
  height: 100%;
}

.wordmark {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

#theme-toggle {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms;
}

#theme-toggle:hover {
  background: var(--surface-raised);
}

:where(a, button):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* --- main --------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  padding: 32px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  margin-right: -0.18em; /* optical centering: tracking adds a trailing gap */
}

.hero h2 {
  margin-top: 8px;
  font-size: 1.25rem;
  font-weight: 600;
}

/* The 404's code is a display number, not a wordmark — no tracking. */
.notfound-code {
  letter-spacing: normal;
  margin-right: 0;
}

.hero a {
  color: var(--ink);
}

.hero p {
  margin-top: 12px;
  color: var(--ink-dim);
  text-wrap: balance;
}

/* --- cards -------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* One card reads as a feature rather than a gap in a shelf (§2 grid math). */
.cards > a:only-child {
  max-width: 480px;
  margin: 0 auto;
}

.card {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform 120ms, border-color 120ms;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card-tile svg {
  width: 34%;
  max-width: 84px;
  height: auto;
}

.card:hover .card-tile,
.card:focus-visible .card-tile {
  filter: brightness(1.08);
}

.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--chip-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.chip-new {
  background: var(--accent-soft);
  color: var(--accent);
}

.card-pitch {
  margin-top: 4px;
  color: var(--ink-dim);
  font-size: 0.9375rem;
}

/* --- coming soon -------------------------------------------------------- */

.soon {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  color: var(--ink-dim);
  font-size: 0.875rem;
}

.soon-label {
  font-weight: 600;
}

/* --- footer ------------------------------------------------------------- */

.footer {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 0.875rem;
}

.footer-nav {
  margin-bottom: 8px;
}

.footer-nav a {
  color: var(--ink-dim);
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--ink);
}

/* --- legal pages ---------------------------------------------------------- */

.legal {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 0;
}

.legal h1 {
  font-size: 2rem;
  font-weight: 800;
}

.legal-updated {
  margin-top: 4px;
  color: var(--ink-dim);
  font-size: 0.875rem;
}

.legal h2 {
  margin-top: 32px;
  font-size: 1.125rem;
  font-weight: 700;
}

.legal p,
.legal ul {
  margin-top: 12px;
}

.legal ul {
  padding-left: 1.25rem;
}

.legal li + li {
  margin-top: 6px;
}

.legal a {
  color: var(--ink);
}

.legal code {
  background: var(--surface-raised);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.contact-email {
  margin-top: 20px;
  font-size: 1.25rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 50ms !important;
  }

  .card:hover,
  .card:focus-visible {
    transform: none;
  }
}
