/* ---------------------------------------------------------------- tokens */
:root {
  --paper: #e9edea;
  --surface: #ffffff;
  --surface-sunk: #f3f6f4;
  --ink: #0e1c18;
  --muted: #566862;
  --rule: #c3cec9;
  --rule-soft: #d8e0dc;
  --accent: #0a6e62;
  --accent-ink: #ffffff;
  --accent-soft: #dbeae6;
  --shadow: 0 1px 2px rgb(14 28 24 / 8%), 0 8px 24px -16px rgb(14 28 24 / 40%);

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ipa: "Doulos SIL", "Charis SIL", "Gentium Plus", "Times New Roman", "DejaVu Serif", Georgia, serif;

  --tap: 2.35rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 62rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1310;
    --surface: #14201c;
    --surface-sunk: #101a17;
    --ink: #e2eae6;
    --muted: #93a49e;
    --rule: #2b3a35;
    --rule-soft: #223029;
    --accent: #4ecfb9;
    --accent-ink: #06231e;
    --accent-soft: #17322c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -16px rgb(0 0 0 / 80%);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 0.2em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ------------------------------------------------------------- masthead */
.masthead {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 9vw, 6rem) var(--gutter) 2rem;
}

.sitelink {
  margin: 0 0 2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.sitelink a {
  color: inherit;
  text-decoration: none;
  font-weight: 550;
}

.sitelink a:hover { color: var(--accent); }

.eyebrow {
  margin: 0 0 1.25rem;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.masthead h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.5rem, 8vw, 4.75rem);
  font-weight: 780;
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 46ch;
  margin: 0 0 1rem;
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  color: var(--ink);
}

.caveat {
  max-width: 52ch;
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  font-size: 0.925rem;
  color: var(--muted);
}

/* --------------------------------------------------------------- search */
.search { margin-top: 2.5rem; max-width: 26rem; }

.search label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.search input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.search input::placeholder { color: var(--muted); }

.search-status {
  min-height: 1.4em;
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* -------------------------------------------------------------- monitor */
.monitor {
  position: sticky;
  top: 0;
  z-index: 10;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
}

.monitor-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.7rem var(--gutter);
}

.monitor-symbol {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface);
  font-family: var(--ipa);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
}

.monitor.is-live .monitor-symbol {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.monitor-body { min-width: 0; flex: 1; }

.monitor-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.monitor-meta {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.replay {
  flex: none;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.replay:disabled { opacity: 0.45; cursor: default; }
.replay:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------- sections */
main { padding-bottom: 4rem; }

.section {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4rem) var(--gutter) 0;
}

.section.wide { max-width: 82rem; }

.section-head { margin-bottom: 1.75rem; }

.section-head h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 720;
  letter-spacing: -0.02em;
}

.section-head p {
  max-width: 58ch;
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------------------------------------------------------------- chips */
.sym {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--ipa);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease,
              border-color 120ms ease, color 120ms ease;
}

.sym:hover { border-color: var(--accent); color: var(--accent); }

.sym.is-playing {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  transform: scale(1.08);
}

.sym.is-mute { border-style: dashed; color: var(--muted); }
.sym.is-dim { opacity: 0.22; }
.sym.is-hit { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------------------------------------------------------------- vowels */
.vowel-figure {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1.6rem;
  min-width: 33rem;
  margin: 0;
  padding: 0.5rem 2.5rem 1rem 0;
}

.vowel-axis-x {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.vowel-axis-y {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  width: 5rem;
}

.vowel-axis-y span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.vowel-plot {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  aspect-ratio: 1.55;
}

.vowel-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.vg-edge, .vg-line {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.vg-edge { stroke: color-mix(in srgb, var(--rule) 70%, var(--ink)); }
.vg-line { stroke-dasharray: 3 4; }

.vowel-plot .sym {
  position: absolute;
  transform: translate(calc(-50% + var(--dx, 0) * 1.15 * var(--tap)), -50%);
}

.vowel-plot .sym.is-playing {
  transform: translate(calc(-50% + var(--dx, 0) * 1.15 * var(--tap)), -50%) scale(1.12);
}

/* --------------------------------------------------------- consonant grid */
.scroller {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 0.5rem;
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  min-width: 60rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.grid th {
  padding: 0.5rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  hyphens: auto;
}

.grid thead th { border-bottom: 1px solid var(--rule); vertical-align: bottom; }
.grid thead th:first-child { width: 9rem; }

.grid tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--surface-sunk);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule-soft);
}

.grid tbody tr:last-child th,
.grid tbody tr:last-child td { border-bottom: 0; }

.grid td {
  padding: 0.2rem;
  text-align: center;
  border-bottom: 1px solid var(--rule-soft);
  border-right: 1px solid var(--rule-soft);
}

.grid td.pair-end { border-right: 1px solid var(--rule); }
.grid td:last-child { border-right: 0; }
.grid td .sym { margin: 0 auto; }

/* ----------------------------------------------------------- list layouts */
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.25rem;
}

.card {
  padding: 1rem 1.1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.card .note {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.row-list { display: grid; gap: 0.4rem; }

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.4rem 1.5rem;
}

.entry {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.entry .name {
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.entry.is-dim .name { opacity: 0.35; }

/* --------------------------------------------------------------- footer */
.footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem var(--gutter) 4rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.82rem;
  color: var(--muted);
}

.footer p { margin: 0 0 0.4rem; }

.noscript {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .sym, .sym.is-playing, .vowel-plot .sym.is-playing { transition: none; transform: none; }
  .vowel-plot .sym,
  .vowel-plot .sym.is-playing {
    transform: translate(calc(-50% + var(--dx, 0) * 1.15 * var(--tap)), -50%);
  }
}

@media (max-width: 34rem) {
  :root { --tap: 2.6rem; }
  .vowel-figure { padding-right: 1.75rem; }
  .monitor-inner { gap: 0.7rem; }
  .replay span { display: none; }
}
