/* ============================================================
   8puzzles — Infinity Puzzles Co.
   Parent-site design system. Same physical world as the games
   (paper-light + dark, neumorphic depth, Inter body / Oswald
   headings / Shrikhand wordmarks) — but the parent chrome stays
   ink-and-paper neutral: ALL color belongs to the six games.
   Theme via [data-theme="dark"].
   ============================================================ */

/* ---------------- fonts (self-hosted, latin subsets) ---------------- */
@font-face { font-family: "Shrikhand"; font-style: normal; font-weight: 400; font-display: swap; src: url("/puzzles-fonts/shrikhand-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 500; font-display: swap; src: url("/puzzles-fonts/oswald-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 600; font-display: swap; src: url("/puzzles-fonts/oswald-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap; src: url("/puzzles-fonts/oswald-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/puzzles-fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/puzzles-fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/puzzles-fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("/puzzles-fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* ---------------- tokens ---------------- */
:root {
  --bg: #f7f3e8;
  --surface: #fffaf0;
  --surface-2: #efe7d6;
  --text: #1f1f1c;
  --muted: #6f675b;
  --border: #ded6c7;
  --btn-bg: #fffaf0;
  --btn-text: #2c2924;
  --btn-hover-bg: #f0e8d8;
  --neu-dark: rgba(0, 0, 0, 0.12);
  --neu-light: rgba(255, 255, 255, 0.75);
  --radius: 16px;
  --radius-lg: 22px;
  --maxw: 1080px;
  /* the six games (light-theme accessible accent + bright decorative pair) */
  --crowns: #2563eb;  --crowns-2: #3b82f6;
  --patches: #6d28d9; --patches-2: #7c3aed;
  --climb: #be123c;   --climb-2: #e11d48;
  --pippy: #15803d;   --pippy-2: #16a34a;
  --wend: #0f766e;    --wend-2: #0d9488;
  --zippy: #b4530a;   --zippy-2: #ea7a28;
  font-synthesis: none;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --surface-2: #1f1f1f;
  --text: #e5e5e5;
  --muted: #a3a3a3;
  --border: #262626;
  --btn-bg: #2d2d2d;
  --btn-text: #e5e5e5;
  --btn-hover-bg: #404040;
  --neu-dark: rgba(0, 0, 0, 0.4);
  --neu-light: rgba(255, 255, 255, 0.045);
  /* brighter accent as the readable one on dark */
  --crowns: #60a5fa;  --crowns-2: #3b82f6;
  --patches: #a78bfa; --patches-2: #7c3aed;
  --climb: #fb7185;   --climb-2: #e11d48;
  --pippy: #4ade80;   --pippy-2: #16a34a;
  --wend: #2dd4bf;    --wend-2: #0d9488;
  --zippy: #fdad63;   --zippy-2: #ea7a28;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.55;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden; /* decorative hero glyphs sit near the edges */
}

h1, h2, h3 { font-family: "Oswald", "Inter", sans-serif; font-weight: 700; letter-spacing: 0.01em; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; }

/* per-game accent hooks: any element with data-g gets --ga/--ga2 */
[data-g="crowns"]  { --ga: var(--crowns);  --ga2: var(--crowns-2); }
[data-g="patches"] { --ga: var(--patches); --ga2: var(--patches-2); }
[data-g="climb"]   { --ga: var(--climb);   --ga2: var(--climb-2); }
[data-g="pippy"]   { --ga: var(--pippy);   --ga2: var(--pippy-2); }
[data-g="wend"]    { --ga: var(--wend);    --ga2: var(--wend-2); }
[data-g="zippy"]   { --ga: var(--zippy);   --ga2: var(--zippy-2); }

/* ---------------- theme toggle ---------------- */
.theme-toggle {
  position: fixed; top: 14px; right: 14px; z-index: 50;
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--btn-bg); color: var(--btn-text);
  box-shadow: 5px 5px 12px var(--neu-dark), -5px -5px 12px var(--neu-light);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-toggle:hover { transform: translateY(-2px); box-shadow: 7px 7px 15px var(--neu-dark), -7px -7px 15px var(--neu-light); }
.theme-toggle:active { box-shadow: inset 4px 4px 8px var(--neu-dark), inset -4px -4px 8px var(--neu-light); }
.theme-toggle svg { width: 21px; height: 21px; }
.theme-toggle .ic-sun { display: none; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }

/* ---------------- hero ---------------- */
.hero {
  position: relative;
  min-height: 92svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: clamp(56px, 9vh, 96px) 20px clamp(40px, 6vh, 72px);
  overflow: visible;
}

/* faint scattered game glyphs — paper texture, not content */
.hero-glyphs { position: absolute; inset: 0; pointer-events: none; color: var(--text); }
.hero-glyphs svg { position: absolute; opacity: 0.055; width: 54px; height: 54px; }
.hg-1 { top: 12%; left: 8%; transform: rotate(-14deg); }
.hg-2 { top: 22%; right: 9%; transform: rotate(11deg); width: 44px !important; }
.hg-3 { bottom: 26%; left: 13%; transform: rotate(8deg); width: 46px !important; }
.hg-4 { bottom: 18%; right: 12%; transform: rotate(-9deg); }
.hg-5 { top: 55%; left: 4%; transform: rotate(17deg); width: 38px !important; }
.hg-6 { top: 48%; right: 4%; transform: rotate(-18deg); width: 40px !important; }
@media (max-width: 720px) { .hero-glyphs svg { width: 34px; height: 34px; opacity: 0.045; } }

.wordmark {
  margin: 0;
  font-family: "Shrikhand", "Oswald", serif; font-weight: 400;
  font-size: clamp(3.4rem, 11vw, 6rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--text);
}
.wordmark .wm-ch { display: inline-block; }
/* the "8" — a single tilted stroke that reads as an ∞ (that's the whole company).
   Drawn as an inline SVG mark so it can stroke itself on in one continuous line. */
.wordmark .wm-8 {
  display: inline-block;
  cursor: pointer;
  margin-right: 0.04em;
  line-height: 0;
}
.wm8-svg { height: 0.98em; width: auto; vertical-align: -0.135em; overflow: visible; }
.wm8-svg path { stroke: currentColor; }

.hero-co {
  margin: 10px 0 0;
  font-family: "Oswald", sans-serif; font-weight: 600;
  font-size: clamp(0.82rem, 2vw, 1rem);
  letter-spacing: 0.34em; text-indent: 0.34em; /* balance the tracking */
  text-transform: uppercase;
  color: var(--muted);
}

.hero-lead {
  margin: clamp(18px, 3vh, 28px) auto 0;
  max-width: 34rem;
  font-size: clamp(1.02rem, 2.4vw, 1.18rem);
  color: var(--text);
}
.hero-lead b { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---------------- the shelf (six launcher tiles) ---------------- */
.shelf {
  margin-top: clamp(26px, 4.5vh, 44px);
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: clamp(12px, 2vw, 18px);
  max-width: 1000px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: 148px; padding: 18px 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-decoration: none;
  box-shadow: 6px 6px 14px var(--neu-dark), -6px -6px 14px var(--neu-light);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: 8px 8px 18px var(--neu-dark), -8px -8px 18px var(--neu-light),
              0 14px 30px color-mix(in srgb, var(--ga) 22%, transparent);
}
.tile:active { transform: translateY(-1px); }
.tile:focus-visible { outline: 3px solid var(--ga); outline-offset: 3px; }
/* the game's official app icon, exactly as shipped by the game itself */
.tile-glyph { line-height: 0; }
.tile-glyph svg { width: 38px; height: 38px; }
.tile-name {
  font-family: "Shrikhand", "Oswald", serif; font-weight: 400;
  font-size: 1.06rem; color: var(--text); line-height: 1;
}
.tile-name .t8 { color: var(--ga); }
.tile-kind { font-size: 0.72rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }

.hero-more {
  margin-top: clamp(26px, 5vh, 42px);
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  color: var(--muted); text-decoration: none;
  transition: color 0.2s ease;
}
.hero-more:hover { color: var(--text); }
.hero-more svg { width: 16px; height: 16px; }

/* ---------------- game sections ---------------- */
.game {
  /* each game gets its own faint world-wash; works in both themes via --bg */
  background: color-mix(in srgb, var(--ga2) 6%, var(--bg));
  padding: clamp(64px, 11vh, 116px) 24px;
  transition: background-color 0.3s ease;
}
.game-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(36px, 6vw, 84px);
  align-items: center;
}
.game:nth-of-type(even) .demo-wrap { order: 2; }

.demo-wrap { display: flex; justify-content: center; }
.demo-card {
  position: relative;
  width: min(100%, 380px);
  aspect-ratio: 1;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 10px 10px 26px var(--neu-dark), -10px -10px 26px var(--neu-light);
  cursor: pointer;
  transition: box-shadow 0.3s ease;
}
.demo-card:hover { box-shadow: 12px 12px 30px var(--neu-dark), -12px -12px 30px var(--neu-light), 0 18px 44px color-mix(in srgb, var(--ga) 16%, transparent); }
.demo-card:focus-visible { outline: 3px solid var(--ga); outline-offset: 4px; }
.demo { width: 100%; height: 100%; display: block; }
/* dark theme: the boards are little physical objects — keep them on a light plate */
[data-theme="dark"] .demo-card { background: #efe9dc; box-shadow: 10px 10px 26px rgba(0,0,0,.5), -6px -6px 18px rgba(255,255,255,.04); }

.demo-replay {
  position: absolute; right: 12px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; color: #4a443a;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(31, 31, 28, 0.14);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
.demo-replay svg { width: 13px; height: 13px; }
.demo-card.played .demo-replay { opacity: 1; }

.game-copy { max-width: 46ch; }
.game-brand {
  margin: 0 0 6px;
  font-family: "Shrikhand", "Oswald", serif; font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 1.9rem); line-height: 1.1;
  color: var(--text);
}
.game-brand .g8 { color: var(--ga); }
.game-copy h2 {
  margin: 0 0 14px;
  font-size: clamp(1.7rem, 3.6vw, 2.45rem);
  line-height: 1.14;
}
.game-copy .game-desc { margin: 0 0 16px; font-size: 1.03rem; color: var(--text); }
.game-meta {
  margin: 0 0 24px;
  font-size: 0.86rem; font-weight: 600; color: var(--muted);
}
.game-meta .dot { color: var(--ga); font-weight: 700; }
/* plain wrapper: GSAP animates this, so the button's own hover transition
   never fights the reveal tween (transition:all + tween = frozen button) */
.game-cta { margin: 0; }

/* CTA — the games' primary-button recipe, in the game's own accent */
.btn-play {
  appearance: none; border: none; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 600; font-size: 1.02rem;
  padding: 13px 26px; border-radius: 24px; min-height: 50px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  white-space: nowrap;
  background: linear-gradient(145deg, var(--ga2), var(--ga));
  color: #fff;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--ga) 32%, transparent);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-play:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 14px 28px color-mix(in srgb, var(--ga) 40%, transparent); }
.btn-play:active { transform: translateY(0); box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.28); }
.btn-play:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.btn-play svg { width: 17px; height: 17px; }
/* dark theme: bright accents need dark label for contrast */
[data-theme="dark"] .btn-play { color: #101010; }

/* ---------------- ritual band ---------------- */
.ritual {
  background: var(--bg);
  padding: clamp(72px, 12vh, 130px) 24px;
  text-align: center;
}
.ritual-inner { max-width: 640px; margin: 0 auto; }
.ritual h2 { margin: 0 0 14px; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.ritual .ritual-copy { margin: 0 auto 34px; max-width: 44ch; font-size: 1.05rem; }
.loop-wrap { margin: 0 auto 34px; width: min(420px, 86%); }
.loop-svg { width: 100%; height: auto; display: block; overflow: visible; }
.ritual-points {
  margin: 0 auto; padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 14px;
  max-width: 560px;
}
.ritual-points li {
  padding: 9px 16px; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 600; color: var(--text);
  box-shadow: 4px 4px 10px var(--neu-dark), -4px -4px 10px var(--neu-light);
}

/* ---------------- footer ---------------- */
.footer {
  background: var(--surface-2);
  padding: clamp(44px, 7vh, 64px) 24px 34px;
  transition: background-color 0.3s ease;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; text-align: center; }
.footer-brand {
  font-family: "Shrikhand", "Oswald", serif; font-weight: 400;
  font-size: 1.5rem; color: var(--text); margin: 0 0 4px;
}
.fb8-svg { height: 0.98em; width: auto; vertical-align: -0.135em; margin-right: 0.04em; }
.fb8-svg path { stroke: currentColor; }
.footer-co { margin: 0 0 26px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.22em; text-indent: 0.22em; text-transform: uppercase; color: var(--muted); }
.footer-games {
  margin: 0 0 30px; padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px;
}
.footer-games a {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 0.95rem; color: var(--text); text-decoration: none;
  padding: 4px 2px;
}
.footer-games a:hover { color: var(--ga); }
.footer-games .glogo { width: 17px; height: 17px; flex: 0 0 auto; }
.footer-fine { margin: 0; font-size: 0.82rem; color: var(--muted); }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  .game-inner { grid-template-columns: 1fr; gap: 30px; }
  .game:nth-of-type(even) .demo-wrap { order: 0; }
  .game-copy { max-width: 54ch; margin: 0 auto; text-align: center; }
  .demo-card { width: min(100%, 330px); }
  .theme-toggle { top: 10px; right: 10px; width: 42px; height: 42px; }
}
@media (max-width: 480px) {
  .tile { width: calc(50% - 7px); padding: 15px 8px 12px; }
  .tile-glyph svg { width: 33px; height: 33px; }
  .shelf { gap: 12px; width: 100%; }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
