:root {
  /* DESIGN typography audit tokens: Fossil* Shard* Mono* Fossil** Shard** Mono** numbers */
  --ledger: #F7E9C8;
  --graphite: #263238;
  --indigo: #3B4CCA;
  --marigold: #F2B705;
  --jade: #14A66A;
  --lilac: #B99CFF;
  --red: #E45745;
  --vellum: #D7C39A;
  --display: "Nunito", Inter, system-ui, sans-serif;
  --book: "Literata", Georgia, serif;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
  --mono: "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--graphite);
  background: var(--ledger);
  font-family: var(--book);
  overflow-x: hidden;
}

.desk-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background:
    linear-gradient(rgba(38,50,56,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38,50,56,.05) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(242,183,5,.24), transparent 24%),
    radial-gradient(circle at 76% 18%, rgba(185,156,255,.2), transparent 24%),
    radial-gradient(circle at 82% 82%, rgba(20,166,106,.16), transparent 25%),
    #F7E9C8;
  background-size: 42px 42px, 42px 42px, auto, auto, auto, auto;
}

.desk-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .34;
  background-image: repeating-linear-gradient(105deg, transparent 0 17px, rgba(215,195,154,.28) 18px 19px);
}

.catalogue { position: relative; }

.drawer {
  min-height: 100vh;
  position: relative;
  padding: 6.5rem clamp(1.3rem, 4vw, 4.5rem) 4rem;
  display: grid;
  align-items: center;
  isolation: isolate;
}

.drawer::before {
  content: attr(data-drawer);
  position: absolute;
  right: 4vw;
  top: 2rem;
  font: 900 clamp(4rem, 12vw, 11rem)/1 var(--display);
  color: rgba(59,76,202,.07);
  z-index: -1;
}

.drawer-rail {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: grid;
  gap: .55rem;
}

.rail-tab {
  border: 2px solid var(--graphite);
  border-radius: 999px;
  background: rgba(247,233,200,.88);
  box-shadow: 3px 3px 0 var(--vellum);
  color: var(--graphite);
  cursor: pointer;
  font: 900 .75rem/1 var(--display);
  padding: .45rem .65rem;
  transform: rotate(-1deg);
  transition: transform .25s ease, background .25s ease, color .25s ease;
}

.rail-tab span { font-family: var(--mono); margin-right: .35rem; }
.rail-tab:nth-child(even) { transform: rotate(1.2deg); }
.rail-tab.active, .rail-tab:hover { background: var(--indigo); color: var(--ledger); transform: translateX(.3rem) rotate(0deg); }

.desk-perspective {
  width: min(1120px, 92vw);
  min-height: 72vh;
  margin-inline: auto;
  position: relative;
  transform: perspective(1100px) rotateX(5deg) rotateZ(-1deg);
}

.specimen-card {
  --r: 0deg;
  --x: 0px;
  --y: 0px;
  position: relative;
  border: 2px solid var(--graphite);
  border-radius: 22px 18px 26px 16px;
  padding: 1.25rem;
  background: rgba(247,233,200,.94);
  box-shadow: 8px 9px 0 rgba(38,50,56,.12), 0 0 0 1px rgba(215,195,154,.75) inset;
  transform: translate(var(--x), var(--y)) rotate(var(--r));
  transition: transform .22s ease, box-shadow .22s ease, filter .22s ease;
  cursor: pointer;
}

.specimen-card::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  right: 18px;
  top: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--red) 0 27%, transparent 30%), rgba(242,183,5,.55);
  box-shadow: 0 2px 0 rgba(38,50,56,.22);
}

.specimen-card:hover, .specimen-card.examined {
  transform: translate(var(--x), calc(var(--y) - 8px)) rotate(calc(var(--r) + var(--tilt, 0deg))) scale(1.018);
  box-shadow: 13px 15px 0 rgba(38,50,56,.16), 0 0 0 1px rgba(215,195,154,.75) inset;
}

.title-board {
  width: min(630px, 76vw);
  position: absolute;
  left: 8%;
  top: 8%;
  padding: 2rem 2.1rem 2.6rem;
  background: linear-gradient(135deg, rgba(247,233,200,.98), rgba(215,195,154,.38));
}

h1, h2, h3 { font-family: var(--display); margin: 0; color: var(--graphite); }
h1 { font-size: clamp(4.2rem, 12vw, 9.5rem); line-height: .82; letter-spacing: .015em; color: var(--indigo); text-shadow: 4px 4px 0 rgba(242,183,5,.55); }
h2 { font-size: clamp(2.3rem, 5vw, 5rem); line-height: .9; }
h3 { font-size: clamp(1.35rem, 2vw, 2rem); }
p { font-size: clamp(1rem, 1.3vw, 1.18rem); line-height: 1.5; }

.lead { max-width: 43rem; font-size: clamp(1.15rem, 2vw, 1.55rem); }
.stamp-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.library-stamp, .accession, .lot-number, .bid-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.library-stamp {
  color: var(--red);
  border: 3px solid var(--red);
  padding: .28rem .55rem;
  border-radius: 8px;
  transform: rotate(-4deg);
  background: rgba(228,87,69,.08);
}
.library-stamp.open { color: var(--jade); border-color: var(--jade); }
.library-stamp.sealed { color: var(--indigo); border-color: var(--indigo); }
.accession, .lot-number { color: var(--indigo); }
.bid-tag { color: var(--red); background: rgba(228,87,69,.12); padding: .3rem .5rem; border-radius: 999px; }

.pencil-note, .hand-label {
  font-family: var(--hand);
  color: var(--red);
  font-size: 1.25rem;
}
.note-one { position: absolute; right: 1.2rem; bottom: .45rem; transform: rotate(-5deg); }

.auction-paddle {
  position: absolute;
  right: 16%;
  top: 18%;
  width: 138px;
  height: 138px;
  display: grid;
  place-items: center;
  color: var(--graphite);
  font: 900 2.2rem/1 var(--display);
  background: var(--marigold);
  clip-path: polygon(50% 0, 91% 18%, 100% 62%, 66% 100%, 22% 91%, 0 45%);
  box-shadow: 8px 10px 0 rgba(38,50,56,.16);
  transform: rotate(12deg);
  transition: transform .35s cubic-bezier(.2,1.5,.4,1);
}
.auction-paddle::after { content: ""; position: absolute; width: 22px; height: 96px; background: var(--graphite); bottom: -70px; border-radius: 12px; transform: rotate(-18deg); }
.auction-paddle.knock { transform: rotate(-8deg) translateY(12px); }

.small-card { width: 260px; position: absolute; left: 60%; bottom: 9%; }
.note-tab { width: 305px; position: absolute; left: 25%; bottom: 3%; }
.torn-card { clip-path: polygon(0 2%, 8% 0, 18% 2%, 29% 0, 39% 2%, 51% 0, 62% 2%, 74% 0, 87% 2%, 100% 0, 99% 100%, 0 98%); }
.vellum-card { background: rgba(215,195,154,.52); backdrop-filter: blur(2px); }

.drawer-heading { max-width: 760px; margin: 0 auto 2rem 9vw; transform: rotate(-1deg); }
.drawer-heading p { max-width: 42rem; }
.offset-heading { margin-left: 18vw; }
.debate-heading { margin-left: 12vw; }

.archive-grid {
  width: min(1080px, 88vw);
  margin: 0 auto;
  display: grid;
  gap: 1.3rem;
  position: relative;
}
.dense-grid { grid-template-columns: 1.1fr .9fr 1fr; grid-template-rows: auto auto; align-items: start; }
.tall-slip { grid-row: span 2; min-height: 520px; }
.square-plate { min-height: 250px; background: rgba(185,156,255,.23); }
.dense-grid .vellum-card { grid-column: 2 / 4; }

.photo-card .duotone, .duotone {
  height: 170px;
  border: 2px solid var(--graphite);
  border-radius: 16px;
  margin: .8rem 0;
  background-blend-mode: multiply;
  filter: saturate(.65) contrast(1.15);
  transition: filter .3s ease, background-position .5s ease;
}
.interactive-lot:hover .duotone { filter: saturate(1.35) contrast(1.08); background-position: 100% 60%; }
.keyboard-plate { background: linear-gradient(135deg, rgba(59,76,202,.88), rgba(247,233,200,.5)), repeating-linear-gradient(0deg, transparent 0 16px, rgba(38,50,56,.8) 17px 22px), repeating-linear-gradient(90deg, transparent 0 24px, rgba(38,50,56,.55) 25px 31px); }
.receipt-plate { background: linear-gradient(135deg, rgba(20,166,106,.86), rgba(38,50,56,.22)), repeating-linear-gradient(90deg, rgba(247,233,200,.55) 0 10px, transparent 11px 22px), radial-gradient(circle at 70% 30%, rgba(185,156,255,.7), transparent 16%); }
.lens-plate { height: 220px; background: radial-gradient(circle at 48% 45%, rgba(247,233,200,.75) 0 18%, rgba(59,76,202,.7) 19% 31%, transparent 32%), linear-gradient(135deg, rgba(242,183,5,.86), rgba(38,50,56,.8)), repeating-linear-gradient(45deg, transparent 0 12px, rgba(247,233,200,.3) 13px 16px); }

.facet-window, .crystal-diagram {
  height: 145px;
  margin: 1rem 0;
  border: 2px solid var(--graphite);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  background: conic-gradient(from 40deg, rgba(185,156,255,.8), rgba(59,76,202,.8), rgba(247,233,200,.75), rgba(20,166,106,.6), rgba(185,156,255,.8));
}
.facet-window i { position: absolute; inset: 12%; border-left: 2px solid rgba(38,50,56,.45); transform: rotate(var(--a, 20deg)); }
.facet-window i:nth-child(2) { --a: -35deg; inset: 22%; }
.facet-window i:nth-child(3) { --a: 68deg; inset: 5% 42%; }

.pencil-arrow { width: 100%; height: 84px; overflow: visible; }
.pencil-arrow path, .string-lines path {
  fill: none;
  stroke: var(--red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 520;
  stroke-dashoffset: 520;
  transition: stroke-dashoffset .75s ease;
}
.specimen-card:hover .pencil-arrow path, .drawer.in-view .string-lines path { stroke-dashoffset: 0; }
.string-lines { position: absolute; inset: 31% 6% auto 6%; height: 420px; z-index: -1; opacity: .55; pointer-events: none; }
.string-lines path { stroke: var(--indigo); stroke-width: 2.4; }

.prism-wall { grid-template-columns: repeat(4, 1fr); align-items: stretch; }
.crystal-card { min-height: 390px; background: linear-gradient(180deg, rgba(247,233,200,.96), color-mix(in srgb, var(--accent) 18%, #F7E9C8)); }
.crystal-diagram { height: 180px; clip-path: polygon(50% 0, 88% 18%, 100% 58%, 63% 100%, 20% 88%, 0 43%); background: conic-gradient(from 20deg, var(--lilac), var(--accent), var(--ledger), var(--accent), var(--lilac)); }
.crystal-diagram.jade { background: conic-gradient(from 20deg, var(--lilac), var(--jade), var(--ledger), var(--graphite), var(--jade)); }
.crystal-diagram.gold { background: conic-gradient(from 20deg, var(--lilac), var(--marigold), var(--ledger), var(--graphite), var(--marigold)); }
.mono-list { font-family: var(--mono); font-size: .94rem; }

.debate-board { width: min(980px, 88vw); margin: 0 auto; display: grid; grid-template-columns: .8fr 1.2fr; gap: 1.4rem; align-items: center; }
.margin-note { background: rgba(247,233,200,.96); font-family: var(--hand); }
.margin-note p { font-family: var(--hand); font-size: 1.8rem; line-height: 1.15; color: var(--indigo); }
.red-note { background: rgba(228,87,69,.13); }
.red-note p { color: var(--red); }
.wide-card { grid-row: span 2; min-height: 510px; }

.final-drawer { min-height: 100vh; }
.seal-scene { position: relative; width: min(900px, 88vw); margin: 0 auto; min-height: 620px; display: grid; place-items: center; }
.archive-seal {
  width: min(560px, 86vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px double var(--indigo);
  background: radial-gradient(circle, rgba(185,156,255,.5), rgba(247,233,200,.96) 48%, rgba(242,183,5,.35) 49% 55%, rgba(247,233,200,.96) 56%);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4rem;
  box-shadow: 0 0 0 18px rgba(215,195,154,.36), 0 22px 0 rgba(38,50,56,.1);
  transform: rotate(-2deg);
}
.hammer { font-size: 4rem; color: var(--red); filter: drop-shadow(4px 4px 0 rgba(242,183,5,.65)); }
.reset-drawer {
  border: 2px solid var(--graphite);
  background: var(--jade);
  color: var(--ledger);
  border-radius: 999px;
  padding: .8rem 1.1rem;
  font: 900 1rem/1 var(--display);
  box-shadow: 4px 4px 0 var(--graphite);
  cursor: pointer;
}
.settled-cards span { position: absolute; width: 170px; height: 230px; border: 2px solid var(--graphite); border-radius: 18px; background: rgba(247,233,200,.82); box-shadow: 7px 7px 0 rgba(38,50,56,.12); }
.settled-cards span:nth-child(1) { left: 4%; top: 10%; transform: rotate(-14deg); }
.settled-cards span:nth-child(2) { right: 5%; top: 15%; transform: rotate(12deg); background: rgba(185,156,255,.32); }
.settled-cards span:nth-child(3) { left: 10%; bottom: 8%; transform: rotate(9deg); background: rgba(20,166,106,.18); }
.settled-cards span:nth-child(4) { right: 10%; bottom: 5%; transform: rotate(-8deg); background: rgba(242,183,5,.28); }

.cursor-crystals { position: fixed; left: 0; top: 0; width: 1px; height: 1px; pointer-events: none; z-index: 100; }
.cursor-crystals span { position: absolute; width: 16px; height: 16px; background: var(--lilac); clip-path: polygon(50% 0, 100% 45%, 70% 100%, 20% 82%, 0 30%); opacity: .8; transform: translate(-50%, -50%); }
.cursor-crystals span:nth-child(2) { width: 10px; height: 10px; background: var(--marigold); opacity: .65; }
.cursor-crystals span:nth-child(3) { width: 7px; height: 7px; background: var(--jade); opacity: .7; }

.story-envelope {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translate(-50%, 150%) rotate(-1deg);
  z-index: 80;
  width: min(560px, calc(100vw - 2rem));
  border: 2px solid var(--graphite);
  border-radius: 20px;
  background: linear-gradient(145deg, #F7E9C8, #D7C39A);
  box-shadow: 10px 12px 0 rgba(38,50,56,.18);
  padding: 1.3rem 1.5rem;
  transition: transform .35s cubic-bezier(.2,1.2,.3,1);
}
.story-envelope.open { transform: translate(-50%, 0) rotate(-1deg); }
.story-envelope button { float: right; border: 2px solid var(--graphite); border-radius: 999px; background: var(--marigold); font: 900 .9rem/1 var(--display); padding: .45rem .75rem; cursor: pointer; }
.envelope-lot { font-family: var(--mono); color: var(--indigo); }
.story-envelope p { margin: .8rem 0 0; }

@keyframes stampBloom { 0% { filter: blur(5px); opacity: .3; transform: scale(1.08) rotate(-4deg); } 100% { filter: blur(0); opacity: 1; transform: scale(1) rotate(-4deg); } }
@keyframes glint { 0%,100% { background-position: 0 0; } 50% { background-position: 100% 100%; } }
.drawer.in-view .library-stamp { animation: stampBloom .55s ease both; }
.drawer.in-view .crystal-diagram, .drawer.in-view .facet-window { animation: glint 3.5s ease-in-out infinite; background-size: 180% 180%; }

@media (max-width: 880px) {
  .drawer-rail { left: .4rem; transform: translateY(-50%) scale(.82); transform-origin: left center; }
  .drawer { padding-left: 3.7rem; }
  .desk-perspective { transform: none; min-height: auto; display: grid; gap: 1rem; }
  .title-board, .small-card, .note-tab, .auction-paddle { position: relative; left: auto; right: auto; top: auto; bottom: auto; width: 100%; }
  .auction-paddle { width: 120px; height: 120px; justify-self: end; }
  .dense-grid, .prism-wall, .debate-board { grid-template-columns: 1fr; }
  .dense-grid .vellum-card, .wide-card { grid-column: auto; grid-row: auto; }
  .drawer-heading, .offset-heading, .debate-heading { margin-left: 0; }
}
