/* ==========================================================================
   Parent Spelling Helper — shared design system
   --------------------------------------------------------------------------
   ONE source of truth for the site's look. Before this file existed the same
   palette was hard-coded in five separate places (styles.css plus a PAGE_CSS
   constant inside each of the four page generators), so the landing page could
   be redesigned while every word page, level page and guide stayed on the old
   orange theme — which is exactly what happened.
   Anything visual that more than one page type shares belongs here. Page-specific
   layout stays with its page.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --cream:      #FAFAF7;
  --cream-warm: #FDF6E6;
  --band:       #F1F5EE;
  --card:       #FFFFFF;
  --line:       #E5E2DA;
  --ink:        #111111;
  --ink-2:      #5D6259;
  --green:      #2E7D32;
  --green-dark: #1F5C23;
  --green-mid:  #66BB6A;
  --green-soft: #E8F5E9;
  --amber-soft: #FDF3DC;
  --radius:     18px;
  --radius-sm:  12px;
  --shadow:     0 2px 10px rgba(40,50,30,0.05);
  --shadow-lg:  0 10px 34px rgba(40,50,30,0.10);
  --maxw:       1160px;
  --maxw-prose: 760px;
  --font-body:  'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

/* ---------- base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
h1, h2, h3, h4 { letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 800; margin-top: 1.6em; margin-bottom: .5em; }
h3 { font-size: 1.05rem; font-weight: 800; margin-top: 1.3em; margin-bottom: .4em; }
p  { margin-bottom: 1em; }
ul, ol { margin: 0 0 1em 1.3em; }
li { margin-bottom: .4em; }
code {
  background: var(--green-soft); padding: 1px 6px;
  border-radius: 5px; font-size: .92em;
}
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.prose { max-width: var(--maxw-prose); margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- beta banner ---------- */
.beta-banner {
  background: var(--green-dark); color: #fff; text-align: center;
  padding: 8px 16px; font-size: .85rem; font-weight: 600;
}
.beta-banner a { color: #DCEBBF; text-decoration: underline; }

/* ---------- site header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,249,239,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: 0 2px 14px rgba(40,50,30,0.05); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 14px 24px; max-width: var(--maxw); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { color: inherit; }
.brand img, .brand svg { width: 46px; height: 46px; flex-shrink: 0; }
.wordmark { font-weight: 800; font-size: 1.02rem; line-height: 1.08; color: var(--ink); }
.wordmark .w-green { color: var(--green-mid); }
.nav { display: flex; align-items: center; gap: 30px; }
.nav a { color: var(--ink); font-weight: 600; font-size: .98rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--green); }
.nav a.active { color: var(--green); border-bottom-color: var(--green); }
.nav .btn-primary { display: none; }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: inherit; font-weight: 700;
  border-radius: 999px; transition: transform .12s, background .18s, box-shadow .18s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: #fff; padding: 12px 26px; font-size: 1rem; }
.btn-primary:hover { background: var(--green-dark); color: #fff; box-shadow: 0 6px 18px rgba(62,123,50,0.28); }
.btn-ghost { background: transparent; color: var(--green); padding: 12px 24px; border: 1.5px solid var(--green); font-size: 1rem; }
.btn-ghost:hover { background: var(--green-soft); }
.btn-lg { padding: 15px 32px; font-size: 1.05rem; }
/* A nowrap label is an unshrinkable box. "Open the free spelling helper →" in
   the /levels/ CTA band measured 309px, which pushed the page 39px past a 320px
   viewport — and horizontal overflow paints as an unfilled white strip down the
   right edge on a phone. Below the narrowest common phone, let a long label wrap
   instead of overflowing; the pill shape is unchanged on every larger screen. */
@media (max-width: 400px) {
  .btn { white-space: normal; max-width: 100%; }
}

/* ---------- cards, chips, callouts ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.callout { border-radius: var(--radius); padding: 18px 20px; margin: 20px 0; }
.callout.green { background: var(--green-soft); border-left: 4px solid var(--green-mid); }
.callout.amber { background: var(--amber-soft); border-left: 4px solid #D9A63C; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips a {
  background: var(--green-soft); border-radius: 10px; padding: 9px 16px;
  font-size: .94rem; font-weight: 600; color: var(--ink);
  transition: background .16s, transform .16s;
}
.chips a:hover { background: #E0EBCD; transform: translateY(-2px); color: var(--green-dark); }

/* ---------- mnemonic scene list (word pages + the tool) ---------- */
.scene {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 18px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.scene p { margin-bottom: 0; }
.scene .letter {
  display: inline-block; background: var(--green); color: #fff; font-weight: 800;
  border-radius: 8px; padding: 1px 11px; margin-right: 8px; letter-spacing: .04em;
}
.scene .prompt { color: var(--ink-2); font-size: .9rem; margin-top: 6px; font-style: italic; }

/* ---------- answer-first block (GEO: the first 30% of the page carries citations) ---------- */
.answer-box {
  background: var(--green-soft); border: 1px solid #DEE8CC; border-radius: var(--radius);
  padding: 20px 22px; margin: 18px 0 26px;
}
.answer-box .lbl {
  font-size: .72rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--green); margin-bottom: 6px;
}
.answer-box p:last-child { margin-bottom: 0; }
.answer-box .spell-out {
  font-weight: 800; font-size: 1.25rem; letter-spacing: .14em; color: var(--ink);
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--band); font-weight: 800; white-space: nowrap; }

/* ---------- FAQ ---------- */
.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 19px; margin-bottom: 10px;
}
.faq summary {
  font-weight: 700; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--green); font-weight: 800; font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: '\2013'; }
.faq details p { margin-top: 10px; margin-bottom: 0; font-size: .94rem; color: var(--ink-2); }

/* ---------- small shared utilities ----------
   Used by the page generators (level lists, guides, the GEO FAQ page). These
   class names were already emitted by build-level-pages.js with no rule behind
   them, so the pages rendered as unstyled paragraphs — defined here rather than
   in any one generator so every page type gets the same treatment. */
.subtitle { color: var(--ink-2); font-size: .98rem; margin-bottom: 1.2em; }
.byline { color: var(--ink-2); font-size: .88rem; margin-bottom: 1.4em; }
.byline a { color: var(--ink-2); text-decoration: underline; }
.disclaimer {
  font-size: .86rem; color: var(--ink-2); background: var(--band);
  border-radius: var(--radius-sm); padding: 12px 15px; margin: 0 0 22px;
}
.levelhub { list-style: none; margin-left: 0; }
.levelhub li {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.nav-row {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  margin: 26px 0 8px; font-weight: 600; font-size: .95rem;
}
.link-list { list-style: none; margin-left: 0; }
.link-list li {
  border-bottom: 1px solid var(--line); padding: 13px 0;
}
.link-list li:last-child { border-bottom: none; }
.link-list a { font-weight: 700; }

/* Guide title illustration (one per guide, generated for that topic). */
.title-img {
  width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line);
  margin: 4px 0 24px; background: var(--band);
}

/* ---------- guide index: filterable card grid ---------- */
.guide-controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 6px 0 22px;
}
.guide-controls .field { position: relative; flex: 1 1 240px; min-width: 0; }
.guide-controls input, .guide-controls select {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 18px;
}
.guide-controls select { width: auto; font-weight: 700; cursor: pointer; padding-right: 38px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%232E7D32' stroke-width='2' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.guide-controls input:focus, .guide-controls select:focus {
  outline: 2px solid var(--green-mid); outline-offset: 1px; border-color: var(--green-mid);
}
.guide-count { font-size: .88rem; color: var(--ink-2); margin: 0 0 16px; }

.guide-grid {
  list-style: none; margin: 0 0 8px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px;
}
.guide-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .16s, box-shadow .16s;
}
.guide-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.guide-card img {
  width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover;
  background: var(--band); border-bottom: 1px solid var(--line);
}
.guide-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.guide-card .date {
  font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--green);
}
.guide-card h2 { font-size: 1.05rem; margin: 0; line-height: 1.35; }
.guide-card h2 a { color: var(--ink); }
.guide-card h2 a:hover { color: var(--green); }
.guide-card p { font-size: .9rem; color: var(--ink-2); margin: 0; }
.guide-empty {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 30px;
  text-align: center; color: var(--ink-2);
}
@media (max-width: 620px) {
  .guide-grid { grid-template-columns: 1fr; gap: 18px; }
  .guide-controls { flex-direction: column; align-items: stretch; }
  .guide-controls select { width: 100%; }
}

/* ---------- breadcrumbs ---------- */
.crumbs { font-size: .85rem; color: var(--ink-2); margin: 18px 0 6px; }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--green); }
.crumbs .sep { margin: 0 7px; opacity: .5; }

/* ---------- CTA band ---------- */
.cta-band {
  background: var(--green); color: #fff; border-radius: 22px;
  padding: 34px 26px; text-align: center; margin: 34px 0;
}
.cta-band h2 { color: #fff; margin-top: 0; }
.cta-band p { opacity: .92; margin-bottom: 18px; }
.cta-band .btn { background: #fff; color: var(--green); padding: 14px 30px; font-size: 1.02rem; }
.cta-band .btn:hover { background: #F2F7E8; color: var(--green-dark); }

/* ---------- footer ---------- */
.site-footer { padding: 26px 0 40px; }
.footer-card {
  background: var(--band); border-radius: 18px; padding: 22px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.footer-brand { display: flex; gap: 12px; align-items: flex-start; }
.footer-brand .t { font-weight: 800; font-size: .95rem; }
.footer-brand .s { font-size: .84rem; color: var(--ink-2); }
.footer-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-nav a { color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.footer-nav a:hover { color: var(--green); }
.footer-social { display: flex; gap: 16px; align-items: center; }
.footer-social a { color: var(--ink); display: flex; }
.footer-social a:hover { color: var(--green); }
.footer-social svg { width: 19px; height: 19px; }
.footer-legal { text-align: center; font-size: .8rem; color: var(--ink-2); margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .nav, .header-inner > .btn-primary { display: none; }
  .nav-toggle { display: block; }
  .site-header.open .nav {
    display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--cream); border-bottom: 1px solid var(--line);
    padding: 18px 24px 22px;
  }
  .site-header.open .nav .btn-primary { display: inline-flex; }
}
@media (max-width: 620px) {
  .footer-card { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
