/* home3d — the design model on its landscape (assets/fx/home3d.js). Box sizes are reserved here, so nothing moves
   when the model loads. Desktop: one full-screen block (pinned while the scroll tells the story). Phones: the copy,
   then the view (fading from white at the top to the dark of the next section at the bottom), then the slider. */
.h3d {
  --h3d-haze: #f7f5f1;
  --h3d-to: var(--ink);
  position: relative; isolation: isolate;
  background: var(--bone); color: var(--ink);
}
.h3d__copy { position: relative; z-index: 3; display: grid; gap: 18px; padding: clamp(64px, 12vw, 96px) var(--gutter) 28px; }
.h3d__copy .h2 { max-width: 15ch; margin: 0; }
.h3d__lead { margin: 0; max-width: 36ch; font-size: clamp(17px, 1.25vw, 20px); line-height: 1.6; font-weight: 400; opacity: 0.86; }
.h3d__note { margin: 0; font-size: 12px; font-family: var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.66; }

.h3d__view { position: relative; height: clamp(400px, 66svh, 640px); overflow: hidden; background: var(--h3d-haze); }
.h3d__view picture { display: contents; }
.h3d__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; transition: opacity 0.9s var(--ease-out); }
/* white in at the top, the next section's dark out at the bottom */
.h3d__view::before, .h3d__view::after { content: ''; position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none; }
.h3d__view::before { top: 0; height: 22%; background: linear-gradient(to bottom, var(--bone), rgba(255, 255, 255, 0)); }
.h3d__view::after { bottom: 0; height: 34%; background: linear-gradient(to top, var(--h3d-to) 4%, rgba(36, 35, 35, 0)); }
/* the start button: a solid pill, clear of the phones' fixed contact bar */
.h3d__start { position: absolute; left: 50%; top: 13%; translate: -50% 0; z-index: 4; white-space: nowrap; color: var(--bone); background: var(--ink); border-color: var(--ink); }
.h3d__start .pill__dot { background: var(--bone); }
.h3d__start .pill__dot svg { stroke: var(--ink) !important; }
.h3d__start:hover { color: var(--ink) !important; }
.h3d__start:hover .pill__dot { background: var(--ink); }
.h3d__start:hover .pill__dot svg { stroke: var(--bone) !important; }
.h3d--live .h3d__start { opacity: 0; pointer-events: none; }
.h3d--ready .h3d__poster { opacity: 0; }
.h3d--lost .h3d__poster { opacity: 1 !important; }
.h3d--lost .h3d__ui, .h3d--lost .h3d__panel { display: none; }

/* live */
.h3d__ui { position: absolute; inset: 0; z-index: 1; }
.h3d__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.1s var(--ease-out); touch-action: pan-y; }
.h3d--ready .h3d__canvas { opacity: 1; }
.h3d__load { position: absolute; left: 50%; bottom: 40%; translate: -50% 0; z-index: 3; display: grid; justify-items: center; gap: 10px; color: var(--ink); }
.h3d__bar { width: 160px; height: 2px; background: rgba(36, 35, 35, 0.16); overflow: hidden; }
.h3d__bar i { display: block; height: 100%; background: var(--ink); transform: scaleX(0.04); transform-origin: left; transition: transform 0.3s; }
.h3d__load[hidden], .h3d__lab[hidden] { display: none; }

/* the dark of the next section rising from the bottom at the end of the pinned story (soft edge, then solid) */
.h3d__dusk {
  position: absolute; left: 0; right: 0; top: 0; height: 200%; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom, rgba(36, 35, 35, 0), var(--h3d-to) 50%);
  transform: translateY(calc(100% - var(--h3d-dusk, 0) * 150%)); will-change: transform;
}
.h3d--still .h3d__dusk { display: none; }

/* level labels with a hairline to the model */
.h3d__labels { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; }
.h3d__lab { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; will-change: transform; }
.h3d__lab .label { font-size: 12px; letter-spacing: 0.14em; color: var(--ink); background: rgba(251, 249, 245, 0.86); padding: 4px 10px; border-radius: 999px; }
.h3d__lab i { position: relative; display: block; width: var(--lead, 40px); height: 1px; background: color-mix(in srgb, var(--ink) 42%, transparent); }
.h3d__lab i::after { content: ''; position: absolute; right: -3px; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--brick); }

/* explode slider: on the dark band under the view (phones), a small glass pill on the view (desktop) */
.h3d__panel {
  display: grid; grid-template-columns: auto 1fr 76px; align-items: center; gap: 12px;
  padding: 6px var(--gutter) 22px; background: var(--h3d-to); color: var(--bone);
}
.h3d__panel .label, .h3d__out { font-size: 12px; letter-spacing: 0.12em; }
.h3d__out { text-align: right; opacity: 0.75; font-variant-numeric: tabular-nums; }
.h3d__range { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; touch-action: pan-y; color: inherit; }
.h3d__range::-webkit-slider-runnable-track { height: 2px; background: color-mix(in srgb, currentColor 32%, transparent); border-radius: 2px; }
.h3d__range::-moz-range-track { height: 2px; background: color-mix(in srgb, currentColor 32%, transparent); }
.h3d__range::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -11px; border-radius: 50%; background: var(--bone); border: 1.5px solid var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
.h3d__range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--bone); border: 1.5px solid var(--ink); }
.h3d__range:focus-visible { outline: 2px solid var(--brick); outline-offset: 2px; box-shadow: none; }

/* desktop: one full-screen block; the copy floats over the haze above the landscape */
@media (min-width: 900px) {
  .h3d { height: 100vh; height: 100svh; min-height: 560px; overflow: hidden; background: var(--h3d-haze); }
  .h3d__copy { position: absolute; left: 0; top: 0; padding: clamp(96px, 15vh, 168px) var(--gutter) 0; max-width: calc(560px + var(--gutter)); opacity: var(--h3d-copy, 1); }
  .h3d__copy .h2 { max-width: 13ch; }
  .h3d__view { position: absolute; inset: 0; height: auto; }
  .h3d__view::before { height: 26%; }
  .h3d__start { left: var(--gutter); translate: none; top: auto; bottom: var(--gutter); }
  .h3d--still .h3d__copy { transition: opacity 0.4s; }
  .h3d__panel {
    position: absolute; right: var(--gutter); bottom: var(--gutter); z-index: 4; width: min(360px, 34vw);
    padding: 4px 18px; border-radius: 999px; border: 1px solid var(--line-dark); color: var(--ink);
    background: rgba(251, 249, 245, 0.72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    opacity: var(--h3d-ui, 1); transition: opacity 0.3s;
  }
  .h3d__panel .h3d__range::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -9px; }
  /* the pinned story makes its own way into the dark, so the view's fades stay only at the top */
  .h3d--pin .h3d__view::after { display: none; }
  .h3d--pin .h3d__view::before { opacity: var(--h3d-copy, 1); }
}

@media (prefers-reduced-motion: reduce) {
  .h3d__poster, .h3d__canvas, .h3d__panel, .h3d--still .h3d__copy { transition: none; }
}
