/* Babel: the site's one stylesheet. Calm and literary, like a chronicle:
   a serif for headings and reading, a sans for the interface, a monospace
   only for signatures and words-as-data. No external requests (decision 0037). */

:root {
  /* Type */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* A 1.25 scale on a 1rem base */
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;

  /* Space */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 1rem;
  --s4: 1.5rem;
  --s5: 2.5rem;
  --s6: 4rem;

  /* Widths */
  --page: 64rem;
  --measure: 40rem;

  /* Colour: paper and ink, one accent */
  --bg: #faf8f3;
  --surface: #f2eee5;
  --text: #22201c;
  --muted: #6d675d;
  --rule: #ebe7df;
  --accent: #8d3d16;
  --accent-soft: #f3e3d7;
  --good: #3f6b3a;
  --bad: #9a3324;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #201e1b;
    --text: #e9e5dc;
    --muted: #a19b8f;
    --rule: #262420;
    --accent: #e39a66;
    --accent-soft: #3a2a20;
    --good: #93bf89;
    --bad: #e88d7c;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--step-0)/1.6 var(--sans);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

/* Headings: one h1 per page, in the serif */
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0;
}
h1 { font-size: var(--step-4); margin-bottom: var(--s2); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 var(--s3); }

/* ---- Header and navigation ---- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.site-header .bar,
.site-nav,
main,
.site-footer .inner {
  max-width: var(--page);
  margin: 0 auto;
  padding-left: var(--s3);
  padding-right: var(--s3);
}
.site-header .bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--s3);
  padding-top: var(--s5);
}
.wordmark {
  font-family: var(--serif);
  font-size: var(--step-2);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.tagline {
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.35;
  color: var(--muted);
  margin: var(--s2) 0 0;
  flex-basis: 100%;
}
.menu-toggle { display: none; margin-left: auto; flex: none; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s5);
  padding-top: var(--s4);
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--step-0);
  font-weight: 600;
  padding: var(--s3) 0;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.site-nav .spacer { flex: 1; }
.site-nav a.cta { color: var(--accent); }

/* More: a small dropdown on wide screens */
.more { position: relative; display: flex; }
.more-toggle {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: var(--step-0);
  font-weight: 600;
  padding: var(--s3) 0;
}
.more-toggle:hover { background: none; color: var(--text); }
.more-toggle.current { color: var(--text); border-bottom-color: var(--accent); }
.more-toggle .caret { margin-left: 0.3em; font-size: 0.8em; }
.more-label { display: none; }
.more-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: -0.75rem;
  z-index: 10;
  min-width: 11rem;
  padding: var(--s2) 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.more.open .more-menu { display: block; }
.site-nav .more-menu a { display: block; padding: var(--s2) 0.75rem; border-bottom: 0; }
.site-nav .more-menu a:hover { background: var(--surface); }
.site-nav .more-menu a[aria-current="page"] { color: var(--accent); }

@media (max-width: 760px) {
  .menu-toggle { display: inline-block; }
  .site-header .bar { padding-bottom: var(--s3); }
  .site-nav { display: none; flex-direction: column; gap: 0; padding-bottom: var(--s2); }
  .site-nav.open { display: flex; }
  .site-nav a { padding: var(--s2) 0; border-bottom: 1px solid var(--rule); }
  .site-nav a[aria-current="page"] { border-bottom-color: var(--rule); color: var(--accent); }
  .site-nav .spacer { display: none; }
  .more { display: block; }
  .more-toggle { display: none; }
  .more-menu { display: block; position: static; border: 0; box-shadow: none; padding: 0; background: none; min-width: 0; }
  .more-label {
    display: block;
    padding: var(--s3) 0 var(--s1);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--rule);
  }
  .site-nav .more-menu a { padding: var(--s2) 0; border-bottom: 1px solid var(--rule); }
  .site-nav .more-menu a:hover { background: none; }
}

/* ---- Page ---- */

main { padding-top: var(--s6); padding-bottom: var(--s6); }

.lede {
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
  max-width: var(--measure);
  margin-bottom: var(--s4);
}

/* A section: heading, one line saying what it is, then the content */
section { margin-top: var(--s6); }
section > h2 { padding-top: var(--s5); border-top: 1px solid var(--rule); }
section > h2 + .explain, section > header + .explain { margin-top: var(--s2); }
section > .content, section > .picker { margin-top: var(--s4); }
.explain {
  color: var(--muted);
  font-size: var(--step--1);
  max-width: var(--measure);
  margin: 0 0 var(--s3);
}
h3 { margin-top: var(--s4); margin-bottom: var(--s1); }
h3 + .explain { margin-top: 0; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  padding-top: var(--s5);
  border-top: 1px solid var(--rule);
}
.section-head h2 { padding: 0; border: 0; }
.more { font-size: var(--step--1); white-space: nowrap; }

.prose {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  max-width: var(--measure);
}
.prose p { margin-bottom: var(--s3); }

.measure { max-width: var(--measure); }

/* Muted text, messages, loading and empty states */
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.msg { color: var(--muted); font-style: italic; max-width: var(--measure); }
.error { color: var(--bad); white-space: pre-wrap; }

/* ---- Babblers, signatures, words ---- */

code, .mono {
  font-family: var(--mono);
  font-size: 0.85em;
}

a.babbler { text-decoration: none; color: inherit; }
a.babbler .name { color: var(--accent); }
a.babbler:hover .name { text-decoration: underline; }
a.babbler.short { white-space: nowrap; }

/* A babbler's sigil: drawn from its signature (app.js, sigil) */
.sigil {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.18em;
  margin-right: 0.35em;
  flex: none;
}
.sigil .ground { fill: hsl(var(--h) 60% 90%); }
.sigil .cells { fill: hsl(var(--h) 55% 38%); }
.babbler-title { display: flex; align-items: flex-start; gap: 0.1em; }
.babbler-title .sigil { width: 0.9em; height: 0.9em; margin-top: 0.12em; }
table.details th { text-transform: none; letter-spacing: 0; font-size: var(--step--1); width: 10rem; }
.sig-full { font-family: var(--mono); font-size: 0.85em; word-break: break-all; }

.words { font-family: var(--mono); font-size: 0.92em; }
.said {
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.4;
}

/* Chips: a list of names or words that wraps */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; padding: 0; margin: 0 0 var(--s3); }
.chips li {
  background: var(--surface);
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  font-size: var(--step--1);
}
.chips .n { color: var(--muted); margin-left: 0.35em; font-variant-numeric: tabular-nums; }
.chips a { text-decoration: none; }

/* ---- Figures: the day at a glance ---- */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--s4);
  margin: var(--s5) 0 var(--s6);
  padding: 0;
  list-style: none;
}
.figures li { border-left: 3px solid var(--accent); padding-left: var(--s4); }
.figures b {
  display: block;
  font-family: var(--serif);
  font-size: var(--step-4);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.figures span { display: block; margin-top: var(--s2); color: var(--muted); font-size: var(--step-0); }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; margin-bottom: var(--s3); }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
caption { text-align: left; color: var(--muted); padding-bottom: var(--s2); }
th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--s2) var(--s3) var(--s2) 0;
  border-bottom: 1px solid var(--rule);
}
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: var(--s4); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }

/* ---- Lists ---- */

ul.plain, ol.plain { list-style: none; padding: 0; margin: 0 0 var(--s3); }
ul.plain > li, ol.plain > li { padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
ul.plain > li:first-child, ol.plain > li:first-child { padding-top: 0; }
ul.plain > li:last-child, ol.plain > li:last-child { border-bottom: 0; }

.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  background: var(--surface);
  color: var(--muted);
  vertical-align: 0.1em;
}
.tag.passed, .tag.in_effect, .tag.pending, .tag.yes { background: var(--accent-soft); color: var(--accent); }
.tag.reverted, .tag.failed, .tag.no { color: var(--bad); }

/* Banter list rows */
.banter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s3); align-items: baseline; }
.banter-row .pair { font-size: var(--step-0); }
.banter-row .vs { color: var(--muted); margin: 0 0.4em; font-style: italic; font-family: var(--serif); }
.banter-row .meta { grid-column: 1 / -1; color: var(--muted); font-size: var(--step--1); }
.banter-row .open { font-size: var(--step--1); white-space: nowrap; }

/* ---- The Wall ---- */

.wall-line .said { display: block; }
.wall-line .by { font-size: var(--step--1); color: var(--muted); }
.meanings { margin: var(--s2) 0 0; padding-left: var(--s3); border-left: 2px solid var(--rule); font-size: var(--step--1); }
.meanings div { margin: 0.1rem 0; }
.meanings b { font-family: var(--mono); font-weight: 600; font-size: 0.92em; }

/* ---- Transcript: a dialogue ---- */

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: var(--s4) 0; max-width: 46rem; }
.side { background: var(--surface); border-radius: 6px; padding: var(--s3); }
.side .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.side .name { font-family: var(--serif); font-size: var(--step-1); }
.side.b { text-align: right; }

.round { margin-top: var(--s4); max-width: 46rem; }
.round h3 { font-size: var(--step-0); font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.utterance { margin: var(--s3) 0; max-width: 85%; }
.utterance.b { margin-left: auto; text-align: right; }
.utterance .who { font-size: var(--step--1); color: var(--muted); }
.utterance .said {
  display: inline-block;
  background: var(--surface);
  border-radius: 10px;
  padding: var(--s2) var(--s3);
  margin: var(--s1) 0;
}
.utterance.a .said { border-top-left-radius: 2px; }
.utterance.b .said { border-top-right-radius: 2px; }
/* Each side speaks in its sigil's hue */
.voice .said { border: 1.5px solid hsl(var(--h) 50% 60%); background: hsl(var(--h) 60% 96%); }
.side.voice { border-top: 3px solid hsl(var(--h) 50% 55%); }
.utterance .gloss { font-size: var(--step--1); color: var(--muted); margin: 0.15rem 0; }
.utterance .gloss i { font-style: normal; font-weight: 600; letter-spacing: 0.02em; }
.verdict {
  margin-top: var(--s5);
  padding: var(--s3) var(--s4);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-family: var(--serif);
  font-size: var(--step-1);
  max-width: 46rem;
}

@media (max-width: 560px) {
  .sides { grid-template-columns: 1fr; }
  .side.b { text-align: left; }
  .utterance { max-width: 100%; }
}

/* ---- The Council ---- */

.statement { max-width: var(--measure); }
.statement .seat { font-family: var(--serif); font-weight: 600; }
.statement .prose { margin-top: var(--s1); }
.votes { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-size: var(--step--1); margin-top: var(--s2); }

/* ---- Rule cards and the daily card ---- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--s3); }
.card {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: var(--s3);
}
.card h3 { margin-top: 0; }
.card p { font-size: var(--step--1); margin-bottom: var(--s2); }

.daily-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: var(--s3) var(--s4);
  max-width: 28rem;
}
.daily-card .line { font-size: var(--step-3); line-height: 1.3; margin: var(--s1) 0 var(--s2); }

/* ---- Forms ---- */

form.inline { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s3); max-width: var(--measure); }
form.inline input, form.inline select { flex: 1 1 12rem; min-width: 0; }
input, select {
  font: inherit;
  font-size: var(--step-0);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-soft); }
button.primary, .button.primary { background: var(--accent); color: var(--bg); }

.daypicker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0 0 var(--s3); font-size: var(--step--1); }

/* ---- Dropdowns: the site's own select, in the dress of the More menu ---- */

.dropdown { position: relative; display: inline-block; max-width: 100%; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: var(--step-0);
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
  max-width: 100%;
}
.dropdown-toggle:hover { background: var(--surface); color: var(--text); }
.dropdown-toggle .dropdown-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-toggle .caret { font-size: 0.8em; color: var(--muted); }
.dropdown.open .dropdown-toggle { border-color: var(--accent); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  min-width: 100%;
  max-height: 18rem;
  overflow-y: auto;
  padding: var(--s2) 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: var(--step-0);
  font-weight: 400;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 0;
  padding: var(--s2) 0.9rem;
  white-space: nowrap;
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--surface); color: var(--text); outline: none; }
.dropdown-item[aria-selected="true"] { color: var(--accent); }
.dropdown-item[aria-selected="true"]::before { content: "✓ "; }
.dropdown.for-select .dropdown-toggle { font-weight: 400; }
label > .dropdown.for-select { display: block; margin-top: var(--s1); }
label > .dropdown.for-select .dropdown-toggle { width: 100%; justify-content: space-between; }

/* ---- Learn and Launch ---- */

article.guide { max-width: var(--measure); }
article.guide h2 { margin-top: var(--s5); padding-top: var(--s3); border-top: 1px solid var(--rule); }
article.guide h3 { margin-top: var(--s4); }
article.guide p, article.guide li { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.7; }
article.guide table { margin: var(--s2) 0; }
article.guide table td { font-family: var(--sans); }

.note {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s4);
  max-width: var(--measure);
}
.note h2, article.guide .note h2 { font-size: var(--step-1); border: 0; padding: 0; margin: 0 0 var(--s2); }
.note ul { margin: 0; padding-left: var(--s4); }
.note p:last-child { margin-bottom: 0; }

.launch > * { max-width: var(--measure); }
.launch fieldset { border: 1px solid var(--rule); border-radius: 6px; margin: 0 0 var(--s3); padding: var(--s3); }
.launch legend { font-weight: 600; padding: 0 var(--s1); }
.launch label { display: block; margin: 0 0 var(--s3); font-weight: 500; }
.launch label input, .launch label select { display: block; width: 100%; margin-top: var(--s1); font-weight: 400; }
.launch .word-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.launch .word-inputs input { width: 100%; font-family: var(--mono); }
.launch article { border-top: 1px solid var(--rule); padding: var(--s3) 0; }
.launch article h3 { margin-top: 0; }
.launch article div { display: flex; flex-wrap: wrap; gap: var(--s2); }
.launch article div input, .launch article div select { flex: 1 1 10rem; min-width: 0; }

/* ---- Phones ---- */

@media (max-width: 560px) {
  h1 { font-size: var(--step-3); }
  h2 { font-size: var(--step-1); }
  .tagline { font-size: 1rem; }
  .lede { font-size: 1.0625rem; }
  main { padding-top: var(--s4); }
  .figures b { font-size: var(--step-2); }
  .said { font-size: 1.125rem; }
}

/* ---- How Babel works: the self-hosted videos ---- */

.how { margin-top: var(--s4); }
.how h2, article.guide .how h2 { border-top: 0; padding-top: 0; margin: 0 0 var(--s3); }
.video {
  aspect-ratio: 16 / 9;
  max-width: 48rem;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1117;
}
.video video { width: 100%; height: 100%; display: block; }
.video-note { color: var(--muted); font-size: var(--step--1); margin-top: var(--s2); max-width: 48rem; }

/* ---- Footer ---- */

.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: var(--step--1); }
.site-footer .inner { padding-top: var(--s4); padding-bottom: var(--s5); }
.site-footer p { margin: 0 0 var(--s1); max-width: var(--measure); }

.updated { color: var(--muted); font-size: 0.75rem; }

[hidden] { display: none !important; }

/* ---- The Chronicle ---- */



/* Sigils and voices in the dark scheme (after their light rules, so they win) */
@media (prefers-color-scheme: dark) {
  .sigil .ground { fill: hsl(var(--h) 30% 22%); }
  .sigil .cells { fill: hsl(var(--h) 65% 68%); }
  .voice .said { border-color: hsl(var(--h) 45% 50%); background: hsl(var(--h) 25% 17%); }
  .side.voice { border-top-color: hsl(var(--h) 50% 55%); }
}

/* ---- Round three: contents lines, the tower list, a tower's dictionary ---- */


.tower-list > li { display: grid; gap: var(--s1); }
.tower-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); }
.tower-name { font-family: var(--serif); font-size: var(--step-2); font-weight: 600; }
.tower-line { margin: 0; }
.tower-line .said { font-size: var(--step-0); }

.glossary { display: grid; grid-template-columns: minmax(6rem, max-content) 1fr; gap: var(--s2) var(--s4); margin: 0; max-width: var(--measure); }
.glossary dt { margin: 0; }
.glossary dd { margin: 0; font-family: var(--serif); }
@media (max-width: 560px) {
  .glossary { grid-template-columns: 1fr; gap: 0; }
  .glossary dd { margin-bottom: var(--s3); }
}

.entry h3 { margin-top: var(--s3); }
.verdict { margin-top: 0; }
.daypicker { margin-bottom: var(--s3); }
