/* Hair color example library: "the colorist's viewing booth".
   Page-scoped to /hair-color-examples/. Builds on /styles.css tokens (Fraunces,
   Kalam, oat/paper/cocoa/rose) and the preset swatch classes (.c-*). The booth is
   a warm-neutral gray so the page's cream doesn't tint how the hair color reads. */

.hair-examples-page {
  --booth: #4a4744;
  --booth-deep: #3b3936;
  --booth-ink: #e9e3d8;
  --booth-line: rgb(251 247 240 / .28);
  --focus-on-booth: #f3bcc4;
}

/* ---------- Head ---------- */
.lab-wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.lab-head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.2rem 3.2rem;
  align-items: end;
  margin: 0 0 1.8rem;
}
.lab-head .hand { font-size: 1.2rem; margin: 0 0 .5rem; rotate: -1.5deg; transform-origin: left; display: inline-block; }
.lab-head h1 { font-size: clamp(2.3rem, 4.4vw, 3.4rem); margin: 0 0 .8rem; max-width: 11em; }
.lab-head .intro { font-size: 1.12rem; line-height: 1.55; color: var(--cocoa-2); max-width: 30em; margin: 0; }
.lab-facts { max-width: 34rem; }
.library-note {
  font-size: .9rem; line-height: 1.55;
  margin: 0;
  padding: .9rem 1.1rem;
  background: rgb(251 247 240 / .7);
  border-left: 3px solid var(--rose);
  border-radius: 0 4px 4px 0;
}
.lab-head-cta { margin-top: 1.1rem; }
.lab-head-cta p { margin: 0; }
.library-access { font-size: .84rem; line-height: 1.5; color: var(--cocoa-2); margin-top: .6rem !important; max-width: 32em; }

/* ---------- Booth (shown only with JS: /site.js sets html.js before paint) ---------- */
.js .lab[hidden] { display: block; }
.lab { margin: 0 0 3rem; }
.lab-booth {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
  background: var(--booth);
  color: var(--paper);
  border-radius: 4px;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  display: grid;
  grid-template-columns: minmax(0, 35rem) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "photo models" "photo panel" "caption panel";
  gap: 1.4rem clamp(1.6rem, 3.5vw, 3rem);
  box-shadow: 0 22px 40px -24px rgb(58 41 32 / .55);
}
.lab-booth a { color: var(--paper); }
.lab-booth :focus-visible { outline-color: var(--focus-on-booth); }
.lab fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.lab legend { padding: 0; font-size: .82rem; color: var(--booth-ink); margin-bottom: .55rem; }
.lab input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }

/* Sample portrait chips */
.lab-models { grid-area: models; }
.lab-model-row { position: relative; display: flex; flex-wrap: wrap; gap: .45rem; }
.lab-model {
  position: relative;
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 2.45rem;
  padding: .35rem .85rem .35rem .55rem;
  border: 1.5px solid var(--booth-line);
  border-radius: 999px;
  font-size: .86rem; line-height: 1.2; white-space: nowrap;
  color: var(--booth-ink);
  cursor: pointer;
}
.lab-model:hover { border-color: rgb(251 247 240 / .6); color: var(--paper); }
.lab-model.is-checked { background: var(--paper); border-color: var(--paper); color: var(--cocoa); font-weight: 600; }
.lab-model:has(input:focus-visible) { outline: 3px solid var(--focus-on-booth); outline-offset: 2px; }
.lab-model-dot { width: .8rem; height: .8rem; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .35); }
.tone-blonde { background: #d8c08f; } .tone-golden { background: #93693f; } .tone-medium { background: #6e4b30; }
.tone-coils { background: #241a15; } .tone-fringe { background: #1d1917; }

/* Before/after stage */
.lab-photo { grid-area: photo; margin: 0; min-width: 0; }
.lab-compare {
  --pos: 50%;
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--booth-deep);
  border-radius: 2px;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
  cursor: ew-resize;
}
.lab-compare img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  -webkit-user-drag: none;
}
.lab-before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); z-index: 2; }
.lab-after.is-incoming { opacity: 0; }
.lab-tag {
  position: absolute; top: .8rem; z-index: 4;
  font-family: var(--hand); font-size: 1.05rem; line-height: 1;
  background: rgb(251 247 240 / .92); color: var(--cocoa);
  padding: .38rem .6rem .26rem; border-radius: 3px;
  box-shadow: 0 1px 3px rgb(58 41 32 / .25);
  pointer-events: none;
}
.lab-tag-before { left: .8rem; rotate: -2deg; }
.lab-tag-after { right: .8rem; rotate: 1.5deg; }
.lab-divider { position: absolute; top: 0; bottom: 0; left: var(--pos); z-index: 3; width: 0; pointer-events: none; }
.lab-divider::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px;
  background: var(--paper); box-shadow: 0 0 0 1px rgb(58 41 32 / .18);
}
.lab-knob {
  position: absolute; left: 0; top: 50%; translate: -50% -50%;
  width: 2.7rem; height: 2.7rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper); color: var(--cocoa);
  box-shadow: 0 2px 8px rgb(0 0 0 / .35);
}
.lab-knob svg { width: 1.4rem; height: .75rem; }
.lab-range {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 0;
  width: 100%; height: 1px; margin: 0; opacity: 0; pointer-events: none;
}
.lab-compare:has(.lab-range:focus-visible) .lab-knob { outline: 3px solid var(--rose); outline-offset: 3px; background: var(--rose-deep); color: var(--paper); }
.lab-compare.is-error::after {
  content: "This preview didn’t load. Use the full-size link below.";
  position: absolute; left: 1rem; right: 1rem; bottom: 1rem; z-index: 5;
  padding: .6rem .8rem; border-radius: 3px;
  background: var(--paper); color: var(--cocoa); font-size: .88rem;
}
.lab-caption { grid-area: caption; font-size: .82rem; line-height: 1.55; color: var(--booth-ink); margin: -.4rem 0 0; max-width: 36em; }

/* Readout + swatch ring */
.lab-panel { grid-area: panel; min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.lab-readout p { margin: 0; }
.lab-shade {
  font-size: clamp(2rem, 3.4vw, 2.7rem); line-height: 1.05;
  font-weight: 470; font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -.015em;
}
.lab-meta { font-size: .92rem; color: var(--booth-ink); margin-top: .35rem !important; }
.lab-meta [data-lab-pct] { color: var(--paper); font-weight: 600; font-variant-numeric: tabular-nums; }

.shade-ring { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .9rem .4rem; }
.shade-family { min-width: 0; display: flex; flex-direction: column; }
.shade-span-4 { grid-column: span 4; }
.shade-span-2 { grid-column: span 2; }
.shade-family-label { flex: 1; display: flex; align-items: flex-end; font-size: .74rem; line-height: 1.2; color: var(--booth-ink); margin: 0 0 .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--booth-line); }
.shade-tufts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .4rem; }
.tuft {
  --d: color-mix(in oklab, var(--c) 60%, black);
  --l: color-mix(in oklab, var(--c) 70%, white);
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding-top: .45rem;
  cursor: pointer;
  min-width: 0;
}
.tuft-hair {
  position: relative; display: block;
  width: 100%; max-width: 2.35rem; aspect-ratio: .64;
  border-radius: 38% 38% 50% 50% / 10% 10% 90% 90%;
  background:
    repeating-linear-gradient(93deg, transparent 0 2px, rgb(255 255 255 / .12) 2px 3px, transparent 3px 5px, rgb(0 0 0 / .1) 5px 6px),
    linear-gradient(90deg, var(--d), var(--c) 26%, var(--l) 47%, var(--c) 66%, var(--d));
  box-shadow: inset 0 -.5rem .7rem rgb(0 0 0 / .18), 0 2px 4px rgb(0 0 0 / .25);
}
/* the clip that holds each tuft on the ring */
.tuft-hair::before {
  content: ""; position: absolute; left: 50%; top: -.45rem; translate: -50% 0;
  width: 78%; height: .7rem; border-radius: 3px;
  background: linear-gradient(#d9d3c9, #a7a198);
  box-shadow: 0 1px 2px rgb(0 0 0 / .35);
}
.tuft-name { font-size: .72rem; line-height: 1.2; text-align: center; color: var(--booth-ink); text-wrap: balance; }
.tuft:hover .tuft-name { color: var(--paper); }
.tuft.is-checked .tuft-hair { translate: 0 -.3rem; box-shadow: 0 0 0 2px var(--booth), 0 0 0 4px var(--paper), 0 .6rem 1rem rgb(0 0 0 / .35); }
.tuft.is-checked .tuft-name { color: var(--paper); font-weight: 650; }
.tuft:has(input:focus-visible) .tuft-hair { outline: 3px solid var(--focus-on-booth); outline-offset: 6px; border-radius: 6px; }

.lab-cta { padding-top: 1.3rem; border-top: 1px solid var(--booth-line); }
.lab-cta .btn-primary { box-shadow: 0 0 0 1.5px rgb(251 247 240 / .5); }
.lab-cta .btn-primary:hover { background: var(--paper); color: var(--rose-deep); }
.lab-cta p { font-size: .82rem; line-height: 1.5; color: var(--booth-ink); margin: .7rem 0 0; max-width: 30em; }

/* ---------- Library sheet ---------- */
.library > h2:first-child { margin-top: 0; }
.library-lede { font-size: 1rem; color: var(--cocoa-2); }
.js-only { display: none; }
.js .js-only { display: inline; }
.portrait-gallery { margin: .7rem 0; border: 1px solid rgb(58 41 32 / .2); border-radius: 6px; scroll-margin-top: 1.5rem; }
.portrait-gallery > summary {
  cursor: pointer; list-style-position: inside;
  padding: .85rem 1rem; line-height: 1.4;
}
.portrait-gallery > summary:hover { background: rgb(229 218 198 / .35); }
.portrait-gallery > summary:focus-visible { outline-offset: -3px; }
.portrait-gallery[open] > summary { border-bottom: 1px solid rgb(58 41 32 / .14); }
.sheet-name { font-weight: 620; }
.sheet-desc { font-size: .88rem; color: var(--cocoa-2); }
.portrait-content { padding: 1rem; }
.example-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem .8rem; }
.example-grid figure { margin: 0; min-width: 0; }
.example-grid a { display: block; border-radius: 4px; }
.example-grid img { width: 100%; height: auto; aspect-ratio: 1; display: block; border-radius: 4px; background: var(--linen); }
.example-grid img[hidden] { display: none; }
.js .example-grid a:hover img { box-shadow: 0 0 0 2px var(--cocoa-2); }
.example-grid a.is-on-stage img { box-shadow: 0 0 0 3px var(--rose-deep); }
.example-grid figcaption { font-size: .8rem; line-height: 1.35; padding-top: .45rem; }
.example-grid figcaption strong, .example-grid figcaption span { display: block; }
.example-grid figcaption strong { font-size: .9rem; font-weight: 600; }
.example-grid figcaption span { color: var(--cocoa-2); }
.sheet-cta { margin: 1rem 0 0; font-size: .95rem; }
.library-method { margin: 1.5rem 0; }
.library-method summary { cursor: pointer; font-weight: 620; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .lab-after { transition: opacity .22s ease; }
  .tuft-hair { transition: translate .16s ease, box-shadow .16s ease; }
}

/* ---------- Responsive ---------- */
@media (max-width: 959px) {
  .lab-head { grid-template-columns: 1fr; align-items: start; }
  .lab-booth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "models" "photo" "panel" "caption";
    max-width: 40rem;
    margin-inline: var(--gutter) auto;
  }
}
@media (max-width: 699px) {
  .crumbs { margin-bottom: .6rem; }
  .lab-head { margin-bottom: 1.2rem; gap: .9rem; }
  .lab-head .hand { font-size: 1rem; margin-bottom: .3rem; }
  .lab-head h1 { font-size: clamp(2rem, 8.6vw, 2.5rem); margin-bottom: .5rem; }
  .lab-head .intro { font-size: .98rem; line-height: 1.5; }
  .library-note { font-size: .8rem; line-height: 1.5; padding: .65rem .85rem; }
  /* The booth carries the CTA on phones, keeping the portrait near the fold. */
  .js .lab-head-cta { display: none; }

  .lab-booth { width: 100%; max-width: none; margin-inline: 0; border-radius: 0; padding: 1rem var(--gutter) 1.6rem; gap: 1rem; }
  .lab-models legend { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lab-model-row {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter)); padding: .2rem var(--gutter);
    scroll-padding-inline: var(--gutter);
  }
  .lab-model-row::-webkit-scrollbar { display: none; }
  .lab-photo { margin-inline: calc(-1 * var(--gutter)); }
  .lab-compare { border-radius: 0; }
  .lab-caption { margin: .2rem 0 0; font-size: .78rem; }
  .lab-panel { gap: 1.1rem; }
  .lab-shade { font-size: 1.9rem; }
  .shade-ring { gap: .9rem .3rem; }
  .tuft-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tuft-hair { aspect-ratio: .68; max-width: 2.6rem; }
  .shade-family-label { font-size: .7rem; }

  .example-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem .5rem; }
  .example-grid figcaption { font-size: .72rem; }
  .example-grid figcaption strong { font-size: .8rem; }
  .portrait-content { padding: .7rem; }
}
