/* =====================================================================
   Worms United - modern rebuild
   A single, dependency-free stylesheet. Mobile-first, dark-mode aware,
   with a per-section accent colour set via a body class (.theme-*).
   ===================================================================== */

/* ---- Design tokens -------------------------------------------------- */
:root {
  --font-sans: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;

  /* neutral ramp (light) */
  --bg:        #f4f6f4;
  --bg-soft:   #ffffff;
  --bg-sunk:   #eaeee9;
  --surface:   #ffffff;
  --border:    #d9ddd7;
  --border-strong: #c3c9bf;
  --text:      #1d221c;
  --text-soft: #55605a;
  --text-faint:#828d85;

  /* brand + default accent (Worms green) */
  --brand:     #4a9d3f;
  --brand-ink: #ffffff;
  --accent:    #4a9d3f;
  --accent-ink:#ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
  --accent-line: color-mix(in srgb, var(--accent) 40%, var(--border));

  --shadow-sm: 0 1px 2px rgba(20, 30, 20, .06), 0 1px 1px rgba(20, 30, 20, .04);
  --shadow-md: 0 6px 20px -8px rgba(20, 40, 20, .25);
  --shadow-lg: 0 18px 46px -18px rgba(20, 40, 20, .35);

  --radius:    6px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --wrap:      1080px;
  --step:      clamp(.9rem, .6rem + 1.2vw, 1.15rem);
}

/* Per-section accents */
.theme-original { --accent: #4a9d3f; }             /* green  */
.theme-worms2   { --accent: #2f7fd6; }             /* blue   */
.theme-wwp      { --accent: #c4489a; }             /* pink   */
.theme-w3d      { --accent: #e0722a; }             /* orange */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14181a;
    --bg-soft:   #1b2124;
    --bg-sunk:   #10151600;
    --surface:   #1e2528;
    --border:    #2c3438;
    --border-strong: #3a444a;
    --text:      #e7ecea;
    --text-soft: #a9b4b0;
    --text-faint:#7d8884;
    --brand:     #6bc95c;
    --accent:    #6bc95c;
    --accent-ink:#0c1410;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 8px 24px -10px rgba(0,0,0,.6);
    --shadow-lg: 0 20px 50px -18px rgba(0,0,0,.7);
  }
  .theme-original { --accent: #6bc95c; }
  .theme-worms2   { --accent: #63b0f5; }
  .theme-wwp      { --accent: #f07ac6; }
  .theme-w3d      { --accent: #f6994f; }
  .theme-original, .theme-worms2, .theme-wwp, .theme-w3d { --accent-ink: #0c1410; }
}

/* ---- Reset / base --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--step);
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -5%, var(--accent-soft), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: color-mix(in srgb, var(--accent) 78%, var(--text)); text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 1.2rem + 2.6vw, 2.9rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.85rem); margin: 2.2em 0 .6em; }
h3 { font-size: 1.2rem; margin: 1.8em 0 .4em; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(1rem, .5rem + 2vw, 2rem); }

.skip-link {
  position: absolute; left: -9999px; top: .5rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .5rem .9rem; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { left: 1rem; }

/* ---- Site header ---------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-soft) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; gap: 1rem; min-height: 62px; }

.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); margin-right: auto; }
.brand__mark { font-size: 1.5rem; filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); transform: rotate(-8deg); }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__text strong { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -.02em; }
.brand__text small { color: var(--text-faint); font-size: .72rem; letter-spacing: .02em; }

.site-nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.site-nav__link {
  padding: .45rem .7rem; border-radius: 999px; text-decoration: none;
  color: var(--text-soft); font-weight: 600; font-size: .92rem; white-space: nowrap;
  transition: background .15s, color .15s;
}
.site-nav__link:hover { background: var(--bg-sunk); color: var(--text); }
.site-nav__link.is-active { background: var(--accent); color: var(--accent-ink); }

/* mobile nav toggle (CSS-only) */
.nav-toggle__btn { display: none; }
@media (max-width: 760px) {
  .nav-toggle__btn {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 40px; padding: 9px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface); cursor: pointer;
  }
  .nav-toggle__btn span { height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }
  .site-nav {
    position: absolute; inset: 62px 0 auto 0; flex-direction: column; gap: 0;
    background: var(--bg-soft); border-bottom: 1px solid var(--border);
    padding: .4rem clamp(1rem, .5rem + 2vw, 2rem) .9rem;
    max-height: 0; overflow: hidden; visibility: hidden; box-shadow: var(--shadow-md);
    transition: max-height .25s ease, visibility .25s;
  }
  .nav-toggle:checked ~ .site-nav { max-height: 420px; visibility: visible; }
  .nav-toggle:checked ~ .nav-toggle__btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-toggle__btn span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-toggle__btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .site-nav__link { width: 100%; border-radius: 8px; padding: .7rem .8rem; font-size: 1rem; }
}

/* ---- Section hero --------------------------------------------------- */
.section-hero {
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 70%);
  border-bottom: 1px solid var(--border);
}
.section-hero__inner {
  display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.4rem);
  padding-block: clamp(1.4rem, 1rem + 2vw, 2.6rem); flex-wrap: wrap;
}
.section-hero__logo {
  width: min(260px, 62vw); border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.section-hero__meta { flex: 1 1 300px; }
.section-hero__meta h1 { margin: 0 0 .3em; }
.section-hero__blurb { color: var(--text-soft); max-width: 48ch; margin: 0 0 1.1em; font-size: 1.05em; }

/* ---- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .6rem 1.05rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn--buy { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn--buy:hover { color: var(--accent-ink); box-shadow: var(--shadow-md); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Sub navigation (per-section pages) ----------------------------- */
.subnav { border-top: 1px dashed var(--accent-line); }
.subnav__inner { display: flex; gap: .3rem; overflow-x: auto; padding-block: .5rem; scrollbar-width: thin; }
.subnav__link {
  padding: .4rem .8rem; border-radius: 999px; white-space: nowrap; text-decoration: none;
  color: var(--text-soft); font-weight: 600; font-size: .9rem;
}
.subnav__link:hover { background: var(--bg-sunk); color: var(--text); }
.subnav__link.is-active { background: var(--accent); color: var(--accent-ink); }

/* ---- Main content --------------------------------------------------- */
.main { padding-block: clamp(1.6rem, 1rem + 3vw, 3rem); }
.main > :first-child { margin-top: 0; }

.lead { font-size: 1.12em; color: var(--text-soft); max-width: 62ch; }

.prose { max-width: 72ch; }
.prose p, .prose li { color: var(--text); }
.prose :is(h2, h3) + p { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .35em; }
.prose i, .prose em { font-style: italic; }

/* callout panel */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem; margin: 0 0 1.6rem; box-shadow: var(--shadow-sm);
}
.panel > :last-child { margin-bottom: 0; }
.panel--tip { border-left-color: var(--accent); }

/* ---- Landing page --------------------------------------------------- */
.hero {
  text-align: center; padding-block: clamp(0rem, 1rem + 6vw, 0.5rem) clamp(1rem, .5rem + 3vw, 2rem);
}
.hero__eyebrow {
  display: inline-block; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  font-size: .74rem; color: var(--accent); background: var(--accent-soft);
  padding: .35rem .8rem; border-radius: 999px; margin-bottom: 1rem;
}
.hero h1 { font-size: clamp(2.2rem, 1.4rem + 4vw, 4rem); margin: 0 0 .2em; }
.hero__tagline { color: var(--text-soft); font-size: 1.2em; max-width: 40ch; margin-inline: auto; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.2rem; }
.game-card {
  --accent: var(--card-accent, var(--brand));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text);
  transition: transform .16s, box-shadow .2s, border-color .2s;
}
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent); color: var(--text); }
.game-card__media { position: relative; aspect-ratio: 296 / 112; background: var(--bg-sunk); overflow: hidden; }
.game-card__media img { width: 100%; height: 100%; object-fit: cover; }
.game-card__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--accent) 30%, transparent));
}
.game-card__body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.game-card__title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 0; font-size: 1.3rem; }
.game-card__year { font-size: .8rem; font-weight: 700; color: var(--accent); }
.game-card__blurb { color: var(--text-soft); font-size: .95em; margin: 0; }
.game-card__cta { margin-top: auto; font-weight: 700; color: var(--accent); font-size: .95em; }
.game-card:hover .game-card__cta { text-decoration: underline; }

.theme-card-original { --card-accent: #4a9d3f; }
.theme-card-worms2   { --card-accent: #2f7fd6; }
.theme-card-wwp      { --card-accent: #c4489a; }
.theme-card-w3d      { --card-accent: #e0722a; }
@media (prefers-color-scheme: dark) {
  .theme-card-original { --card-accent: #6bc95c; }
  .theme-card-worms2   { --card-accent: #63b0f5; }
  .theme-card-wwp      { --card-accent: #f07ac6; }
  .theme-card-w3d      { --card-accent: #f6994f; }
}

/* ---- Data tables (cheats codes etc.) -------------------------------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 0 0 1.6rem; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: .95em; background: var(--surface); }
table.data caption { text-align: left; padding: .8rem 1rem; font-weight: 700; color: var(--text-soft); }
table.data th, table.data td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data thead th { position: sticky; top: 0; background: var(--bg-sunk); color: var(--text); font-family: var(--font-display); white-space: nowrap; z-index: 1; }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
table.data tbody tr:hover { background: var(--accent-soft); }
table.data code, .code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 600; letter-spacing: .02em; }
table.data td:last-child { color: var(--text-soft); }

/* inline code chip */
code.chip, .chip {
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: .92em;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: 6px;
  padding: .06em .4em; color: var(--text); white-space: nowrap;
}

/* ---- Cheats list (definition style) --------------------------------- */
.cheats { display: grid; gap: .9rem; margin: 0 0 1.6rem; }
.cheat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .9rem 1.1rem; box-shadow: var(--shadow-sm);
}
.cheat__code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--accent); font-size: 1.02em; }
.cheat__name { font-weight: 700; }
.cheat h3 { margin: 0 0 .2em; font-size: 1.05rem; }
.cheat p { margin: .3em 0 0; color: var(--text-soft); }
.cheat p:first-of-type { color: var(--text); }
.cheat cite { display: block; margin-top: .5em; font-size: .85em; color: var(--text-faint); font-style: normal; }

/* ---- Download grid (landscapes / imports) --------------------------- */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 1rem; margin: 0 0 1.6rem; }
.dl-card {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .14s, box-shadow .18s, border-color .18s;
}
.dl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); color: var(--text); }
.dl-card img { width: 100%; aspect-ratio: 192 / 75; object-fit: cover; background: var(--bg-sunk); border-bottom: 1px solid var(--border); }
.dl-card__foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .8rem; }
.dl-card__name { font-weight: 700; font-size: .95em; }
.dl-card__dl { font-size: .8rem; font-weight: 700; color: var(--accent); }

/* ---- Download table (sound schemes) --------------------------------- */
.score { display: inline-flex; gap: 2px; color: var(--accent); letter-spacing: 1px; }
.score[data-score] { font-size: .8em; }

/* ---- FAQ (details/summary) ------------------------------------------ */
.faq-toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem 1.1rem; margin: 0 0 1.8rem; box-shadow: var(--shadow-sm); }
.faq-toc h2 { margin: 0 0 .5em; font-size: 1.1rem; }
.faq-toc ul { columns: 2; column-gap: 2rem; margin: 0; padding-left: 1.1em; }
@media (max-width: 560px) { .faq-toc ul { columns: 1; } }

.qa { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin: 0 0 .7rem; box-shadow: var(--shadow-sm); overflow: hidden; }
.qa > summary {
  cursor: pointer; list-style: none; position: relative;
  padding: .85rem 2.8rem .85rem 1.1rem; font-weight: 700; font-family: var(--font-display);
}
.qa > summary::-webkit-details-marker { display: none; }
.qa > summary::after {
  content: "+"; color: var(--accent); font-weight: 700; font-size: 1.15em; line-height: 1;
  position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%); transition: transform .2s;
}
.qa[open] > summary::after { transform: translateY(-50%) rotate(45deg); }
.qa > summary:hover { color: var(--accent); }
.qa__body { padding: 0 1.1rem 1rem; border-top: 1px solid var(--border); }
.qa__body > :first-child { margin-top: 1rem; }

.faq-group { margin: 2rem 0 1rem; font-family: var(--font-display); font-size: 1.4rem; color: var(--accent); }

/* spec table used in a couple of FAQ answers */
.spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1rem; margin: 1rem 0; }
.spec > div { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.spec h4 { margin: 0 0 .4em; }

/* ---- Footer --------------------------------------------------------- */
.site-footer { margin-top: 3rem; border-top: 1px solid var(--border); background: var(--bg-soft); }
.site-footer__inner { padding-block: 1.8rem 2.4rem; }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin-bottom: .9rem; }
.site-footer__nav a { color: var(--text-soft); text-decoration: none; font-weight: 600; font-size: .92rem; }
.site-footer__nav a:hover { color: var(--accent); }
.site-footer__note { color: var(--text-faint); font-size: .85rem; max-width: 70ch; margin: 0; }
.site-footer__note a { color: var(--text-soft); }

/* ---- Utilities ------------------------------------------------------ */
.center { text-align: center; }
.muted { color: var(--text-soft); }
.mt-2 { margin-top: 2rem; }
.stack > * + * { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
