/* Cross-document view transitions: navigating to/from detail.html morphs
   the active item's video into the detail viewer's canvas (both carry
   view-transition-name: space-model) instead of a hard cut. Browsers
   without support (Firefox) just navigate normally. */
@view-transition { navigation: auto; }
::view-transition-group(space-model) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

::selection { background: rgba(142, 142, 147, 0.4); }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--ui-font-sans, Arial, sans-serif);
  background: var(--ui-paper, #ffffff);
  color: var(--ui-ink, #1c1c19);
}

.landing {
  display: flex;
  height: 100vh;
  height: 100dvh;
  background: var(--ui-paper, #ffffff);
}

/* ---------- left: cover flow ---------- */
/* 62.6% (not an even 60/40 split) — the "untitled.mesprodukt.com" Figma
   file's "Desktop Main" frame (29:3, see js/landing.js's FIGMA_FRAME_W
   comment for the full file/node breakdown) is 1728px wide with Contents
   at exactly 1081px, info panel taking the remaining 647px. 1081/1728 =
   62.6%. */
.coverflow-panel {
  position: relative;
  width: 62.6%;
  height: 100%;
}

.coverflow {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  outline: none;
  touch-action: none;
  /* Left-edge fade: the orbit's return path (offset past ±2 sweeping back
     to the far-left seam — see KEYFRAMES in js/landing.js) lives in this
     region, so items dissolve into the edge instead of visibly traveling
     it. The counter (#index-indicator) is a sibling, not a child, so it's
     unaffected. */
  mask-image: linear-gradient(to right, transparent 0%, #000 22%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 22%);
}
.coverflow:active { cursor: grabbing; }

.coverflow-track {
  position: absolute;
  inset: 0;
}

/* No CSS transition here — js/landing.js drives transform/opacity every
   animation frame from a continuous position value (drag physics,
   momentum, spring-snap). A CSS transition on top of that would fight the
   per-frame updates and reintroduce exactly the "input now, animate a beat
   later" lag it's meant to avoid. */
/* Anchor is panel center (50%/50%) — js/landing.js's KEYFRAMES carry the
   actual per-item offset from that center (measured off the real Figma
   node, see the comment above FIGMA_FRAME_W) as part of the transform, so
   the CSS anchor itself just needs to be a plain center point. */
.cover-item {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  will-change: transform, opacity;
}
/* Each item's canvas is a lightweight Draco GLB turntable. Sized in vh (not
   fixed px) so it scales with viewport height while preserving the 1.25
   aspect ratio of the active-item box. */
.cover-item canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 85vh;
  height: 68vh;
  background: transparent;
  pointer-events: none;
}
.cover-item::after {
  content: '';
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 72%;
  width: 56%;
  height: 18%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.08) 42%, transparent 72%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 250ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 250ms cubic-bezier(0.23, 1, 0.32, 1);
  pointer-events: none;
}
.coverflow.shadow-ready .cover-item.is-active::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.cover-item:focus-visible {
  outline: 1px dotted var(--ui-ink, #1c1c19);
  outline-offset: 6px;
}
.coverflow-benchmark {
  position: fixed;
  z-index: 20;
  left: 20px;
  bottom: 20px;
  padding: 9px 12px;
  color: var(--ui-ink, #1c1c19);
  background: var(--ui-paper-raised, #fbfaf6);
  border: 1px solid var(--ui-rule, rgba(28, 28, 25, 0.42));
  border-radius: 0;
  font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.01em;
}

@media (prefers-reduced-motion: reduce) {
  .cover-item::after,
  .coverflow.shadow-ready .cover-item.is-active::after {
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
  }
}

/* Figma "Desktop Main v1" counter: a compact outlined box at x=221 of the
   1081px coverflow contents area, vertically centered on the frame. */
.index-indicator {
  position: absolute;
  /* Keep the right edge anchored to the Figma counter position; width
     changes therefore grow only toward the left. */
  left: calc(20.4% + 136px);
  top: 50%;
  transform: translate(-100%, -50%);
  display: inline-flex;
  width: 112px;
  height: 64px;
  align-items: center;
  justify-content: flex-end;
  padding-right: 18px;
  border: 1px solid var(--ui-ink, #1c1c19);
  background: var(--ui-paper-raised, #fbfaf6);
  color: var(--ui-ink, #1c1c19);
  font-family: var(--ui-font-display, Georgia, serif);
  font-size: 28px;
  font-weight: 400;
  font-variant-numeric: tabular-nums; /* fixed digit width so a roll never shifts neighboring characters */
  line-height: 1;
  pointer-events: none; /* sits over the coverflow panel — must not steal its drag/click */
  transition: width 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
.index-indicator.is-double-digit { width: 128px; }

/* Rolling-digit transition (js/landing.js's updateCounter): each character
   is its own clipped slot; a changed one holds both the outgoing and
   incoming glyph stacked, and only that slot animates. --dir (set inline
   per slot) is +1 rolling forward (number went up — old exits upward, new
   enters from below, both moving the same direction) or -1 rolling back. */
.digit-slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1em;
  width: 0.62em;
  text-align: center;
  vertical-align: middle;
}
.digit { display: block; }
.intro-total-rail {
  display: block;
  will-change: transform;
}
.digit-out {
  position: absolute;
  inset: 0;
  animation: digit-roll-out 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}
.digit-in {
  animation: digit-roll-in 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}
.digit-sequence {
  position: absolute;
  inset: 0;
  animation-name: digit-roll-sequence;
}
.digit-sequence > span {
  display: block;
  height: 1em;
}
@keyframes digit-roll-out {
  to { transform: translateY(calc(var(--dir) * -100%)); opacity: 0; }
}
@keyframes digit-roll-in {
  from { transform: translateY(calc(var(--dir) * 100%)); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes digit-roll-sequence {
  from { transform: translateY(var(--sequence-start)); opacity: 1; }
  to { transform: translateY(var(--sequence-end)); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .digit-out, .digit-in { animation: none; }
  .digit-out { display: none; } /* skip straight to the new value, no stacked old glyph left visible */
}

/* ---------- right: title / copy ---------- */
/* Figma's "Text" frame (29:17) is NOT top-padded — it's a 383px-tall block
   vertically centered on the panel (y=367..750 of a 1117-tall screen,
   center=558.5 = dead center), 647px wide (fills the whole info panel),
   with the title/body column inset 35px symmetrically on both sides
   (35/647 = 5.4%). `align-items: center` reproduces that centering
   natively instead of guessing a top padding. */
.info-panel {
  width: 37.4%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 5.4%;
}

.info {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.info h1 {
  font-family: var(--ui-font-display, Georgia, serif);
  font-size: clamp(32px, 2.2vw, 40px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.018em;
  margin: 0;
}

.info p {
  max-width: 52ch;
  font-size: 13px;
  line-height: 1.78;
  color: var(--ui-ink, #1c1c19);
  margin: 0;
  word-break: keep-all;
}

/* Credit names stay typographically still. Interaction is shown with a
   precise underline so the paragraph never wobbles or changes its rhythm. */
.credit {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: inline-block;
  padding: 0 1px;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}
.credit:focus-visible {
  color: inherit;
  text-decoration-style: dotted;
  text-decoration-color: currentColor;
}
.credit:active { opacity: 0.6; }

/* A caption-like information panel anchored to the selected name. */
.credit-popup {
  position: fixed;
  z-index: 100;
  width: 260px;
  max-width: calc(100vw - 32px);
  background: var(--ui-paper-raised, #fbfaf6);
  border: 1px solid var(--ui-ink, #1c1c19);
  border-radius: 0;
  padding: 18px 20px;
  box-shadow: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms var(--ui-ease-out, cubic-bezier(0.23, 1, 0.32, 1)),
    transform 180ms var(--ui-ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}
.credit-popup[hidden] { display: none; }
.credit-popup.is-open { opacity: 1; transform: translateY(0); }
.credit-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  border-radius: 0;
  font-family: var(--ui-font-sans, Arial, sans-serif);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  color: var(--ui-ink, #1c1c19);
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .credit-popup-close:hover {
    color: var(--ui-ink, #1c1c19);
    background: var(--ui-paper-deep, #ece9e0);
  }
}
.credit-popup-name {
  margin: 0 0 8px;
  font-family: var(--ui-font-sans, Arial, sans-serif);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}
.credit-popup-affiliation {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ui-ink, #1c1c19);
}
.credit-popup-contact {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.45;
}
.credit-popup-contact a {
  width: fit-content;
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .credit-popup-contact a:hover { text-decoration-color: currentColor; }
}

/* ---------- mobile / tablet portrait ----------
   A narrow screen is a different reading order, not a scaled desktop: the
   space selector stays as a focused first screen and the project text flows
   naturally below it. Dynamic viewport units avoid Safari's URL bar making
   the selector jump in height. */
@media (max-width: 900px) {
  html, body { height: auto; min-height: 100%; }

  .landing {
    display: block;
    height: auto;
    min-height: 100dvh;
  }

  .coverflow-panel {
    width: 100%;
    height: 62svh;
    min-height: 420px;
    max-height: 620px;
  }

  .coverflow {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 13%, #000 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 13%, #000 100%);
  }

  .cover-item canvas {
    width: min(112vw, 34rem);
    height: min(89.6vw, 27.2rem);
  }

  .index-indicator {
    left: max(20px, env(safe-area-inset-left));
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
  }

  .info-panel {
    width: 100%;
    height: auto;
    display: block;
    padding: 32px max(20px, env(safe-area-inset-right))
      calc(52px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  }

  .info { gap: 24px; }
  .info h1 {
    font-size: clamp(34px, 10vw, 46px);
    line-height: 0.96;
    letter-spacing: -0.018em;
  }
  .info p {
    max-width: 58ch;
    font-size: 12.5px;
    line-height: 1.78;
  }

  .credit {
    padding: 10px 2px;
    margin: -10px -2px;
    touch-action: manipulation;
  }

  .credit-popup {
    left: max(16px, env(safe-area-inset-left)) !important;
    right: max(16px, env(safe-area-inset-right));
    top: auto !important;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    padding: 20px 52px 20px 20px;
    transform-origin: center bottom !important;
  }

  .credit-popup-close {
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 420px) and (max-height: 740px) {
  .coverflow-panel { height: 59svh; min-height: 360px; }
}

@media (max-width: 600px) {
  html,
  body,
  .landing,
  .coverflow-panel,
  .coverflow {
    background: #fff;
  }

  .coverflow-panel {
    position: sticky;
    top: 0;
    z-index: 0;
    height: 100svh;
    min-height: 100svh;
    max-height: none;
  }

  .index-indicator {
    width: 96px;
    height: 52px;
    padding-right: 21px;
    font-size: 22px;
  }
  .index-indicator.is-double-digit { width: 110px; }

  .info-panel {
    position: relative;
    z-index: 2;
    min-height: 100svh;
    margin-top: -30svh;
    padding-top: 10svh;
    background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0.84) 8svh,
      #fff 16svh
    );
  }
  .info-panel::after {
    content: '';
    position: absolute;
    z-index: 3;
    top: 0;
    left: 0;
    right: 0;
    height: 32svh;
    background: rgba(255, 255, 255, 0.01);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent 30%, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, transparent 30%, #000 100%);
    opacity: 1;
    pointer-events: none;
    transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1);
  }
  .mobile-info-scrolled .info-panel::after { opacity: 0; }
  .info { position: relative; z-index: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .credit::after { transition: none; }
  .credit-popup { transition: none; }
  .info-panel::after { transition: none; }
}

@media (prefers-reduced-transparency: reduce) and (max-width: 600px) {
  .info-panel::after {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.92));
  }
}
