/* Shared styles for the landing page, the literate viewer and every demo. */
:root {
  color-scheme: dark;
  /* The page is dark. The vocal tract has its own colours, as in the 🗣️ emoji: a blue head and green
     parts that move (tongue, soft palate, lips, vocal cords). The interface is the same blue, on cool
     navy-tinted greys, with green kept for the tract's moving parts. */
  --bg: #0a0d12;
  --panel: #121820;
  --ink: #e8eef6;
  --muted: #8fa0b5;
  --line: #232d3b;
  --accent: #6db8f2;
  --accent-strong: #2b78c8;
  --accent-soft: #14263f;
  --code-bg: #0d1218;
  --code-ink: #e8eef6;
  --head: #55acee;
  --tissue: #5fd68a;
  --tissue-soft: #1d3a2a;
  --tongue: #3fbf6f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ipa: "Charis SIL", "Gentium Plus", "Doulos SIL", "Noto Sans", "Segoe UI", "DejaVu Sans", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body {
  margin: 0 auto;
  max-width: 62rem;
  padding: 1.25rem 1rem 4rem;
  font: 1.0625rem/1.6 var(--serif);
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; }
h1 { font-size: 2.1rem; margin: 1.5rem 0 .5rem; }
code { font-family: var(--mono); font-size: .92em; background: var(--accent-soft); padding: .05em .3em; border-radius: 4px; }
.ipa { font-family: var(--ipa); }
nav.top { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; font: .95rem var(--serif); color: var(--muted); }
nav.top a { text-decoration: none; }
nav.top strong { color: var(--ink); }

/* Landing page */
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); padding: 0; list-style: none; }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .9rem 1rem; text-decoration: none; color: inherit; min-height: 7.5rem;
}
.card .n { font: 600 .8rem var(--mono); color: var(--accent); }
.card h3 { margin: .15rem 0 .3rem; font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.4; }
a.card:hover { border-color: var(--accent); }
.pill { float: inline-end; font: .7rem var(--mono); border: 1px solid var(--line); border-radius: 99px; padding: .05rem .5rem; color: var(--muted); }
.pill.live { color: var(--accent); border-color: var(--accent); }

/* Literate viewer */
.prose { max-width: 40rem; }
.prose h1, .prose h2, .prose h3 { margin: 1.4rem 0 .4rem; }
.prose p, .prose ul, .prose ol { margin: .5rem 0; }
.code {
  background: var(--code-bg); color: var(--code-ink); border-radius: 8px; padding: .8rem 1rem; margin: .8rem 0;
  overflow-x: auto; font: .85rem/1.5 var(--mono);
}
.code code { background: none; padding: 0; font-size: inherit; }
.code .c { color: #9a8189; font-style: italic; }
.code .s { color: #ffc08a; }
.code .n { color: #9ad6ff; }
.code .k { color: #ff9ac0; }
.src-path { font: .8rem var(--mono); color: var(--muted); }

/* Demo chrome shared by every experiment */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: 1rem 0; }
.row { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; }
label { font: .9rem var(--serif); color: var(--muted); }
button, select, input[type="text"], textarea {
  font: 1rem var(--ipa); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .4rem .7rem;
}
/* Buttons are controls, not text: a press-and-hold should never start a text selection or a long-press menu. */
/* Double-tap should not zoom the page (it fires when you press the same vowel twice). Pinch-zoom still works. */
html { touch-action: manipulation; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent-strong); color: #fff; border-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
.readout { font: .9rem var(--mono); color: var(--muted); }
canvas { max-width: 100%; height: auto; touch-action: none; }
.note { color: var(--muted); font-size: .95rem; }

/* IPA charts */
svg.vowel-chart { width: 100%; max-width: 30rem; height: auto; touch-action: none; user-select: none; cursor: crosshair; }
.chart-outline { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-dot { fill: var(--muted); }
.chart-symbol { font: 22px var(--ipa); fill: var(--ink); }
.chart-symbol.active { fill: var(--accent); font-weight: 700; }
.chart-row { stroke: var(--accent); stroke-width: 2; opacity: .55; }
.chart-caption { font: 12px var(--serif); fill: var(--muted); font-style: italic; }
.chart-cursor { fill: none; stroke: var(--tongue); stroke-width: 2.5; pointer-events: none; }
.demo-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); align-items: start; }
.vowel-buttons { display: flex; flex-wrap: wrap; gap: .3rem; }
.vowel-buttons button { min-width: 2.4rem; font-size: 1.15rem; padding: .25rem .45rem; }
.vowel-buttons button.active { background: var(--accent-strong); color: #fff; border-color: var(--accent); }

/* consonant table */
.ipa-table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.ipa-table th { font-weight: 500; color: var(--muted); padding: .2rem .3rem; text-align: start; }
.ipa-table thead th { font-size: .7rem; writing-mode: horizontal-tb; }
.ipa-table td { border: 1px solid var(--line); text-align: center; padding: .1rem; min-width: 2.2rem; }
.ipa-cell { font: 1.25rem var(--ipa); min-width: 2rem; padding: .15rem .3rem; margin: .05rem; }
.ipa-cell.active, .ipa-cell.playing { background: var(--accent-strong); color: #fff; }
.table-wrap { overflow-x: auto; }
.vowel-buttons button.playing { background: var(--accent-strong); color: #fff; }

/* Lesson navigation */
nav.lessons { display: grid; grid-template-columns: 1fr auto 1fr; gap: .75rem; align-items: center; margin: 2rem 0 0; }
a.lesson { text-decoration: none; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: .6rem .9rem; color: var(--ink); font: .85rem var(--serif); line-height: 1.3; }
a.lesson strong { display: block; font-size: 1.05rem; }
a.lesson:hover { border-color: var(--accent); }
a.lesson.next { text-align: end; background: var(--accent-strong); border-color: var(--accent); color: #fff; }
a.lesson.all { color: var(--muted); border: none; background: none; }
@media (max-width: 38rem) { nav.lessons { grid-template-columns: 1fr 1fr; } a.lesson.all { grid-column: 1 / -1; order: 3; text-align: center; } }

/* Right-to-left languages (Arabic): text and layout mirror, but drawings and IPA keep their own
   direction, because a vowel chart or a phonetic string reads the same in every language. */
canvas, svg, .ipa-table, .vowel-buttons, textarea.ipa, #ipa { direction: ltr; }

/* On a phone the picture comes first. A demo page is written in reading order (title, explanation,
   controls, drawing), which on a narrow screen buries the drawing under a screenful of text.
   There the page becomes a column and is reordered: title, the drawing, then the controls and
   charts, then the explanation, then the lesson buttons. The first thing a visitor sees is a mouth
   that moves, and the reading is there for whoever scrolls. */
@media (max-width: 38rem) {
  body:has(#tract) { display: flex; flex-direction: column; }
  body:has(#tract) > * { order: 2; }
  body:has(#tract) .demo-grid { display: contents; }
  body:has(#tract) .demo-grid > * { order: 2; }
  body:has(#tract) > nav.top, body:has(#tract) > h1 { order: 0; }
  body:has(#tract) section:has(> #tract) { order: 1; margin-top: .5rem; }
  body:has(#tract) > p:not(.note) { order: 3; }
  body:has(#tract) > nav.lessons { order: 4; }
}

/* The language menu sits at the very bottom of every page. */
footer.lang { margin: 2.5rem 0 0; text-align: center; font: .9rem var(--serif); color: var(--muted); }
@media (max-width: 38rem) { body:has(#tract) > footer.lang { order: 5; } }

/* The small "See also" line under the list of demos on the home page. */
.seealso { margin-top: 2rem; font-size: 0.9rem; opacity: 0.7; }

/* The tagline under the name on the home page. */
.tagline { margin: -0.6rem 0 1rem; font-size: 1.15rem; color: var(--muted); }

/* The place axis of the consonant lessons: the same kind of picture as the vowel chart. */
.place-axis { width: 100%; height: auto; touch-action: none; cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.place-axis text { -webkit-user-select: none; user-select: none; }
.axis-line { stroke: var(--accent); stroke-width: 2; opacity: .6; }
.axis-tick { stroke: var(--muted); stroke-width: 1; }

/* The steps under a lesson's card on the home page. */
.steps { margin: .35rem .2rem 0; font-size: .85rem; color: var(--muted); }
.steps a { margin-inline-end: .35rem; }
