/* ==========================================================================
   Puzzlemore — design system
   Single stylesheet, no build step, no dependencies.
   ========================================================================== */

/* --- Tokens: light (default) ---------------------------------------------- */
:root {
  color-scheme: light;
  --brand:        #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft:   #dbeafe;
  --brand-ghost:  #eff6ff;

  --bg:        #ffffff;
  --bg-alt:    #f6f8fc;
  --surface:   #ffffff;
  --border:    #e3e8f0;
  --border-strong: #cbd5e1;

  --text:      #0f172a;
  --text-soft: #475569;
  --text-mute: #64748b;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .10);

  --radius:    14px;
  --radius-lg: 22px;
  --maxw:      1120px;
  --gutter:    clamp(1.25rem, 4vw, 2.5rem);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

/* --- Tokens: dark --------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand:        #60a5fa;
    --brand-strong: #93c5fd;
    --brand-soft:   #1e3a5f;
    --brand-ghost:  #16233b;

    --bg:        #0b1220;
    --bg-alt:    #101a2d;
    --surface:   #141f33;
    --border:    #24334d;
    --border-strong: #35486a;

    --text:      #e8eefc;
    --text-soft: #b3c1da;
    --text-mute: #8497b6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand:        #60a5fa;
  --brand-strong: #93c5fd;
  --brand-soft:   #1e3a5f;
  --brand-ghost:  #16233b;

  --bg:        #0b1220;
  --bg-alt:    #101a2d;
  --surface:   #141f33;
  --border:    #24334d;
  --border-strong: #35486a;

  --text:      #e8eefc;
  --text-soft: #b3c1da;
  --text-mute: #8497b6;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
img { height: auto; display: block; }

a, button, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }

h1, h2, h3, h4 {
  text-wrap: balance;
  scroll-margin-top: 88px;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 0 0 .5em;
  font-weight: 700;
}
h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.25rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.35rem); }
p  { margin: 0 0 1.1em; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: .75rem 1.25rem;
  z-index: 200;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* --- Layout --------------------------------------------------------------- */
.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.wrap-narrow { max-width: 760px; }

section { padding-block: clamp(3rem, 8vw, 5.5rem); }
.section-alt { background: var(--bg-alt); }

.eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: .75rem;
}

.lede {
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  color: var(--text-soft);
  max-width: 62ch;
}

.section-head { max-width: 62ch; margin-bottom: 2.5rem; }

/* --- Header --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.brand svg, .brand img { width: 32px; height: 32px; color: var(--brand); }
.brand:hover { color: var(--text); }

.nav { display: flex; align-items: center; gap: .35rem; }
.nav a {
  color: var(--text-soft);
  text-decoration: none;
  font-size: .95rem;
  font-weight: 500;
  padding: .5rem .8rem;
  border-radius: 9px;
}
.nav a:hover { color: var(--text); background: var(--bg-alt); }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }

.nav-toggle, .theme-toggle {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-soft);
  cursor: pointer;
}
.nav-toggle:hover, .theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.nav-toggle { display: none; }

@media (max-width: 820px) {
  .nav-toggle { display: grid; }
  .nav {
    position: absolute;
    inset: 68px 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: .5rem var(--gutter) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .nav[hidden] { display: none; }
  .nav a { padding: .8rem .25rem; font-size: 1.05rem; }
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8rem 1.4rem;
  border-radius: 11px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: .98rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary:hover { color: #0b1220; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary,
  :root:not([data-theme="light"]) .btn-primary:hover { color: #0b1220; }
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }

/* --- Store badges --------------------------------------------------------- */
.stores { display: flex; flex-wrap: wrap; gap: .7rem; margin: 0; padding: 0; list-style: none; }
.store-badge {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem 1.05rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.store-badge:hover { border-color: var(--brand); color: var(--text); transform: translateY(-1px); }
.store-badge svg { width: 22px; height: 22px; flex: none; }
.store-badge span { display: block; font-size: .68rem; color: var(--text-mute); line-height: 1.3; }
.store-badge strong { display: block; font-size: .95rem; line-height: 1.25; letter-spacing: -.01em; }
.store-badge[aria-disabled="true"] { opacity: .55; pointer-events: none; }

/* --- Hero ----------------------------------------------------------------- */
.hero {
  padding-block: clamp(3.5rem, 9vw, 6.5rem);
  background:
    radial-gradient(900px 420px at 15% -8%, var(--brand-ghost), transparent 70%),
    radial-gradient(700px 380px at 95% 5%, var(--brand-ghost), transparent 65%);
}
.hero { position: relative; }
.hero > .wrap { position: relative; z-index: 1; }

/* Sudoku-style grid backdrop: thin cell lines, a heavier line every third
   cell, faded out toward the edges so the text stays fully readable. */
.hero-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  --cell: 23px;
  --thin:  rgba(37, 99, 235, .14);
  background-image:
    linear-gradient(to right,  var(--thin) 1px, transparent 1px),
    linear-gradient(to bottom, var(--thin) 1px, transparent 1px);
  background-size:
    var(--cell) var(--cell),
    var(--cell) var(--cell);
  -webkit-mask-image: radial-gradient(130% 110% at 30% 0%, black 0%, transparent 85%);
          mask-image: radial-gradient(130% 110% at 30% 0%, black 0%, transparent 85%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-grid::before {
    --thin:  rgba(96, 165, 250, .13);
  }
}
:root[data-theme="dark"] .hero-grid::before {
  --thin:  rgba(96, 165, 250, .13);
}

.hero h1 { margin-bottom: .4em; }
.hero .lede { margin-bottom: 2rem; }
.hero-logo { width: clamp(200px, 28vw, 300px); height: auto; margin-bottom: 1.25rem; margin-left: -4%; }
.game-hero-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.game-hero-head .eyebrow { margin-bottom: .35rem; }
.game-hero-head h1 { margin-bottom: 0; }
.game-icon { width: 88px; height: 88px; flex: none; border-radius: 20px; box-shadow: var(--shadow-md); }
@media (max-width: 560px) {
  .game-hero-head { gap: 1rem; }
  .game-icon { width: 64px; height: 64px; border-radius: 15px; }
}

/* --- Cards / grids -------------------------------------------------------- */
.grid {
  display: grid;
  gap: 1.35rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease;
}
.card h3 { margin-bottom: .35rem; }
.card p { color: var(--text-soft); font-size: .96rem; }
.card > :last-child { margin-bottom: 0; }

a.card { text-decoration: none; color: inherit; }
a.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
  color: inherit;
}

.card-head {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: .9rem;
}
.card-head h3 { margin-bottom: 0; }

.card-icon {
  width: 52px; height: 52px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.6rem;
}
.card-icon svg { width: 28px; height: 28px; }
/* When a real app icon is supplied, it fills the tile and the tint is dropped. */
.card-icon.has-img { background: none; overflow: hidden; }
.card-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.card-teaser { border-style: dashed; box-shadow: none; background: transparent; }
.card-teaser .card-icon { background: var(--bg-alt); color: var(--text-mute); }

.card-meta {
  margin-top: auto;
  padding-top: 1rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--brand);
}

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: .5rem;
}
.badge-soon { background: var(--bg-alt); color: var(--text-mute); }

/* --- Feature list --------------------------------------------------------- */
.feature-list { list-style: none; margin: 0 0 2.5rem; padding: 0; display: grid; gap: .9rem; }
.feature-list + h2 { margin-top: 0; }
.feature-list li {
  position: relative;
  padding-left: 2.1rem;
  color: var(--text-soft);
}
.feature-list li strong { color: var(--text); }
.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .2em;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--brand-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 13px no-repeat;
}

/* --- Prose (legal + support pages) ---------------------------------------- */
.prose { max-width: 74ch; }
.prose h2 { margin-top: 2.6rem; font-size: 1.5rem; }
.prose h3 { margin-top: 1.9rem; font-size: 1.13rem; }
.prose ul, .prose ol { padding-left: 1.3rem; color: var(--text-soft); }
.prose li { margin-bottom: .5rem; }
.prose p { color: var(--text-soft); }
.prose strong { color: var(--text); }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .93rem;
}
.prose th, .prose td {
  text-align: left;
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prose th { color: var(--text); font-weight: 600; background: var(--bg-alt); }
.prose td { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.page-head {
  padding-block: clamp(2.5rem, 6vw, 4rem) 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.page-head h1 { margin-bottom: .3em; }
.meta { color: var(--text-mute); font-size: .9rem; margin: 0; }

.callout {
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.15rem 1.35rem;
  margin: 1.75rem 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout p { color: var(--text-soft); }

/* --- TOC ------------------------------------------------------------------ */
.toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}
.toc h2 { margin: 0 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-mute); }
.toc ol { margin: 0; padding-left: 1.2rem; columns: 2; column-gap: 2rem; }
.toc li { margin-bottom: .35rem; break-inside: avoid; }
@media (max-width: 640px) { .toc ol { columns: 1; } }

/* --- Contact rows --------------------------------------------------------- */
.contact-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); }
.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
}
.contact-card h3 { font-size: 1rem; margin-bottom: .25rem; }
.contact-card p { font-size: .92rem; margin-bottom: .5rem; color: var(--text-soft); }

/* --- Contact form --------------------------------------------------------- */
.contact-form { max-width: 560px; margin: 1.5rem 0 3.5rem; }
.field { margin-bottom: 1.15rem; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .93rem;
  margin-bottom: .4rem;
}
.field .optional { font-weight: 400; color: var(--text-mute); }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: .7rem .9rem;
  font: inherit;
  font-size: .97rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}
.field textarea { resize: vertical; min-height: 8rem; }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-mute); }
.form-note { margin-top: .8rem; }

/* --- FAQ ------------------------------------------------------------------ */
details.faq {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: .75rem;
  overflow: hidden;
}
details.faq summary {
  cursor: pointer;
  padding: 1.05rem 1.3rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "+";
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
  flex: none;
}
details.faq[open] summary::after { content: "\2212"; }
details.faq .faq-body { padding: 0 1.3rem 1.15rem; color: var(--text-soft); font-size: .96rem; }
details.faq .faq-body > :last-child { margin-bottom: 0; }

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding-block: 3rem 2rem;
  font-size: .93rem;
}
.footer-grid {
  display: grid;
  gap: 2rem;
  /* min() keeps the track from ever demanding more than the container width,
     which is what stops the footer overflowing on narrow phones. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  margin-bottom: 2.5rem;
}
.footer-grid > * { min-width: 0; }
@media (min-width: 900px) {
  .footer-grid { grid-template-columns: 1.6fr repeat(3, 1fr); }
}
.footer-grid .footer-heading {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-mute);
  margin-bottom: .9rem;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: .5rem; }
.footer-grid a { color: var(--text-soft); text-decoration: none; }
.footer-grid a:hover { color: var(--brand); text-decoration: underline; }
.footer-about p { color: var(--text-mute); font-size: .9rem; max-width: 34ch; }

.footer-legal {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
  color: var(--text-mute);
  font-size: .86rem;
}
.footer-legal p { margin: 0; }

/* --- Utilities ------------------------------------------------------------ */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.center { text-align: center; }
.center .lede, .center .section-head { margin-inline: auto; }
.center .btn-row, .center .stores { justify-content: center; }
.mb-0 { margin-bottom: 0; }

/* The official logo is a fixed brand blue; lift it slightly on dark backgrounds. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand img,
  :root:not([data-theme="light"]) .hero-logo { filter: brightness(1.5); }
}
:root[data-theme="dark"] .brand img,
:root[data-theme="dark"] .hero-logo { filter: brightness(1.5); }
