/* Layer stack with a cursor-following detail card.
   Design space is 854 x 668 (the reference recording at 1x); the stage scales to fit. */

:root {
  --bg-0: #0e100f;
  --bg-1: #131514;
  --bg-2: #1a1c1b;
  --card-line: rgba(255, 255, 255, 0.075);
  --card-line-hot: rgba(206, 210, 228, 0.62);
  --label: #4b4e54;
  --label-hot: #c9cbd0;
  --panel-bg: #0a0b0b;
  --panel-line: rgba(255, 255, 255, 0.09);
  --ink: #f4f5f5;
  --ink-2: #8d9195;
  --ink-3: #5d6165;
  --ink-4: #3a3d40;
  --track: #232527;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(62% 58% at 44% 52%, var(--bg-2) 0%, var(--bg-1) 52%, var(--bg-0) 100%);
}

/* placed by app.js: --tx/--ty put the stage in the window, --fit scales it */
.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 854px;
  height: 668px;
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--fit, 1));
  transform-origin: 0 0;
}

/* ---------- 3D stack ---------- */

.scene {
  position: absolute;
  left: 370.6px;
  top: 431.6px;
  width: 0;
  height: 0;
  perspective: 983px;
  perspective-origin: 3.9px -110px;
}

.plane {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(43.6deg) rotateZ(30.3deg);
}

.layer,
.hit {
  position: absolute;
  left: calc(var(--w) * -0.5);
  top: calc(var(--h) * -0.5);
  width: var(--w);
  height: var(--h);
  border-radius: 16px;
}

/* rev 4: square layers, the same 276 x 276 as the hover card */
.plane { --w: 276px; --h: 276px; }

.layer {
  pointer-events: none;
  transform: translateZ(var(--z, 0px));
  transition:
    transform 720ms var(--ease-out),
    opacity 420ms var(--ease-out);
  opacity: var(--o, 1);
  will-change: transform;
}

.layer__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(150deg, rgba(40, 42, 43, 0.62) 0%, rgba(27, 29, 30, 0.6) 60%, rgba(22, 24, 25, 0.62) 100%);
  border: 1px solid var(--card-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  /* a transparent outline makes Chromium anti-alias the edges of 3D-rotated boxes */
  outline: 1px solid transparent;
  backface-visibility: hidden;
  transition: border-color 260ms ease, background-color 260ms ease;
}

.layer__label {
  position: absolute;
  left: 17px;
  bottom: 13px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
  white-space: nowrap;
  transition: color 260ms ease;
}

.layer.is-hot .layer__face { border-color: var(--card-line-hot); }
.layer.is-hot .layer__label { color: var(--label-hot); }

/* idle: compact, quiet stack */
.stack-idle .layer__face { border-color: rgba(255, 255, 255, 0.05); }
.stack-idle .layer__label { color: #3d4049; }
.stack-idle .layer:not(:first-child) .layer__label { color: #2a2c30; }

/* hit areas: invisible, static, receive the pointer */
.hit {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: default;
  transform: translateZ(var(--z, 0px));
  outline: none;
}

.hit:focus-visible { opacity: 1; box-shadow: 0 0 0 2px rgba(216, 255, 94, 0.9); background: transparent; }

/* ---------- detail panel: the picture only ---------- */

.panel {
  position: absolute;
  left: 0;
  top: 0;
  width: 276px;
  height: 276px;
  border-radius: 18px;
  background: var(--panel-bg);
  box-shadow:
    0 30px 60px -12px rgba(0, 0, 0, 0.6),
    0 12px 24px -8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(var(--px, 600px), var(--py, 160px), 0) scale(var(--ps, 0.97));
  transition: opacity 220ms ease;
  will-change: transform, opacity;
  z-index: 5;
}

.panel.is-on { opacity: 1; }

.panel__inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  transition: opacity 120ms linear;
}

.panel__inner.is-out { opacity: 0; transition-duration: 110ms; }

.panel__media {
  position: absolute;
  inset: 0;
  margin: 0;
  /* size, position and pad colour are set per picture by app.js */
  background-repeat: no-repeat;
}

/* hairline on top of the picture so the edge reads on dark images */
.panel__inner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  pointer-events: none;
}

.strip {
  position: absolute;
  left: 0;
  width: 100%;
  background-repeat: no-repeat;
  clip-path: inset(0 100% 0 0);
}

@media (prefers-reduced-motion: reduce) {
  .layer { transition-duration: 1ms; }
  .panel { transition-duration: 1ms; }
}
