/*
 * butai — the kamishibai design system.
 * 舞台: the wooden stage a kamishibai storyteller slides cards into.
 *
 * Two inks on one stage. No accent color exists in this system;
 * emphasis is inversion (paper chip), weight, or dimming — exactly
 * like the TUI this site is drawn from. Colors mirror the TUI's
 * locked palette in kamishibai/src/tui/palette.rs, verbatim.
 *
 * Voices:
 *   machine  — JetBrains Mono (the TUI's own face, via VHS)
 *   narrator — Literata (the print side: cards, PDF sheet)
 */

:root {
  --stage: #0e0e10;
  --stage-deep: #09090b;
  --stage-raised: #1c1c1f;
  --line: #2a2a2d;
  --paper: #e6e3da;
  --ink-dim: #8b8a83;
  --ink-faint: #5a5953;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-hero: clamp(1.625rem, 1.2rem + 2vw, 2.25rem);
  --text-title: clamp(1.0625rem, 1rem + 0.4vw, 1.125rem);
  --text-body: 0.9375rem;
  --text-small: 0.875rem;
  --text-ui: 0.8125rem;
  --text-term: 0.75rem;
  --content-frame: 46rem;
  --measure: 62ch;
  --gap: 1.5rem;
  --section-gap: clamp(4rem, 3.5rem + 2vw, 5.5rem);
  --title-gap: clamp(2.25rem, 2rem + 0.75vw, 2.5rem);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--stage);
  color-scheme: dark;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--stage);
  color: var(--paper);
  font-family: var(--mono);
  font-size: var(--text-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

strong {
  font-weight: 700;
  color: inherit;
}

::selection {
  background: var(--paper);
  color: var(--stage);
}

:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

a {
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--ink-faint);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--paper);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

code,
kbd,
pre {
  font-family: var(--mono);
}

/* ---- machine voice ------------------------------------------------ */

.m {
  font-family: var(--mono);
  font-size: var(--text-ui);
  line-height: 1.6;
}

.dim {
  color: var(--ink-dim);
}

.faint {
  color: var(--ink-faint);
}

/* chip — the TUI's inverted title block: ▮what i understood▮ */
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--text-ui);
  font-weight: 700;
  line-height: 1.5;
  padding: 0.1em 0.65em;
  background: var(--paper);
  color: var(--stage);
  white-space: nowrap;
}

/* keycap — [C] copy: the bracketed key bright, label follows */
.key {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--paper);
  white-space: nowrap;
}

/* rule — the TUI's dashed horizontal line */
.rule {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 0;
}

/* btn — a mono action; hover inverts, like a selected row */
.btn {
  font-family: var(--mono);
  font-size: var(--text-ui);
  font-weight: 500;
  color: var(--paper);
  padding: 0.35em 0.9em;
  border: 1px solid var(--line);
  background: var(--stage);
  transition: background 120ms, color 120ms, border-color 120ms;
}

.btn:hover {
  background: var(--stage-raised);
  color: var(--paper);
  border-color: var(--ink-dim);
}

.btn[disabled] {
  color: var(--ink-faint);
  border-color: var(--line);
  background: var(--stage);
  cursor: default;
}

.btn--bare {
  border-color: transparent;
}

.btn--bare:hover {
  border-color: var(--paper);
}

/* rows — unnumbered editorial list: bold item title, dim body */
.rows {
  list-style: none;
  display: grid;
  gap: 2rem;
  max-width: 72ch;
}

.rows li {
  display: grid;
  row-gap: 0.6rem;
  align-content: start;
}

.rows h3 {
  font-family: var(--mono);
  font-size: var(--text-body);
  font-weight: 700;
  line-height: 1.45;
  color: var(--paper);
}

.rows li > p {
  color: var(--ink-dim);
  max-width: var(--measure);
}

/* page head — page title and lede: the opener of every page */
.page-head {
  padding-top: clamp(2.5rem, 2rem + 2vw, 3.5rem);
}

.page-head h1 {
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.3;
  max-width: 36ch;
  text-align: start;
  text-wrap: balance;
}

.page-head .lede {
  margin-top: 1.5rem;
  max-width: var(--measure);
  color: var(--ink-dim);
}

/* section heading: a quiet lowercase phrase that opens a terminal divider */
.screen-title {
  max-inline-size: var(--content-frame);
  margin-bottom: var(--title-gap);
}

.sec-title {
  overflow: hidden;
  font-family: var(--mono);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.35;
  color: var(--paper);
}

.sec-title::after {
  content: "";
  display: inline-block;
  inline-size: 100%;
  margin-inline: 2ch -100%;
  vertical-align: middle;
  border-top: 1px dashed var(--line);
}

/* modal — Clear + Block::bordered(), centered */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 11, 0.82);
  z-index: 60;
}

.modal.open {
  display: flex;
}

.modal-box {
  position: relative;
  background: var(--stage);
  border: 1px solid var(--ink-dim);
  padding: 1.5rem 1.75rem 1.25rem;
  min-width: min(24rem, calc(100vw - 3rem));
  overflow: visible;
}

.modal-box > .modal-title {
  position: absolute;
  top: -0.75em;
  left: 1rem;
  background: var(--stage);
  padding: 0 0.75ch;
  font-family: var(--mono);
  font-size: var(--text-ui);
  font-weight: 700;
}

/* thin stage scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line);
}

*::-webkit-scrollbar-track {
  background: transparent;
}
