/* One app, many views: a fixed bar on top owns navigation and the model
   connection; views render below it and never reload the page. */
@import url("../../assets/css/theme.css");

/* Course-app names for the site theme's tokens, plus the few colors only the app
   needs (status dots, the meaning-map groups). Nothing here defines text or
   background colors of its own. */
:root {
  --paper: var(--bg); --plate: var(--surface); --ink-2: var(--muted); --ink-3: var(--faint);
  --bar: color-mix(in srgb, var(--accent) 40%, var(--surface));
  --display: var(--sans); --body: var(--serif);
  --ok: #5fcf93; --warn: #e3a84b; --bad: #f08a80;
  --g-theology: #3987e5; --g-mind: #d95926; --g-machine: #199e70; --g-making: #c98500;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --ok: #1b7f4b; --warn: #8a4f00; --bad: #b3261e;
  --g-theology: #2a78d6; --g-mind: #eb6834; --g-machine: #1baf7a; --g-making: #eda100 } }
:root[data-theme="light"] {
  --ok: #1b7f4b; --warn: #8a4f00; --bad: #b3261e;
  --g-theology: #2a78d6; --g-mind: #eb6834; --g-machine: #1baf7a; --g-making: #eda100 }

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.6 var(--body) }
.wrap { max-width: 1080px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 48px); padding-block: 0 4rem }
h1, h2 { font-family: var(--display); font-weight: 400; text-wrap: balance; line-height: 1.12; margin: 0 }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem) }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem) }
p { margin: 0; max-width: 65ch }
a { color: var(--accent) }
.muted { color: var(--ink-3) }
.mono { font-family: var(--mono) }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0) }
.eyebrow { font: 500 .78rem/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3) }
button, select, input { font: inherit; color: var(--ink) }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }

/* App bar */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(16px, 4vw, 48px); background: var(--paper); border-bottom: 1px solid var(--rule); flex-wrap: wrap }
.brand { font-family: var(--display); font-size: 1.25rem; color: var(--ink); text-decoration: none }
.crumbs { flex: 1; min-width: 0; font: 500 .8rem/1.3 var(--mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.crumbs a { color: var(--ink-2); text-decoration: none }
.chip { display: inline-flex; align-items: center; gap: .5rem; font: 500 .8rem/1 var(--mono); background: var(--plate);
  border: 1px solid var(--rule); border-radius: 999px; padding: .5rem .85rem; cursor: pointer; max-width: 100% }
.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none }
.dot.ready { background: var(--ok) } .dot.loading { background: var(--warn) } .dot.error { background: var(--bad) }

.btn { font: 500 .85rem/1 var(--mono); background: var(--plate); border: 1px solid var(--rule); border-radius: 6px; padding: .6rem .85rem; cursor: pointer }
.btn:hover { border-color: var(--ink-3) }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg) }
.btn.ghost { background: transparent }
.btn:disabled { opacity: .5; cursor: default }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap }
.row.end { justify-content: flex-end }

/* Settings dialog */
dialog { border: 1px solid var(--rule); border-radius: 12px; background: var(--plate); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px) }
dialog::backdrop { background: rgb(0 0 0 / .35) }
.settings { display: grid; gap: 1rem; padding: 1.25rem }
.settings-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem }
.settings h2 { font-size: 1.5rem }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: .6rem }
.choice { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; border: 1px solid var(--rule); border-radius: 8px; padding: .7rem .8rem; cursor: pointer; font-size: .95rem }
.choice:has(input:checked) { border-color: var(--accent) }
.more { border-top: 1px solid var(--rule); padding-top: .6rem }
.more summary { cursor: pointer; font: 500 .8rem/1.4 var(--mono); color: var(--ink-2) }
.more .choices { margin-top: .6rem }
.tag { font: 500 .72rem/1 var(--mono); color: var(--accent); margin-left: .35rem }
.pane { display: grid; gap: .45rem }
.pane label, .settings > label:not(.check) { font: 500 .78rem/1.2 var(--mono); color: var(--ink-2) }
.pane input, .pane select { background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: .5rem .6rem; width: 100%; font-family: var(--mono); font-size: .9rem }
.check { display: flex; gap: .5rem; align-items: center; font-size: .92rem }
.progress { display: grid; gap: .35rem }
.progress .bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s }
.status { font: 500 .85rem/1.4 var(--mono); color: var(--ink-2); min-height: 1.2em }
.status.error { color: var(--bad) }
.ok { color: var(--ok); font: 500 .85rem/1 var(--mono) }

/* Views */
section.plate { display: grid; gap: 1.5rem; padding-block: 3rem; border-bottom: 1px solid var(--rule) }
.figure { background: var(--plate); border: 1px solid var(--rule); border-radius: 10px; padding: clamp(14px, 2.5vw, 28px); min-width: 0 }
.caption { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem }
.caption > div { min-width: 0 }
.caption h3 { font: 600 .8rem/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; margin: 0 0 .4rem; color: var(--ink-2) }
.caption .not h3 { color: var(--ink-3) }
@media (max-width: 720px) { .caption { grid-template-columns: 1fr } }

.home-hero { padding-block: 3rem 1rem; display: grid; gap: 1rem }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; padding-block: 1rem }
.card { display: grid; gap: .5rem; background: var(--plate); border: 1px solid var(--rule); border-radius: 10px; padding: 1.1rem; color: var(--ink); text-decoration: none }
.card:hover { border-color: var(--ink-3) }
.card h3 { font-family: var(--display); font-weight: 400; font-size: 1.35rem; margin: 0 }

.quote { font-family: var(--display); font-size: clamp(1.5rem, 3.4vw, 2.4rem); line-height: 1.25; max-width: 30ch }
.quote .gen { color: var(--accent) }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.1rem }
.tabs button { font: 500 .82rem/1 var(--mono); background: none; border: 0; border-bottom: 2px solid transparent; padding: .6rem .8rem; cursor: pointer; color: var(--ink-2) }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent) }
.controls { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-bottom: 1.25rem }
.controls label { font: 500 .8rem/1.2 var(--mono); color: var(--ink-2); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap }
.controls select, .controls input[type=text] { background: var(--plate); border: 1px solid var(--rule); border-radius: 6px; padding: .45rem .6rem; max-width: 100% }
.controls input[type=text] { min-width: min(28rem, 100%); font-family: var(--body); font-size: 1rem }
input[type=range] { accent-color: var(--accent); width: 9rem }
.sentence { font-size: clamp(1.25rem, 2.6vw, 1.7rem); line-height: 1.45; margin-bottom: 1.25rem; min-height: 2.6em }
.sentence .done { color: var(--accent) }
.sentence .cursor { display: inline-block; width: .55em; border-bottom: 3px solid var(--accent); margin-left: .1em }
.bars { display: grid; gap: 6px }
.barrow { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr 4.2rem; align-items: center; gap: .75rem; font-family: var(--mono); font-size: .92rem }
.barrow .tok { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.barrow .meta { color: var(--ink-3) }
.barrow .track { height: 22px }
.barrow .fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .25s ease }
.barrow.chosen .fill { background: var(--accent) }
.barrow.chosen .tok { font-weight: 500 }
.barrow .pct { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums }
.stepper { display: flex; gap: .5rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap }
.stepper .where { font: 500 .8rem/1.2 var(--mono); color: var(--ink-3) }
.note { font-size: .88rem; color: var(--ink-3); margin-top: .9rem }

.maplayout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1.25rem; align-items: start }
@media (max-width: 820px) { .maplayout { grid-template-columns: 1fr } }
.mapbox { overflow-x: auto }
svg.map { display: block; width: 100%; min-width: 520px; height: auto }
svg.map .word text { font: 500 12.5px var(--mono); fill: var(--ink); paint-order: stroke; stroke: var(--plate); stroke-width: 3px }
svg.map .word circle { stroke: var(--plate); stroke-width: 2px }
svg.map .word { cursor: pointer }
svg.map .word.dim { opacity: .22 }
svg.map line.link { stroke: var(--ink-2); stroke-width: 1.5px; stroke-dasharray: 3 3 }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font: 500 .8rem/1.2 var(--mono); color: var(--ink-2); margin-bottom: .75rem }
.legend span { display: inline-flex; align-items: center; gap: .4rem }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block }
.panel { border-left: 1px solid var(--rule); padding-left: 1.25rem; min-width: 0 }
@media (max-width: 820px) { .panel { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 1rem } }
.panel .pick { font-family: var(--display); font-size: 1.7rem; margin: .25rem 0 .75rem }
.panel ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem }
.panel li { display: grid; grid-template-columns: 1fr auto; font-family: var(--mono); font-size: .92rem; gap: .5rem }
.panel li .s { color: var(--ink-3); font-variant-numeric: tabular-nums }
details.table { margin-top: 1rem; font-size: .9rem }
details.table summary { cursor: pointer; font: 500 .82rem/1.3 var(--mono); color: var(--ink-2) }
.tablebox { overflow-x: auto; margin-top: .75rem }
table { border-collapse: collapse; font-family: var(--mono); font-size: .82rem; min-width: 520px; width: 100% }
th, td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--rule) }
th { color: var(--ink-2); font-weight: 500 }

.ask { display: grid; gap: .75rem }
.ask textarea { width: 100%; min-height: 5.5rem; resize: vertical; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: .7rem; font: inherit }
.answer { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: .9rem 1rem; min-height: 3rem }
.answer .who { display: block; font: 500 .75rem/1.3 var(--mono); color: var(--ink-3); margin-bottom: .4rem; white-space: normal }

.questions { counter-reset: q; display: grid; gap: 1rem; padding: 0; margin: 0; list-style: none }
.questions li { counter-increment: q; display: grid; grid-template-columns: 2rem 1fr; gap: .5rem; max-width: 70ch }
.questions li::before { content: counter(q); font: 500 1.1rem/1.5 var(--mono); color: var(--accent) }
.prov { font: 400 .82rem/1.6 var(--mono); color: var(--ink-3); display: grid; gap: .35rem }
.prov code { color: var(--ink-2); overflow-wrap: anywhere }
@media (prefers-reduced-motion: reduce) { .barrow .fill, .progress .bar span { transition: none } }

/* Draft notice: every view opens with what it is, who made it, what is reviewed */
.draft { margin-top: 1.25rem; border: 1px dashed var(--warn); border-radius: 8px; padding: .65rem .9rem; font-size: .9rem; background: var(--plate) }
.draft-line { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-family: var(--mono); font-size: .8rem; color: var(--ink-2) }
.draft .badge { text-transform: uppercase; letter-spacing: .08em; color: var(--warn); font-weight: 500 }
.draft .warn { color: var(--warn) }
.draft details { margin-top: .4rem }
.draft summary { cursor: pointer; font: 500 .8rem/1.4 var(--mono); color: var(--ink-2) }
.draft ul { margin: .4rem 0; padding-left: 1.1rem; display: grid; gap: .2rem }
.draft p { margin-top: .4rem }
