/* ==========================================================================
   CDEFGAB Music Toolkit — site design system
   Mirrors the app: dark-first canvas, neon-lime accent (#E0F500), orange
   tonic accent (#FF8C00), soft raised cards.
   No dependencies, no build step — works as-is on GitHub Pages.

   Structure:
     1. Tokens (colour, spacing scale, grid, breakpoints)
     2. Base + typography
     3. Layout primitives (container, section, grid)
     4. Components (header, buttons, cards, media, docs, FAQ, footer)
     5. Motion + a11y
   ========================================================================== */

/* ------------------------------------------------------------------ 1. TOKENS */
:root {
  color-scheme: dark light;

  /* --- brand: taken straight from AppMenuStyling --- */
  --lime: #E0F500;
  --orange: #FF8C00;
  --sky: #007EF5;
  --red: #F53E33;

  /* --- dark canvas (default) --- */
  --bg: #0A0B0C;
  --bg-elev: #131517;
  --card: #16181A;
  --card-2: #1C1F22;
  --line: #26292D;
  --text: #F2F4F5;
  --muted: #9AA0A6;
  --faint: #6B7076;
  --accent: var(--lime);
  --accent-ink: #0A0B0C;

  /* --- SPACING SCALE — one 8px module, no ad-hoc values anywhere --- */
  --s-1: 0.25rem;   /*  4px */
  --s-2: 0.5rem;    /*  8px */
  --s-3: 0.75rem;   /* 12px */
  --s-4: 1rem;      /* 16px */
  --s-5: 1.5rem;    /* 24px */
  --s-6: 2rem;      /* 32px */
  --s-7: 3rem;      /* 48px */
  --s-8: 4rem;      /* 64px */
  --s-9: 6rem;      /* 96px */
  --s-10: 8rem;     /* 128px */

  /* Fluid steps built *from* the scale, so rhythm stays proportional. */
  --space-section: clamp(var(--s-7), 8vw, var(--s-9));   /* vertical section rhythm */
  --space-block:   clamp(var(--s-5), 4vw, var(--s-7));   /* between blocks in a section */
  --gutter:        clamp(var(--s-4), 3vw, var(--s-6));   /* grid gutter + page inset */

  /* --- grid --- */
  --measure: 68ch;          /* comfortable reading width */
  --maxw: 1200px;           /* container */
  --col-min: 17rem;         /* min column before the grid re-flows */

  /* --- radii --- */
  --r-sm: 0.5rem;
  --r-md: 0.875rem;
  --r-lg: 1.25rem;
  --r-pill: 999px;

  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 40px rgba(0, 0, 0, .45);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --ease: cubic-bezier(.22, .68, 0, 1);
}

/* Light appearance mirrors the app's light mode: chartreuse instead of neon. */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #FBFBFA; --bg-elev: #FFFFFF; --card: #FFFFFF; --card-2: #F4F5F3;
    --line: #E3E5E1; --text: #14161A; --muted: #5C6169; --faint: #8A9099;
    --accent: #96A300; --accent-ink: #FFFFFF;
    --shadow: 0 1px 2px rgba(16, 20, 24, .06), 0 12px 32px rgba(16, 20, 24, .08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0B0C; --bg-elev: #131517; --card: #16181A; --card-2: #1C1F22;
  --line: #26292D; --text: #F2F4F5; --muted: #9AA0A6; --faint: #6B7076;
  --accent: var(--lime); --accent-ink: #0A0B0C;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 40px rgba(0,0,0,.45);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FBFBFA; --bg-elev: #FFFFFF; --card: #FFFFFF; --card-2: #F4F5F3;
  --line: #E3E5E1; --text: #14161A; --muted: #5C6169; --faint: #8A9099;
  --accent: #96A300; --accent-ink: #FFFFFF;
  --shadow: 0 1px 2px rgba(16,20,24,.06), 0 12px 32px rgba(16,20,24,.08);
}

/* -------------------------------------------------------- 2. BASE + TYPOGRAPHY */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  font-size: clamp(0.95rem, 0.55vw + 0.88rem, 1.0625rem);
  line-height: 1.65;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient glow — the app's neon accent bleeding into the canvas. */
body::before {
  content: "";
  position: fixed;
  inset: -30vh -10vw auto;
  height: 70vh;
  background:
    radial-gradient(50% 60% at 20% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(40% 50% at 85% 10%, color-mix(in srgb, var(--orange) 9%, transparent), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

img, video, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* Type scale — one ratio, fluid between breakpoints. */
h1, h2, h3, h4 {
  margin: 0 0 var(--s-3);
  line-height: 1.08;
  letter-spacing: -.03em;
  font-weight: 680;
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 5.5vw, 4.25rem); }
h2 { font-size: clamp(1.625rem, 3.2vw, 2.5rem); }
h3 { font-size: clamp(1.125rem, 1.5vw, 1.3125rem); letter-spacing: -.02em; }
h4 { font-size: 1rem; }
p  { margin: 0 0 var(--s-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: clamp(1.0625rem, 1.3vw, 1.25rem);
  color: var(--muted);
  max-width: var(--measure);
}
.note { color: var(--faint); font-size: 0.9rem; }
.copy { color: var(--faint); font-size: 0.875rem; margin: 0; }
.updated { color: var(--faint); font-size: 0.9rem; }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 0.75rem; font-weight: 660; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--s-4);
}
.eyebrow::before {
  content: ""; width: var(--s-2); height: var(--s-2); border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}

.mono {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em; letter-spacing: 0;
}

/* ------------------------------------------------- 3. LAYOUT PRIMITIVES */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: 1;
}

section { padding-block: var(--space-section); position: relative; z-index: 1; }
section + section { padding-top: 0; }          /* one rhythm between sections, not two */

.section-head { max-width: var(--measure); margin-bottom: var(--space-block); }
.section-head > :last-child { margin-bottom: 0; }

/* Auto-reflowing grid: 3 → 2 → 1 columns, driven by --col-min, not media queries. */
.grid { display: grid; gap: var(--gutter); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--col-min)), 1fr)); }

/* Two-up feature block. Stacks below the medium breakpoint. */
.split { display: grid; gap: var(--space-block); align-items: center; grid-template-columns: 1fr; }
@media (min-width: 56.25em) {           /* 900px */
  .split { grid-template-columns: 1.05fr 1fr; }
  .split.rev > :first-child { order: 2; }
}

/* A split that follows another block inside the same section. */
.split-follow { margin-top: var(--space-block); }

/* Vertical rhythm helper — replaces one-off margins. */
.stack > * + * { margin-top: var(--s-5); }
.stack-tight > * + * { margin-top: var(--s-3); }

/* Inline accent for a word in running text. */
.hl { color: var(--accent); }

/* ------------------------------------------------------- 4. COMPONENTS */

/* --- header --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.site-header.is-stuck { border-bottom-color: var(--line); }
.nav { display: flex; align-items: center; gap: var(--s-4); min-height: 3.875rem; }
.nav-links { display: flex; gap: var(--s-4); margin-left: auto; align-items: center; }
.nav-links a { color: var(--muted); font-size: 0.9375rem; font-weight: 520; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); text-decoration: none; }
@media (min-width: 48em) { .nav-links { gap: var(--s-5); } }
@media (max-width: 38.75em) { .nav-links a.opt { display: none; } }

/* Wordmark — echoes the CDEFGAB pill chip in the app's title bar. */
.wordmark {
  display: inline-flex; align-items: center;
  font-weight: 700; letter-spacing: .04em; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: var(--s-1) var(--s-3); font-size: 0.9375rem;
  background: var(--card);
}
.wordmark:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.wordmark b { color: var(--accent); font-weight: 700; }

.theme-toggle {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); border-radius: var(--r-pill); cursor: pointer;
  width: 2.125rem; height: 2.125rem; display: grid; place-items: center; font-size: 0.9rem;
  transition: color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  font-weight: 640; font-size: 1rem; letter-spacing: -.01em;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .18s var(--ease), background-color .2s, border-color .2s, color .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, white); }
.btn-ghost { border-color: var(--line); color: var(--text); background: var(--card); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.btn-row-lead { margin-bottom: var(--space-block); }

/* --- cards --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow);
  transition: border-color .25s var(--ease);
}
@media (min-width: 48em) { .card { padding: var(--s-6); } }
.card:hover { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.card-lg { padding: var(--s-6); }
@media (min-width: 48em) { .card-lg { padding: var(--s-7); } }

.card .dot {
  width: 2.125rem; height: 2.125rem; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); font-size: 1rem; margin-bottom: var(--s-4);
}
.card .dot.o { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.card .dot.s { background: color-mix(in srgb, var(--sky) 18%, transparent); color: var(--sky); }

/* --- hero ---
   Bottom padding must be a full section step: the next section collapses its own
   top padding (`section + section`), so the gap comes entirely from here. */
.hero { padding-block: var(--space-block) var(--space-section); }
.hero h1 span { color: var(--accent); }
.hero .lead { margin-top: var(--s-5); }
.hero-media { margin-top: var(--space-block); }
/* Screen recordings are 2868×1320 — reserve the box so nothing jumps while it loads. */
.hero-media video { width: 100%; aspect-ratio: 2868 / 1320; background: var(--bg-elev); }

/* --- media --- */
.shot {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.shot img, .shot video { width: 100%; display: block; }
figure { margin: 0; }
figcaption {
  color: var(--faint);
  font-size: 0.875rem;
  padding: var(--s-3) var(--s-4) var(--s-4);
}
/* Figures used inside prose get the section rhythm, not an arbitrary margin. */
.doc figure.shot { margin-block: var(--space-block); }

/* --- lists --- */
.ticks { list-style: none; padding: 0; margin: var(--s-5) 0 0; display: grid; gap: var(--s-3); }
.ticks li { padding-left: var(--s-6); position: relative; color: var(--muted); }
.ticks li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 0.5625rem; height: 0.5625rem; border-radius: 50%; background: var(--accent);
}
.ticks strong { color: var(--text); font-weight: 620; }

/* --- documents (guide / privacy / support) --- */
.doc { max-width: var(--measure); }
.doc h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); }
.doc h2 { margin-top: var(--s-8); scroll-margin-top: var(--s-9); }
.doc h3 { margin-top: var(--s-6); scroll-margin-top: var(--s-9); }
.doc h2:first-of-type { margin-top: var(--s-6); }
.doc ul, .doc ol { padding-left: var(--s-5); margin: 0 0 var(--s-5); }
.doc li { margin-bottom: var(--s-2); }
.doc li::marker { color: var(--accent); }
.doc hr { border: 0; border-top: 1px solid var(--line); margin-block: var(--s-8); }
.doc code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  font-size: .88em; background: var(--card-2); border: 1px solid var(--line);
  padding: 0.1em 0.4em; border-radius: var(--r-sm);
}
.doc table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-6); font-size: 0.95rem; }
.doc th, .doc td { text-align: left; padding: var(--s-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--text); font-weight: 620; }
.doc td { color: var(--muted); }
.table-scroll { overflow-x: auto; }

.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--card);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  margin-block: var(--s-6);
}
.callout strong { color: var(--text); }

.toc {
  border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r-md); padding: var(--s-5);
  margin-bottom: var(--s-7);
}
.toc p {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); margin: 0 0 var(--s-3); font-weight: 640;
}
.toc ol { margin: 0; padding-left: var(--s-5); display: grid; gap: var(--s-1); }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); }

/* --- FAQ --- */
details.faq {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-3);
}
details.faq summary {
  cursor: pointer; font-weight: 600; color: var(--text);
  list-style: none; display: flex; justify-content: space-between; gap: var(--s-4); align-items: center;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--accent); font-size: 1.25rem; line-height: 1; }
details.faq[open] summary::after { content: "−"; }
details.faq[open] summary { margin-bottom: var(--s-3); }
details.faq p { color: var(--muted); }

/* --- footer --- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: var(--space-block);
  margin-top: var(--space-section);
}
.footer-grid {
  display: flex; flex-wrap: wrap;
  gap: var(--s-5) var(--s-8);
  align-items: flex-start; justify-content: space-between;
}
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s-5); }
.footer-links a { color: var(--muted); font-size: 0.9375rem; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { margin-top: var(--s-6); }

/* ------------------------------------------------------- 5. MOTION + A11Y */
.reveal { opacity: 0; transform: translateY(0.875rem); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover { transform: none; }
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: var(--s-3) var(--s-5); border-radius: 0 0 var(--r-sm) 0; z-index: 100;
}
.skip:focus { left: 0; }
