/* Arborescent — design tokens */
:root {
  --paper: #FBF8F1;
  --ink: #1F1B17;
  --faded: #6A5F52;
  --hairline: #E0D8C8;
  --plate-line: #D5CBB8;
  --red: #A33B31;
  --topo: #8C5B2F;
  --teal: #2A7C74;
  --ochre: #B0762A;
  --blue: #33538F;
}

/* topotrails' fourth-wall break: scrubbing past dusk turns the site to night */
:root.night {
  --paper: #171412;
  --ink: #EDE6D8;
  --faded: #9A8F7E;
  --hairline: #2E2822;
  --plate-line: #3A332B;
  --red: #C4574B;
}

body, .masthead, .plate {
  transition: background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease;
}

:root.night .plate {
  border-color: #3A332B;
}

/* zellij's fourth-wall break: a tileable assembly papers the page */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: repeat;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.wallpaper.on { opacity: 0.09; }
:root.night .wallpaper.on { opacity: 0.14; }

.masthead, .content {
  position: relative;
  z-index: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'EB Garamond', Garamond, Georgia, serif;
}

a { color: var(--red); }
a:hover { color: #7E2D25; }

/* ---------- animation keyframes ---------- */

@keyframes dcdraw { to { stroke-dashoffset: 0; } }
.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: dcdraw 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes dcbloom { from { opacity: 0; transform: scale(0.94); } }
.bloom {
  animation: dcbloom 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: 50% 50%;
  transform-box: fill-box;
}

/* the mark flips on every click, anywhere on the page */
.mark-a, .mark-b { transition: opacity 0.8s linear; }
.mark-a { opacity: 1; }
.mark-b { opacity: 0; }
.markwrap.flipped .mark-a { opacity: 0; }
.markwrap.flipped .mark-b { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .draw { animation: none; stroke-dashoffset: 0; }
  .bloom { animation: none; }
  .mark-a, .mark-b { transition: none; }
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 56px;
  border-bottom: 1px solid var(--hairline);
  max-width: 1200px;
  margin: 0 auto;
}

.mark-and-name {
  display: flex;
  align-items: center;
  gap: 14px;
}

.markwrap {
  position: relative;
  width: 28px;
  height: 28px;
}

.markwrap svg {
  position: absolute;
  left: 0;
  top: 0;
}

.wordmark {
  font-size: 23px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.mastnav {
  display: flex;
  gap: 16px;
}

/* quiet icon row: no chrome, the active choice marked by a short red
   underline — same grammar as the index rows and old text toggle */
.theme-opt {
  width: 20px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faded);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.theme-opt:hover { color: var(--ink); }
.theme-opt:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.theme-opt.active { color: var(--ink); }

.theme-opt.active::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  border-bottom: 2px solid var(--red);
}

/* ---------- main layout ---------- */

.content {
  display: flex;
  gap: 64px;
  padding: 48px 56px;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
}

.index-column {
  width: 480px;
  display: flex;
  flex-direction: column;
  gap: 36px;
  flex-shrink: 0;
}

.intro {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kicker {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--red);
}

.definition {
  font-size: 38px;
  line-height: 1.2;
  font-weight: 400;
}

.usage {
  font-size: 18px;
  line-height: 1.5;
  font-style: italic;
  color: var(--faded);
}

.project-index {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  /* text column starts where the wordmark's text starts (mark 28px + gap
     14px past the shared left edge); the active diamond hangs back in the
     logo's own column */
  padding: 10px 0 0 42px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

/* the leader aligns with the text column (not the bullet margin) so the
   dots underline the words, not the whole shelf */
.project-row::after {
  content: '';
  display: block;
  border-bottom: 1px dotted var(--plate-line);
  margin-top: 10px;
}

.project-row:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.project-row-top {
  display: flex;
  align-items: center;
  position: relative;
}

/* the active diamond hangs in the margin so product text aligns flush
   with the wordmark/logo column edge */
.project-marker {
  position: absolute;
  left: -33px; /* centered under the 28px logo mark (14px center - 5px half-width - 42px text offset) */
  /* optically centered on the x-height of the mostly-lowercase names,
     not the full line box — sits a touch below geometric center */
  top: calc(50% + 3.5px);
  transform: translateY(-50%);
}

.project-marker {
  opacity: 0;
  flex-shrink: 0;
}

.project-row.active .project-marker {
  opacity: 1;
}

.project-name {
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 5px;
  transition: text-decoration-color 120ms;
}

.project-row.active .project-name {
  color: var(--red);
}

.project-row:hover .project-name {
  text-decoration-color: var(--plate-line);
}

.project-gloss {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--faded);
}

/* ---------- plate column ---------- */

.plate-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  flex-grow: 1;
  min-width: 0;
}

.plate {
  width: 500px;
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--plate-line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* stages and toy-host are absolutely positioned so no toy content can
   ever inflate the plate — the plate's size comes from width+aspect-ratio
   alone ("the plate never moves") */
.stage {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage.active {
  display: block;
}

.stage-caption {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--faded);
}

.toy-host {
  position: absolute;
  inset: 0;
  padding: 18px;
  box-sizing: border-box;
}

.toy-host[hidden] { display: none; }

/* host-owned want-more link: identical location on every toy, sitting in
   the plate's padding band below the toy's content area */
.plate-link {
  position: absolute;
  right: 6px;
  bottom: 2px;
  z-index: 3;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--faded);
  text-decoration: none;
  transition: color 0.1s ease;
  /* paper knock-out so the label stays legible when a toy paints the
     plate edge-to-edge (topotrails' map); invisible — paper on paper —
     everywhere else. right/bottom shrunk by the padding so the text
     itself keeps its old 12px/3px position on every plate */
  background: var(--paper);
  padding: 1px 6px;
}

.plate-link:hover { color: var(--red); }

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .content {
    flex-direction: column;
    align-items: center;
  }

  .index-column {
    width: 100%;
    max-width: 500px;
  }

  /* accordion: the plate column lives inside the index, under the active
     row (main.js moves the node); it reads as that row's expanded panel */
  .plate-column {
    width: 100%;
    margin: 6px 0 16px;
  }

  .plate {
    width: 100%;
    max-width: 500px;
  }
}

/* phones: desktop's 56px gutters would leave the plate under 300px wide;
   masthead and content shift together so the wordmark/index alignment
   (left pad + 42px text column) is preserved */
@media (max-width: 640px) {
  .masthead { padding: 20px 24px; }
  .content { padding: 28px 24px; }
}
