/* ═══════════════════════════════════════════
   DRIVERS OF CHANGE — Stylesheet v6
   StoryMe · Pengon · 2025
═══════════════════════════════════════════ */

:root {
  --gear-full:   490px;
  --gear-small:  294px;   /* 60% */
  --gear-loader: 98px;    /* 20% */
  --track-h:     72px;
  --nav-h:       56px;
  --gold:        #C4A35A;
  --deep:        #0d1a0f;
  --text:        #F0EDE6;
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: auto; }
body {
  background: var(--deep);
  color: var(--text);
  font-family: 'Ubuntu', system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { display: block; }
button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; }

/* ─────────────────────────────────────────
   SCREEN 1 — LOADER
───────────────────────────────────────── */
#loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.9s var(--ease-out);
}
#loader.out { opacity: 0; pointer-events: none; }

.loader__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/*
  Gear position derived from Illustrator canvas coords:
  Illustrator canvas: ~1600 × 900 (typical A3 landscape)
  x=1040, y=550 → approximately 65% from left, 61% from top
  We use % positioning so it works on all screens.
*/
.loader__gear-wrap {
  position: absolute;
  /* Place at convergence of drawn lines */
  left: 65%;
  top:  61%;
  transform: translate(-50%, -50%);
  width:  var(--gear-loader);
  height: var(--gear-loader);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader__gear {
  position: absolute;
  width:  var(--gear-loader);
  height: var(--gear-loader);
  object-fit: contain;
  /* Rotate around true center of the gear image */
  transform-origin: 50% 50%;
  animation: spin-cw 2.5s linear infinite;
}

.loader__pct {
  /* Left-aligned, 20px from left edge of gear */
  position: absolute;
  left: calc(100% + 20px);
  top:  50%;
  transform: translateY(-50%);
  color: #fff;
  font-family: 'Ubuntu', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ─────────────────────────────────────────
   SCREEN 2 — LANDING
───────────────────────────────────────── */
#landing {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
#landing.out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

/* Background image */
.landing__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}

/* Quds city mural — bottom portion, bleeds up */
.landing__quds {
  position: absolute;
  bottom: var(--track-h);
  left: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Gear — 100% size, centered, slow rotation, drop shadow */
.landing__gear-wrap {
  position: absolute;
  /* Horizontally centered, vertically in lower-mid area */
  left: 50%;
  top:  52%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width:  var(--gear-full);
  height: var(--gear-full);
  pointer-events: none;
}

.landing__gear {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 50% 50%;
  animation: spin-cw 18s linear infinite;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.55))
          drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

/* White rule + subtitle — sits above gear area */
.landing__subtitle-wrap {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.landing__rule {
  width: 60px;
  height: 1.5px;
  background: #fff;
  flex-shrink: 0;
}

.landing__subtitle {
  font-family: 'Ubuntu', sans-serif;
  font-size: 20px;
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.01em;
}

/* Main title block */
.landing__title-wrap {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  text-align: left;
  white-space: nowrap;
}

.landing__title {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.landing__title-line1 {
  font-family: 'Ubuntu', sans-serif;
  font-size: 45pt;
  font-weight: 500;
  font-style: italic;
  color: #fff;
  display: block;
  line-height: 1.1;
}

.landing__title-line2 {
  font-family: 'Ubuntu', sans-serif;
  font-size: 100pt;
  font-weight: 700;
  font-style: normal;
  color: #fff;
  display: block;
  line-height: 0.9;
  letter-spacing: -0.02em;
}

/* Logos */
.landing__logos {
  position: absolute;
  bottom: calc(var(--track-h) + 20px);
  left: 50%;
  transform: translateX(-50%);
  height: 44px;
  width: auto;
  z-index: 4;
  opacity: 0.9;
}

/* Bottom: tented track + drive button */
.landing__bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--track-h);
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.landing__track {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--track-h);
  object-fit: cover;
  object-position: top center;
}

.drive-btn {
  position: absolute;
  bottom: calc(var(--track-h) + 32px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 15px 52px;
  background: var(--gold);
  color: #1A1200;
  font-family: 'Ubuntu', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 3px;
  box-shadow: 0 4px 24px rgba(196,163,90,0.45);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.drive-btn:hover {
  background: #d4b86a;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 8px 36px rgba(196,163,90,0.55);
}

/* ─────────────────────────────────────────
   SCREEN 3 — BAB AL-AMOUD
───────────────────────────────────────── */
#babSection {
  position: fixed;
  inset: 0;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s var(--ease-out);
  background: #e87b3a; /* orange bg — matches illustration */
}
#babSection.visible { opacity: 1; pointer-events: all; }
#babSection.out     { opacity: 0; pointer-events: none; }

.bab__wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bab__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom; /* anchor to bottom, hide top bleed */
  transform-origin: 50% 28%;     /* zoom target: top-center gate window */
  will-change: transform;
}

/* Mask: covers any mural tips bleeding from top of PNG */
.bab__top-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 18%;   /* covers the bleed area */
  background: #e87b3a;
  z-index: 2;
}

.bab__hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  animation: bab-pulse 2.5s ease-in-out infinite;
}
.bab__hint svg { width: 20px; height: 20px; }
@keyframes bab-pulse {
  0%, 100% { opacity: 0.75; transform: translateX(-50%) translateY(0); }
  50%       { opacity: 0.35; transform: translateX(-50%) translateY(4px); }
}

/* ─────────────────────────────────────────
   SCREEN 4 — MURAL JOURNEY
───────────────────────────────────────── */
#storyStage {
  position: relative;
  /* height set by JS */
}

.mural-viewport {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--deep);
}

.mural-wrap {
  position: relative;
  height: 100vh;
  will-change: transform;
}

.mural-img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  width: auto;
  max-width: none;
  display: block;
  /* Hidden until layers assembled — base only shows if layers fail */
  opacity: 0;
}

/* ─────────────────────────────────────────
   LAYERS
───────────────────────────────────────── */
.mural-layers {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  pointer-events: none;
  /* Invisible until scroll engine initializes — prevents white flash */
  opacity: 0;

}

.mural-layer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  max-width: none;
  pointer-events: none;
  opacity: 0; /* each layer fades in after GSAP positions it */
}

/* ─────────────────────────────────────────
   GEAR + TRACK SYSTEM
───────────────────────────────────────── */
.gear-system {
  position: absolute;
  bottom: 0;
  left: 0;
  height: var(--track-h);
  pointer-events: none;
  /* width set by JS to match mural display width */
}

.track-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--track-h);
}

.track-canvas {
  position: absolute;
  bottom: 0;
  left: 0;
  /* drawn in JS by tiling the track PNG at exact gear pitch */
}

.mural-gear {
  position: absolute;
  /* bottom and left set dynamically in JS */
  object-fit: contain;
  transform-origin: 50% 50%;
  will-change: transform, left, width, height;
  pointer-events: none;
}

/* ─────────────────────────────────────────
   CHAPTER TEXT BOXES
───────────────────────────────────────── */
.chapters-wrap {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  pointer-events: none;
}

.chapter-box {
  position: absolute;
  width: 340px;
  background: rgba(12, 24, 14, 0.93);
  border: 1px solid rgba(196,163,90,0.35);
  border-radius: 6px;
  overflow: hidden;
  pointer-events: all;
  /* Start invisible and shifted down */
  opacity: 0;
  transform: translateY(24px);
  /* GSAP controls animation */
}

.chapter-box__header {
  padding: 22px 44px 16px 24px;
  border-bottom: 1px solid rgba(196,163,90,0.15);
  flex-shrink: 0;
}

.chapter-box__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.chapter-box__title {
  font-family: 'Ubuntu', serif;
  font-size: 1.25rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text);
  line-height: 1.2;
}

/* Scrollable text area inside box */
.chapter-box__body {
  padding: 16px 24px 20px;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(196,163,90,0.3) transparent;
  font-size: 0.9rem;
  line-height: 1.78;
  color: rgba(240,237,230,0.75);
}
.chapter-box__body::-webkit-scrollbar { width: 4px; }
.chapter-box__body::-webkit-scrollbar-track { background: transparent; }
.chapter-box__body::-webkit-scrollbar-thumb { background: rgba(196,163,90,0.3); border-radius: 4px; }
.chapter-box__body p + p { margin-top: 0.85em; }

.chapter-box__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.chapter-box__close:hover { opacity: 1; }
.chapter-box__close img { width: 14px; height: 14px; }

/* ─────────────────────────────────────────
   HOTSPOTS
───────────────────────────────────────── */
.hotspots-wrap {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
}

.hotspot {
  position: absolute;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.hotspot.visible { opacity: 1; pointer-events: all; }

.hotspot__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--gold);
  animation: ring-out 2.5s ease-out infinite;
}
@keyframes ring-out {
  0%   { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}
.hotspot__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(196,163,90,0.7);
  transition: transform 0.2s, box-shadow 0.2s;
}
.hotspot:hover .hotspot__dot {
  transform: scale(1.3);
  box-shadow: 0 0 18px rgba(196,163,90,0.9);
}

/* ─────────────────────────────────────────
   HOTSPOT PANEL
───────────────────────────────────────── */
.hotspot-panel {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 92vw;
  background: rgba(10,20,12,0.97);
  border-left: 1px solid rgba(196,163,90,0.2);
  backdrop-filter: blur(20px);
  z-index: 80;
  transform: translateX(100%);
  transition: transform 0.5s var(--ease-out);
  overflow-y: auto;
}
.hotspot-panel.open { transform: translateX(0); }
.hotspot-panel[aria-hidden="true"] { pointer-events: none; }

.panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.panel-close:hover { opacity: 1; }
.panel-close img { width: 16px; height: 16px; }

.panel-content { padding: 52px 30px 44px; }
.panel-chapter  { font-size: 10px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.panel-title    { font-family: 'Ubuntu', serif; font-size: 1.5rem; font-weight: 500; font-style: italic; color: var(--text); margin-bottom: 16px; line-height: 1.25; }
.panel-body     { font-size: 0.93rem; line-height: 1.8; color: rgba(240,237,230,0.72); }
.panel-body p + p { margin-top: 0.9em; }

/* ─────────────────────────────────────────
   NAVIGATION BAR
───────────────────────────────────────── */
.story-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 70;
  background: rgba(8,16,10,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(196,163,90,0.12);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.5s, transform 0.5s var(--ease-out);
}
.story-nav.visible { opacity: 1; transform: translateY(0); }

.story-nav__inner {
  max-width: 860px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}

.nav-dots {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 0;
}
.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.22);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  flex-shrink: 0;
}
.nav-dot:hover  { border-color: var(--gold); }
.nav-dot.active { background: var(--gold); border-color: var(--gold); transform: scale(1.45); }
.nav-dot.visited{ background: rgba(196,163,90,0.45); border-color: rgba(196,163,90,0.45); }
.nav-dot-line   { flex: 1; height: 1px; background: rgba(255,255,255,0.08); min-width: 10px; }

.nav-progress {
  width: 90px;
  height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.nav-progress__fill {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.1s linear;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-width: 110px;
  text-align: right;
}

/* ─────────────────────────────────────────
   AUDIO TOGGLE
───────────────────────────────────────── */
.audio-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.65);
  backdrop-filter: blur(10px);
  transition: background 0.2s;
}
.audio-toggle:hover { background: rgba(196,163,90,0.18); }
.audio-toggle svg { width: 17px; height: 17px; }

/* ─────────────────────────────────────────
   KEYFRAMES
───────────────────────────────────────── */
@keyframes spin-cw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --gear-full:   300px;
    --gear-small:  180px;
    --gear-loader: 60px;
  }
  .landing__title-line1 { font-size: 28pt; }
  .landing__title-line2 { font-size: 60pt; }
  .landing__subtitle    { font-size: 14px; }
  .hotspot-panel {
    width: 100vw;
    top: auto;
    height: 68vh;
    border-left: none;
    border-top: 1px solid rgba(196,163,90,0.2);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }
  .hotspot-panel.open { transform: translateY(0); }
}

@media (max-width: 480px) {
  .landing__title-line1 { font-size: 22pt; }
  .landing__title-line2 { font-size: 48pt; }
  .drive-btn { padding: 13px 36px; font-size: 0.88rem; }
}

/* Force all individual layers invisible until GSAP reveals them */
.mural-layer {
  opacity: 0;
}

/* All layers start invisible — GSAP reveals them */
.mural-layers .mural-layer {
  opacity: 0;

}
