/* ============================================================
   ANIMA — WP-003 · visual system
   Option B: Urban Animism (Nordic Sage & Terracotta)
   Tactile outdoor monograph: pale celadon mist, deep spruce pine,
   terracotta brick / vermilion accents, and lichen patina spec panels.
   ============================================================ */

:root {
  /* Canvas & Ground: Pale Celadon Mist / Morning Park Sky */
  --bg-page: #edf4f0;
  --bg-page-subtle: #e3ece6;
  --panel: #ffffff;
  --panel-tint: #f6faf7;

  /* Typographic Inks: Deep Spruce Pine & Earthy River Silt */
  --ink: #132b24;
  --ink-soft: #1e3e34;
  --bone-dim: #3f594e;
  --muted: #5e786d;
  --line: #cfe0d6;
  --line-strong: #b3c7bc;

  /* Accent: Terracotta Brick & Shinto Vermilion */
  --amber: #c24a35;
  --amber-hover: #a53723;
  --amber-dim: #dc725f;
  --amber-tint: rgba(194, 74, 53, 0.09);
  --amber-pill: #f8ded9;

  /* Spec Aside Panels: Lichen Stone & Nordic Bronze Patina */
  --cold: #1a4d3e;
  --cold-bg: #e2ece6;
  --cold-line: #b3c9be;
  --cold-text: #0e271f;
  --cold-code: #0b1f19;

  /* Typography Stacks */
  --serif: "Fraunces", Georgia, serif;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 42rem;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg-page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Subtle analog paper grain texture */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 99;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

::selection {
  background: var(--amber-pill);
  color: var(--ink);
}

a { color: inherit; }

/* ---------- progress ---------- */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--amber);
  z-index: 100;
  box-shadow: 0 1px 4px rgba(184, 110, 38, 0.3);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.95rem 1.75rem;
  background: rgba(237, 244, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.topbar-crumbs {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  white-space: nowrap;
}

.topbar-crumbs a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  transition: color 0.15s ease;
}

.topbar-crumbs a:hover {
  color: var(--amber);
}

.topbar-crumbs .crumb-sep {
  color: var(--line-strong);
  font-weight: 400;
}

.topbar .back-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  transition: color 0.15s ease;
  white-space: nowrap;
}
.topbar .back-link:hover {
  color: var(--amber);
}

.topbar .brand {
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
}
.topbar .brand span { color: var(--muted); }
.topbar .series { color: var(--muted); }

@media (max-width: 640px) {
  .topbar .series { display: none; }
  .topbar .brand span { display: none; }
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 16rem 1fr;
  max-width: 76rem;
  margin: 0 auto;
  min-height: calc(100vh - 8rem);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- rail / contents ---------- */
.rail {
  border-right: 1px solid var(--line);
  padding: 2.75rem 1.25rem 2.75rem 1.75rem;
  position: sticky;
  top: 3.5rem;
  align-self: start;
  max-height: calc(100vh - 3.5rem);
  overflow: auto;
}

.rail-head {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 1.15rem;
  font-weight: 500;
}

.rail-link {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.45rem 0.6rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  color: var(--bone-dim);
  font-size: 0.92rem;
  line-height: 1.4;
  border-radius: 0 4px 4px 0;
  transition: all 0.15s ease;
}
.rail-link .n {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 1.4rem;
  font-weight: 500;
}
.rail-link:hover {
  color: var(--ink);
  background-color: var(--bg-page-subtle);
}
.rail-link.active {
  color: var(--ink);
  font-weight: 500;
  border-left-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-tint), transparent);
}
.rail-link.active .n { color: var(--amber); }

@media (max-width: 860px) {
  .rail {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
  }
  .rail-head { display: none; }
  .rail-link {
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
  }
  .rail-link.active { border-bottom-color: var(--amber); }
}

/* ---------- view ---------- */
.view {
  padding: 3.75rem 2.5rem 5rem;
  min-width: 0;
  position: relative;
}
@media (max-width: 640px) {
  .view { padding: 2.25rem 1.25rem 3.5rem; }
}

/* ---------- hero (index) ---------- */
.hero { max-width: var(--measure); }

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  color: var(--amber);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.75rem, 7.5vw, 4.75rem);
  line-height: 1.02;
  margin: 0 0 1.25rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.hero h1 em {
  font-style: italic;
  color: var(--bone-dim);
}

.lede {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--bone-dim);
  line-height: 1.6;
  max-width: 35rem;
}

.hero .meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 1.75rem 0 2.25rem;
}

.cta {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  font-weight: 500;
  text-decoration: none;
  color: #ffffff;
  background: var(--amber);
  padding: 0.85rem 1.75rem;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(184, 110, 38, 0.25);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.cta:hover {
  background: var(--amber-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(184, 110, 38, 0.35);
}

/* ---------- chapter cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 4.25rem;
  max-width: 64rem;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(28, 36, 33, 0.04);
}

.card {
  background: var(--panel);
  padding: 1.75rem 1.5rem 2rem;
  text-decoration: none;
  display: block;
  transition: background 0.15s ease, transform 0.15s ease;
}
.card:hover {
  background: var(--panel-tint);
}
.card .n {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--amber);
  font-weight: 500;
}
.card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.35rem;
  margin: 0.75rem 0 0.45rem;
  line-height: 1.25;
  color: var(--ink);
}
.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- chapter article ---------- */
.chapter { max-width: var(--measure); }

.chapter-head { margin-bottom: 3rem; }
.chapter-head .num {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.26em;
  color: var(--amber);
  font-weight: 500;
}
.chapter-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 5vw, 3.25rem);
  line-height: 1.08;
  margin: 0.65rem 0 0.95rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.chapter-head .readtime {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.chapter-body > p:first-of-type::first-letter {
  font-family: var(--serif);
  font-size: 3.5em;
  float: left;
  line-height: 0.86;
  padding-right: 0.14em;
  color: var(--amber);
}

.chapter-body p {
  margin: 0 0 1.6rem;
  color: var(--ink-soft);
}

.chapter-body strong {
  color: var(--ink);
  font-weight: 600;
}
.chapter-body em {
  color: var(--bone-dim);
}

.chapter-body h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  margin: 2.85rem 0 1rem;
  color: var(--ink);
}

.chapter-body ul, .chapter-body ol {
  margin: 0 0 1.6rem;
  padding-left: 1.5rem;
  color: var(--ink-soft);
}
.chapter-body li { margin-bottom: 0.55rem; }
.chapter-body li::marker { color: var(--amber); }

.chapter-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-page-subtle);
  border: 1px solid var(--line);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--cold-code);
}

.chapter-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3.25rem 0;
}

/* ---------- pullquote ---------- */
.pullquote {
  margin: 3rem 0;
  padding: 0 0 0 1.6rem;
  border-left: 3px solid var(--amber);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.55;
  color: var(--ink);
}
.pullquote p { margin: 0; }

/* ---------- spec aside : weathered bronze & sage patina ---------- */
.spec-aside {
  margin: 3rem 0;
  padding: 1.85rem 2rem;
  background: var(--cold-bg);
  border: 1px solid var(--cold-line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--cold-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.spec-aside .spec-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.68rem;
  letter-spacing: 0.26em;
  color: var(--cold);
  margin-bottom: 1rem;
  font-weight: 500;
}
.spec-aside .spec-dot {
  width: 0.5rem; height: 0.5rem;
  background: var(--cold);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(26, 77, 62, 0.45);
  flex: none;
}
.spec-aside .spec-body p {
  margin: 0 0 1rem;
  color: var(--cold-text);
}
.spec-aside .spec-body p:last-child { margin-bottom: 0; }
.spec-aside .spec-body strong { color: #081d16; }
.spec-aside .spec-body code {
  color: #081d16;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--cold-line);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* ---------- spec table & appendix technical standards ---------- */
.table-wrap {
  margin: 2.75rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(19, 43, 36, 0.05);
}

.table-wrap table,
.chapter-body table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
  background: var(--panel);
  margin: 0;
}

.table-wrap th,
.chapter-body table th {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cold);
  background: var(--cold-bg);
  border-bottom: 2px solid var(--cold-line);
  padding: 0.85rem 1.25rem;
  white-space: nowrap;
}

.table-wrap td,
.chapter-body table td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-soft);
}

.table-wrap tbody tr:last-child td,
.chapter-body table tbody tr:last-child td {
  border-bottom: none;
}

.table-wrap tbody tr:nth-child(even),
.chapter-body table tbody tr:nth-child(even) {
  background: var(--panel-tint);
}

.table-wrap tbody tr:hover,
.chapter-body table tbody tr:hover {
  background: #edf5f0;
}

.table-wrap td strong,
.chapter-body table td strong {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}

.table-wrap td code,
.chapter-body table td code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg-page-subtle);
  border: 1px solid var(--line);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  color: var(--cold-code);
}

.table-target-metric {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--amber);
  background: var(--amber-tint);
  border: 1px solid rgba(194, 74, 53, 0.24);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.2rem;
  white-space: nowrap;
}

.table-detail {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 0.25rem;
}

.table-stack {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--cold-text);
  line-height: 1.5;
}

/* ---------- exhibits (Nordic sage & terracotta tones) ---------- */
.exhibit {
  margin: 3.25rem 0;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(19, 43, 36, 0.06);
}
.exhibit-art {
  aspect-ratio: 16 / 8;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.exhibit-art::after {
  content: "FIG. — PLACEHOLDER · drop final art in public/exhibits/";
  position: absolute;
  inset: auto 0 0.75rem 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: rgba(19, 43, 36, 0.55);
}

/* Exhibit 00: Park Bench - weathered cedar slats & morning mist / spruce green */
.exhibit[data-variant="bench"] .exhibit-art {
  background:
    repeating-linear-gradient(0deg, rgba(194, 74, 53, 0.18) 0 14px, transparent 14px 30px),
    radial-gradient(120% 90% at 50% 110%, #d8caa7 0%, #cad9ce 55%, #b2c7b8 100%);
}

/* Exhibit 01: Strata - Spruce pine, lichen sage, warm terracotta silt, sand */
.exhibit[data-variant="strata"] .exhibit-art {
  background: linear-gradient(180deg,
    #1e3e34 0 22%, #4d7062 22% 45%, #b86b58 45% 68%, #d8caa7 68% 100%);
}

/* Exhibit 02: Matsuda Split - Terracotta tint vs Nordic mist sage */
.exhibit[data-variant="split"] .exhibit-art {
  background:
    linear-gradient(90deg, transparent 49.6%, var(--line-strong) 49.6% 50.4%, transparent 50.4%),
    linear-gradient(90deg,
      #fceae5 0 50%, #e2eee6 50% 100%);
}
.exhibit[data-variant="split"] .exhibit-art::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 22% 35%, rgba(194, 74, 53, 0.5) 0 3.5%, transparent 4.5%),
    radial-gradient(circle at 30% 60%, rgba(42, 140, 110, 0.4) 0 3%, transparent 4%),
    radial-gradient(circle at 18% 70%, rgba(200, 130, 60, 0.45) 0 2.5%, transparent 3.5%);
}

/* Exhibit 03: Tiers - Celadon mist background with pine, terracotta, and lichen accents */
.exhibit[data-variant="tiers"] .exhibit-art {
  background:
    linear-gradient(180deg,
      transparent 0 18%, rgba(26, 77, 62, 0.14) 18% 38%,
      transparent 38% 42%, rgba(194, 74, 53, 0.16) 42% 66%,
      transparent 66% 70%, rgba(94, 120, 109, 0.14) 70% 92%, transparent 92%),
    #eef5f1;
}

/* Exhibit 04: Spectrum - Celadon, pine, terracotta, soft gold daylight */
.exhibit[data-variant="spectrum"] {
  margin: 4.5rem 0 5rem;
}
.exhibit[data-variant="spectrum"] .exhibit-art {
  background:
    linear-gradient(115deg, transparent 46%, rgba(255, 255, 255, 0.8) 46.5% 47.5%, transparent 48%),
    linear-gradient(90deg, #1d3e34 0%, #4a806c 28%, #dca156 55%, #c24a35 80%, #7d5469 100%);
  opacity: 0.92;
}
.exhibit[data-variant="spectrum"] img {
  aspect-ratio: auto;
  object-fit: contain;
  padding: 2.25rem 0;
  box-sizing: border-box;
}

/* Exhibit 05: Flow - Lichen nodes with terracotta routing links */
.exhibit[data-variant="flow"] .exhibit-art {
  background:
    radial-gradient(circle at 20% 60%, rgba(26, 77, 62, 0.4) 0 5.5%, transparent 6.5%),
    radial-gradient(circle at 50% 40%, rgba(194, 74, 53, 0.4) 0 5.5%, transparent 6.5%),
    radial-gradient(circle at 80% 65%, rgba(63, 89, 78, 0.35) 0 5.5%, transparent 6.5%),
    linear-gradient(90deg, transparent 19%, rgba(26, 77, 62, 0.28) 19% 21%, transparent 21% 49%, rgba(194, 74, 53, 0.28) 49% 51%, transparent 51% 79%, rgba(63, 89, 78, 0.22) 79% 81%, transparent 81%),
    #e5ede7;
}

/* Exhibit 06: Zones - exclusion zone mapping in subtle terracotta diagonal stripe over lichen stone */
.exhibit[data-variant="zones"] .exhibit-art {
  background:
    repeating-linear-gradient(45deg, rgba(194, 74, 53, 0.16) 0 18px, transparent 18px 36px),
    radial-gradient(60% 60% at 50% 50%, #e2ece5 0%, #cee0d4 100%);
}


.exhibit figcaption {
  padding: 1.25rem 1.75rem 1.4rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--bone-dim);
  background: var(--panel-tint);
}
.exhibit .exhibit-tag {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  color: var(--amber);
  margin-bottom: 0.5rem;
  font-weight: 500;
}
.exhibit img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  background: var(--bg-page);
  border-bottom: 1px solid var(--line);
}
.exhibit img[src$=".svg"] {
  aspect-ratio: auto;
  object-fit: contain;
}

/* ---------- prev / next ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 4.25rem;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(28, 36, 33, 0.03);
}
.pager a {
  background: var(--panel);
  padding: 1.35rem 1.5rem;
  text-decoration: none;
  transition: background 0.15s ease;
}
.pager a:hover {
  background: var(--panel-tint);
}
.pager .dir {
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.pager .t {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
}
.pager .next { text-align: right; }
.pager .only { grid-column: 1 / -1; }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1.75rem 3rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 76rem;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ---------- print ---------- */
@media print {
  .topbar, .rail, .pager, .progress, .cta { display: none; }
  body { background: #fff; color: #111; font-size: 11pt; }
  body::before { display: none; }
  .layout { display: block; }
  .view { padding: 0; }
  .chapter { max-width: none; }
  .spec-aside {
    background: #f4f4f4;
    border: 1px solid #999;
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    color: #222;
  }
  .spec-aside .spec-label { color: #333; }
  .exhibit { margin: 1.5rem 0; break-inside: avoid; }
  .exhibit-art { display: none; }
  .pullquote { color: #111; border-left-color: #111; }
}
