/**
 * Gallery lab stage. OSD = huddi.css
 */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--stage-bg, #f7f3ec);
  color: var(--stage-ink, #1c1916);
}

body[data-theme="paper"] {
  --stage-bg: #f4f2ec;
  --stage-ink: #16140f;
  --stage-muted: #6b6760;
  --stage-line: #d8d3c8;
  --paper-white: #fffcf7;
}
body[data-theme="ink"] {
  --stage-bg: #0c0b09;
  --stage-ink: #ece7dc;
  --stage-muted: #8c887e;
  --stage-line: #262320;
  --paper-white: #f4f0e6;
}

#page {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.75rem);
  padding-right: max(clamp(1.25rem, 4vw, 2.75rem), min(24ch, 30vw));
  padding-bottom: 5rem;
}
body.osd-dock-tl #page {
  padding-right: clamp(1.25rem, 4vw, 2.75rem);
  padding-left: max(clamp(1.25rem, 4vw, 2.75rem), min(24ch, 30vw));
}

.section {
  border-top: 1px solid var(--stage-line);
  padding: 2.25rem 0 1.5rem;
  overflow: visible;
}
.section:first-of-type { border-top: none; }

.section__label {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stage-muted);
  margin-bottom: 0.75rem;
}
.section__hint {
  font-size: 0.85rem;
  color: var(--stage-muted);
  max-width: 36rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  font-family: "Instrument Sans", system-ui, sans-serif;
}

/* ── Print atom ─────────────────────────────────────────── */

.if-print {
  position: relative;
  width: 100%;
  max-width: 100%;
  display: block;
}
.if-print__paper {
  background: var(--paper-white);
  padding: var(--print-border, 6px);
  border-radius: var(--print-radius, 0);
  box-shadow: var(--print-shadow);
  height: 100%;
  box-sizing: border-box;
}
.if-print__frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ddd;
  line-height: 0;
}
.if-print__bh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  filter: blur(12px);
  transform: scale(1.08);
  transition: opacity 400ms ease;
}
.if-print__bh.is-done {
  opacity: 0;
  pointer-events: none;
}
.if-print__img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  vertical-align: middle;
}
.if-print.is-interactive {
  cursor: pointer;
}
.if-print.is-interactive:focus-visible {
  outline: 2px solid #c45c3e;
  outline-offset: 4px;
}

/* ── Collection stage (pile → fan → masonry → immersive) ─ */

.if-collection {
  position: relative;
  width: 100%;
  min-height: 380px;
}
.if-collection__viewport {
  position: relative;
  width: 100%;
  min-height: 360px;
  /* height driven by JS springs */
}
.if-collection__card {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: center center;
  will-change: transform, width, height, opacity;
  cursor: pointer;
  /* no CSS transition on transform — springs own pose */
  transition: none;
}
.if-collection__print {
  width: 100%;
  height: 100%;
}
.if-collection__print .if-print,
.if-collection__print .if-print__paper {
  width: 100%;
  height: 100%;
}
.if-collection__hit {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -55%);
  width: min(240px, 70%);
  height: min(300px, 80%);
  z-index: 80;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.if-collection__dim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #0c0b09;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}
.if-collection__dim.is-on {
  pointer-events: auto;
}
.if-collection[data-mode="immersive"] .if-collection__viewport {
  position: fixed;
  inset: 0;
  z-index: 35;
  min-height: 100vh;
  padding: 0;
}
.if-collection[data-mode="immersive"] .if-collection__card {
  cursor: default;
}
.if-collection[data-mode="immersive"] .if-collection__card[style*="z-index: 200"],
.if-collection[data-mode="immersive"] .if-collection__card {
  cursor: pointer;
}

/* ── Hero ───────────────────────────────────────────────── */

.if-hero {
  position: relative;
  margin-bottom: 0.5rem;
}
.if-hero__title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  max-width: 18ch;
  color: var(--stage-ink);
}
.if-hero__title.is-instrument {
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0;
}
.if-hero__media {
  width: 100%;
  max-height: 72vh;
}
.if-hero__media .if-print {
  max-height: 72vh;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}
.if-hero.is-angled .if-hero__media {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  overflow: visible;
}
.if-hero.is-angled .if-hero__tilt {
  transform-origin: center center;
  max-width: min(90%, 52rem);
  width: 100%;
}

/* ── Grid ───────────────────────────────────────────────── */

.if-grid {
  display: grid;
  gap: var(--grid-gap, 20px);
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 180px), 1fr));
}
.if-grid.is-scroll-x {
  display: flex;
  overflow-x: auto;
  gap: var(--grid-gap, 20px);
  padding-bottom: 1rem;
  scroll-snap-type: x mandatory;
}
.if-grid.is-scroll-x .if-grid__cell {
  flex: 0 0 min(70vw, 280px);
  scroll-snap-align: start;
}
.if-grid.is-scroll-y {
  display: flex;
  flex-direction: column;
  gap: var(--grid-gap, 20px);
  max-width: 36rem;
  margin-inline: auto;
}
.if-grid__cell .if-print {
  width: 100%;
}

/* ── Immersive ──────────────────────────────────────────── */

.if-immersive {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 11, 9, var(--imm-dim, 0.55));
  padding: 2rem;
}
.if-immersive.is-open {
  display: flex;
}
.if-immersive__print {
  width: min(92vw, 1000px);
  max-height: 88vh;
}
.if-immersive__print .if-print {
  max-height: 88vh;
}
.if-immersive__meta {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}
.if-immersive__caption {
  position: absolute;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 36rem;
  text-align: center;
  color: #fff;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 0.9rem;
}

#story {
  font-family: "Instrument Sans", system-ui, sans-serif;
  max-width: 38rem;
  line-height: 1.65;
  color: var(--stage-ink);
}
#story h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  font-size: 1.75rem;
  margin: 1.5rem 0 0.75rem;
  line-height: 1.2;
}
#story p { margin-bottom: 1rem; color: var(--stage-muted); }

#hint {
  position: fixed;
  bottom: 10px;
  left: 14px;
  z-index: 35;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stage-muted);
  opacity: 0.65;
  pointer-events: none;
}

/* HUDDI chrome host */
#chrome {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
#topRight {
  position: absolute;
  top: calc(8px * var(--s, 2));
  right: calc(8px * var(--s, 2));
  bottom: calc(8px * var(--s, 2));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  z-index: 60;
}
body.osd-dock-tl #topRight {
  right: auto;
  left: calc(8px * var(--s, 2));
  align-items: flex-start;
}
#menu {
  pointer-events: auto;
  width: max-content;
  max-width: min(100%, 22ch);
  max-height: calc(100dvh - 16px * var(--s, 2));
  overflow-y: scroll;
  scrollbar-width: none;
}
#menu::-webkit-scrollbar { display: none; }
#trkStack {
  position: absolute;
  left: calc(8px * var(--s, 2));
  bottom: calc(8px * var(--s, 2));
  pointer-events: none;
  z-index: 60;
}
body.osd-dock-tl #trkStack {
  left: auto;
  right: calc(8px * var(--s, 2));
}
#trk { pointer-events: auto; display: flex; gap: 1ch; }
#hudChip {
  position: absolute;
  top: calc(8px * var(--s, 2));
  left: calc(8px * var(--s, 2));
  display: none;
  z-index: 61;
  pointer-events: none;
  transition: opacity 280ms ease-in-out;
}
#hudChip.is-hiding { opacity: 0; }
body.osd-dock-tl #hudChip {
  left: auto;
  right: calc(8px * var(--s, 2));
}
