/* ============================================================================
   studio.css — Prototype C · The Stitch Studio
   Direction: documentary / museum-of-craft. Gallery white, charcoal ink,
   grotesque + mono type, spool-teal working accent, madder for one rare
   gesture. Asymmetric editorial grid, exposed 1px rules, 0px corners, flat
   surfaces. The OBJECTS supply chroma; the UI stays achromatic.
   Every class a page uses lives HERE (loaded by every page) — the swatch wall,
   filmstrip, catalog grid, and stitch seams are shared, so no page depends on
   the PDP-only previewer-skin.css. (Lesson from A/B review cycles.)
   ========================================================================== */

@import url('../fonts/fonts.css');

/* ── reduced-motion global gate (day one) ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ── tokens ────────────────────────────────────────────────────────────────── */
:root {
  /* palette */
  --gallery:    #FAFAF8;  /* page ground — gallery white */
  --panel:      #F0EEE9;  /* fog panel */
  --linen:      #D9CFC0;  /* natural linen / kraft */
  --linen-deep: #C9BDA9;  /* stronger kraft edge */
  --charcoal:   #2B2B28;  /* charcoal thread — primary ink + footer */
  --ink-soft:   #5C5A52;  /* secondary ink — AA at small sizes (6.6:1 on gallery) */
  --teal:       #1F6E6B;  /* spool teal — interactive / active (5.7:1 on gallery) */
  --teal-deep:  #16524F;  /* teal hover */
  --madder:     #B5452E;  /* rare single gesture per page (5.2:1 on gallery) */
  --rule:       #D8D5CE;  /* hairline seam (decorative) */
  --rule-firm:  #B9B5AB;  /* firmer rule */
  --on-ink:     #FAFAF8;  /* text on charcoal (13.6:1) */
  --on-ink-dim: #B9B6AE;  /* dim text on charcoal (7.0:1) */

  /* type */
  --f-grotesk: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --f-mono:    'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --f-serif:   'Newsreader', Georgia, 'Times New Roman', serif;

  /* rhythm */
  --wrap:   1240px;
  --gutter: clamp(18px, 5vw, 40px);
  --gap-section: clamp(58px, 9vw, 92px);
}

/* ── reset / base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--gallery);
  color: var(--charcoal);
  font-family: var(--f-grotesk);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.08; }
p { margin: 0; }
button { font-family: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--charcoal); color: var(--on-ink);
  padding: 10px 16px; font: 500 0.8rem/1 var(--f-mono); letter-spacing: .04em;
  text-decoration: none; transition: top .18s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ── layout ────────────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.wrap--narrow { max-width: 760px; }
.section { padding: var(--gap-section) 0; }
.section--tight { padding: clamp(34px, 6vw, 54px) 0; }
.section--panel { background: var(--panel); }
.section--linen { background: var(--linen); }
.section--ink { background: var(--charcoal); color: var(--on-ink); }

/* ── type helpers ──────────────────────────────────────────────────────────── */
.eyebrow {
  font: 500 0.72rem/1.2 var(--f-mono);
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0;
}
.eyebrow--teal { color: var(--teal); }
.eyebrow--onink { color: var(--on-ink-dim); }
.num {
  font: 500 0.72rem/1 var(--f-mono);
  letter-spacing: .12em; color: var(--teal);
}
.display {
  font-family: var(--f-grotesk);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.02;
  color: var(--charcoal);
}
.d-hero { font-size: clamp(2.5rem, 8.5vw, 5.2rem); }
.d-1    { font-size: clamp(2.05rem, 5.6vw, 3.4rem); }
.d-2    { font-size: clamp(1.6rem, 4vw, 2.35rem); }
.d-3    { font-size: clamp(1.25rem, 2.6vw, 1.6rem); }
.lede {
  font: 400 clamp(1.05rem, 2vw, 1.28rem)/1.5 var(--f-grotesk);
  color: var(--charcoal); max-width: 42ch;
}
.prose p { margin-bottom: 1em; max-width: 62ch; }
.prose p:last-child { margin-bottom: 0; }
/* essay — the ONE editorial serif, essay moments only */
.essay {
  font-family: var(--f-serif);
  font-size: clamp(1.12rem, 2.1vw, 1.32rem);
  line-height: 1.62;
  color: var(--charcoal);
}
.essay p { margin-bottom: 0.9em; max-width: 60ch; }
.essay p:last-child { margin-bottom: 0; }
.pull {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: clamp(1.5rem, 3.6vw, 2.35rem);
  line-height: 1.24;
  color: var(--charcoal);
  max-width: 22ch;
}

/* museum wall-label caption — mono, small, precise */
.caption {
  font: 400 0.72rem/1.45 var(--f-mono);
  letter-spacing: .015em;
  color: var(--ink-soft);
  margin: 0;
}
.caption b, .caption strong { color: var(--charcoal); font-weight: 700; }
.mono { font-family: var(--f-mono); }
.madder { color: var(--madder); }

/* inline link */
.tlink {
  color: var(--teal); text-decoration: none;
  border-bottom: 1px solid currentColor; padding-bottom: 1px;
  transition: color .15s ease, border-color .15s ease;
}
.tlink:hover { color: var(--teal-deep); }

/* ── buttons (flat, bordered, 0px) ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 0.82rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  padding: 15px 26px; border: 1px solid var(--charcoal);
  background: var(--charcoal); color: var(--on-ink);
  text-decoration: none; cursor: pointer; border-radius: 0;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.btn:hover { background: var(--teal); border-color: var(--teal); }
.btn--ghost { background: transparent; color: var(--charcoal); }
.btn--ghost:hover { background: transparent; color: var(--teal-deep); border-color: var(--teal); }
.btn--onink { background: var(--gallery); color: var(--charcoal); border-color: var(--gallery); }
.btn--onink:hover { background: var(--teal); border-color: var(--teal); color: var(--on-ink); }
.btn--sm { padding: 11px 18px; font-size: 0.72rem; }

/* ── header ────────────────────────────────────────────────────────────────── */
.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--gallery) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 62px;
}
.nav__brand {
  display: inline-flex; align-items: baseline; gap: 8px;
  font: 500 1.02rem/1 var(--f-grotesk); letter-spacing: .01em;
  text-decoration: none; color: var(--charcoal);
}
.nav__brand .mark {
  width: 15px; height: 15px; display: inline-block; align-self: center;
  background:
    linear-gradient(var(--charcoal),var(--charcoal)) 0 0/6px 6px no-repeat,
    linear-gradient(var(--teal),var(--teal)) 9px 0/6px 6px no-repeat,
    linear-gradient(var(--charcoal),var(--charcoal)) 0 9px/6px 6px no-repeat,
    linear-gradient(var(--charcoal),var(--charcoal)) 9px 9px/6px 6px no-repeat;
}
.nav__brand small {
  font: 500 0.62rem/1 var(--f-mono); letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-soft);
}
.nav__links {
  display: flex; gap: clamp(14px, 2.4vw, 26px); list-style: none; margin: 0; padding: 0;
}
.nav__links a {
  font: 500 0.74rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; color: var(--charcoal); padding: 6px 0; white-space: nowrap;
  border-bottom: 1px solid transparent; transition: border-color .15s ease, color .15s ease;
}
.nav__links a:hover, .nav__links a[aria-current="page"] { color: var(--teal); border-color: var(--teal); }
.nav__cart {
  position: relative; display: inline-flex; align-items: center;
  color: var(--charcoal); text-decoration: none;
}
.nav__cart svg { width: 21px; height: 21px; }
.nav__cart-count {
  position: absolute; top: -6px; right: -8px; min-width: 15px; height: 15px;
  display: grid; place-items: center; padding: 0 3px;
  background: var(--teal); color: var(--on-ink);
  font: 500 0.58rem/1 var(--f-mono); border-radius: 999px;
}
/* mobile: hide inline links, keep brand + cart (nav stays legible at 375) */
@media (max-width: 620px) {
  .nav__links { gap: 12px; }
  .nav__links a { font-size: 0.64rem; letter-spacing: .04em; }
  .nav__brand small { display: none; }
}
/* ≤400px — tighten nav gap/tracking so all four labels (incl. "The Proof",
   held on one line by white-space:nowrap) fit without wrap or overflow. */
@media (max-width: 400px) {
  .nav { gap: 10px; }
  .nav__links { gap: 9px; }
  .nav__links a { letter-spacing: .02em; }
}

/* ── seams / rules (exposed grid, where they inform) ───────────────────────── */
.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }
.rule--firm { border-top-color: var(--rule-firm); }

/* running-stitch seam — scroll-drawn (see stitch.js) */
.seam { display: block; width: 100%; height: 12px; overflow: visible; }
.seam line {
  stroke: var(--charcoal); stroke-width: 1.4;
  stroke-dasharray: 6 6; stroke-dashoffset: 1200;
  transition: stroke-dashoffset 1.1s ease;
  opacity: .5;
}
.seam.is-drawn line { stroke-dashoffset: 0; }

/* vertical scroll-progress stitch (home signature) */
.stitch-gutter {
  position: fixed; left: 12px; top: 0; bottom: 0; width: 12px; z-index: 5;
  pointer-events: none;
}
@media (max-width: 900px) { .stitch-gutter { display: none; } }
.stitch-gutter line {
  stroke: var(--teal); stroke-width: 1.6;
  stroke-dasharray: 4 6; stroke-dashoffset: var(--stitch-off, 0);
  opacity: .55;
}

/* ── catalog grid (image-first cards, contact-sheet seams) ─────────────────── */
.cat-grid {
  display: grid; gap: 1px; background: var(--rule);
  border: 1px solid var(--rule);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.cat-item {
  display: flex; flex-direction: column; background: var(--gallery);
  text-decoration: none; color: var(--charcoal);
  min-width: 0; /* let 1fr grid tracks shrink below image intrinsic width */
}
.cat-item__media { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--panel); }
.cat-item__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.cat-item:hover .cat-item__media img { transform: scale(1.03); }
.cat-item__tag {
  position: absolute; top: 0; left: 0;
  font: 500 0.6rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--on-ink); background: var(--charcoal); padding: 6px 9px;
}
.cat-item__tag--custom { background: var(--teal); }
.cat-item__body { padding: 15px 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cat-item__no { font: 400 0.66rem/1 var(--f-mono); letter-spacing: .06em; color: var(--ink-soft); }
.cat-item__name { font: 500 1.02rem/1.2 var(--f-grotesk); letter-spacing: -0.01em; }
.cat-item__spec { font: 400 0.72rem/1.4 var(--f-mono); color: var(--ink-soft); margin-top: auto; }
.cat-item__price { font: 500 0.9rem/1 var(--f-mono); color: var(--charcoal); }
.cat-item:hover .cat-item__name { color: var(--teal); }
.cat-item__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
/* home "selected work" trio — deliberate 1-up / 3-up column counts (both divide 3)
   so the museum row always fills flush, with no trailing empty contact-sheet cell. */
.cat-grid--trio { grid-template-columns: 1fr; }
@media (min-width: 760px) { .cat-grid--trio { grid-template-columns: repeat(3, 1fr); } }

/* ── filmstrip (ordered process frames — order IS information) ──────────────── */
.filmstrip {
  display: grid; gap: 1px; background: var(--charcoal);
  border: 1px solid var(--charcoal);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .filmstrip { grid-template-columns: repeat(3, 1fr); } }
.filmstrip--4 { grid-template-columns: 1fr; }
@media (min-width: 720px) { .filmstrip--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .filmstrip--4 { grid-template-columns: repeat(4, 1fr); } }
.frame { background: var(--gallery); display: flex; flex-direction: column; }
.frame__media { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--panel); }
.frame__media img { width: 100%; height: 100%; object-fit: cover; }
.frame__no {
  position: absolute; top: 8px; left: 8px;
  font: 700 0.66rem/1 var(--f-mono); letter-spacing: .04em;
  color: var(--charcoal); background: var(--gallery); padding: 4px 7px;
}
.frame__body { padding: 14px 16px 18px; }
.frame__step { font: 500 0.62rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--teal); }
.frame__title { font: 500 1.02rem/1.2 var(--f-grotesk); margin: 8px 0 6px; }
.frame__text { font: 400 0.86rem/1.5 var(--f-grotesk); color: var(--ink-soft); }

/* ── swatch wall (SIGNATURE — shared: Home hero + PDP picker) ───────────────── */
.swatch-wall { --cell: 30px; }
.swatch-wall__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.swatch-wall__grid {
  display: grid; gap: 1px; background: var(--rule);
  border: 1px solid var(--rule);
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
}
.sw {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; margin: 0;
  cursor: pointer; background: var(--sw-hex, #ccc); border-radius: 0;
  display: block; width: 100%;
}
.sw--static { cursor: default; } /* inspection mode (Home): not clickable */
.sw:hover, .sw:focus-visible { z-index: 3; box-shadow: inset 0 0 0 2px var(--gallery), 0 0 0 2px var(--teal); }
.sw[aria-selected="true"] { z-index: 2; box-shadow: inset 0 0 0 2px var(--gallery), 0 0 0 2px var(--charcoal); }
/* orderable subset mark — a filled teal corner wedge + faint teal keyline, so the
   24 orderable colours read at a glance against the neutral solids field.
   (hover/selected box-shadows out-specify the keyline and replace it.) */
.sw--order { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--teal) 62%, transparent); }
.sw--order::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  width: 0; height: 0;
  border-left: 8px solid transparent; border-bottom: 8px solid var(--teal);
}
.sw[aria-selected="true"].sw--order::after { border-bottom-color: var(--charcoal); }
/* readout under the wall */
.swatch-wall__readout {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; min-height: 22px;
  font: 400 0.75rem/1.3 var(--f-mono); color: var(--ink-soft);
}
.swatch-wall__chip {
  width: 16px; height: 16px; flex: none; border: 1px solid var(--rule-firm);
  background: var(--chip-hex, transparent);
}
.swatch-wall__legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px;
  font: 400 0.68rem/1.3 var(--f-mono); color: var(--ink-soft);
}
/* legend marker mirrors the field's orderable corner-wedge, so the legend shows
   the exact mark a swatch carries. */
.swatch-wall__legend .dot {
  display: inline-block; width: 0; height: 0; margin-right: 6px; vertical-align: middle;
  border-left: 7px solid transparent; border-bottom: 7px solid var(--teal);
}

/* ── figure / caption blocks ───────────────────────────────────────────────── */
.plate { margin: 0; }
.plate__frame { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--rule); }
.plate__frame img { width: 100%; height: auto; display: block; }
.plate__cap {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: 8px;
}

/* ── accordions ────────────────────────────────────────────────────────────── */
.acc { border-top: 1px solid var(--rule); }
.acc:last-of-type { border-bottom: 1px solid var(--rule); }
.acc > summary {
  list-style: none; cursor: pointer; padding: 15px 2px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font: 500 0.82rem/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--charcoal);
}
.acc > summary::-webkit-details-marker { display: none; }
.acc__sign { position: relative; width: 12px; height: 12px; flex: none; }
.acc__sign::before, .acc__sign::after {
  content: ""; position: absolute; background: var(--teal);
}
.acc__sign::before { left: 0; top: 5px; width: 12px; height: 2px; }
.acc__sign::after { left: 5px; top: 0; width: 2px; height: 12px; transition: transform .18s ease; }
.acc[open] .acc__sign::after { transform: scaleY(0); }
.acc__panel { padding: 0 2px 18px; }
.acc__panel p { margin-bottom: .7em; color: var(--ink-soft); font-size: 0.92rem; }
.acc__panel p:last-child { margin-bottom: 0; }
.acc__panel ul { margin: 0; padding-left: 1.1em; color: var(--ink-soft); font-size: 0.92rem; }
.acc__panel li { margin-bottom: .35em; }

/* ── footer ────────────────────────────────────────────────────────────────── */
.site-foot { background: var(--charcoal); color: var(--on-ink); padding: clamp(44px,7vw,72px) 0 30px; }
.foot__grid {
  display: grid; gap: 30px 24px;
  grid-template-columns: 1fr;
}
@media (min-width: 680px) { .foot__grid { grid-template-columns: 1.6fr 1fr 1fr; } }
.foot__brand { font: 500 1.2rem/1 var(--f-grotesk); letter-spacing: .01em; }
.foot__tag { margin-top: 12px; max-width: 34ch; color: var(--on-ink-dim); font-size: 0.9rem; line-height: 1.55; }
.foot__col h3 { font: 500 0.68rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--on-ink-dim); margin-bottom: 14px; }
.foot__col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.foot__col a { color: var(--on-ink); text-decoration: none; font-size: 0.9rem; border-bottom: 1px solid transparent; padding-bottom: 2px; }
.foot__col a:hover { border-color: var(--on-ink-dim); }
.foot__base {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-top: 34px; padding-top: 20px; border-top: 1px solid rgba(250,250,248,.16);
}
.foot__fine { font: 400 0.72rem/1.5 var(--f-mono); color: var(--on-ink-dim); max-width: 52ch; }
.foot__proto { font: 400 0.72rem/1.4 var(--f-mono); color: var(--on-ink-dim); }
.foot__proto a { color: var(--gallery); }

/* ── generic grid helpers ──────────────────────────────────────────────────── */
.split {
  display: grid; gap: clamp(24px, 4vw, 48px);
  grid-template-columns: 1fr;
}
@media (min-width: 860px) {
  .split--5-7 { grid-template-columns: 5fr 7fr; }
  .split--7-5 { grid-template-columns: 7fr 5fr; }
  .split--1-1 { grid-template-columns: 1fr 1fr; }
  .split--4-8 { grid-template-columns: 4fr 8fr; }
}
.stack-sm > * + * { margin-top: 12px; }
.stack-md > * + * { margin-top: 20px; }
.stack-lg > * + * { margin-top: 32px; }
.measure { max-width: 60ch; }
.eyebrow-row { display: flex; align-items: center; gap: 12px; }
.eyebrow-row::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
