/* The Verishell Library. Layout: a daylight reading room in 3D, with a reading desk (packet panel)
   beside it, then a card catalogue of the same books in plain HTML. One accent: green leather.
   Brass marks focus and plaques; ribbons carry verdict colours. */
:root {
  --paper: #e3ded2;      /* limestone */
  --card: #f4f0e6;       /* index card stock */
  --ink: #1f1c17;
  --ink-2: #5b5447;
  --rule: #c7bfad;
  --leather: #24453a;    /* the one accent */
  --leather-on: #f4f0e6;
  --brass: #9c742a;
  --catalog-red: #b0463a;
  --pass: #2c774a;
  --warn: #9e5f12;
  --block: #a9352b;
  --none: #7d776a;
  --shadow: rgba(40, 30, 15, 0.18);
  --font-display: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151a17; --card: #1e2420; --ink: #e8e3d7; --ink-2: #a9a394; --rule: #36423b;
    --leather: #86bfa8; --leather-on: #10201a; --brass: #d4ab57; --catalog-red: #e07b6d;
    --pass: #5dc28c; --warn: #e5a84b; --block: #ef7c6e; --none: #9b9485; --shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151a17; --card: #1e2420; --ink: #e8e3d7; --ink-2: #a9a394; --rule: #36423b;
  --leather: #86bfa8; --leather-on: #10201a; --brass: #d4ab57; --catalog-red: #e07b6d;
  --pass: #5dc28c; --warn: #e5a84b; --block: #ef7c6e; --none: #9b9485; --shadow: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--leather); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; margin: 0; text-wrap: balance; }
p { margin: 0; }
code, .mono { font-family: var(--font-data); font-size: 0.82em; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 12px; background: var(--card); padding: 8px 12px; z-index: 50; }

.wrap {
  max-width: 1320px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-block: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-size: 1.35rem; }
.brand svg { color: var(--leather); flex: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 0.95rem; }
.top nav a { color: var(--ink); text-decoration: none; }
.top nav a:hover { color: var(--leather); text-decoration: underline; }

/* Intro */
.intro { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 16px 48px; align-items: end; padding-block: 18px 22px; }
.intro h1 { font-size: clamp(2.3rem, 5.4vw, 4.4rem); letter-spacing: -0.01em; }
.intro .lede { font-size: 1.15rem; color: var(--ink-2); max-width: 34em; }
.status { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; color: var(--ink-2); margin-top: 12px; }
.status .seal-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px dashed var(--brass); margin-top: 0.25em; }

/* Stage: canvas + reading desk */
.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0;
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--card);
  box-shadow: 0 24px 50px -36px var(--shadow);
}
.canvas-wrap { position: relative; min-height: 560px; height: min(74vh, 720px); background: #cfc8b8; overflow: hidden; touch-action: pan-y; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.canvas-wrap .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #3b352b; }
.no-webgl .canvas-wrap { height: auto; min-height: 0; }
.no-webgl .canvas-wrap .fallback { position: static; display: block; }
.loading-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #3b352b; font-size: 0.95rem; }

.overlay-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.overlay-top > * { pointer-events: auto; }
.modes { display: inline-flex; background: rgba(244, 240, 230, 0.9); border: 1px solid #b9b09c; border-radius: 999px; padding: 3px; backdrop-filter: blur(4px); }
.modes button {
  font: inherit; font-size: 0.9rem; border: 0; background: transparent; color: #2b271f; padding: 7px 14px; border-radius: 999px; cursor: pointer; min-height: 36px;
}
.modes button[aria-pressed="true"] { background: #24453a; color: #f4f0e6; }
.legend { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; background: rgba(244, 240, 230, 0.9); border: 1px solid #b9b09c; border-radius: 8px; padding: 6px 10px; font-size: 0.8rem; color: #2b271f; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 16px; border-radius: 1px 1px 3px 3px; display: inline-block; }
.legend .seal { width: 13px; height: 13px; border-radius: 50%; border: 1.5px dashed #8a6a24; }

.touch-hint { width: 100%; margin: 0; font-size: 0.8rem; color: #2b271f; background: rgba(244, 240, 230, 0.9); border: 1px solid #b9b09c; border-radius: 8px; padding: 5px 9px; }
.tooltip {
  position: absolute; pointer-events: none; background: #1f1c17; color: #f4f0e6; font-size: 0.82rem; padding: 6px 9px; border-radius: 6px;
  transform: translate(12px, 12px); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.tooltip[hidden] { display: none; }

.steps-bar {
  position: absolute; left: 12px; right: 12px; bottom: 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center;
  background: rgba(244, 240, 230, 0.94); border: 1px solid #b9b09c; border-radius: 10px; padding: 10px 12px; color: #1f1c17;
}
.steps-bar[hidden] { display: none; }
.step-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.step-buttons button {
  font: inherit; font-family: var(--font-display); font-size: 1.05rem; width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 1px solid #8f8670; background: #fbf8f1; color: #1f1c17;
}
.step-buttons button[aria-current="step"] { background: #24453a; color: #f4f0e6; border-color: #24453a; }
.step-caption b { font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; display: block; line-height: 1.2; }
.step-caption p { font-size: 0.9rem; color: #4a4439; }

/* Reading desk (packet panel) */
.desk { border-left: 1px solid var(--rule); padding: 20px 20px 24px; overflow-y: auto; max-height: min(74vh, 720px); min-height: 560px; display: grid; align-content: start; gap: 14px; }
.desk h2 { font-size: 1.7rem; }
.desk .kicker { font-size: 0.85rem; color: var(--ink-2); }
.desk .close { justify-self: start; font: inherit; font-size: 0.85rem; background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.desk dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 0.92rem; }
.desk dt { color: var(--ink-2); }
.desk dd { margin: 0; overflow-wrap: anywhere; }
.verdict { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.verdict i { width: 9px; height: 20px; border-radius: 1px 1px 4px 4px; display: inline-block; }
.v-pass { color: var(--pass); } .v-pass i { background: var(--pass); }
.v-warn { color: var(--warn); } .v-warn i { background: var(--warn); }
.v-block { color: var(--block); } .v-block i { background: var(--block); }
.v-none { color: var(--none); } .v-none i { background: var(--none); }
.seal-line { display: flex; gap: 10px; align-items: center; font-size: 0.92rem; color: var(--ink-2); }
.seal-line .seal { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--brass); flex: none; }
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.findings li { border-left: 3px solid var(--rule); padding: 2px 0 2px 10px; font-size: 0.86rem; }
.findings li.sev-high, .findings li.sev-critical { border-left-color: var(--warn); }
.findings .where { color: var(--ink-2); font-size: 0.8rem; }
.findings q { display: block; font-family: var(--font-data); font-size: 0.78rem; quotes: none; color: var(--ink); overflow-wrap: anywhere; }
.note { font-size: 0.86rem; background: color-mix(in srgb, var(--warn) 12%, transparent); border-radius: 6px; padding: 8px 10px; }
.desk .links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; }
.desk-legend { display: grid; gap: 8px; font-size: 0.9rem; color: var(--ink-2); }
.desk-legend div { display: flex; gap: 10px; align-items: center; }

/* Sections */
section.block { padding-block: 64px 8px; display: grid; gap: 22px; }
section.block > header { display: grid; gap: 10px; max-width: 44rem; }
section.block h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); }
section.block header p { color: var(--ink-2); }

/* Card catalogue */
.catalogue { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 18px; }
.icard {
  position: relative; background: var(--card); border: 1px solid var(--rule); border-radius: 3px; padding: 14px 16px 34px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 25px, color-mix(in srgb, var(--rule) 55%, transparent) 25px 26px);
  background-position: 0 46px; min-width: 0; display: grid; gap: 4px; align-content: start;
}
.icard::before { content: ""; position: absolute; left: 0; right: 0; top: 42px; height: 2px; background: var(--catalog-red); opacity: 0.8; }
.icard::after { content: ""; position: absolute; left: 50%; bottom: 10px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--paper); border: 1px solid var(--rule); }
.icard .call { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--font-data); font-size: 0.75rem; color: var(--ink-2); height: 28px; }
.icard h3 { font-size: 1.4rem; margin-top: 6px; overflow-wrap: anywhere; }
.icard .src { font-size: 0.82rem; color: var(--ink-2); overflow-wrap: anywhere; }
.icard p { font-size: 0.92rem; line-height: 26px; }
.icard .facts { font-size: 0.85rem; line-height: 26px; }
.icard button {
  justify-self: start; margin-top: 6px; font: inherit; font-size: 0.86rem; border: 1px solid var(--leather); color: var(--leather); background: transparent;
  border-radius: 999px; padding: 4px 12px; cursor: pointer; min-height: 32px;
}
.icard button:hover { background: var(--leather); color: var(--leather-on); }
.no-js .icard button { display: none; }

/* How a book gets here */
.how { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); counter-reset: s; border-top: 2px solid var(--ink); }
.how li { counter-increment: s; padding: 16px 16px 8px 0; display: grid; gap: 6px; align-content: start; min-width: 0; }
.how li + li { padding-left: 16px; border-left: 1px solid var(--rule); }
.how li::before { content: counter(s); font-family: var(--font-display); font-size: 2.6rem; line-height: 1; color: var(--leather); }
.how b { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; line-height: 1.2; }
.how p { font-size: 0.93rem; color: var(--ink-2); }

/* Reference shelf */
.refs { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.refs-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); }
.refs th, .refs td { text-align: left; padding: 9px 12px; border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); vertical-align: top; }
.refs th { color: var(--ink-2); font-weight: 600; font-size: 0.85rem; }
.refs tr:last-child td { border-bottom: 0; }
.refs { min-width: 620px; }

footer { margin-top: 72px; border-top: 1px solid var(--rule); padding-block: 22px 40px; display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: space-between; font-size: 0.88rem; color: var(--ink-2); }

/* Responsive */
@media (max-width: 1040px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .desk { border-left: 0; border-top: 1px solid var(--rule); max-height: none; min-height: 0; }
  .how { grid-template-columns: minmax(0, 1fr); border-top: 0; }
  .how li, .how li + li { padding: 14px 0; border-left: 0; border-top: 1px solid var(--rule); grid-template-columns: 52px minmax(0, 1fr); column-gap: 10px; }
  .how li::before { grid-row: span 2; }
}
@media (max-width: 760px) {
  .intro { grid-template-columns: minmax(0, 1fr); }
  .canvas-wrap { min-height: 420px; height: 62vh; }
  .legend { display: none; }
  .steps-bar { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
