/* Kika Moye. Tokens first, then layout, then components. */
:root {
  --ink: #14213d;
  --ground: #eef2f6;
  --paper: #ffffff;
  --teal: #0e7c7b;
  --teal-soft: #d6ecea;
  --amber: #e9a23b;
  --muted: #55617a;
  --line: #d3dbe6;
  --bad: #a4343a;
  --display: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --measure: 66ch;
  --pad: clamp(1.1rem, 4vw, 3.5rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--body);
}

a { color: var(--teal); text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 0.6rem 1rem; z-index: 20; }
.skip:focus { left: 0; }

/* The language's own words. Unstressed syllables are light, stressed are heavy:
   the type shows the one pronunciation rule a reader must know. */
.km { font-family: var(--display); font-weight: 300; letter-spacing: 0.01em; }
.km b { font-weight: 800; }

h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
h2 { font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 1.2rem; font-weight: 600; margin-top: 2.4rem; margin-bottom: 0.5rem; }
p { margin: 0 0 1rem; max-width: var(--measure); }
.section-lede { font-size: 1.15rem; color: var(--muted); margin-top: 0.8rem; margin-bottom: 2rem; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.7rem var(--pad);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); text-decoration: none; font-size: 1.15rem; white-space: nowrap; }
.top nav { display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; white-space: nowrap; padding: 0.25rem 0; }
.top nav a:hover { color: var(--teal); }

/* ---------- sections ---------- */
main > section { padding: clamp(3rem, 8vw, 6rem) var(--pad); }
main > section > * { margin-left: auto; margin-right: auto; max-width: 68rem; }
main > section > p, main > section > h2, main > section > h3 { max-width: 68rem; }
.band { background: var(--ground); }

/* ---------- hero ---------- */
.hero {
  display: grid; gap: clamp(2rem, 5vw, 4rem);
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
  background: var(--ink); color: #fff;
}
.hero > * { max-width: none; margin: 0; }
.name { font-size: clamp(3.4rem, 13vw, 8.5rem); letter-spacing: -0.04em; line-height: 0.95; }
.name span { display: block; }
.name b { color: var(--amber); }
.name-gloss { color: #b9c4d9; margin-top: 1rem; }
.lede { font-size: clamp(1.15rem, 2.4vw, 1.45rem); line-height: 1.45; max-width: 34ch; margin-top: 1.5rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.draft-note { font-size: 0.95rem; color: #b9c4d9; margin-top: 1.5rem; max-width: 44ch; }
.draft-note a { color: #fff; }

.button {
  display: inline-block; cursor: pointer;
  font: 700 1rem/1 var(--body);
  padding: 0.85rem 1.2rem; border-radius: 6px;
  border: 2px solid var(--teal); background: var(--teal); color: #fff; text-decoration: none;
}
.button:hover { background: #0a6564; border-color: #0a6564; }
.button.quiet { background: transparent; color: var(--teal); }
.button.quiet:hover { background: var(--teal-soft); }
.hero .button { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.hero .button:hover { background: #f2b65c; border-color: #f2b65c; }
.hero .button.quiet { background: transparent; color: #fff; border-color: #6c7896; }
.hero .button.quiet:hover { background: rgba(255, 255, 255, 0.08); }

.grid-figure { margin: 0; }
.syllable-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; max-width: 26rem; }
.cell {
  aspect-ratio: 1.5; border: 1px solid #36456b; border-radius: 4px;
  background: transparent; color: #dfe6f3; cursor: pointer;
  font-size: clamp(0.9rem, 2.6vw, 1.15rem); font-weight: 400; padding: 0;
}
.cell.marker { background: rgba(14, 124, 123, 0.45); border-color: #2aa3a1; color: #fff; }
.cell.on { background: var(--amber); border-color: var(--amber); color: var(--ink); font-weight: 800; }
.cell.banned { border-style: dashed; color: #5f6d8f; text-decoration: line-through; cursor: default; }
.grid-figure figcaption { font-size: 0.92rem; color: #b9c4d9; margin-top: 0.9rem; max-width: 26rem; min-height: 4.4em; }

/* ---------- goals ---------- */
.goals { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 2rem 2.5rem; }
.goals article { border-top: 3px solid var(--ink); padding-top: 0.9rem; }
.goals h3 { margin-top: 0; }
.goals p { margin: 0; }

/* ---------- choices ---------- */
.choices { margin: 0; }
.choices > div { display: grid; grid-template-columns: minmax(0, 18rem) minmax(0, 1fr); gap: 0.5rem 2.5rem; padding: 1.3rem 0; border-top: 1px solid var(--line); }
.choices dt { font-family: var(--display); font-weight: 600; font-size: 1.08rem; line-height: 1.3; }
.choices dd { margin: 0; max-width: var(--measure); }
.sounds { font-weight: 600; letter-spacing: 0.12em; white-space: nowrap; }

/* ---------- structure ---------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 3.5rem; margin-top: 1rem; }
.rules { margin: 0; padding-left: 1.3rem; max-width: var(--measure); }
.rules li { margin-bottom: 0.45rem; padding-left: 0.3rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.chip {
  font: 400 0.95rem/1.2 var(--body); cursor: pointer; text-align: left;
  padding: 0.55rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.breakdown { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; min-height: 3rem; }
.breakdown:empty { display: none; }
.breakdown .sentence { font-size: clamp(1.25rem, 3.6vw, 1.75rem); line-height: 1.3; margin-bottom: 0.2rem; }
.breakdown .english { color: var(--muted); margin-bottom: 1rem; }
.parts { margin: 0; }
.parts > div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.2rem 1rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.parts dt { display: flex; gap: 0.6rem; align-items: baseline; }
.parts .marker { font-weight: 600; color: var(--teal); min-width: 1.6rem; }
.parts .job { font-size: 0.9rem; color: var(--muted); }
.parts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; align-items: baseline; }
.parts .gloss { color: var(--muted); font-size: 0.95rem; }
.bad { color: var(--bad); }
.good { color: #0a6564; }

.table-wrap { overflow-x: auto; }
.markers { border-collapse: collapse; width: 100%; max-width: 44rem; background: var(--paper); }
.markers th, .markers td { text-align: left; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); }
.markers th { font: 600 0.9rem var(--display); color: var(--muted); }
.markers td.km { font-weight: 600; font-size: 1.1rem; color: var(--teal); }
audio { width: 100%; max-width: 30rem; display: block; margin-top: 0.5rem; }

/* ---------- lessons ---------- */
.lessons { list-style: none; counter-reset: lesson; padding: 0; margin: 0 auto 3rem; }
.lessons > li { counter-increment: lesson; border-top: 1px solid var(--line); }
.lessons > li:last-child { border-bottom: 1px solid var(--line); }
.lessons summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 1rem;
  padding: 1.05rem 0; font: 600 1.15rem/1.3 var(--display);
}
.lessons summary::-webkit-details-marker { display: none; }
.lessons summary::before { content: counter(lesson); color: var(--teal); font-weight: 800; min-width: 1.2rem; }
.lessons summary::after { content: "+"; margin-left: auto; font-weight: 300; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.lessons details[open] summary::after { content: "\2212"; }
.lesson-body { padding: 0 0 1.5rem 2.2rem; }
.examples { margin: 0.4rem 0 1.1rem; border-left: 3px solid var(--teal); padding-left: 1rem; }
.example { margin: 0 0 0.7rem; display: flex; flex-direction: column; }
.example .km { font-size: 1.2rem; }
.example .english { color: var(--muted); font-size: 0.97rem; }

/* ---------- practice ---------- */
.practice { background: var(--ground); border-radius: 10px; padding: clamp(1rem, 3vw, 2rem); }
.tabs { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs button {
  font: 700 1rem/1 var(--body); cursor: pointer; white-space: nowrap;
  background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px;
  padding: 0.8rem 0.9rem; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); }

.controls { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.controls label, label[for="check-input"] { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.controls .grow { flex: 1 1 16rem; }
select, input[type="text"], input[type="search"] {
  font: 400 1rem/1.3 var(--body); color: var(--ink);
  padding: 0.7rem 0.8rem; border: 1px solid #9aa6bb; border-radius: 6px; background: var(--paper);
  min-width: 0; width: 100%;
}
.prompt { font: 600 clamp(1.5rem, 5vw, 2.2rem)/1.2 var(--display); margin: 0.5rem 0 1.1rem; }
.prompt .km { font-weight: 300; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem; }
.option, .tile {
  cursor: pointer; text-align: left; color: var(--ink);
  font: 400 1.1rem/1.3 var(--body);
  background: var(--paper); border: 1px solid #9aa6bb; border-radius: 6px; padding: 0.85rem 1rem;
}
.option:hover:not(:disabled), .tile:hover { border-color: var(--teal); }
.option:disabled { cursor: default; opacity: 0.75; }
.option.right { background: var(--teal-soft); border-color: var(--teal); opacity: 1; }
.option.wrong { background: #f6dfe0; border-color: var(--bad); opacity: 1; }
.feedback { min-height: 1.7em; margin: 1rem 0 0.5rem; font-weight: 700; }
.score { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; margin: 0.75rem 0 0; color: var(--muted); }

.tiles { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 3.6rem; margin-bottom: 0.9rem; }
.tiles.answer { border: 2px dashed #9aa6bb; border-radius: 8px; padding: 0.5rem; background: var(--paper); }
.tiles.answer:empty::before { content: "Select words below to build the sentence here"; color: var(--muted); padding: 0.5rem; font-size: 0.95rem; }
.tile { padding: 0.6rem 0.8rem; }
.check-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.4rem 0 1rem; }
.check-row input { flex: 1 1 16rem; width: auto; font-family: var(--display); }

/* ---------- dictionary ---------- */
.count { color: var(--muted); font-size: 0.95rem; }
.dict { list-style: none; padding: 0; margin: 0 auto 1.25rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.dict li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1.2fr); gap: 0.2rem 1.25rem; padding: 0.65rem 1rem; border-top: 1px solid var(--line); align-items: baseline; }
.dict li:first-child { border-top: 0; }
.dict .en { font-weight: 700; }
.dict .km { font-size: 1.12rem; }
.dict .lit { color: var(--muted); font-size: 0.93rem; }

/* ---------- status and footer ---------- */
.gaps { padding-left: 1.2rem; max-width: 68rem; }
.gaps li { max-width: var(--measure); margin-bottom: 0.8rem; }
footer { background: var(--ink); color: #b9c4d9; padding: 2rem var(--pad); font-size: 0.95rem; }
footer p { margin: 0 auto; max-width: 68rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .choices > div { grid-template-columns: 1fr; }
  .parts > div { grid-template-columns: 1fr; }
  .dict li { grid-template-columns: 1fr 1fr; }
  .dict .lit { grid-column: 1 / -1; }
  .lesson-body { padding-left: 0; }
  .top { gap: 1rem; }
}
