/* ── Scene: full-viewport stage ─────────────────────────────────────────── */
.scene {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  /* Tile the water texture at native size; fallback color while image loads */
  background-color: var(--ocean-mid);
  background-image: url('../location_images/background_texture.png');
  background-repeat: repeat;
  background-size: auto;
}

/* ── Water canvas: sits behind all layers ───────────────────────────────── */
#water-canvas {
  position: absolute;
  inset: 0;
  z-index: var(--z-water);
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Parallax layers ────────────────────────────────────────────────────── */
.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  will-change: transform;
  transition: transform var(--t-parallax);
}

#layer-island {
  z-index: var(--z-island);
}

#layer-districts {
  z-index: var(--z-districts);
}

/* Give the districts wrapper an explicit height matching the SVG aspect ratio.
   Without this, the empty div has height:0 and top-% marker positions
   would all collapse to 0. The ratio matches viewBox="0 0 1100 720". */
#districts-wrapper {
  aspect-ratio: 1100 / 720;
}

/* ── Island SVG wrapper: centered, fills the scene ──────────────────────── */
.island-svg-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Constrain so island fits both viewport width and height */
  width: min(100%, calc(100vh * 1100 / 720), 1200px);
  pointer-events: auto;
  transform-origin: center center;
  transition: transform var(--t-zoom);
}

.island-svg-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Loading screen ─────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #0f1c30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 0.4s;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-screen p {
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ld { display: flex; gap: 8px; }
.ld span {
  width: 20px; height: 20px; border-radius: 4px;
  animation: ldp 1.1s ease-in-out infinite;
  position: relative;
}
.ld span::before {
  content: ''; position: absolute; top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 10px; height: 6px; border-radius: 3px 3px 0 0;
  background: inherit;
}
.ld span:nth-child(1) { background: #f2cd37; }
.ld span:nth-child(2) { background: #006cb7; animation-delay: .18s; }
.ld span:nth-child(3) { background: #e3000b; animation-delay: .36s; }

@keyframes ldp {
  0%, 100% { transform: translateY(0) scale(.85); opacity: .5; }
  45% { transform: translateY(-10px) scale(1); opacity: 1; }
}

/* ── Page title (top-left overlay on the island scene) ──────────────────── */
#page-title {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: var(--z-districts);
  pointer-events: none;
}

#page-title h1 {
  display: flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

.lego-word-gap {
  display: inline-block;
  width: 8px;
}

.lego-brick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', 'Nunito', Arial, sans-serif;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
  width: 36px;
  height: 36px;
  background: var(--brick-bg, #e3000b);
  color: var(--brick-text, #ffffff);
  border-radius: 5px;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.45),
    inset 0 -3px 0 rgba(0,0,0,0.25),
    inset 0 2px 0 rgba(255,255,255,0.25);
  position: relative;
  text-shadow: none;
}

/* Stud on top of each brick */
.lego-brick::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 7px;
  background: var(--brick-bg, #e3000b);
  border-radius: 4px 4px 0 0;
  box-shadow:
    0 -2px 0 rgba(0,0,0,0.3),
    inset 0 2px 0 rgba(255,255,255,0.2);
}

#page-title p {
  font-size: 10px;
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 10px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  font-family: var(--font-body);
}

/* ── Year Interval Slider ───────────────────────────────────────────────── */
#year-slider-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  transition: transform 420ms cubic-bezier(.2, .8, .2, 1);
  z-index: 9999;
  background: #0f1c30;
  border: 2px solid #b38b36;
  border-radius: 28px;
  padding: 16px 32px;
  width: 560px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  color: #fff;
  font-family: var(--font-body);
}

.slider-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.slider-header-new {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.slider-year-text {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: #f2cd37;
  line-height: 1;
  letter-spacing: -0.02em;
}

.slider-count-text {
  font-size: 14px;
  color: #94a3b8;
  font-weight: 500;
}

.slider-track-container {
  position: relative;
  width: 100%;
  height: 24px;
}

/* Base track background */
.slider-track-container::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  top: 9px;
  z-index: 0;
}

/* The highlighted active track (filled via JS) */
.slider-track-fill {
  position: absolute;
  height: 6px;
  background: #f2cd37;
  border-radius: 3px;
  top: 9px;
  z-index: 1;
  pointer-events: none;
}

/* Dual range slider technique */
.slider-track-container input[type="range"] {
  position: absolute;
  width: 100%;
  height: 6px;
  top: 9px;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  z-index: 2;
  margin: 0;
}

.slider-track-container input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: transparent;
  border: none;
  border-radius: 3px;
}

.slider-track-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f2cd37;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  margin-top: -9px;
  border: 4px solid #ffffff;
  transition: transform 0.1s ease;
}

.slider-track-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-track-container input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

/* Firefox thumb styles */
.slider-track-container input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px; /* Firefox width includes border */
  height: 16px;
  border-radius: 50%;
  background: #f2cd37;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border: 4px solid #ffffff;
  transition: transform 0.1s ease;
}
.slider-track-container input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
}
.slider-track-container input[type="range"]:active::-moz-range-thumb {
  cursor: grabbing;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 12px; /* Aligns with center of thumb at min/max */
}

.tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tick-mark {
  width: 2px;
  height: 6px;
  background: #475569;
  border-radius: 1px;
}

.tick-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
  font-family: var(--font-body);
}

#year-slider-panel.slider-hidden {
  transform: translateX(-50%) translateY(calc(100% + 64px));
}
