/* Spark Games — landing page styles.

   Matches the Spark Transcribe home-hub aesthetic: warm terracotta radial
   wash on a soft neutral base, Apple system fonts, generous tap targets,
   iOS-web-app polish (safe-area insets, no rubber-band, large-title feel).

   No CDN fonts. No frameworks. Static + hand-authored, works offline. */

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

:root {
  --bg:          #fdf8f3;
  --bg-tint:     #f5ebde;
  --card:        #ffffff;
  --card-2:      rgba(255, 255, 255, 0.72);
  --text:        #1d1d1f;
  --text-muted:  #6e6e73;
  --accent:      #c87850;   /* Spark terracotta */
  --accent-2:    #e08a64;
  --accent-soft: rgba(200, 120, 80, 0.10);
  --line:        rgba(29, 29, 31, 0.08);
  --line-strong: rgba(29, 29, 31, 0.16);
  --shadow-sm:   0 1px 2px rgba(29, 29, 31, 0.05);
  --shadow:      0 8px 24px rgba(200, 120, 80, 0.08);
  --radius:      18px;
  --radius-sm:   12px;
  --radius-lg:   28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0a0a0d;
    --bg-tint:     #14100e;
    --card:        #1c1c1e;
    --card-2:      rgba(28, 28, 30, 0.72);
    --text:        #f5f5f7;
    --text-muted:  #98989d;
    --accent:      #e08a64;
    --accent-2:    #ee9a74;
    --accent-soft: rgba(232, 150, 113, 0.14);
    --line:        rgba(245, 245, 247, 0.08);
    --line-strong: rgba(245, 245, 247, 0.16);
    --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:      0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "PingFang TC", "PingFang SC", "Noto Sans TC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;

  background:
    radial-gradient(1200px 800px at 15% 12%, var(--accent-soft), transparent 60%),
    radial-gradient(1000px 700px at 90% 90%, var(--accent-soft), transparent 55%),
    var(--bg);
  background-attachment: fixed;

  padding-top:    env(safe-area-inset-top);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── top nav ──────────────────────────────────────────────────────────── */

.games-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(253, 248, 243, 0.72);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
          backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .games-nav { background: rgba(10, 10, 13, 0.72); }
}

.games-nav .brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 16.5px; font-weight: 600; letter-spacing: 0.005em;
  color: var(--text);
}
.games-nav .brand .mark {
  color: var(--accent); font-size: 18px; line-height: 1;
}
.games-nav .nav-actions {
  display: inline-flex; align-items: center; gap: 8px;
}
.games-nav .back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14.5px; color: var(--text-muted);
  padding: 6px 10px; border-radius: 999px;
}
.games-nav .back:hover { color: var(--text); background: var(--accent-soft); }

#lang-toggle {
  min-width: 52px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
#lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── hero + large-title ───────────────────────────────────────────────── */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.page-title {
  margin: 26px 4px 6px;
  font-size: clamp(33px, 6.2vw, 46px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-title .mark {
  color: var(--accent); font-size: 0.82em;
  margin-right: 7px;
  display: inline-block;
  animation: sg-spark 4s ease-in-out infinite;
}
.page-title-sub {
  margin: 4px 4px 24px;
  font-size: 15px; color: var(--text-muted);
}

/* ── entrance choreography ─────────────────────────────────────────────
   Everything fades + rises in on load, staggered top-to-bottom, so the
   page assembles itself rather than snapping in. Honors reduced-motion. */
@keyframes sg-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sg-spark {
  0%, 100% { transform: rotate(0)   scale(1);    opacity: 1;   }
  50%      { transform: rotate(18deg) scale(1.12); opacity: .82; }
}
@keyframes sg-float {
  0%, 100% { transform: translateY(0)   rotate(0);   }
  50%      { transform: translateY(-7px) rotate(9deg); }
}
@keyframes sg-sheen {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.page-title,
.page-title-sub,
.section-label,
.hero-featured,
.game-grid .game-card,
.games-foot {
  animation: sg-rise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}
.page-title      { animation-delay: 0.02s; }
.page-title-sub  { animation-delay: 0.07s; }
.hero-featured   { animation-delay: 0.12s; }
.section-label   { animation-delay: 0.18s; }
.game-grid .game-card:nth-child(1) { animation-delay: 0.22s; }
.game-grid .game-card:nth-child(2) { animation-delay: 0.27s; }
.game-grid .game-card:nth-child(3) { animation-delay: 0.32s; }
.game-grid .game-card:nth-child(4) { animation-delay: 0.37s; }
.game-grid .game-card:nth-child(5) { animation-delay: 0.42s; }
.game-grid .game-card:nth-child(6) { animation-delay: 0.47s; }
.game-grid .game-card:nth-child(7) { animation-delay: 0.52s; }
.games-foot      { animation-delay: 0.56s; }

@media (prefers-reduced-motion: reduce) {
  .page-title, .page-title-sub, .section-label, .hero-featured,
  .game-grid .game-card, .games-foot, .page-title .mark,
  .hero-card::before, .hero-card .hero-icon {
    animation: none !important;
  }
}

/* Featured Spark Jump — big card, full width, animated aurora sheen */
.hero-featured {
  margin-bottom: 24px;
}
.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 24px 26px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(200,120,80,0.24), rgba(232,150,113,0.10) 58%, transparent),
    var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform 0.16s cubic-bezier(.2,.7,.3,1), box-shadow 0.16s ease;
  min-height: 138px;
}
/* Slow-drifting warm sheen band across the hero — subtle, premium. */
.hero-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg,
    transparent 30%, rgba(255,255,255,0.14) 48%, transparent 66%);
  background-size: 200% 100%;
  animation: sg-sheen 7s linear infinite;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .hero-card::before { background: linear-gradient(110deg,
    transparent 30%, rgba(255,255,255,0.06) 48%, transparent 66%);
    background-size: 200% 100%; }
}
.hero-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(200,120,80,0.18); }
.hero-card:active { transform: translateY(-1px) scale(0.995); }
.hero-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.hero-card .hero-badge {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 9px;
}
.hero-card h1 {
  margin: 0 0 5px;
  font-size: clamp(25px, 4.6vw, 31px);
  font-weight: 700; letter-spacing: -0.015em;
}
.hero-card p {
  margin: 0;
  font-size: 14.5px; color: var(--text-muted);
  line-height: 1.42;
}
/* Play affordance — a soft terracotta disc with a ▶ that pulses on hover. */
.hero-card .hero-play {
  position: relative;
  width: 76px; height: 76px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, rgba(232,150,113,0.30), rgba(200,120,80,0.16));
  color: var(--accent);
  font-size: 30px;
  animation: sg-float 3.6s ease-in-out infinite;
}
.hero-card .hero-play::after {
  content: "▶";
  margin-left: 4px;
  filter: drop-shadow(0 2px 6px rgba(200,120,80,0.35));
}
.hero-card:hover .hero-play {
  box-shadow: 0 0 0 8px var(--accent-soft);
}
/* Best-score line under the hero tagline (populated by JS). */
.hero-card .hero-best {
  margin-top: 10px;
  font-size: 12.5px; font-weight: 600;
  color: var(--accent);
  display: none;
}
.hero-card .hero-best.show { display: block; }

/* ── grid of 7 remaining games ────────────────────────────────────────── */

.section-label {
  margin: 24px 6px 12px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.12em; text-transform: uppercase;
}

.game-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.game-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px; align-items: center;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  min-height: 88px;
  overflow: hidden;
  transition: transform 0.16s cubic-bezier(.2,.7,.3,1),
              box-shadow 0.16s ease, border-color 0.16s ease;
}
.game-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent-soft);
}
.game-card:active { transform: translateY(0) scale(0.99); }
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* On hover, the icon tile blooms slightly + the chevron slides in. */
.game-card:hover .icon { transform: scale(1.06) rotate(-3deg); }
.game-card:hover .chevron { opacity: 0.9; transform: translateX(2px); }

.game-card .icon {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1;
  background: var(--accent-soft);
  color: var(--accent);
  transition: transform 0.18s cubic-bezier(.26,1.4,.6,1);
}
.game-card .icon.warm    { background: rgba(232, 150, 113, 0.18); color: #c87850; }
.game-card .icon.gold    { background: rgba(230, 183, 72,  0.18); color: #ca9a2b; }
.game-card .icon.cyan    { background: rgba(127, 212, 255, 0.18); color: #2b8bbf; }
.game-card .icon.violet  { background: rgba(160, 130, 210, 0.18); color: #6b53a3; }
.game-card .icon.mint    { background: rgba(120, 210, 170, 0.18); color: #298a67; }
.game-card .icon.rose    { background: rgba(232, 130, 140, 0.18); color: #b04e5c; }
.game-card .icon.olive   { background: rgba(160, 180, 100, 0.18); color: #6b7b3c; }
@media (prefers-color-scheme: dark) {
  .game-card .icon.warm    { color: #f2a684; }
  .game-card .icon.gold    { color: #e6c76e; }
  .game-card .icon.cyan    { color: #9ad9f5; }
  .game-card .icon.violet  { color: #b39ce0; }
  .game-card .icon.mint    { color: #a2e0c2; }
  .game-card .icon.rose    { color: #f0a4ad; }
  .game-card .icon.olive   { color: #c1cf82; }
}

.game-card .text { min-width: 0; }
.game-card .text strong {
  display: block;
  font-size: 15.5px; font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.game-card .text em {
  display: block;
  font-size: 12.5px; color: var(--text-muted);
  font-style: normal; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
/* Personal best chip — appears only when the player has a saved score for
   this game (populated by JS reading each game's localStorage key). */
.game-card .best {
  display: none;
  margin-top: 5px;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.game-card .best.show { display: block; }
.game-card .chevron {
  width: 20px; height: 20px;
  color: var(--text-muted); opacity: 0.5;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

/* ── footer ───────────────────────────────────────────────────────────── */

.games-foot {
  margin: 40px 6px 6px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-muted);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 8px;
}
.games-foot .foot-brand { color: var(--accent); }

/* ── responsive ───────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  main { padding: 16px 16px 48px; }
  .hero-card { padding: 20px 20px; gap: 14px; }
  .hero-card .hero-play { width: 58px; height: 58px; font-size: 24px; }
  .page-title { font-size: 31px; margin: 22px 4px 4px; }
}
