/* CodeSwiftr card games: shared styles for /games, /cardgame and /<slug>.
   Concept: a calm card table. Pages are baize felt, games are ivory playing
   cards with the game's own felt as the face. Per-page and per-card felt
   arrives as --felt-1/2/3, --accent and --ink, set inline by build-games.py. */

:root {
  --felt-1: #183A2E;
  --felt-2: #0D241C;
  --felt-3: #07130F;
  --accent: #D8B46A;
  --ink: #F5EEE0;
  --ink-muted: rgba(245, 238, 224, 0.76);
  --ink-faint: rgba(245, 238, 224, 0.54);
  --paper: #F3EBDB;
  --card-ink: #211D27;
  --card-red: #A5352C;
  --pip-red: #DE6E61;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --step--1: 0.84rem;
  --step-0: 1.0625rem;
  --step-1: 1.33rem;
  --step-2: clamp(1.6rem, 4.2vw, 2.15rem);
  --step-3: clamp(2rem, 6vw, 3rem);
  --step-4: clamp(2.9rem, 11vw, 5.4rem);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--felt-3);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
}

/* The felt: one overhead lamp, a vignette and a faint nap. Fixed layers
   instead of background-attachment: fixed, which iOS Safari ignores. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background: radial-gradient(130% 85% at 50% 0%, var(--felt-1) 0%, var(--felt-2) 50%, var(--felt-3) 100%);
}
body::after {
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 20;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: var(--paper);
  color: var(--card-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: max(12px, env(safe-area-inset-top)); }

.wrap {
  width: min(1120px, calc(100% - var(--gutter) * 2));
  margin-inline: auto;
}

/* ---------- Header ---------- */
.site-header { padding-top: max(10px, env(safe-area-inset-top)); }
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font: 600 1.15rem/1 var(--display);
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 26px; height: 26px; flex: none; transform: rotate(-8deg); }
.brand-sub { font: 400 1rem/1 var(--sans); color: var(--ink-faint); }
.site-nav { display: flex; gap: 2px; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.94rem;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.5em; }
@media (max-width: 420px) {
  .brand-sub { display: none; }
  .site-nav a { padding: 0 9px; font-size: 0.9rem; }
}

/* ---------- Type ---------- */
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); line-height: 0.98; letter-spacing: -0.028em; }
h2 { font-size: var(--step-3); line-height: 1.05; letter-spacing: -0.02em; }
h3 { font-size: var(--step-1); line-height: 1.2; letter-spacing: -0.01em; }
h2 a, h3 a { color: inherit; text-decoration: none; }
p { margin: 0; }
.lede {
  font: 600 var(--step-2)/1.2 var(--display);
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.sub { color: var(--ink-muted); max-width: 33em; text-wrap: pretty; }
.muted { color: var(--ink-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 600 1rem/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-gold { background: var(--accent); color: #1C1608; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn-gold:hover { background: #E4C584; color: #1C1608; }
.btn-ghost { border-color: rgba(245, 238, 224, 0.28); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { min-height: 44px; padding: 0 18px; font-size: 0.94rem; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.appstore {
  display: inline-flex;
  align-items: center;
  min-height: 56px;
  padding: 8px 22px;
  border-radius: 14px;
  background: #000;
  border: 1px solid rgba(245, 238, 224, 0.4);
  color: #fff;
  text-decoration: none;
}
.appstore:hover { color: #fff; border-color: var(--accent); }
.appstore span { display: flex; flex-direction: column; line-height: 1.1; }
.appstore small { font-size: 0.72rem; opacity: 0.85; }
.appstore strong { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }
.appstore-sm { min-height: 44px; padding: 5px 16px; border-radius: 11px; }
.appstore-sm strong { font-size: 1.02rem; }

/* ---------- Hero ---------- */
.hero { padding: clamp(24px, 6vw, 72px) 0 clamp(36px, 7vw, 80px); }
.hero-grid, .feature-grid {
  display: grid;
  gap: clamp(20px, 5vw, 56px);
  align-items: center;
}
@media (min-width: 900px) {
  .hero-grid, .feature-grid { grid-template-columns: 1.1fr 0.9fr; }
}
.hero-id {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
}
.app-icon {
  width: 56px; height: 56px;
  flex: none;
  border-radius: 22.5%;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(245, 238, 224, 0.14);
}
.emblem { flex: none; }
.hero h1 { margin-bottom: 18px; }
.hero .lede { margin-bottom: 14px; max-width: 18em; }
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}
.promise-line { margin-top: 14px; color: var(--accent); font-size: 0.95rem; font-weight: 500; }

.hero-art { width: 100%; max-width: 480px; margin-inline: auto; }
.fan { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 22px 26px rgba(0, 0, 0, 0.45)); }

/* The one motion moment: the hand is dealt out once on load. */
.fan-card {
  transform-origin: 200px 420px;
  transform: rotate(var(--a));
  animation: deal 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(150ms + var(--i) * 80ms);
}
@keyframes deal {
  from { transform: translateY(34px) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
}

.facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 24px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

/* ---------- Waitlist ---------- */
.wl { width: 100%; max-width: 440px; }
.wl-label { display: block; margin-bottom: 10px; font-size: 0.95rem; font-weight: 600; }
.wl-row { display: flex; gap: 8px; }
.wl input[type="email"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(245, 238, 224, 0.3);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: 400 16px/1.2 var(--sans); /* 16px stops iOS zoom on focus */
}
.wl input[type="email"]::placeholder { color: var(--ink-faint); }
.wl input[type="email"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(216, 180, 106, 0.3); }
.wl .btn { flex: none; }
.wl-note { margin-top: 10px; font-size: var(--step--1); color: var(--ink-faint); }
.wl-status { margin-top: 10px; font-size: 0.95rem; }
.wl-status:empty { display: none; }
.wl-status[data-tone="error"] { color: #F4B9AA; }
.wl-status[data-tone="ok"] { color: var(--ink); }
.wl.is-done .wl-row, .wl.is-done .wl-note, .wl.is-done .wl-label { display: none; }
.wl.is-done .wl-status { margin-top: 0; font: 600 1.1rem/1.35 var(--display); }
.wl-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 420px) {
  .wl-row { flex-direction: column; }
  .wl .btn { width: 100%; }
}

/* ---------- Sections ---------- */
.section { padding: clamp(40px, 8vw, 88px) 0; }
.section-head { max-width: 38rem; margin-bottom: clamp(22px, 4vw, 36px); }
.section-head p { margin-top: 10px; }
.section-more { padding-top: clamp(16px, 4vw, 40px); }
.more-link { margin-top: 28px; }

/* Suit pips as list markers: black suits in ivory, red suits in red. */
.pip { width: 22px; height: 22px; color: var(--ink); }
.features li:nth-child(4n+2) .pip, .features li:nth-child(4n+3) .pip,
.promise li:nth-child(4n+2) .pip, .promise li:nth-child(4n+3) .pip { color: var(--pip-red); }

.features {
  display: grid;
  gap: 28px 48px;
  max-width: 920px;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 760px) { .features { grid-template-columns: 1fr 1fr; } }
.features li {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 16px;
  align-items: start;
}
.features .pip { grid-row: span 2; margin-top: 3px; }
.features h3 { margin-bottom: 6px; }
.features p { color: var(--ink-muted); max-width: 30em; }

/* ---------- Gallery ---------- */
.gallery {
  display: flex;
  gap: 14px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 4px var(--gutter) 18px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery li { flex: 0 0 clamp(190px, 62vw, 260px); scroll-snap-align: start; }
.gallery img {
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 1304;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 20px 36px -24px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(245, 238, 224, 0.08);
}
.gallery-hint { font-size: var(--step--1); color: var(--ink-faint); }
@media (min-width: 900px) {
  .gallery {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  .gallery-hint { display: none; }
}

/* ---------- Closing call to action ---------- */
.cta-band {
  display: grid;
  gap: 24px;
  align-items: end;
}
.cta-band h2 { margin-bottom: 10px; }
.cta-band p { max-width: 28em; }
@media (min-width: 860px) { .cta-band { grid-template-columns: 1fr auto; } .cta-band .wl { width: 440px; } }

/* ---------- Playing cards (the catalog) ---------- */
.hand {
  --cols: 2;
  --gap: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 700px) { .hand { --cols: 3; --gap: 22px; row-gap: 30px; } }
@media (min-width: 1000px) { .hand { --cols: 4; } }
.hand-catalog { justify-content: center; }
.hand > li { display: flex; flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); }
.hand > li:nth-child(4n+1) { --tilt: -1.6deg; }
.hand > li:nth-child(4n+2) { --tilt: 1deg; }
.hand > li:nth-child(4n+3) { --tilt: -0.6deg; }
.hand > li:nth-child(4n+4) { --tilt: 1.4deg; }

.pc {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  aspect-ratio: 5 / 7;
  padding: 12px 27px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--card-ink);
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 2px 3px rgba(0, 0, 0, 0.35), 0 22px 34px -20px rgba(0, 0, 0, 0.9);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.25s ease;
}
.pc:hover { color: var(--card-ink); }
@media (hover: hover) {
  .pc:hover { transform: translateY(-8px) rotate(0deg); }
}
.pc:focus-visible { transform: translateY(-8px) rotate(0deg); outline-offset: 5px; border-radius: 12px; }
.pc-index {
  position: absolute;
  top: 10px;
  left: 5px;
  width: 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--card-ink);
}
.pc-red .pc-index { color: var(--card-red); }
.pc-index-flip { top: auto; left: auto; bottom: 10px; right: 5px; transform: rotate(180deg); }
.pc-rank { font: 600 1.02rem/1 var(--display); letter-spacing: -0.06em; }
.pc-pip { width: 12px; height: 12px; }
.pc-face {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 14px;
  border-radius: 6px;
  background: linear-gradient(165deg, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(216, 180, 106, 0.55), inset 0 0 0 4px var(--felt-2), inset 0 0 0 5px rgba(216, 180, 106, 0.25);
}
.pc-name { font: 600 clamp(1.15rem, 3.4vw, 1.5rem)/1.08 var(--display); letter-spacing: -0.01em; }
.pc-alt { margin-top: 4px; font-size: 0.8rem; color: var(--ink-faint); }
.pc-center { flex: 1; display: grid; place-items: center; min-height: 20px; padding: 8px 0; }
.pc-big { width: 36%; max-width: 64px; color: var(--accent); opacity: 0.3; }
.pc-tagline { font-size: 0.86rem; line-height: 1.45; color: var(--ink-muted); }
.pc-status { padding-top: 12px; font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.pc.is-next .pc-status { color: var(--ink); }
.pc.is-next .pc-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--accent); }
@media (max-width: 480px) {
  .pc { padding: 10px 23px; border-radius: 10px; }
  .pc-index { left: 4px; }
  .pc-index-flip { right: 4px; }
  .pc-face { padding: 12px 10px 10px; }
  .pc-tagline { font-size: 0.8rem; }
  .pc-status { font-size: 0.78rem; }
}

/* ---------- Hub ---------- */
.hub-hero h1 { max-width: 12ch; }
.hub-hero .sub { margin-top: 20px; }
.promise {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 24px;
  margin: clamp(32px, 6vw, 52px) 0 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 900px) { .promise { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.promise .pip { margin-bottom: 12px; }
.promise strong { display: block; margin-bottom: 4px; font: 600 1.12rem/1.25 var(--display); }
.promise span { color: var(--ink-muted); font-size: 0.93rem; }

/* The featured game sits on its own table: a full-bleed band of its felt. */
.feature-game {
  background: radial-gradient(120% 90% at 30% 0%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  box-shadow: inset 0 18px 30px -18px rgba(0, 0, 0, 0.7), inset 0 -18px 30px -18px rgba(0, 0, 0, 0.7);
}
.feature-game h2 { font-size: var(--step-4); line-height: 0.98; letter-spacing: -0.028em; margin-bottom: 16px; }
.feature-game .lede { margin-bottom: 12px; }
.feature-copy .hero-cta { margin-top: 26px; }

/* ---------- Recommender (/cardgame) ---------- */
.rec-hero { padding: clamp(16px, 5vw, 48px) 0 22px; }
.rec-hero h1 { font-size: var(--step-3); line-height: 1.05; margin-bottom: 10px; max-width: 16ch; }
.rec-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 760px) { .rec-list { grid-template-columns: 1fr 1fr; gap: 16px; } }
.rec-list > li { display: flex; }
.rec-list > li[hidden] { display: none; }
.rec {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--felt-1) 0%, var(--felt-2) 70%);
  box-shadow: inset 0 0 0 1px rgba(216, 180, 106, 0.24), 0 18px 30px -24px rgba(0, 0, 0, 0.9);
}
.rec-top { display: flex; align-items: center; gap: 14px; }
.rec h3 { font-size: 1.4rem; }
.rec-alt { font: 400 0.82rem/1 var(--sans); color: var(--ink-faint); margin-left: 4px; }
.rec-status { margin-top: 3px; font-size: 0.88rem; font-weight: 500; color: var(--accent); }
.rec-tagline { color: var(--ink-muted); }
.rec-price { color: var(--accent); font-size: 0.92rem; font-weight: 500; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: auto; }
.rec-actions details { flex: 0 0 auto; }
.rec-actions details[open] { flex: 1 1 100%; }
.rec-actions summary { list-style: none; display: inline-flex; cursor: pointer; }
.rec-actions summary::-webkit-details-marker { display: none; }
.rec-actions details[open] summary { margin-bottom: 14px; }
.rec-actions details[open] summary .btn { background: transparent; color: var(--ink); border-color: rgba(245, 238, 224, 0.28); box-shadow: none; }
.rec-actions .wl { max-width: none; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: clamp(24px, 5vw, 56px);
  padding: 28px 0 max(28px, env(safe-area-inset-bottom));
  color: var(--ink-faint);
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.18);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-muted);
  text-decoration: none;
}
.footer-links a:hover { color: var(--ink); }
.footer-links a.footer-more { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fan-card { animation: none; }
  .pc, .btn { transition: none; }
}
