*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #f4f4f0;
  --bg-card: #e2e2dc;
  --text: #111;
  --text-muted: #999;
  --text-light: #bbb;
  --accent: #c5e7e5;
  --border: #e0e0da;
}
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", sans-serif;
  user-select: none;
}

/* ── HEADER ─────────────────────────────────────────────── */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2rem 2.5rem 0;
  z-index: 300;
  pointer-events: none;
  will-change: opacity, transform;
}
.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
}
h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.35rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.01em;
}
h1 em {
  font-style: italic;
  color: #666;
}
.year {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
  text-align: right;
  line-height: 1.8;
}

/* ── CAROUSEL LAYER ──────────────────────────────────────── */
.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective-origin: 50% 50%;
  cursor: grab;
  overflow: hidden;
  will-change: opacity, transform;
}
.scene:active {
  cursor: grabbing;
}
.wheel {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.card {
  position: absolute;
  border-radius: 4px;
  overflow: hidden;
  will-change: transform, opacity;
  /* Force GPU antialiasing on 3D-transformed elements */
  outline: 1px solid transparent;
  -webkit-font-smoothing: antialiased;
  transform-style: flat;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
}
.edge-fade {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 20vw;
  pointer-events: none;
  z-index: 100;
}
.edge-fade-left {
  left: 0;
  background: linear-gradient(
    to right,
    var(--bg) 0%,
    var(--bg) 30%,
    transparent 100%
  );
}
.edge-fade-right {
  right: 0;
  background: linear-gradient(
    to left,
    var(--bg) 0%,
    var(--bg) 30%,
    transparent 100%
  );
}

/* ── FRONT-CARD DOT INDICATOR (mobile only) ─────────────── */
.front-dot {
  display: none;
}
@media (max-width: 768px) {
  .front-dot {
    display: block;
    position: fixed;
    top: 50%; /* overridden per-frame by JS with card-height offset */
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
  }
}

/* ── FOOTER / COUNTER ────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 2.5rem 1.8rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 300;
  pointer-events: none;
}
.counter,
.hint {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

/* ── SCROLL HINT ─────────────────────────────────────────── */
.scroll-hint {
  position: fixed;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 300;
  z-index: 300;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.4s;
}
.back-hint-arrow {
  width: 1px;
  height: 20px;
  background: linear-gradient(to top, transparent, var(--text-light));
  animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scaleY(0.6);
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* ── LOADING STATE ───────────────────────────────────────── */
#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.6s ease;
}
#loadingScreen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-text {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
}

/* ── DETAIL OVERLAY ──────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  overflow-y: auto;
}
.detail-inner {
  width: min(1100px, 83vw);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 5rem);
  align-items: center;
}
.detail-photo {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 6px;
  overflow: hidden;
  transform: scale(0.88) translateY(24px);
  opacity: 0;
  transition: none;
}
.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.detail-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  transform: translateX(32px);
  opacity: 0;
}
.detail-index {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
  margin-bottom: 1.2rem;
}
.detail-title {
  font-size: clamp(1.6rem, 2vw, 2.4rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
}
.detail-title em {
  font-style: italic;
  color: #555;
}
.detail-meta-line {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 300;
  margin-bottom: 2rem;
}
.detail-divider {
  width: 24px;
  height: 1px;
  background: var(--border);
  margin-bottom: 1.6rem;
}
.detail-journal {
  font-size: 13px;
  line-height: 1.45;
  color: #444;
  font-weight: 400;
  margin-bottom: 2.4rem;
  max-width: 45ch;
}
.detail-facts {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.fact-row:first-child {
  border-top: 1px solid var(--border);
}
.fact-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  image-rendering: pixelated;
  opacity: 0.6;
  transition: opacity 0.25s ease;
}
.fact-row:hover .fact-icon {
  opacity: 1;
}

/* ── PIXEL ICON HOVER STATES ─────────────────────────────── */
.px-icon .px-h { opacity: 0; }

/* Coordinates: ring pulses between grey and blue, dot blinks */
@keyframes px-coord-base { 0%,100% { fill: #bbb; } 50% { fill: #3b82f6; } }
@keyframes px-coord-hover { 0%,100% { opacity: 0; } 50% { opacity: 1; } }
.fact-row:hover .px-coordinates .px-b { animation: px-coord-base 1.4s ease-in-out infinite; }
.fact-row:hover .px-coordinates .px-h { animation: px-coord-hover 1.4s ease-in-out infinite; }

/* Moon: crescent fades cool blue, stars twinkle with a slight delay */
@keyframes px-moon-base  { 0%,100% { fill: #bbb; } 50% { fill: #8a9dcc; } }
@keyframes px-moon-hover { 0%,40%,100% { opacity: 0; } 60%,90% { opacity: 1; } }
.fact-row:hover .px-moon .px-b { animation: px-moon-base 1.8s ease-in-out infinite; }
.fact-row:hover .px-moon .px-h { animation: px-moon-hover 1.8s ease-in-out infinite 0.3s; }

/* Temperature — hot: thermometer flares red, heat waves flicker */
@keyframes px-temp-base  { 0%,100% { fill: #bbb; } 40% { fill: #ef4444; } 70% { fill: #fb923c; } }
@keyframes px-temp-hover { 0%,100% { opacity: 0; } 35%,65% { opacity: 1; } }
.fact-row:hover .px-temperature .px-b { animation: px-temp-base 1.2s ease-in-out infinite; }
.fact-row:hover .px-temperature .px-h { animation: px-temp-hover 0.6s ease-in-out infinite; }

/* Temperature — cold: thermometer goes icy blue, frost crystals drift in slowly */
@keyframes px-temp-cold-base  { 0%,100% { fill: #bbb; } 50% { fill: #67afee; } }
@keyframes px-temp-cold-hover { 0%,60%,100% { opacity: 0; } 75%,90% { opacity: 0.9; } }
.fact-row.temp-cold:hover .px-temperature .px-b { animation: px-temp-cold-base 2.4s ease-in-out infinite; }
.fact-row.temp-cold:hover .px-temperature .px-h { animation: px-temp-cold-hover 2.4s ease-in-out infinite; fill: #bfdbfe; }

/* Zodiac: ring glows gold, corner rays beam on and off */
@keyframes px-zodiac-base  { 0%,100% { fill: #bbb; } 50% { fill: #fcd34d; } }
@keyframes px-zodiac-hover { 0%,100% { opacity: 0; } 40%,70% { opacity: 1; } }
.fact-row:hover .px-zodiac .px-b { animation: px-zodiac-base 1.6s ease-in-out infinite; }
.fact-row:hover .px-zodiac .px-h { animation: px-zodiac-hover 1.6s ease-in-out infinite 0.2s; }
.fact-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
  min-width: 80px;
}
.fact-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 400;
  margin-left: auto;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.detail-back {
  margin-top: 2rem;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 300;
  cursor: pointer;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.up-hint-arrow {
  width: 1px;
  height: 15px;
  background: linear-gradient(to bottom, transparent, var(--text-light));
  animation: scrollPulse 2s ease-in-out infinite;
}
/* ── MOBILE DETAIL VIEW (<480px) ─────────────────────────── */
@media (max-width: 480px) {
  /* Left-align the overlay column */
  .detail-overlay {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-x: hidden;
  }

  /* 75vw column, left-aligned with breathing room at top */
  .detail-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 75vw;
    margin-left: 1.5rem;
    padding: 3rem 0 4rem;
    gap: 0;
  }

  /* Dissolve detail-info so its children become flex siblings of detail-photo,
     enabling order-based reflow across both DOM branches */
  .detail-info {
    display: contents;
  }

  /* Content order: slug → title → meta → photo → journal → facts → back */
  .detail-index     { order: 1; margin-bottom: 0.5rem; }
  .detail-title     { order: 2; margin-bottom: 0.4rem; font-size: 1.6rem; }
  .detail-meta-line { order: 3; margin-bottom: 1.2rem; }
  .detail-photo     { order: 4; width: 100%; margin-top: 0.6rem; margin-bottom: 1.2rem; transform: none; }
  .detail-divider   { display: none; }
  .detail-journal   { order: 5; margin-bottom: 1.8rem; }
  /* Break out of the 75vw column to span full viewport width */
  .detail-facts     { order: 6; width: 100vw; margin-left: -1.5rem; padding: 0 1.5rem; }

  /* Back button: fixed to top-right of viewport, always reachable while scrolling.
     Parent overlay opacity composites it, so it stays invisible until detail opens. */
  .detail-back {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    margin-top: 0;
    z-index: 210;
  }
}
