/* ==========================================================================
   KIWARO - Explore page (PU Layer Explorer, Shade Studio)
   ========================================================================== */

/* ---------- shared ---------- */
.lab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

/* ==========================================================================
   1 - PU Layer Explorer
   ========================================================================== */
.layer-section { position: relative; }
.layer-pin {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: clamp(24px, 4vw, 80px);
  padding-block: 90px 40px;
}
.layer-stage {
  height: clamp(380px, 56vh, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
}
/* exploded 6-layer stack; each layer is its own photoreal panel baked onto a
   shared canvas at its final cascade position, so all six stack in perfect
   registration and can be revealed one at a time. Canvas aspect 1576/1675. */
.layer-visual {
  position: relative;
  height: 100%;
  aspect-ratio: 1576 / 1675;
}
.layer-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: translateY(-30px);
  transition: opacity 0.5s var(--ease-swift), transform 0.8s var(--ease-swift);
  will-change: opacity, transform;
}
/* higher layer sits in front, matching the exploded stack */
.layer-panel[data-layer="1"] { z-index: 1; }
.layer-panel[data-layer="2"] { z-index: 2; }
.layer-panel[data-layer="3"] { z-index: 3; }
.layer-panel[data-layer="4"] { z-index: 4; }
.layer-panel[data-layer="5"] { z-index: 5; }
.layer-panel[data-layer="6"] { z-index: 6; }
.layer-panel.is-shown { opacity: 1; transform: translateY(0); }
/* soft floor shadow grounding the board at the base of the stack */
.layer-visual::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 10%;
  bottom: 3%;
  height: 7%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(54, 29, 24, 0.22), transparent 72%);
  z-index: 0;
}
/* numbered callouts anchored to each slab, catalogue-style */
.layer-mark {
  position: absolute;
  left: 96%;
  top: var(--y);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.4s;
}
.layer-mark.is-revealed { opacity: 0.55; }
.layer-mark i {
  position: relative;
  display: block;
  width: clamp(22px, 3.4vw, 54px);
  height: 1.5px;
  background: var(--tan);
}
.layer-mark i::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -2.75px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tan);
}
.layer-mark b {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--tan);
  background: var(--paper);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s;
}
.layer-mark.is-passed { opacity: 0.7; }
.layer-mark.is-active { opacity: 1; }
.layer-mark.is-active b { background: var(--brown-800); border-color: var(--brown-800); color: #fff; }

.layer-rail { max-width: 520px; }
.layer-steps { margin-top: 26px; display: flex; flex-direction: column; }
.layer-step {
  display: flex;
  gap: 18px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  transition: opacity 0.35s;
  opacity: 0.4;
  text-align: left;
  background: none;
  border-top: 0; border-left: 0; border-right: 0;
}
.layer-step .dot {
  flex-shrink: 0;
  width: 30px; height: 30px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--tan);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.35s;
}
.layer-step h3 { font-size:  17px; }
.layer-step p { font-size: 14px; margin-top: 3px; max-height: 0; overflow: hidden; opacity: 0; transition: max-height .5s var(--ease-swift), opacity .4s; }
.layer-step.is-active { opacity: 1; }
.layer-step.is-active .dot { background: var(--brown-800); border-color: var(--brown-800); color: #fff; }
.layer-step.is-active p { max-height: 120px; opacity: 1; }
.layer-step.is-passed { opacity: 0.8; }
.layer-hint { margin-top: 20px; font-size: 13px; color: var(--body-soft); display: flex; align-items: center; gap: 8px; }

/* static fallback (no JS / reduced motion) */
.no-pin .layer-pin { min-height: 0; }
.no-pin .layer-visual { transform: none; }
.no-pin .layer-panel { opacity: 1; transform: none; }
.no-pin .layer-mark { opacity: 1; }
.no-pin .layer-step { opacity: 1; }
.no-pin .layer-step p { max-height: 120px; opacity: 1; }

/* ==========================================================================
   2 - Shade Studio: a real-time material viewport.
   Dark engine-style shell, pointer-tracked key light, and a three-state
   finish model (matt / satin / gloss) driven by CSS vars.
   ========================================================================== */
.studio {
  /* finish response model: sheen = fixed environment reflection,
     spec = pointer key light, img-c/img-s = surface contrast/saturation */
  --sheen-a: 0.05;
  --spec-a: 0.09;
  --spec-r: 40%;
  --img-c: 1;
  --img-s: 1;
  background: linear-gradient(180deg, #251814 0%, #170f0c 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--r-lg);
  overflow: hidden;
  color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 2px 6px rgba(15, 8, 6, 0.4), 0 40px 90px -40px rgba(15, 8, 6, 0.8);
}
.studio[data-finish="satin"] { --sheen-a: 0.11; --spec-a: 0.18; --spec-r: 30%; --img-c: 1.02; --img-s: 1.02; }
.studio[data-finish="gloss"] { --sheen-a: 0.17; --spec-a: 0.3; --spec-r: 21%; --img-c: 1.05; --img-s: 1.06; }

.studio-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(18px, 2.5vw, 28px);
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.studio-tabs { display: flex; gap: 8px; }
.studio .filter-chip {
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.75);
  padding: 9px 18px;
}
.studio .filter-chip:hover { border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.studio .filter-chip.active { background: var(--paper); border-color: var(--paper); color: var(--brown-900); }

/* finish segmented control */
.finish-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.25);
}
.seg-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 800; font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase;
  cursor: pointer;
  transition: background .18s var(--ease-out), color .18s var(--ease-out);
}
.seg-btn:hover { color: #fff; }
.seg-btn.active { background: var(--paper); color: var(--brown-900); }

.studio-body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
}
.studio-stagewrap {
  position: relative;
  background: #0d0908;
  perspective: 1200px;
  overflow: hidden;
}
.studio-stage { display: none; position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform; }
.studio-stage.is-active { display: block; }
/* JS wraps the photo + zone overlays in .stage-fit so they stay in exact
   registration while the stage covers its viewport with no letterboxing.
   Cover behaviour applies at every size; the wrap gets its height from the
   grid on desktop and from a 4:3 ratio on stacked mobile. */
.stage-fit {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  min-width: 100%;
  min-height: 100%;
}
.stage-fit img {
  width: 100%; height: 100%; display: block;
  filter: contrast(var(--img-c)) saturate(var(--img-s));
  transition: filter 0.5s ease;
}
@media (min-width: 1025px) {
  .studio-stagewrap { min-height: 500px; }
}
@media (max-width: 1024px) {
  .studio-stagewrap { aspect-ratio: 4 / 3; }
}
.studio-stage svg.tint {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.studio-stage svg.tint rect { transition: fill 0.45s ease; }

/* fixed environment sheen: strength follows the finish */
.studio-stage .gloss {
  position: absolute;
  inset: 0;
  background: linear-gradient(112deg,
    rgba(255, 255, 255, 0) 24%,
    rgba(255, 255, 255, calc(var(--sheen-a) * 1.5)) 40%,
    rgba(255, 255, 255, 0) 54%,
    rgba(255, 255, 255, var(--sheen-a)) 76%,
    rgba(255, 255, 255, 0) 90%);
  mix-blend-mode: screen;
  opacity: 1;
  transition: opacity 0.5s;
  pointer-events: none;
}
/* pointer-tracked key light (injected by JS) */
.studio-stage .spec {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 62%) var(--my, 30%),
    rgba(255, 244, 230, var(--spec-a)) 0%,
    rgba(255, 244, 230, calc(var(--spec-a) * 0.4)) calc(var(--spec-r) * 0.5),
    transparent var(--spec-r));
  mix-blend-mode: screen;
  pointer-events: none;
  transition: background 0.2s ease;
}
/* depth grade: vignette + top light (injected by JS) */
.studio-stage .vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 18%),
    radial-gradient(120% 90% at 50% 42%, transparent 62%, rgba(10, 6, 4, 0.34) 100%);
  pointer-events: none;
}
/* viewport status readout (injected by JS) */
.studio-status {
  position: absolute;
  left: 14px; bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(10, 6, 4, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}
.studio-status i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--olive-light);
}

/* zone hover affordance */
.studio-stage svg.zones { position: absolute; inset: 0; width: 100%; height: 100%; }
.studio-stage svg.zones rect {
  fill: transparent;
  stroke: transparent;
  stroke-width: 3;
  cursor: pointer;
  transition: stroke 0.3s, fill 0.3s;
}
.studio-stage svg.zones g:hover rect { stroke: rgba(255,255,255,.45); }
.studio-stage svg.zones g.zone-hot rect { stroke: rgba(255,255,255,.95); fill: rgba(255,255,255,.08); stroke-dasharray: 8 6; }

/* control panel: dark glass */
.studio-panel {
  padding: clamp(20px, 2.6vw, 30px);
  display: flex; flex-direction: column; gap: 16px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}
.studio-panel .panel-label,
.swatch-block h4 {
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 8px;
}
.swatch-block h4 { margin-top: 10px; }
.zone-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.shade-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  padding: 0;
  transition: transform .18s var(--ease-out), box-shadow .18s, border-color .18s;
  position: relative;
}
.shade-dot:hover { transform: scale(1.14); border-color: rgba(255,255,255,.55); }
.shade-dot.is-on {
  border-color: var(--paper);
  box-shadow: 0 0 0 3px #170f0c, 0 0 0 5px var(--paper);
  transform: scale(1.06);
}
.studio-meta {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.studio-meta .current { font-size: 13.5px; color: rgba(255, 255, 255, 0.62); }
.studio-meta .current strong { display: block; font-family: var(--serif); font-size:  17px; font-weight: 500; color: #fff; }
.studio-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  background: transparent;
  font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: all .18s var(--ease-out);
}
.mini-btn:hover { border-color: #fff; color: #fff; }
.mini-btn.solid { background: var(--paper); border-color: var(--paper); color: var(--brown-900); }
.mini-btn.solid:hover { background: var(--tan); border-color: var(--tan); color: var(--brown-900); }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .layer-pin { grid-template-columns: 1fr; align-items: start; padding-top: 96px; gap: 8px; }
  .layer-stage { height: clamp(300px, 42vh, 420px); }
  .studio-body { grid-template-columns: 1fr; }

  /* stack-mode: the stage parks under the (auto-hiding) header while the
     six steps scroll past beneath it and drive the build */
  .stack-mode .layer-pin { min-height: 0; padding-top: 88px; }
  .stack-mode .layer-stage {
    position: sticky;
    top: 10px;
    z-index: 5;
    height: clamp(230px, 36vh, 330px);
    padding-bottom: 16px;
    background: linear-gradient(180deg, var(--paper) 88%, transparent 100%);
  }
  .stack-mode .layer-rail { max-width: none; padding-top: 10px; }
  .stack-mode .layer-step { padding: 17px 4px; }
  .stack-mode .layer-hint { display: none; }
}
@media (max-width: 720px) {
  .layer-mark i { width: 16px; }
  .layer-mark b { width: 24px; height: 24px; font-size: 11px; }
  .layer-step p { font-size: 13.5px; }
  .studio-panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .layer-visual { transform: none; }
}
