/* In-page album layer: the album opens on top of the timeline instead of
   navigating, so nothing jumps while it loads.

   Stage 1  click → load everything invisibly (timeline stays exactly as it was)
   Stage 2  the photos rush past you in black space, upright, rounded corners
   Stage 3  the grid itself flies in from far away, grows, and becomes the UI */

.album-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #06070a;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transition: opacity 0.25s linear;
  will-change: opacity;
}
.album-layer.on { opacity: 1; }

.album-layer .album-view-inner {
  transform: perspective(900px) translateZ(0);
  transform-origin: 50% 42%;
  transition:
    transform 0.78s cubic-bezier(0.16, 0.72, 0.1, 1),
    filter 0.55s ease,
    opacity 0.2s ease;
  will-change: transform, filter, opacity;
}

/* parked in the dark and invisible, so it can never be seen before its cue.
   Only -3000px away, not -6200, so when it arrives it reads as one more photo
   coming at you rather than a speck growing out of nothing. */
.album-layer.far .album-view-inner {
  transform: perspective(900px) translateZ(-3000px);
  filter: blur(2.5px);
  opacity: 0;
}

.album-layer .album-head { padding-top: 84px; }

/* loading hint: only shows if the wait is long enough to notice */
.load-line {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  z-index: 95;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.load-line.on { opacity: 1; }
.load-line span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(to right, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.album-layer .album-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 70;
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--paper);
  background: rgba(244, 239, 231, 0.07);
  border: 1px solid var(--line);
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.album-layer .album-close:hover { background: rgba(232, 176, 106, 0.85); color: var(--ink); }

.tunnel-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 87;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s linear;
}
.tunnel-canvas.on { opacity: 1; }

body.album-open { overflow: hidden; }

/* The still that grows out of the tapped card and dissolves into the flight.
   A real element with real geometry, so the zoom is always visible. */
.handoff {
  position: fixed;
  z-index: 92;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9);
  will-change: left, top, width, height, opacity, border-radius;
  transition:
    left 0.5s cubic-bezier(0.16, 0.72, 0.1, 1),
    top 0.5s cubic-bezier(0.16, 0.72, 0.1, 1),
    width 0.5s cubic-bezier(0.16, 0.72, 0.1, 1),
    height 0.5s cubic-bezier(0.16, 0.72, 0.1, 1),
    border-radius 0.5s ease,
    opacity 0.4s ease;
}
.handoff.grown { border-radius: 0; }
.handoff.dissolve { opacity: 0; }

/* once the landing transition has finished, drop the 3D transform entirely so
   the grid behaves like a normal page (and view transitions inside it are clean) */
.album-layer.settled .album-view-inner {
  transform: none;
  filter: none;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .tunnel-canvas { display: none !important; }
  .album-layer,
  .album-layer .album-view-inner { transition: none !important; transform: none !important; filter: none !important; opacity: 1 !important; }
}
