/* ==========================================================================
   Ahmed's Driving School Ballito — "Kerb & line"
   Palette & rules from research/design-language.md.
   Dedicated attention to the 17 "Known kiro bugs" (design-language.md §2).
   ========================================================================== */

/* ---- Tokens (light = default) ---------------------------------------- */
:root {
  --ground: #F4F5F0;
  --surface: #FFFFFF;
  --ink: #16202B;
  --muted: #4A5663;
  --brand: #0F6B4F;          /* CTA fill; white text */
  --brand-text: #0F6B4F;     /* accent text/links on NORMAL surfaces */
  --accent-dark: #FFD23F;    /* accent text on ALWAYS-DARK bands (bug 1) */
  --signal: #FFC21A;         /* highlight fill — dark text only */
  --ink-fixed: #16202B;      /* fixed dark text on signal yellow (never flips) */
  --on-brand: #FFFFFF;       /* fixed text on brand fills (never flips) */
  --cream: #F1F3EC;          /* fixed text on always-dark bands (never flips) */
  --band: #16202B;           /* always-dark header/hero/footer/CTA/planner */

  --card-border: #D7DBD2;    /* visible card border in light (bug 16) */
  --note-bg: #FFF2CC;        /* small note chip tint (light) */
  --note-text: #5A4A00;      /* ≥4.5:1 on note-bg (bug 17) */

  --radius: 12px;
  --maxw: 1080px;
  --font-head: "Archivo", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, sans-serif;
}

/* Dark override — same brand hue, remapped for a dark ground (not inverted) */
[data-theme="dark"] {
  --ground: #0E141B;
  --surface: #18212B;
  --ink: #F1F3EC;
  --muted: #C4CCD4;
  --brand: #0F6B4F;          /* identical; white ≥4.5:1 verified (bug 7) */
  --brand-text: #7FD9B3;     /* readable accent text on dark surfaces */
  /* --accent-dark, --signal, --ink-fixed, --on-brand, --cream stay fixed */
  --band: #070B10;

  --card-border: #2A3745;
  --note-bg: #2A2410;
  --note-text: #FFD23F;
}

/* ---- Reset / base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--ground);
  line-height: 1.55;
  overflow-wrap: anywhere;            /* bug 3 safety */
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 800; line-height: 1.15; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); margin: 0 0 .5em; }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); margin: 0 0 .5em; }
h3 { font-size: 1.2rem; margin: 0 0 .4em; }
p { margin: 0 0 1rem; }
a { color: var(--brand-text); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 20px;            /* never padding: X 0 here (bug 4) */
}

.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }  /* vertical spacing lives here, not on .container (bug 4) */
.eyebrow { font-family: var(--font-head); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; color: var(--brand-text); margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); }
.center { text-align: center; }
.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; }

/* Dashed centre-line divider motif */
.rule-dash { height: 0; border: 0; border-top: 3px dashed var(--signal); max-width: var(--maxw); margin: 0 auto; opacity: .85; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-head); font-weight: 700; font-size: 1rem;
  padding: .7rem 1.1rem; border-radius: var(--radius);
  text-decoration: none; cursor: pointer; border: 2px solid transparent;
  line-height: 1.2;
}
.btn--primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn--primary:hover { background: #0c5a42; border-color: #0c5a42; color: var(--on-brand); }
.btn--signal { background: var(--signal); color: var(--ink-fixed); border-color: var(--signal); }  /* bug 8 */
.btn--signal:hover { background: #e6ae13; border-color: #e6ae13; color: var(--ink-fixed); }
.btn--ghost { background: transparent; color: var(--ink); border-color: currentColor; }
.btn--ghost:hover { background: rgba(0,0,0,.06); color: var(--ink); }
[data-theme="dark"] .btn--ghost:hover { background: rgba(255,255,255,.08); }

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

/* ---- Header ----------------------------------------------------------- */
.site-header { background: var(--band); color: var(--cream); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: .9rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--cream); font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }  /* brand wraps (bug 3) */
.brand .brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--signal); color: var(--ink-fixed); font-weight: 800; flex: none; }
.main-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0; padding: 0; }
.main-nav a { color: var(--cream); text-decoration: none; font-weight: 500; padding: .35rem 0; border-bottom: 2px solid transparent; }
.main-nav a:hover, .main-nav a[aria-current="page"] { border-bottom-color: var(--signal); color: var(--cream); }
.header-actions { display: flex; align-items: center; gap: .5rem; }

/* Theme toggle */
.theme-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 8px; border: 2px solid rgba(241,243,236,.35);
  background: transparent; color: var(--cream); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--signal); }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

/* Header-band link/button exceptions so dark-section link rules
   don't repaint button text or nav (bug 6) */
.site-header a.btn--primary { color: var(--on-brand); }
.site-header a.btn--signal { color: var(--ink-fixed); }
.site-header a.btn--ghost { color: var(--cream); border-color: var(--cream); }
.site-header a.btn--ghost:hover { color: var(--cream); }

/* ---- Always-dark bands: hero / .band / footer / planner --------------- *
 * bug 1: every text role gets an explicit light-on-dark colour.
 * bug 2: no light card surfaces inside these bands.
 * bug 6: button-text exceptions inside each band.                         */
.hero, .band, .site-footer, .planner-panel {
  background: var(--band);
  color: var(--cream);
}
.hero h1, .hero h2, .hero h3, .hero h4,
.band h1, .band h2, .band h3, .band h4,
.site-footer h1, .site-footer h2, .site-footer h3, .site-footer h4,
.planner-panel h1, .planner-panel h2, .planner-panel h3, .planner-panel h4 { color: var(--cream); }

.hero p, .hero li, .hero .muted,
.band p, .band li, .band .muted,
.site-footer p, .site-footer li, .site-footer .muted,
.planner-panel p, .planner-panel li, .planner-panel .muted { color: var(--cream); }

.hero .eyebrow, .band .eyebrow, .site-footer .eyebrow, .planner-panel .eyebrow { color: var(--accent-dark); }  /* accent on dark = fixed accent-dark, never brand-text (bug 1) */

/* generic links inside dark bands */
.hero a, .band a, .site-footer a, .planner-panel a { color: var(--accent-dark); }

/* dl.nap on dark bands (bug 1 explicitly names dt & dd) */
.hero dl.nap dt, .hero dl.nap dd,
.band dl.nap dt, .band dl.nap dd,
.site-footer dl.nap dt, .site-footer dl.nap dd { color: var(--cream); }

/* stat/proof text, notes, img-note on dark bands */
.hero .stat, .band .stat, .site-footer .stat,
.hero .img-note, .band .img-note, .site-footer .img-note, .planner-panel .img-note { color: var(--cream); }

/* chips on dark bands */
.hero .chip, .band .chip, .site-footer .chip, .planner-panel .chip {
  background: rgba(255,255,255,.08); color: var(--cream); border-color: rgba(255,255,255,.3);
}

/* ghost buttons on dark bands — BOTH a.btn--ghost and button.btn--ghost, incl :hover (bug 1 & 6) */
.hero a.btn--ghost, .hero button.btn--ghost,
.band a.btn--ghost, .band button.btn--ghost,
.site-footer a.btn--ghost, .site-footer button.btn--ghost,
.planner-panel a.btn--ghost, .planner-panel button.btn--ghost {
  color: var(--cream); border-color: var(--cream); background: transparent;
}
.hero a.btn--ghost:hover, .hero button.btn--ghost:hover,
.band a.btn--ghost:hover, .band button.btn--ghost:hover,
.site-footer a.btn--ghost:hover, .site-footer button.btn--ghost:hover,
.planner-panel a.btn--ghost:hover, .planner-panel button.btn--ghost:hover {
  color: var(--cream); border-color: var(--signal); background: rgba(255,255,255,.08);
}

/* primary/signal buttons keep their fixed text inside dark bands (bug 6) */
.hero a.btn--primary, .band a.btn--primary, .site-footer a.btn--primary, .planner-panel a.btn--primary { color: var(--on-brand); }
.hero a.btn--signal, .band a.btn--signal, .site-footer a.btn--signal, .planner-panel a.btn--signal { color: var(--ink-fixed); }

/* ---- Hero ------------------------------------------------------------- */
.hero { position: relative; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; }
.hero-media { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
.hero-media img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4/3; }
.img-note { font-size: .8rem; margin-top: .4rem; }

/* ---- Cards ------------------------------------------------------------ */
.grid { display: grid; gap: 1.25rem; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--card-border);   /* visible border in light (bug 16) */
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.card-media img { width: 100%; height: 180px; object-fit: cover; }
.card-body { padding: 1.1rem 1.1rem 1.3rem; display: flex; flex-direction: column; gap: .4rem; }
.card ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.card li { margin-bottom: .25rem; }

/* ---- Chips / notes ---------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .82rem; font-weight: 600;
  padding: .25rem .6rem; border-radius: 999px;
  background: var(--note-bg); color: var(--note-text);      /* ≥4.5:1 (bug 17) */
  border: 1px solid transparent;
}
.note {
  display: inline-block; font-size: .85rem;
  background: var(--note-bg); color: var(--note-text);       /* bug 17 */
  padding: .4rem .7rem; border-radius: 8px;
}

/* ---- Proof strip ------------------------------------------------------ */
.proof { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: center; align-items: center; }
.proof .stat { font-family: var(--font-head); font-weight: 700; }
.proof .stat b { font-size: 1.3rem; }

/* ---- NAP list --------------------------------------------------------- */
dl.nap { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; }
dl.nap dt { font-weight: 700; }
dl.nap dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }   /* bug 3 */

/* ---- Find us / contact layout ---------------------------------------- */
.findus { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.findus > * { min-width: 0; }                                     /* bug 3 */

/* ==========================================================================
   LESSON PLANNER (signature feature)
   ========================================================================== */
.planner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.5rem; align-items: start; }
.planner-form fieldset { border: 1px solid var(--card-border); border-radius: var(--radius); margin: 0 0 1.25rem; padding: 1rem 1.1rem 1.2rem; background: var(--surface); }
.planner-form legend { font-family: var(--font-head); font-weight: 700; padding: 0 .4rem; }
.planner-form .hint { font-size: .85rem; color: var(--muted); margin: -.2rem 0 .8rem; }

/* option tiles: selected state visible without colour alone — outline + tick (bug 13) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; }
.tile { position: relative; display: flex; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile label {
  width: 100%; cursor: pointer;
  border: 2px solid var(--card-border); border-radius: 10px;
  padding: .7rem .8rem .7rem 2.2rem; position: relative;
  font-weight: 600; background: var(--ground);
}
.tile label::before {
  content: ""; position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  width: 1.1rem; height: 1.1rem; border: 2px solid var(--muted); border-radius: 5px; background: var(--surface);
}
.tile input[type="radio"] + label::before { border-radius: 50%; }
/* checked: thick brand outline + a drawn tick glyph (shape, not just colour) */
.tile input:checked + label { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.tile input:checked + label::before { border-color: var(--brand); background: var(--brand); }
.tile input:checked + label::after {
  content: ""; position: absolute; left: 1.03rem; top: 50%;
  width: .32rem; height: .62rem; border: solid var(--on-brand); border-width: 0 .17rem .17rem 0;
  transform: translateY(-62%) rotate(45deg);
}
.tile input:focus-visible + label { outline: 3px solid var(--signal); outline-offset: 2px; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field input[type="text"], .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--card-border); border-radius: 8px; padding: .6rem .7rem;
}
.field textarea { resize: vertical; min-height: 4.5rem; }
.field .count { font-size: .8rem; color: var(--muted); }

/* dependent groups hidden via [hidden] (bug 14 — JS also clears values) */
[hidden] { display: none !important; }

/* ---- Plan panel (ALWAYS dark, both themes) ---------------------------- */
.planner-panel { border-radius: var(--radius); padding: 1.25rem 1.3rem 1.4rem; position: sticky; top: 1rem; }
.planner-panel h3 { margin-top: 0; }
.plan-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .55rem; }
.plan-list li { padding-left: 1.4rem; position: relative; color: var(--cream); }
.plan-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-dark); font-weight: 800; }  /* tick on dark = accent-dark, never brand (bug 9) */
.plan-empty { color: var(--cream); opacity: .85; }
.plan-message {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: .8rem .9rem; margin: 0 0 1rem; color: var(--cream); white-space: pre-wrap;
}
.planner-panel .btn-row { margin-top: .5rem; }
.copied-note { font-size: .85rem; color: var(--accent-dark); margin: .5rem 0 0; min-height: 1.2em; }

/* ---- Footer ----------------------------------------------------------- */
.site-footer { margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 1.5rem 2rem; }
.footer-grid > * { min-width: 0; }                                /* bug 3 */
.footer-grid h3 { font-size: 1rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.footer-grid a { color: var(--cream); text-decoration: none; }
.footer-grid a:hover { text-decoration: underline; text-decoration-color: var(--signal); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.14); margin-top: 1.5rem; padding-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; color: var(--cream); font-size: .85rem; }
.demo-note { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: .7rem .9rem; color: var(--cream); font-size: .85rem; }
.footer-bottom .demo-note strong, .demo-note strong { color: var(--accent-dark); }   /* bug 1 names .footer-bottom .demo-note strong */

/* ==========================================================================
   RESPONSIVE (bug 3)
   ========================================================================== */
@media (max-width: 860px) {
  .hero-grid, .planner, .findus { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .planner-panel { position: static; }
}
@media (max-width: 700px) {
  .main-nav { order: 3; flex-basis: 100%; }      /* nav gets its own row ≤700px (bug 3) */
  .main-nav ul { gap: .25rem .9rem; }
}
@media (max-width: 560px) {
  .grid--3, .grid--2, .footer-grid { grid-template-columns: 1fr; }
  dl.nap { grid-template-columns: 1fr; gap: .1rem .5rem; }
  dl.nap dt { margin-top: .5rem; }
}
@media (max-width: 480px) {
  .header-cta { display: none; }                 /* hide header CTA ≤480px (bug 3) */
}
