/* ==========================================================
   ZLIJE — cinematic 3D journey
   ========================================================== */
:root {
  --ink: #07080f;
  --bone: #f2ece0;
  --bone-dim: rgba(242, 236, 224, .66);
  --teal: #2fb3a7;
  --saffron: #f0b323;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Manrope", system-ui, sans-serif;
  --arabic: "Amiri", serif;
  --gutter: clamp(16px, 4vw, 64px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.is-loading { overflow: hidden; }
a { color: inherit; text-decoration: none; }
h1, h2 { font-family: var(--serif); font-weight: 300; margin: 0; line-height: .98; letter-spacing: -.01em; }
h2 em { font-style: italic; color: var(--saffron); }
p { margin: 0; }

.eyebrow {
  font-size: .7rem; font-weight: 600; letter-spacing: .32em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 1.2rem;
}
.eyebrow b { color: var(--saffron); font-weight: 600; margin-right: .8em; }

/* ---------- Stage ---------- */
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, rgba(4,5,10,.7) 100%);
}
.grain {
  position: fixed; inset: -50%; z-index: 2; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1s steps(4) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-3%)} 75%{transform:translate(-2%,-1%)} }
.journey { position: relative; z-index: -1; }

.fallback { display: none; position: fixed; inset: 0; }
.fallback img { width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.no-webgl .fallback { display: block; }
.no-webgl #scene, .no-webgl .labels, .no-webgl .readout { display: none; }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; align-content: center; gap: 1.4rem;
  background: var(--ink);
}
.loader__star { width: 92px; height: 92px; overflow: visible; }
.loader__star polygon { fill: none; stroke: var(--saffron); stroke-width: 1.2; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.6s var(--ease) forwards; }
.loader__star .inner { stroke: var(--teal); animation-delay: .25s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.loader__word { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.loader__word .ar { font-family: var(--arabic); font-size: 2rem; line-height: 1.2; }
.loader__word .lat { font-size: .66rem; letter-spacing: .6em; padding-left: .6em; color: var(--bone-dim); }
.loader__bar { width: 120px; height: 1px; background: rgba(242,236,224,.15); }
.loader__bar span { display: block; height: 100%; width: 100%; background: var(--saffron); transform-origin: left; transform: scaleX(0); transition: transform .6s var(--ease); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 22px var(--gutter);
}
.nav__brand { display: flex; align-items: center; gap: .7rem; font-weight: 600; letter-spacing: .42em; font-size: .8rem; }
.nav__mark { width: 22px; height: 22px; fill: none; stroke: var(--saffron); stroke-width: 5; transition: transform 1.2s var(--ease); }
.nav__brand:hover .nav__mark { transform: rotate(45deg); }
.nav__ar { font-family: var(--arabic); font-size: 1.15rem; color: var(--bone-dim); }
.nav__cta {
  font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  border: 1px solid rgba(242,236,224,.4); padding: .6rem 1.1rem; border-radius: 999px;
  backdrop-filter: blur(8px); background: rgba(7,8,15,.25);
  transition: background .5s var(--ease), color .5s, border-color .5s;
}
.nav__cta:hover { background: var(--saffron); color: var(--ink); border-color: var(--saffron); }
@media (max-width: 640px) { .nav__ar { display: none; } }

.progress { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 60; }
.progress span { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--teal), var(--saffron), #a3271f); }

/* ---------- HUD ---------- */
.hud { position: fixed; right: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 40; }
.hud__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; align-items: flex-end; }
.hud__list li {
  display: flex; align-items: center; gap: .8rem; cursor: pointer;
  font-size: .64rem; letter-spacing: .24em; text-transform: uppercase; color: rgba(242,236,224,.38);
  transition: color .5s var(--ease);
}
.hud__list li::after {
  content: ""; width: 7px; height: 7px; border: 1px solid currentColor; transform: rotate(45deg);
  transition: background .5s, border-color .5s, box-shadow .5s;
}
.hud__list li:hover { color: var(--bone); }
.hud__list li.is-active { color: var(--bone); }
.hud__list li.is-active::after { background: var(--saffron); border-color: var(--saffron); box-shadow: 0 0 14px var(--saffron); }
.hud__list li span { opacity: 0; transform: translateX(8px); transition: opacity .5s, transform .5s var(--ease); }

.readout {
  position: fixed; right: var(--gutter); bottom: 26px; z-index: 40; text-align: right;
  font-variant-numeric: tabular-nums;
}
.readout__k { display: block; font-size: .6rem; letter-spacing: .3em; text-transform: uppercase; color: rgba(242,236,224,.45); }
.readout__v { font-family: var(--serif); font-size: 1.6rem; font-weight: 300; }

@media (max-width: 860px) {
  .hud { display: none; }
  .readout { bottom: 18px; }
  .readout__v { font-size: 1.2rem; }
}

/* ---------- Chapter copy ---------- */
.chapters { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.ch {
  position: absolute; left: var(--gutter); bottom: 13vh; width: min(30rem, calc(100vw - 2 * var(--gutter)));
  opacity: 0; visibility: hidden; will-change: opacity, transform;
}
.ch h2 { font-size: clamp(2.6rem, 6vw, 5.6rem); margin-bottom: 1.4rem; text-shadow: 0 4px 40px rgba(0,0,0,.6); }
.ch p:not(.eyebrow) { color: var(--bone-dim); font-size: clamp(.95rem, 1.2vw, 1.06rem); max-width: 36ch; text-shadow: 0 2px 18px rgba(0,0,0,.8); }
.ch--center { left: 0; right: 0; margin: 0 auto; bottom: auto; top: 50%; width: min(56rem, calc(100vw - 2 * var(--gutter))); text-align: center; translate: 0 -50%; }
.ch--center p:not(.eyebrow) { margin: 0 auto; }

.ch--hero { left: 0; right: 0; margin: 0 auto; bottom: auto; top: 0; height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 var(--gutter); }
.ch--hero h1 { font-size: clamp(5rem, 19vw, 19rem); letter-spacing: .04em; line-height: .85; text-shadow: 0 10px 70px rgba(0,0,0,.7); }
.ch--hero .eyebrow { color: var(--bone-dim); }
.ch--hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 60% 45% at 50% 50%, rgba(7,8,15,.55), transparent 75%); }
.ch__ar { font-family: var(--arabic); font-size: clamp(1.5rem, 2.8vw, 2.3rem); color: var(--saffron); margin: .4rem 0 .6rem; }
.ch--hero .ch__lead { max-width: 30rem; color: var(--bone-dim); text-shadow: 0 2px 20px rgba(0,0,0,.9); }
.scroll-cue { position: absolute; left: 50%; bottom: 30px; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: .6rem; font-size: .62rem; letter-spacing: .4em; text-transform: uppercase; color: var(--bone-dim); }
.scroll-cue i { width: 1px; height: 44px; background: linear-gradient(var(--bone), transparent); animation: cue 2.2s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

.ch--end { pointer-events: auto; padding: 3rem var(--gutter); border-radius: 28px; background: radial-gradient(ellipse at center, rgba(7,8,15,.72), rgba(7,8,15,0) 72%); }
.ch__links { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-top: 2.2rem; }
.ch__links a { border: 1px solid rgba(242,236,224,.35); padding: .8rem 1.4rem; border-radius: 999px; font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; backdrop-filter: blur(8px); background: rgba(7,8,15,.3); transition: background .5s var(--ease), color .5s, border-color .5s; }
.ch__links a:hover { background: var(--saffron); color: var(--ink); border-color: var(--saffron); }

@media (max-width: 760px) {
  .ch { bottom: 9vh; }
  .ch h2 { font-size: clamp(2.2rem, 11vw, 3.4rem); margin-bottom: .9rem; }
}

/* ---------- 3D-anchored callouts ---------- */
.labels { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.lbl {
  position: absolute; left: 0; top: 0; display: flex; align-items: center;
  opacity: 0; will-change: transform, opacity;
}
.lbl__dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--saffron); background: rgba(240,179,35,.25); flex: none; translate: -50% 0; box-shadow: 0 0 12px rgba(240,179,35,.6); }
.lbl__line { width: 54px; height: 1px; background: linear-gradient(90deg, var(--saffron), rgba(242,236,224,.5)); flex: none; }
.lbl__text { padding-left: 10px; white-space: nowrap; }
.lbl__text b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.35rem; line-height: 1.05; }
.lbl__text small { display: block; font-size: .6rem; letter-spacing: .22em; text-transform: uppercase; color: var(--bone-dim); }
.lbl--left { flex-direction: row-reverse; }
.lbl--left .lbl__dot { translate: 50% 0; }
.lbl--left .lbl__line { background: linear-gradient(270deg, var(--saffron), rgba(242,236,224,.5)); }
.lbl--left .lbl__text { padding-left: 0; padding-right: 10px; text-align: right; }

.lbl--era { flex-direction: column; translate: -50% -50%; text-align: center; }
.lbl--era .lbl__text b { text-shadow: 0 4px 30px rgba(0,0,0,.85); }
.lbl--era .lbl__dot { translate: 0 0; order: 3; }
.lbl--era .lbl__line { width: 1px; height: 40px; order: 2; background: linear-gradient(var(--bone-dim), var(--saffron)); }
.lbl--era .lbl__text { padding: 0 0 10px; }
.lbl--era .lbl__text b { font-size: clamp(2rem, 4.4vw, 3.8rem); font-weight: 300; }
.lbl--era .lbl__text small { font-size: .7rem; color: var(--saffron); margin-top: .4rem; }

@media (max-width: 760px) {
  .lbl__line { width: 26px; }
  .lbl__text b { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .scroll-cue i { animation: none; }
}

/* ---------- Jump curtain (cuts between distant chapters) ---------- */
.curtain {
  position: fixed; inset: 0; z-index: 80; visibility: hidden; opacity: 0;
  display: grid; place-items: center; align-content: center; gap: 1.2rem;
  background: var(--ink);
}
.curtain svg { width: 56px; height: 56px; fill: none; stroke: var(--saffron); stroke-width: 2; animation: spin 6s linear infinite; }
.curtain__label { font-family: var(--serif); font-style: italic; font-size: clamp(1.6rem, 3vw, 2.4rem); color: var(--bone); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Section links in the film's nav ---------- */
.nav__links { display: flex; gap: 1.8rem; }
.nav__links a { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; opacity: .78; transition: opacity .3s, color .3s; }
.nav__links a:hover { opacity: 1; color: var(--saffron); }
@media (max-width: 980px) { .nav__links { display: none; } }

/* ---------- Gilded type: legible over the mosaic ---------- */
:root {
  --gold-grad: linear-gradient(176deg, #fff6da 0%, #f7d98a 34%, #e6ad45 62%, #f9dc92 100%);
  --gold-em: linear-gradient(176deg, #ffe7a6 0%, #f2b43a 55%, #d88a1c 100%);
  --cream: #f8ead0;
  --halo: 0 1px 2px rgba(5,5,10,.95), 0 0 10px rgba(5,5,10,.85), 0 0 26px rgba(5,5,10,.7);
}
.ch h2, .ch--hero h1, .lbl--era .lbl__text b, .curtain__label {
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; text-shadow: none;
  filter: drop-shadow(0 2px 1.5px rgba(5,5,10,.95)) drop-shadow(0 0 16px rgba(5,5,10,.8)) drop-shadow(0 0 34px rgba(240,179,35,.32));
}
.ch h2 em { background: var(--gold-em); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ch p:not(.eyebrow), .ch--hero .ch__lead { color: var(--cream); font-weight: 500; text-shadow: var(--halo); }
.ch .eyebrow, .ch--hero .eyebrow { color: #f3c969; text-shadow: var(--halo); }
.ch .eyebrow b { color: #ffd77a; }
.ch__ar { color: #f7cf6d; text-shadow: var(--halo), 0 0 24px rgba(240,179,35,.4); }
.scroll-cue { color: var(--cream); text-shadow: var(--halo); }
/* soft dark pool behind the side copy */
.ch:not(.ch--hero):not(.ch--end)::before {
  content: ""; position: absolute; inset: -4rem -5rem; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(7,8,15,.66), rgba(7,8,15,.35) 55%, rgba(7,8,15,0));
}
.lbl__text b { color: #f7d98a; text-shadow: var(--halo); }
.lbl__text small { color: var(--cream); text-shadow: var(--halo); }
.hud__list li { text-shadow: var(--halo); }
.hud__list li.is-active { color: #f7d98a; }
.ch__links a { color: #f7d98a; border-color: rgba(247,217,138,.45); }

/* ---------- Corridor of history: era placards ---------- */
.eras { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.era {
  position: absolute; left: var(--gutter); bottom: 12vh; width: min(27rem, calc(100vw - 2 * var(--gutter)));
  padding: 1.6rem 1.8rem 1.5rem; opacity: 0; visibility: hidden; will-change: opacity, transform;
  background: linear-gradient(160deg, rgba(9,10,18,.82), rgba(9,10,18,.62));
  border: 1px solid rgba(247,217,138,.28); border-radius: 4px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.era::before {
  /* a thin gilded rule along the top, like a museum plate */
  content: ""; position: absolute; left: 1.8rem; right: 1.8rem; top: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, #f2c35e, transparent);
}
.era .eyebrow { margin-bottom: .7rem; color: #f3c969; font-variant-numeric: tabular-nums; }
.era .eyebrow b { color: #ffd77a; }
.era h2 {
  font-size: clamp(2.2rem, 4vw, 3.4rem); margin-bottom: .8rem; line-height: 1.02;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 1.5px rgba(5,5,10,.9)) drop-shadow(0 0 22px rgba(240,179,35,.25));
}
.era p:not(.eyebrow) { color: var(--cream); font-size: .98rem; line-height: 1.55; }
.era__see {
  display: flex; align-items: center; gap: .7rem; margin-top: 1rem !important; padding-top: .9rem;
  border-top: 1px solid rgba(242,236,224,.14);
  font-size: .68rem !important; letter-spacing: .2em; text-transform: uppercase; color: #f7d98a !important;
}
.era__see::before { content: ""; width: 7px; height: 7px; flex: none; transform: rotate(45deg); background: var(--saffron); box-shadow: 0 0 10px var(--saffron); }
@media (max-width: 760px) {
  .era { bottom: 8vh; padding: 1.2rem 1.3rem; }
  .era h2 { font-size: 2rem; }
  .era p:not(.eyebrow) { font-size: .9rem; }
}

/* ---------- Light beyond the last arch ---------- */
.wash {
  position: fixed; inset: 0; z-index: 25; pointer-events: none; opacity: 0; visibility: hidden;
  background: radial-gradient(ellipse 70% 60% at 50% 48%, #fffaf0 0%, #fbe8c2 38%, #e9bf78 78%, #c98f45 100%);
}

/* ---------- Readout: metres in the workshop, years in history ---------- */
.readout__k--year, .readout.is-year .readout__k--fov { display: none; }
.readout.is-year .readout__k--year { display: block; }
.readout.is-year .readout__v {
  font-size: 2.4rem; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 2px rgba(5,5,10,.9));
}

/* ---------- Reveal copy sits low, clear of the rosette ---------- */
.ch--low { top: auto; bottom: 8vh; translate: 0 0; }

/* ---------- Finale: the rosette above, the closing words below ---------- */
.ch--end { top: auto; bottom: 3vh; translate: 0 0; padding-top: 2rem; padding-bottom: 2rem; }
.ch--end h2 { font-size: clamp(2.4rem, 5vw, 4.6rem); margin-bottom: 1rem; }
.ch--end p:not(.eyebrow) { max-width: 46rem; font-size: clamp(.92rem, 1.1vw, 1.02rem); }
.ch--end .ch__links { margin-top: 1.5rem; }
@media (max-height: 760px) and (min-width: 761px) {
  .ch--end h2 br { display: none; }
}
@media (max-width: 760px) {
  .ch--end { bottom: 1.5vh; padding: 1rem var(--gutter); }
  .ch--end .eyebrow { margin-bottom: .6rem; }
  .ch--end h2 { font-size: 2.3rem; margin-bottom: .7rem; }
  .ch--end p:not(.eyebrow) { font-size: .84rem; line-height: 1.5; }
  .ch--end .ch__links { gap: .45rem; margin-top: 1rem; }
  .ch--end .ch__links a { padding: .55rem .9rem; font-size: .62rem; letter-spacing: .12em; }
}

/* Gilded text is painted only inside its box: give descenders (J, ج, g, y) and italic overhangs room */
.ch h2, .ch--hero h1, .era h2, .curtain__label { padding: .06em .08em .16em; margin-left: -.08em; margin-right: -.08em; }
.ch--hero h1 { padding-bottom: .2em; margin-bottom: -.2em; line-height: .95; }
html[lang="ar"] .ch--hero h1 { line-height: 1.3; padding: .1em .1em .3em; margin-bottom: -.3em; }

/* Section links sit on the screen's centre line, the same axis as the rosette */
@media (min-width: 981px) {
  .nav__links { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
}
@media (max-width: 760px) { .readout.is-fin { display: none; } }
