:root {
  --bg: #f4efe0;
  --paper: #fdfaf0;
  --ink: #0c0b08;
  --muted: #58524a;
  --mid: #9a9288;
  --line: rgba(12, 11, 8, 0.12);
  --line-strong: rgba(12, 11, 8, 0.22);

  /* Bauhaus primaries */
  --red: #c82010;
  --yellow: #f0be08;
  --blue: #1428b0;

  --max-width: 1180px;
  --mono: 'IBM Plex Mono', monospace;
  --display: 'Syne', sans-serif;
  --serif: 'Libre Baskerville', Georgia, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.page-shell {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding: 0 0 6rem;
  position: relative;
}

/* ── HERO ───────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  padding: 2.5rem 0 4rem;
  border-bottom: 3px solid var(--ink);
  position: relative;
  overflow: hidden;
  animation: appear 0.5s ease both;
}

/* Kandinsky circle — structural, not decorative */
.hero::before {
  content: '';
  position: absolute;
  right: 140px;
  top: 50%;
  transform: translateY(-58%);
  width: 440px;
  height: 440px;
  border-radius: 50%;
  border: 3px solid var(--red);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

/* Small filled circle — counterpoint */
.hero::after {
  content: '';
  position: absolute;
  right: 360px;
  bottom: 3.5rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  pointer-events: none;
  z-index: 0;
}

.hero-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.hero-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--ink);
}

.lang-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.42rem 0.75rem;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.lang-button:not(:last-child) {
  border-right: 2px solid var(--ink);
}

.lang-button.is-active {
  background: var(--ink);
  color: var(--paper);
}

.lang-button:hover:not(.is-active) {
  background: rgba(12, 11, 8, 0.07);
  color: var(--ink);
}

h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 4.5vw, 3.8rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--ink);
  max-width: 12ch;
  margin-bottom: 2.4rem;
  position: relative;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.72rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid var(--ink);
  transition: background 100ms, color 100ms, transform 120ms;
}

.button-primary {
  background: var(--ink);
  color: var(--paper);
}

.button-primary:hover {
  background: var(--blue);
  border-color: var(--blue);
  transform: translateY(-2px);
}

.button-secondary {
  background: transparent;
  color: var(--ink);
}

.button-secondary:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-2px);
}

/* Hero panel */
.hero-panel {
  border: 2px solid var(--ink);
  border-top: 6px solid var(--red);
  background: var(--paper);
  padding: 1.6rem;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
}

.panel-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 1.1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line-strong);
}

.memory-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.memory-list li {
  font-family: var(--serif);
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.58;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.65rem;
}

.memory-list li:last-child {
  border-bottom: none;
}

.memory-list li::before {
  content: '—';
  font-family: var(--mono);
  color: var(--red);
  font-size: 0.82rem;
  flex-shrink: 0;
  margin-top: 0.2em;
}

/* ── SECTIONS ───────────────────────────────────────── */

.section {
  margin-top: 2rem;
  padding: 2rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  animation: appear 0.5s ease both;
  animation-delay: 0.08s;
}

/* Primary color cycling — Bauhaus rhythm */
main > .section:nth-child(3n+1) { border-top: 6px solid var(--red); }
main > .section:nth-child(3n+2) { border-top: 6px solid var(--blue); }
main > .section:nth-child(3n+3) { border-top: 6px solid var(--yellow); }

.section-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  margin-bottom: 1.8rem;
  align-items: start;
}

.section-kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--paper);
  background: var(--ink);
  padding: 0.42rem 0.6rem;
  display: inline-block;
  align-self: start;
  line-height: 1.1;
  white-space: nowrap;
}

main > .section:nth-child(3n+1) .section-kicker { background: var(--red); }
main > .section:nth-child(3n+2) .section-kicker { background: var(--blue); }
main > .section:nth-child(3n+3) .section-kicker { background: var(--ink); color: var(--yellow); }

h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.4vw, 2rem);
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink);
}

h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.18rem;
  line-height: 1.1;
  color: var(--ink);
}

.section-heading p:last-child {
  margin-top: 0.55rem;
}

p, li {
  font-family: var(--serif);
  font-size: 0.97rem;
  line-height: 1.72;
  color: var(--muted);
}

/* ── CARDS ──────────────────────────────────────────── */

.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
}

.card {
  border: 2px solid var(--ink);
  padding: 1.3rem;
  background: var(--bg);
  transition: background 120ms;
}

.card:hover {
  background: var(--paper);
}

.feature-card {
  grid-column: span 2;
  background: var(--paper);
  border-left: 6px solid var(--ink);
}

.card-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 0.75rem;
  padding: 0.24rem 0.48rem;
  background: var(--ink);
  color: var(--paper);
}

/* Cycling tag colors — Bauhaus color grammar */
.card:nth-child(3n+1) .card-tag { background: var(--red); }
.card:nth-child(3n+2) .card-tag { background: var(--blue); }
.card:nth-child(3n+3) .card-tag { background: var(--yellow); color: var(--ink); }

/* ── SPLIT PANEL ────────────────────────────────────── */

.split-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}

.contrast-card {
  border: 2px solid var(--ink);
  padding: 1.6rem;
  background: var(--bg);
}

.contrast-card h3 {
  margin: 0.6rem 0 0.8rem;
}

.contrast-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.safety {
  border-top: 6px solid var(--blue);
}

.safety .contrast-label { color: var(--blue); }

.security {
  border-top: 6px solid var(--red);
}

.security .contrast-label { color: var(--red); }

.bridge-note {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border: 2px solid var(--ink);
  border-left: 6px solid var(--red);
  background: var(--bg);
  font-family: var(--serif);
  font-size: 0.97rem;
  color: var(--ink);
  line-height: 1.65;
}

/* ── TIMELINE ───────────────────────────────────────── */

.timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 2px solid var(--ink);
}

.timeline-item {
  padding: 1.4rem 1.1rem 1.2rem;
  background: var(--bg);
  position: relative;
  transition: background 120ms;
}

.timeline-item:not(:first-child) {
  border-left: 2px solid var(--ink);
}

.timeline-item:nth-child(1) { border-top: 4px solid var(--red); }
.timeline-item:nth-child(2) { border-top: 4px solid var(--yellow); }
.timeline-item:nth-child(3) { border-top: 4px solid var(--blue); }
.timeline-item:nth-child(4) { border-top: 4px solid var(--red); }
.timeline-item:nth-child(5) { border-top: 4px solid var(--yellow); }

.timeline-item:hover {
  background: var(--paper);
}

.timeline-item h3 {
  font-size: 1.05rem;
}

.timeline-item p {
  margin-top: 0.7rem;
  font-size: 0.9rem;
}

/* ── WIDE NOTE ──────────────────────────────────────── */

.wide-note {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border: 2px solid var(--ink);
  border-left: 6px solid var(--yellow);
  background: var(--bg);
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.65;
}

.wide-note strong {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── PILLARS ────────────────────────────────────────── */

.pillars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}

.pillar {
  border: 2px solid var(--ink);
  padding: 1.5rem;
  background: var(--bg);
}

.pillar h3 {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;
}

.pillar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pillar ul li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}

.pillar ul li:last-child {
  border-bottom: none;
}

/* ── TRIAD ──────────────────────────────────────────── */

.triad {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
}

.triad-card {
  border: 2px solid var(--ink);
  padding: 1.4rem;
  background: var(--bg);
  transition: background 120ms;
}

.triad-card:hover {
  background: var(--paper);
}

.triad-card:nth-child(1) { border-top: 4px solid var(--red); }
.triad-card:nth-child(2) { border-top: 4px solid var(--blue); }
.triad-card:nth-child(3) { border-top: 4px solid var(--yellow); }

.mini-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

/* ── VOCABULARY ─────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

#term-search {
  flex: 1 1 280px;
  min-width: 240px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 0.8rem 1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 150ms;
}

#term-search::placeholder {
  color: var(--mid);
}

#term-search:focus {
  border-color: var(--blue);
  background: var(--bg);
}

.term-counter {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
}

.vocab-card {
  border: 2px solid var(--ink);
  padding: 1.1rem;
  background: var(--bg);
  transition: background 120ms, transform 140ms, box-shadow 140ms;
  cursor: default;
}

.vocab-card h3 {
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin-bottom: 0.45rem;
  line-height: 1.35;
  text-transform: none;
}

.vocab-card p {
  font-size: 0.9rem;
  line-height: 1.6;
}

.vocab-card:hover {
  background: var(--paper);
  transform: translateY(-3px);
  box-shadow: 0 3px 0 var(--ink);
}

/* Primary color cycling on vocab card borders */
.vocab-card:nth-child(6n+1) { border-left: 4px solid var(--red); }
.vocab-card:nth-child(6n+2) { border-left: 4px solid var(--blue); }
.vocab-card:nth-child(6n+3) { border-left: 4px solid var(--yellow); }
.vocab-card:nth-child(6n+4) { border-left: 4px solid var(--blue); }
.vocab-card:nth-child(6n+5) { border-left: 4px solid var(--red); }
.vocab-card:nth-child(6n+6) { border-left: 4px solid var(--yellow); }

.vocab-card.hidden {
  display: none;
}

/* ── CLOSING ────────────────────────────────────────── */

.closing-section {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.closing-card {
  border: 2px solid var(--ink);
  border-top: 6px solid var(--blue);
  background: var(--paper);
  padding: 2.5rem;
}

.closing-card .section-kicker {
  background: var(--blue);
  color: var(--paper);
}

.closing-card h2 {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.closing-card ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: items;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.closing-card ol li {
  counter-increment: items;
  display: flex;
  gap: 1.2rem;
  align-items: baseline;
  padding: 0.9rem 1rem;
  border: 2px solid var(--ink);
  background: var(--bg);
  font-family: var(--serif);
  font-size: 0.97rem;
  color: var(--ink);
  line-height: 1.5;
  transition: background 120ms;
}

.closing-card ol li:hover {
  background: var(--paper);
}

.closing-card ol li::before {
  content: counter(items, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--mid);
  flex-shrink: 0;
  padding-top: 0.16em;
  letter-spacing: 0.06em;
}

/* ── ACCESSIBILITY ──────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── ANIMATION ──────────────────────────────────────── */

@keyframes appear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section:nth-child(1) { animation-delay: 0.04s; }
.section:nth-child(2) { animation-delay: 0.08s; }
.section:nth-child(3) { animation-delay: 0.12s; }
.section:nth-child(n+4) { animation-delay: 0.16s; }

/* ── RESPONSIVE ─────────────────────────────────────── */

@media (max-width: 1080px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 1.5rem;
  }

  .hero-panel { order: -1; }
  .hero::before, .hero::after { display: none; }

  .concept-grid,
  .timeline,
  .triad,
  .vocab-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-card { grid-column: span 2; }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(calc(100% - 1rem), var(--max-width));
    padding-bottom: 3rem;
  }

  .hero,
  .section-heading,
  .split-panel,
  .pillars,
  .timeline,
  .triad,
  .concept-grid,
  .vocab-grid {
    grid-template-columns: 1fr;
  }

  .section { padding: 1.4rem; }

  .feature-card { grid-column: span 1; }

  h1 { font-size: clamp(1.8rem, 9vw, 3rem); }
}

/* ── SIDE INDEX ──────────────────────────────────── */

.index-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--blue);
  color: var(--paper);
  border: 0;
  cursor: pointer;
  padding: 0.7rem 0.38rem;
  z-index: 200;
  transition: background 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
}

.index-toggle:hover {
  background: var(--red);
}

.index-toggle-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  user-select: none;
}

.index-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 230px;
  background: var(--paper);
  border-left: 2px solid var(--ink);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 199;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.index-panel.is-open {
  transform: translateX(0);
}

.index-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 2px solid var(--ink);
  background: var(--bg);
  position: sticky;
  top: 0;
  flex-shrink: 0;
}

.index-title {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.index-close {
  border: 2px solid var(--ink);
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.18rem 0.4rem;
  line-height: 1;
  transition: background 100ms, color 100ms;
}

.index-close:hover {
  background: var(--ink);
  color: var(--paper);
}

.index-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.index-list a {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 0.86rem;
  line-height: 1.3;
  border-bottom: 1px solid var(--line);
  transition: background 100ms, color 100ms;
}

.index-list li:last-child a {
  border-bottom: none;
}

.index-list a:hover {
  background: var(--bg);
  color: var(--ink);
}

.idx-num {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--mid);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  width: 2.4rem;
}

.index-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 11, 8, 0.3);
  z-index: 198;
  cursor: pointer;
}

.index-overlay.is-visible {
  display: block;
}
