/* ---------- Root variables for dynamic background & scale steps ---------- */
:root {
  --ppm: 8px;
  --step10: 80px;    /* 10 m in pixels (overridden by JS) */
  --step100: 800px;  /* 100 m in pixels (overridden by JS) */

  /* Background gradient stops (overridden by zone classes) */
  --bg1: #003a7a;
  --bg2: #001a33;
  --bg3: #000814;

  /* NEW: Scale colors (overridden by zone classes) */
  --scale-bg: rgba(5,5,15,0.65);
  --tick-minor: rgba(180,180,220,0.25);
  --tick-major: rgba(220,220,255,0.35);
  --tick-glow: rgba(255,80,80,0.06);
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(to bottom, var(--bg1) 0%, var(--bg2) 30%, var(--bg3) 60%);
  color: #e0e0ff;
  font-family: 'Segoe UI', Arial, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background 600ms ease, filter 600ms ease;
}

/* ---------- Zone transitions (colors subtly darken) ---------- */

/* Epipelagic – brighter, cooler ticks */
body.zone-epipelagic {
  --scale-bg: rgba(10,18,40,0.55);
  --tick-minor: rgba(200,220,255,0.35);
  --tick-major: rgba(255,255,255,0.6);
  --tick-glow: rgba(100,160,255,0.06);
}

/* Mesopelagic – dimmer, bluish */
body.zone-mesopelagic {
  --scale-bg: rgba(6,12,28,0.6);
  --tick-minor: rgba(180,200,255,0.28);
  --tick-major: rgba(230,240,255,0.5);
  --tick-glow: rgba(120,160,255,0.05);
}

/* Bathypelagic – darker, neutral */
body.zone-bathypelagic {
  --scale-bg: rgba(5,8,20,0.62);
  --tick-minor: rgba(180,190,230,0.22);
  --tick-major: rgba(210,220,240,0.42);
  --tick-glow: rgba(160,120,200,0.045);
}

/* Abyssopelagic – very dark, subtle violet tint */
body.zone-abyssopelagic {
  --scale-bg: rgba(4,6,16,0.66);
  --tick-minor: rgba(180,180,220,0.18);
  --tick-major: rgba(210,210,240,0.36);
  --tick-glow: rgba(200,120,160,0.038);
}

/* Hadalpelagic – darkest, faint red accents */
body.zone-hadalpelagic {
  --scale-bg: rgba(3,4,10,0.7);
  --tick-minor: rgba(200,160,170,0.15);
  --tick-major: rgba(255,200,210,0.3);
  --tick-glow: rgba(255,80,80,0.035);
}


/* ---------- HUD: current depth ---------- */
.current-depth {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
  font-weight: bold;
  background: rgba(10, 10, 30, 0.85);
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #440000;
  box-shadow: 0 0 15px rgba(200,0,0,0.4);
  z-index: 30;
  pointer-events: none;
}

/* ---------- Zone banner ---------- */
.zone-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  color: #ffdede;
  background: rgba(40, 10, 10, 0.5);
  border: 1px solid rgba(120, 0, 0, 0.6);
  border-radius: 8px;
  text-shadow: 0 0 8px rgba(255, 64, 64, 0.35);
  box-shadow: 0 0 12px rgba(220, 20, 20, 0.15);
  z-index: 29;
  opacity: 0.92;
  transition: opacity 300ms ease;
}

/* ---------- Fixed vertical scale panels ---------- */

.scale-left, .scale-right {
  position: fixed;
  top: 0;
  height: 100vh;
  width: 10px;
  overflow: hidden;
  background-color: var(--scale-bg);
  z-index: 20;
  pointer-events: none;

  /* Ticks via gradients using variables */
  background-image:
    /* major ticks every 100m: 2px line */
    repeating-linear-gradient(
      to bottom,
      var(--tick-major),
      var(--tick-major) 2px,
      transparent 2px,
      transparent var(--step100)
    ),
    /* minor ticks every 10m: 1px line */
    repeating-linear-gradient(
      to bottom,
      var(--tick-minor),
      var(--tick-minor) 1px,
      transparent 1px,
      transparent var(--step10)
    ),
    /* optional subtle inner glow color wash */
    linear-gradient(to right, transparent, var(--tick-glow));
  background-repeat: repeat, repeat, no-repeat;
  background-size: auto, auto, 100% 100%;
  background-position: 0 0, 0 0, 0 0;

  /* Smooth color transitions between zones */
  transition: background-color 400ms ease, filter 400ms ease;
}

.scale-left { left: 0; }
.scale-right { right: 0; }

/* Container for lightweight labels that move with scroll */
.scale-content {
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  transition: transform 0.05s linear;
}

/* Only labels remain (every 100m) */
.scale-label {
  position: absolute;
  font-size: 9.5px;
  color: rgba(200,200,220,0.75);
  font-weight: 300;
  white-space: nowrap;
}
.scale-left .scale-label  { right: 6px; text-align: right; }
.scale-right .scale-label { left: 6px; }

/* ---------- Fact cards ---------- */
.fact {
  position: absolute;
  left: 12%;
  width: 76%;
  text-align: center;
  opacity: 0;
  transition: transform 0.6s ease-out, opacity 0.6s ease-out, box-shadow 0.25s ease;
  background: rgba(8, 8, 25, 0.92);
  padding: 2rem 1.5rem;
  border-radius: 12px;
  border: 1px solid #22000044;
  box-shadow: 0 4px 25px rgba(0,0,0,0.8), 0 0 12px rgba(180,0,0,0.15);
  transform: translate3d(0, 30px, 0);
  will-change: transform, opacity;
}

.fact.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.fact:hover {
  transform: translate3d(0, -8px, 0) scale(1.015);
  box-shadow: 0 12px 40px rgba(0,0,0,0.9), 0 0 30px rgba(220,20,20,0.35);
  border-color: #44000088;
  z-index: 5;
}

.fact h2 {
  margin: 0 0 1rem;
  font-size: 2.1rem;
  color: #ff4040;
  text-shadow: 0 0 10px #ff000088;
}

.fact p {
  margin: 0.8rem 0;
  line-height: 1.5;
  font-size: 1.1rem;
}

.fact img {
  max-width: 100%;
  height: auto;
  margin: 1.2rem 0 0.5rem;
  border-radius: 8px;
  border: 2px solid #111133;
  box-shadow: 0 0 20px rgba(0,0,0,0.9);
}

/* ---------- Responsive ---------- */
@media (min-width: 900px) {
  .fact { left: 22%; width: 56%; }
  .scale-left, .scale-right { width: 90px; }
  .scale-label { font-size: 10.5px; }
}

@media (max-width: 600px) {
  .current-depth { font-size: 1.2rem; padding: 6px 12px; }
  .zone-banner { font-size: 0.95rem; top: 54px; }
  .fact { padding: 1.5rem 1rem; left: 5%; width: 90%; }
  .scale-left, .scale-right { width: 55px; }
  .scale-label { font-size: 8.5px; }
}