/* 3D Lab — Design Library
   Technical specimen archive: graphite ground, ruled grid, mono data.
   Layout is a fixed left rail plus a scrolling main column. */

:root {
  --ink:      #0C0D0F;
  --ink-2:    #121417;
  --plate:    #16191D;
  --rule:     #262A31;
  --rule-hi:  #3A4049;
  --bone:     #EDEAE3;
  --bone-dim: #8D8F92;
  --signal:   #FF5C1A;
  --signal-d: #C43F09;

  --rail-w: 17.5rem;
  --gutter: clamp(1.25rem, 3.5vw, 3.5rem);
  --step: 1.5rem;

  --mono: "Martian Mono", ui-monospace, monospace;
  --sans: "Archivo", "Helvetica Neue", sans-serif;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
/* display: grid/flex on a section would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  padding-left: var(--rail-w);
  overflow-x: clip;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-variation-settings: "wdth" 100;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 64px 64px;
}

.grain {
  position: fixed; inset: 0; z-index: 100; pointer-events: none;
  opacity: .28; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

::selection { background: var(--signal); color: #0C0D0F; }
a { color: inherit; }

/* ── micro-label ─────────────────────────────────────────── */
.rail-label, .rail-readout dt, .rail-foot, .hero-rule, .field label, .count,
.tag, .card-no, .box-no, .index-table th, .spec dt, .drawer-close, .fine, kbd,
.section-head, .back, .box-go {
  font-family: var(--mono);
  font-size: .625rem;
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* ── left rail ───────────────────────────────────────────── */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 45;
  width: var(--rail-w);
  display: flex; flex-direction: column; gap: 1.6rem;
  padding: 1.4rem 1.2rem 1.2rem;
  background: var(--ink-2);
  border-right: 1px solid var(--rule);
  overflow-y: auto; overscroll-behavior: contain;
}

.mark {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none;
  font-family: var(--mono); font-weight: 800; font-size: .72rem; letter-spacing: .2em;
}
.mark svg { width: 22px; height: 22px; fill: none; stroke: var(--signal); stroke-width: 1.6; }

.rail-label { color: var(--rule-hi); margin: 0 0 .7rem; }

/* stage pill — Planning / In-Progress / Live */
.stage {
  font-family: var(--mono); font-size: .55rem; letter-spacing: .12em;
  text-transform: uppercase; padding: .2rem .45rem; border-radius: 2px;
  border: 1px solid currentColor;
}
.stage.is-live { color: #35C88B; }
.stage.is-in-progress { color: #E5A13B; }
.stage.is-planning { color: var(--bone-dim); }

.rail-stage {
  background: var(--ink-2); color: var(--rule-hi);
  font-family: var(--mono); font-size: .55rem; letter-spacing: .16em;
  text-transform: uppercase; padding: .6rem .75rem .25rem;
}

.rail-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); }
.rail-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--ink-2); padding: .6rem .75rem;
  text-decoration: none; font-size: .85rem; font-weight: 500; line-height: 1.25;
  color: var(--bone-dim);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.rail-nav a b { font-family: var(--mono); font-size: .62rem; color: var(--rule-hi); }
.rail-nav a:hover { background: #1A1D22; color: var(--bone); }
.rail-nav a.is-on { background: var(--signal); color: #0C0D0F; font-weight: 700; }
.rail-nav a.is-on b { color: #0C0D0F; }

.rail-filters { display: grid; gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); }
.rail-filters .rail-label { grid-column: 1/-1; background: var(--ink-2);
  margin: 0; padding: .7rem .75rem .2rem; }

.field { position: relative; background: var(--ink-2); padding: .55rem .75rem .5rem; }
.field label { display: block; color: var(--bone-dim); margin-bottom: .15rem; }
.field input, .field select {
  width: 100%; border: 0; background: transparent; color: var(--bone);
  font-family: var(--sans); font-size: .9rem; font-weight: 500;
  padding: 0; outline: none; appearance: none; cursor: pointer;
}
.field input { cursor: text; }
.field input::placeholder { color: #55585D; }
.field select option { background: var(--ink-2); color: var(--bone); }
.field:focus-within { background: #1A1D22; box-shadow: inset 0 -2px 0 var(--signal); }
.field.search kbd {
  position: absolute; right: .7rem; bottom: .6rem;
  border: 1px solid var(--rule-hi); border-radius: 3px;
  padding: .1rem .3rem; color: var(--bone-dim);
}
.field.search:focus-within kbd { opacity: 0; }

.view-toggle { display: flex; background: var(--ink-2); }
.view-toggle button {
  flex: 1; border: 0; background: transparent; color: var(--bone-dim);
  font-family: var(--mono); font-size: .625rem; letter-spacing: .14em;
  text-transform: uppercase; padding: .7rem .4rem; cursor: pointer;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.view-toggle button.is-on { background: var(--signal); color: #0C0D0F; font-weight: 600; }
.view-toggle button:not(.is-on):hover { color: var(--bone); }

.rail-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin: auto 0 0; background: var(--rule); border: 1px solid var(--rule); }
.rail-readout > div { background: var(--ink-2); padding: .6rem .5rem; text-align: center; }
.rail-readout dt { margin: 0 0 .3rem; color: var(--rule-hi); font-size: .5rem; }
.rail-readout dd { margin: 0; font-family: var(--mono); font-weight: 800;
  font-size: .95rem; font-variant-numeric: tabular-nums; }
.rail-readout > div:last-child dd { color: var(--signal); }

.rail-foot { margin: 0; color: var(--rule-hi); line-height: 1.9; word-break: break-all; }

/* rail toggle — small screens only */
.rail-toggle {
  display: none; position: fixed; top: .8rem; right: .8rem; z-index: 55;
  align-items: center; gap: .5rem;
  background: var(--ink-2); color: var(--bone);
  border: 1px solid var(--rule-hi); border-radius: 3px;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .14em;
  text-transform: uppercase; padding: .55rem .8rem; cursor: pointer;
}
.rail-toggle .bars { width: 13px; height: 9px; border-top: 2px solid var(--signal);
  border-bottom: 2px solid var(--signal); }

/* ── hero ────────────────────────────────────────────────── */
.hero { padding: clamp(2.5rem, 7vw, 5.5rem) var(--gutter) 2.5rem; }
.hero-rule {
  display: flex; justify-content: space-between;
  color: var(--bone-dim);
  padding-bottom: .6rem; border-bottom: 1px solid var(--rule);
}
.hero-title {
  margin: clamp(1.2rem, 3vw, 2.4rem) 0 0;
  font-size: clamp(3.2rem, 13vw, 12rem);
  line-height: .78; font-weight: 800;
  font-variation-settings: "wdth" 112;
  letter-spacing: -.045em; text-transform: uppercase;
}
.hero-title .line { display: block; animation: rise 1.1s var(--ease) backwards; }
.hero-title .l2 {
  color: transparent; -webkit-text-stroke: 1.5px var(--rule-hi);
  margin-left: .1em; animation-delay: .1s;
}
@keyframes rise { from { opacity: 0; transform: translateY(.22em); } }

.hero-body {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(21rem, 100%), 1fr));
  gap: var(--step); margin-top: clamp(1.8rem, 4vw, 3rem); max-width: 72rem;
  animation: rise 1.1s .25s var(--ease) backwards;
}
.lede { margin: 0; font-size: clamp(1rem, 1.4vw, 1.15rem); max-width: 46ch; color: #C9C6C0; }
.lede em { color: var(--bone); font-style: italic; }
.caveat {
  margin: 0; align-self: end;
  font-family: var(--mono); font-size: .66rem; line-height: 1.9;
  color: var(--bone-dim); max-width: 38ch;
  border-left: 1px solid var(--signal); padding-left: 1rem;
}
.caveat .dot {
  display: inline-block; width: 6px; height: 6px; margin-right: .5rem;
  background: var(--signal); border-radius: 50%; animation: blink 2.4s infinite;
}
@keyframes blink { 50% { opacity: .25; } }

/* ── collection boxes ────────────────────────────────────── */
.section-head {
  margin: 0; padding: 0 var(--gutter) 1rem;
  color: var(--rule-hi); font-weight: 400;
}
.collections {
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fill, minmax(min(23rem, 100%), 1fr));
  margin: 0 var(--gutter);
  background: var(--rule); border: 1px solid var(--rule);
}
.box {
  display: flex; flex-direction: column;
  background: var(--plate); text-decoration: none; color: inherit;
  transition: background .3s var(--ease);
  animation: fade .5s var(--ease) backwards;
}
@keyframes fade { from { opacity: 0; transform: translateY(10px); } }
.box:hover, .box:focus-visible { background: #1B1F24; outline: none; }
.box:focus-visible { box-shadow: inset 0 0 0 2px var(--signal); }

/* the lid is a peek inside: up to three of the collection's own plates */
.box-lid {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 118px; padding: 12px;
  border-bottom: 1px solid var(--rule);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.06), transparent 70%),
    #101317;
  overflow: hidden;
}
.box-plate {
  height: 100%; width: auto; flex: 0 1 auto; object-fit: contain;
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
  transition: transform .4s var(--ease);
}
.box:hover .box-plate { transform: translateY(-2px); }
.box-lid .box-plate:nth-child(1) { transform: rotate(-1.2deg); }
.box-lid .box-plate:nth-child(3) { transform: rotate(1.2deg); }
.box:hover .box-lid .box-plate:nth-child(1) { transform: rotate(-1.2deg) translateY(-2px); }
.box:hover .box-lid .box-plate:nth-child(3) { transform: rotate(1.2deg) translateY(-2px); }

.box-body { padding: 1.1rem 1.2rem 1.25rem; display: flex; flex-direction: column;
  gap: .55rem; flex: 1; }
.box-no { margin: 0; display: flex; align-items: center; gap: .6rem; color: var(--bone-dim); }
.box-kind { margin-left: auto; }
.box-kind { color: var(--rule-hi); margin-left: auto; }
.box:hover .box-kind { color: var(--signal); }
.box-name {
  margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.05;
  font-variation-settings: "wdth" 98; letter-spacing: -.025em;
}
.box-blurb { margin: 0; font-size: .85rem; color: var(--bone-dim); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.box-foot { margin-top: auto; padding-top: .6rem; display: flex; align-items: center; gap: .7rem; }
.box-count { font-family: var(--mono); font-size: .62rem; color: var(--bone-dim);
  letter-spacing: .1em; text-transform: uppercase; }
.box-count b { color: var(--bone); font-size: .95rem; }
.box-go { margin-left: auto; color: var(--rule-hi); transition: color .2s var(--ease), transform .2s var(--ease); }
.box:hover .box-go { color: var(--signal); transform: translateX(3px); }

/* ── collection view ─────────────────────────────────────── */
.collection-head { padding: clamp(2rem, 5vw, 3.5rem) var(--gutter) 1.4rem; }
.back { display: inline-block; color: var(--bone-dim); text-decoration: none;
  margin-bottom: 1.2rem; transition: color .2s var(--ease); }
.back:hover { color: var(--signal); }
#collection-stage { margin: 0 0 .7rem; }
.collection-head h1 {
  margin: 0 0 .5rem; font-size: clamp(2rem, 5.5vw, 4rem); font-weight: 800;
  letter-spacing: -.035em; line-height: 1; text-transform: uppercase;
  font-variation-settings: "wdth" 108;
}
.collection-blurb { margin: 0; max-width: 62ch; color: var(--bone-dim); font-size: .95rem; }
.count { color: var(--bone-dim); margin: 1.4rem 0 0; }

/* ── plate grid ──────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
  gap: 1px; margin: 1.5rem var(--gutter) 0;
  background: var(--rule); border: 1px solid var(--rule);
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--plate); border: 0; padding: 0;
  text-align: left; color: inherit; cursor: pointer; font: inherit;
  transition: background .3s var(--ease);
  animation: fade .5s var(--ease) backwards;
}
.card:hover, .card:focus-visible { background: #1B1F24; outline: none; }
.card:focus-visible { box-shadow: inset 0 0 0 2px var(--signal); }

.card-plate {
  display: block; width: 100%; height: auto; aspect-ratio: 1.75;
  object-fit: contain;
  border-bottom: 1px solid var(--rule);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.07), transparent 70%),
    #101317;
  transition: transform .5s var(--ease);
}
.card:hover .card-plate { transform: scale(1.015); }

.card-meta { padding: 1rem 1.15rem 1.2rem; display: flex; flex-direction: column; gap: .7rem; flex: 1; }
.card-no { color: var(--bone-dim); display: flex; justify-content: space-between; }
.card-no .div { color: var(--rule-hi); }
.card:hover .card-no .div { color: var(--signal); }
.card-name {
  margin: 0; font-size: 1.32rem; font-weight: 700; line-height: 1.1;
  font-variation-settings: "wdth" 96; letter-spacing: -.02em;
}
.card-sub { margin: 0; font-size: .82rem; color: var(--bone-dim); line-height: 1.5; }
.card-foot { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding-top: .4rem; }

.chips { display: flex; gap: 3px; }
.chip { width: 14px; height: 14px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.tag {
  margin-left: auto; color: var(--bone-dim);
  border: 1px solid var(--rule-hi); border-radius: 2px; padding: .18rem .45rem;
}
.box-foot .tag { margin-left: 0; }
.tag.is-ref { border-color: var(--signal-d); color: #E09166; }

/* ── index table ─────────────────────────────────────────── */
.index-table { width: calc(100% - var(--gutter) * 2); margin: 1.5rem var(--gutter) 0;
  border-collapse: collapse; font-size: .9rem; table-layout: fixed; }
.index-table th:nth-child(1) { width: 4.5rem; }
.index-table th:nth-child(3) { width: 8rem; }
.index-table th:nth-child(4) { width: 10rem; }
.index-table th:nth-child(5) { width: 8rem; }
.index-table th:nth-child(6), .index-table th:nth-child(7) { width: 6.5rem; }
.index-table th:nth-child(8) { width: 11rem; }
.index-table th {
  text-align: left; color: var(--bone-dim); font-weight: 400;
  padding: .7rem .9rem; border-bottom: 1px solid var(--rule-hi);
}
.index-table td { padding: .75rem .9rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.index-table tbody tr { cursor: pointer; transition: background .2s var(--ease); }
.index-table tbody tr:hover { background: var(--plate); }
.index-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .78rem; }
.index-table .no { font-family: var(--mono); font-size: .7rem; color: var(--bone-dim); }
.index-table .name { font-weight: 600; }
.index-table .dim { color: var(--bone-dim); font-size: .8rem; }

.empty { font-family: var(--mono); font-size: .8rem; color: var(--bone-dim);
  padding: 4rem 0; text-align: center; }

/* ── method ──────────────────────────────────────────────── */
.method { padding: clamp(3.5rem, 8vw, 6rem) var(--gutter) 0; }
.method h2 {
  margin: 0 0 2rem; font-size: clamp(1.6rem, 3.5vw, 2.6rem); font-weight: 800;
  text-transform: uppercase; letter-spacing: -.03em; font-variation-settings: "wdth" 108;
}
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); }
.steps li { counter-increment: s; background: var(--ink); padding: 1.5rem 1.3rem 1.8rem; }
.steps li::before {
  content: counter(s, decimal-leading-zero);
  font-family: var(--mono); font-size: .625rem; letter-spacing: .14em;
  color: var(--signal); display: block; margin-bottom: 1.1rem;
}
.steps h3 { margin: 0 0 .5rem; font-size: 1.1rem; font-weight: 700; }
.steps p { margin: 0; font-size: .86rem; color: var(--bone-dim); line-height: 1.65; }
.steps code { font-family: var(--mono); font-size: .74rem; color: var(--bone); }
.steps strong { color: var(--bone); }
.steps li:last-child { background: #131417; }
.steps li:last-child strong { color: var(--signal); }

/* ── footer ──────────────────────────────────────────────── */
.foot { margin-top: clamp(4rem, 9vw, 7rem); padding: 2.5rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--rule); color: var(--bone-dim); }
.foot p { margin: 0 0 .5rem; font-size: .8rem; }
.fine { color: var(--rule-hi); max-width: 70ch; line-height: 1.9; }

/* ── drawer ──────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6,7,8,.72); backdrop-filter: blur(3px);
  animation: fadein .3s var(--ease);
}
@keyframes fadein { from { opacity: 0; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(38rem, 100%);
  background: var(--ink-2); border-left: 1px solid var(--rule-hi);
  overflow-y: auto; overscroll-behavior: contain;
  animation: slide .45s var(--ease);
}
@keyframes slide { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .drawer, .scrim, .card, .box, .hero-title .line, .hero-body { animation: none; }
}

.drawer-close {
  position: sticky; top: 0; z-index: 2; width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink-2); border: 0; border-bottom: 1px solid var(--rule);
  color: var(--bone-dim); padding: 1rem 1.6rem; cursor: pointer;
}
.drawer-close:hover { color: var(--signal); }

.drawer-body { padding: 1.8rem 1.6rem 4rem; }
.drawer-plate { display: block; width: 100%; height: auto; object-fit: contain;
  border: 1px solid var(--rule); background: #101317; }
.drawer h2 {
  margin: 1.6rem 0 .3rem; font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 800;
  letter-spacing: -.03em; line-height: 1.05; font-variation-settings: "wdth" 100;
}
.drawer .path { font-family: var(--mono); font-size: .62rem; color: var(--rule-hi);
  word-break: break-all; letter-spacing: .04em; }
.drawer .blurb { font-size: .95rem; color: #C2BFB9; margin: 1.4rem 0; }
.drawer .notes {
  font-size: .85rem; color: var(--bone-dim); line-height: 1.75;
  border-left: 1px solid var(--signal-d); padding-left: 1rem; margin: 1.4rem 0;
}

.spec { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); margin: 1.6rem 0; }
.spec > div { background: var(--ink-2); padding: .85rem 1rem; }
.spec dt { color: var(--bone-dim); margin-bottom: .35rem; }
.spec dd { margin: 0; font-family: var(--mono); font-size: .9rem; font-weight: 600;
  font-variant-numeric: tabular-nums; }

.swatches { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); margin: 1.6rem 0; }
.swatch { display: flex; align-items: center; gap: .9rem; background: var(--ink-2); padding: .6rem .8rem; }
.swatch i { width: 26px; height: 26px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.swatch b { font-weight: 600; font-size: .85rem; text-transform: capitalize; }
.swatch code { margin-left: auto; font-family: var(--mono); font-size: .68rem; color: var(--bone-dim); }

.links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.8rem; }
.links a {
  font-family: var(--mono); font-size: .625rem; letter-spacing: .14em; text-transform: uppercase;
  text-decoration: none; border: 1px solid var(--rule-hi); padding: .55rem .9rem;
  transition: all .25s var(--ease);
}
.links a:hover { background: var(--signal); border-color: var(--signal); color: #0C0D0F; }

/* ── small screens: rail becomes a drawer ────────────────── */
@media (max-width: 900px) {
  body { padding-left: 0; }
  .rail {
    transform: translateX(-100%);
    transition: transform .35s var(--ease);
    box-shadow: 0 0 60px rgba(0,0,0,.6);
  }
  body.rail-open .rail { transform: none; }
  .rail-toggle { display: flex; }
  .hero, .collection-head { padding-top: 4.5rem; }
  /* tapping the page closes the rail */
  body.rail-open main, body.rail-open .foot { pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

@media (max-width: 640px) {
  .index-table .hide-sm { display: none; }
  .spec { grid-template-columns: 1fr; }
}
