/* ==========================================================================
   The Zero Flare Journey
   Loaded on /zero-flare.

   The page is an article with a desert behind it. Without JavaScript the
   chapters simply stack and are read top to bottom; `.zf.is-live`, added by
   the scene once WebGL is up, is what switches on the pinned stage, the
   cross-fading cards and the timeline rail.

   Bright daytime, deliberately: the gas-processing scene is a dusk piece and
   these two should not be mistaken for one another.
   ========================================================================== */

.zfx {
  --zf-ink: #12303f;
  --zf-blue: #015a8d;
  --zf-gold: #f1c42b;
  --zf-sand: #f4ecde;
  --zf-paper: #ffffff;
  --zf-muted: #5c7383;
  --zf-line: rgba(1, 90, 141, .16);
  --zf-flame: #e8762a;

  background: var(--zf-sand);
  color: var(--zf-ink);
  overflow-x: clip;
}

/* The page is set after dark by default. A flare is a light source, so at
   night it is the brightest thing on the screen and the story has an obvious
   subject; the daylight set is kept because it is the hour the client's
   reference film uses, and ?theme=light previews it. */
.zfx[data-theme="dark"] {
  --zf-ink: #eaf2f9;
  --zf-blue: #4aa6e0;
  --zf-gold: #f1c42b;
  --zf-sand: #080e18;
  --zf-paper: #111c2c;
  --zf-muted: #97adc2;
  --zf-line: rgba(154, 192, 224, .22);
  --zf-flame: #ff8f33;
}

.zf { position: relative; }

/* Screen-reader summary of what the canvas is doing. */
.zf-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- The stage ----------------------------------------------------------- */

/* Sticky, not fixed. A fixed overlay paints above the site footer, which sits
   in normal flow; sticky releases at the end of .zf and never covers it. */
.zf-stage { display: none; }
.zf.is-live .zf-stage {
  display: block;
  position: sticky; top: 0; z-index: 0;
  height: 100vh; height: 100svh;
  margin-bottom: -100vh; margin-bottom: -100svh;
  transition: opacity .5s ease;
}
/* The stage does not fade out at the end. It is sticky, so it simply
   releases at the bottom of .zf and scrolls away under the footer of its own
   accord — fading it instead left a tall empty block between the last
   chapter and the footer, with the timeline rail floating in it. */

.zf-canvas { display: block; width: 100%; height: 100%; }

/* A scrim under the copy so the words hold against sand and sky at any
   camera angle. It swaps sides with the text direction. */
.zf-haze {
  position: absolute; inset: 0; pointer-events: none;
  /* The nav band is listed first on purpose: CSS paints the first background
     layer on top, and underneath the near-opaque copy wash it did nothing at
     all on the side where the logo actually sits. */
  background:
    linear-gradient(to bottom, rgba(8, 28, 42, .72) 0%, rgba(8, 28, 42, .5) 96px,
      rgba(8, 28, 42, .2) 170px, transparent 260px),
    linear-gradient(to right,
      rgba(246, 239, 227, .96) 0%,
      rgba(246, 239, 227, .93) 30%,
      rgba(246, 239, 227, .7) 43%,
      rgba(246, 239, 227, .26) 54%,
      rgba(246, 239, 227, 0) 66%);
}
.zf[dir="rtl"] .zf-haze {
  /* The nav band is listed first on purpose: CSS paints the first background
     layer on top, and underneath the near-opaque copy wash it did nothing at
     all on the side where the logo actually sits. */
  background:
    linear-gradient(to bottom, rgba(8, 28, 42, .72) 0%, rgba(8, 28, 42, .5) 96px,
      rgba(8, 28, 42, .2) 170px, transparent 260px),
    linear-gradient(to left,
      rgba(246, 239, 227, .96) 0%,
      rgba(246, 239, 227, .93) 30%,
      rgba(246, 239, 227, .7) 43%,
      rgba(246, 239, 227, .26) 54%,
      rgba(246, 239, 227, 0) 66%);
}

/* After dark the scrim is a shadow rather than a wash, and the nav needs no
   help: the sky behind it is already dark. */
.zfx[data-theme="dark"] .zf-haze {
  background:
    linear-gradient(to right,
      rgba(6, 11, 20, .95) 0%,
      rgba(6, 11, 20, .9) 27%,
      rgba(6, 11, 20, .6) 40%,
      rgba(6, 11, 20, .2) 52%,
      rgba(6, 11, 20, 0) 66%);
}
.zfx[data-theme="dark"] .zf[dir="rtl"] .zf-haze {
  background:
    linear-gradient(to left,
      rgba(6, 11, 20, .95) 0%,
      rgba(6, 11, 20, .9) 27%,
      rgba(6, 11, 20, .6) 40%,
      rgba(6, 11, 20, .2) 52%,
      rgba(6, 11, 20, 0) 66%);
}

/* Surfaces that were translucent white have to flip, or they glow. */
.zfx[data-theme="dark"] .zf-fig {
  background: rgba(17, 28, 44, .72);
  border-color: var(--zf-line);
}
.zfx[data-theme="dark"] .zf-gauge-well { fill: rgba(154, 192, 224, .07); }
.zfx[data-theme="dark"] .zf-gauge-label {
  background: rgba(8, 14, 24, .68);
  color: var(--zf-ink);
}
.zfx[data-theme="dark"] .zf-gauge.is-zero .zf-gauge-label [data-zf-gauge-gone] { color: var(--zf-gold); }
.zfx[data-theme="dark"] .zf-gauge.is-zero .zf-gauge-flame,
.zfx[data-theme="dark"] .zf-gauge.is-zero .zf-gauge-fill { fill: var(--zf-gold); }
.zfx[data-theme="dark"] .zf-year-n {
  -webkit-text-stroke: 2px rgba(234, 242, 249, .62);
  text-shadow: 0 10px 50px rgba(0, 0, 0, .55);
}
.zfx[data-theme="dark"] .zf-rail-stop.is-done .zf-rail-dot,
.zfx[data-theme="dark"] .zf-rail-stop.is-done .zf-rail-year { color: var(--zf-blue); }
.zfx[data-theme="dark"] .zf-rail-stop.is-done .zf-rail-dot {
  background: var(--zf-blue); border-color: var(--zf-blue);
}
.zfx[data-theme="dark"] .zf-rail-stop.is-now .zf-rail-year { color: var(--zf-ink); }
.zfx[data-theme="dark"] .zf-chapter--closing .zf-h { color: var(--zf-ink); }

/* Blue on near-black is too quiet for the one thing the page asks you to do.
   Gold carries it, and it is the other half of the brand. */
.zfx[data-theme="dark"] .zf-cta {
  background: var(--zf-gold); color: #10192a;
}
.zfx[data-theme="dark"] .zf-cta:hover,
.zfx[data-theme="dark"] .zf-cta:focus-visible {
  background: #ffd645; color: #10192a;
  box-shadow: 0 10px 30px rgba(241, 196, 43, .24);
}

/* --- The year numeral ---------------------------------------------------- */

/* Set in the DOM rather than in the scene: crisp at any pixel ratio, and it
   translates, which geometry does not. */
.zf-year {
  position: absolute; inset-inline-end: 4vw; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0; transition: opacity .45s ease;
}
.zf-year.is-on { opacity: 1; }
.zf-year-n {
  display: none;
  font-family: 'Montserrat', sans-serif; font-weight: 700;
  font-size: clamp(5rem, 17vw, 16rem); line-height: .82;
  letter-spacing: -.03em;
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, .88);
  text-shadow: 0 10px 44px rgba(18, 48, 63, .3);
}
.zf-year-n.is-on { display: block; animation: zf-year-in .7s cubic-bezier(.2, .8, .25, 1) both; }
@keyframes zf-year-in {
  from { opacity: 0; transform: translate3d(0, 24px, 0) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* --- The flare gauge ----------------------------------------------------- */

/* Ties the number to the picture: the readout is a flame that fills to the
   height the one in the scene is burning at, and the label says what that
   height means. It was a vertical bar, which at the end of the story — where
   the value is almost nothing — read as a scrollbar rather than a reading. */
.zf-gauge {
  position: absolute; inset-inline-end: 2.2vw; bottom: 8vh;
  display: flex; align-items: center; gap: .7rem;
  pointer-events: none;
}
.zf-gauge-flame { display: block; flex: none; color: var(--zf-flame); }
.zf-gauge-well { fill: rgba(1, 90, 141, .07); }
.zf-gauge-edge { fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .8; }
.zf-gauge-fill { fill: url(#zf-gauge-grad); }
.zf-gauge-g0 { stop-color: var(--zf-flame); }
.zf-gauge-g1 { stop-color: var(--zf-gold); }

/* Out. The outline stays — a flare stack is still there, it is just not
   burning anything it should not be. */
.zf-gauge.is-zero .zf-gauge-flame { color: var(--zf-blue); }
.zf-gauge.is-zero .zf-gauge-fill { fill: var(--zf-blue); }

.zf-gauge-label {
  padding: .3rem .55rem; border-radius: 2px;
  background: rgba(255, 255, 255, .72);
  font-family: 'Montserrat', sans-serif; font-size: 11px;
  font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--zf-ink); max-width: 9rem;
}
.zf-gauge-label [data-zf-gauge-gone],
.zf-gauge.is-zero .zf-gauge-label [data-zf-gauge-live] { display: none; }
.zf-gauge.is-zero .zf-gauge-label [data-zf-gauge-gone] { display: inline; color: var(--zf-blue); }

/* --- Scroll hint --------------------------------------------------------- */

.zf-hint {
  position: absolute; inset-inline-start: 50%; bottom: 3vh;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: .45rem; margin: 0;
  font-family: 'Montserrat', sans-serif; font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--zf-muted);
  opacity: .9; transition: opacity .4s ease;
}
.zf-hint svg { animation: zf-nudge 1.8s ease-in-out infinite; }
.zf-hint.is-gone { opacity: 0; }
@keyframes zf-nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

/* --- The timeline rail --------------------------------------------------- */

.zf-rail { display: none; }
/* Sticky the same way the stage is, and for the same reason: with no height
   of its own the sticky box ended up at the bottom of .zf and its stops,
   which hang from the middle of the viewport, carried on over the footer.
   Given the viewport's height and the matching negative margin it releases
   exactly when the scene does and takes its stops with it. */
.zf.is-live .zf-rail {
  display: block; position: sticky; top: 0; z-index: 3;
  height: 100vh; height: 100svh;
  margin-bottom: -100vh; margin-bottom: -100svh;
  pointer-events: none;
}
.zf-rail-list {
  position: absolute; inset-inline-start: clamp(.75rem, 2.2vw, 2rem); top: 50%;
  transform: translateY(-50%);
  margin: 0; padding: 0; list-style: none;
  display: grid; gap: clamp(.9rem, 2.4vh, 1.6rem);
  pointer-events: auto;
}
.zf-rail-link {
  display: grid; grid-template-columns: 14px auto; align-items: center;
  column-gap: .6rem; row-gap: 0;
  text-decoration: none; color: var(--zf-muted);
  transition: color .3s ease;
}
.zf-rail-link:hover, .zf-rail-link:focus-visible { color: var(--zf-blue); }
.zf-rail-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid currentColor; background: transparent;
  transition: background .35s ease, transform .35s ease, border-color .35s ease;
}
.zf-rail-year {
  font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 13px;
  letter-spacing: .06em;
}
.zf-rail-tag {
  grid-column: 2; font-family: 'Roboto', sans-serif; font-size: 11.5px;
  color: var(--zf-muted); opacity: 0;
  max-height: 0; overflow: hidden;
  transition: opacity .3s ease, max-height .3s ease;
}
.zf-rail-stop.is-done .zf-rail-dot { background: var(--zf-blue); border-color: var(--zf-blue); }
.zf-rail-stop.is-done .zf-rail-year { color: var(--zf-blue); }
.zf-rail-stop.is-now .zf-rail-dot {
  background: var(--zf-gold); border-color: var(--zf-gold); transform: scale(1.35);
}
.zf-rail-stop.is-now .zf-rail-year { color: var(--zf-ink); }
.zf-rail-stop.is-now .zf-rail-tag { opacity: 1; max-height: 3em; }

/* --- Chapters ------------------------------------------------------------ */

.zf-scroll { position: relative; z-index: 2; }

/* The static reading of the page, before (or without) the scene. */
.zf-chapter {
  position: relative;
  padding-block: clamp(2.5rem, 7vh, 5rem);
  padding-inline: clamp(1.25rem, 6vw, 5rem);
}
/* The site nav is fixed and tall; the first screen has to clear it. */
.zf-chapter:first-child { padding-top: 200px; }

.zf-card-in { max-width: 46rem; }

.zf.is-live .zf-chapter {
  display: flex; align-items: center;
  min-height: 100vh; min-height: 100svh;
  padding-block: 0;
  pointer-events: none;
}
.zf.is-live .zf-chapter:first-child { padding-top: 0; }
.zf.is-live .zf-card {
  width: min(42rem, 48vw);
  margin-inline-start: clamp(3.5rem, 7vw, 8rem);
  opacity: 0; transform: translate3d(0, 28px, 0);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2, .8, .25, 1);
}
.zf.is-live .zf-chapter--figures .zf-card { width: min(48rem, 56vw); }
.zf.is-live .zf-chapter.is-on .zf-card { opacity: 1; transform: none; pointer-events: auto; }
.zf.is-live .zf-card-in { max-width: none; }

/* --- Type ---------------------------------------------------------------- */

.zf-brow {
  margin: 0 0 .9rem;
  font-family: 'Montserrat', sans-serif; font-weight: 600;
  font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--zf-blue);
  display: flex; align-items: center; gap: .6rem;
}
.zf-brow::after {
  content: ''; flex: 0 0 2.5rem; height: 2px; background: var(--zf-gold);
}
.zf-h {
  margin: 0 0 1.1rem;
  font-family: 'Montserrat', sans-serif; font-weight: 700;
  font-size: clamp(1.9rem, 4.2vw, 3.4rem); line-height: 1.1;
  letter-spacing: -.015em; color: var(--zf-ink);
}
.zf-h-line { display: block; }
.zf-chapter--hero .zf-h { font-size: clamp(2.2rem, 5.4vw, 4.4rem); }
.zf-lede {
  margin: 0 0 1rem; font-family: 'Roboto', sans-serif;
  font-size: clamp(1.0625rem, 1.5vw, 1.3125rem); line-height: 1.6;
  color: var(--zf-ink);
}
.zf-body p {
  margin: 0 0 .85rem; font-family: 'Roboto', sans-serif;
  font-size: clamp(.9375rem, 1.1vw, 1.0625rem); line-height: 1.75;
  color: var(--zf-muted);
}
.zf-body p:last-child { margin-bottom: 0; }

.zf-pull {
  margin: 1.5rem 0 0; padding: 0; border: 0;
  border-inline-start: 3px solid var(--zf-gold);
  padding-inline-start: 1.1rem;
}
.zf-pull p {
  margin: 0; font-family: 'Montserrat', sans-serif; font-weight: 600;
  font-size: clamp(1.0625rem, 1.6vw, 1.375rem); line-height: 1.45;
  color: var(--zf-blue);
}

/* --- Impact figures ------------------------------------------------------ */

.zf-fig-list {
  margin: 1.4rem 0 0; padding: 0; list-style: none;
  display: grid; gap: .8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.zf-fig {
  display: grid; gap: .2rem; align-content: start;
  padding: .95rem 1rem;
  background: rgba(255, 255, 255, .78);
  border: 1px solid var(--zf-line);
  border-radius: 4px;
  backdrop-filter: blur(6px);
}
.zf-fig-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-bottom: .3rem;
  border-radius: 50%; background: var(--zf-blue); color: #fff;
}
.zf-fig-value {
  font-family: 'Montserrat', sans-serif; font-weight: 700;
  font-size: clamp(1.375rem, 2vw, 1.875rem); line-height: 1.05;
  color: var(--zf-ink);
}
.zf-fig-unit {
  font-family: 'Roboto', sans-serif; font-size: .875rem; color: var(--zf-ink);
}
.zf-fig-caption {
  margin-top: .3rem; padding-top: .45rem;
  border-top: 1px solid var(--zf-line);
  font-family: 'Roboto', sans-serif; font-size: .8125rem; color: var(--zf-muted);
}

/* The figures chapter carries a lot in one screen; the heading stands down
   so the numbers are what the eye lands on. */
.zf-chapter--figures .zf-h { font-size: clamp(1.5rem, 2.6vw, 2.125rem); }
.zf-chapter--figures .zf-lede { font-size: clamp(1rem, 1.2vw, 1.0625rem); color: var(--zf-muted); }

/* --- Closing and call to action ------------------------------------------ */

.zf-chapter--closing .zf-h {
  font-size: clamp(1.8rem, 3.6vw, 3rem); color: var(--zf-blue);
}
.zf-cta-wrap { margin: 1.8rem 0 0; }
.zf-cta {
  display: inline-flex; align-items: center; gap: .65rem;
  padding: .9rem 1.6rem;
  background: var(--zf-blue); color: #fff; text-decoration: none;
  border-radius: 2px;
  font-family: 'Montserrat', sans-serif; font-weight: 600;
  font-size: 13.5px; letter-spacing: .04em;
  transition: background .25s ease, box-shadow .25s ease;
}
.zf-cta:hover, .zf-cta:focus-visible {
  background: #01486f; color: #fff;
  box-shadow: 0 10px 28px rgba(1, 90, 141, .28);
}
/* `transform` is a single property: both the resting and the hover state have
   to declare the direction flip, or hovering silently un-flips the arrow. */
.zf-cta-arrow { display: inline-flex; transform: translateX(0); transition: transform .25s ease; }
.zf-cta:hover .zf-cta-arrow { transform: translateX(4px); }
.zf[dir="rtl"] .zf-cta-arrow { transform: scaleX(-1) translateX(0); }
.zf[dir="rtl"] .zf-cta:hover .zf-cta-arrow { transform: scaleX(-1) translateX(4px); }

/* --- The end ------------------------------------------------------------- */

/* A short run-out after the last chapter. The stage is sticky and stays put
   through it, so this is not a gap — it is the closing card clearing the
   frame before the footer arrives, instead of being sliced in half by the
   site nav on its way out. An earlier version faded the whole stage here
   instead, which left a tall empty block between the story and the footer. */
.zf-end { height: 1px; }
.zf.is-live .zf-end { height: 40vh; }

/* The rail is sticky with no height of its own and its stops hang from the
   middle of the viewport, so past the end of .zf they would hang on over the
   footer. They go when the story does. */
.zf.is-live.is-ended .zf-rail,
.zf.is-live.is-ended .zf-gauge,
.zf.is-live.is-ended .zf-year {
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}

/* --- Arabic -------------------------------------------------------------- */

/* arabic.css only sets the face on `body`, which a page-level class outranks.
   Declare it here for everything the page sets a family on. */
.zf[dir="rtl"],
.zf[dir="rtl"] .zf-h,
.zf[dir="rtl"] .zf-brow,
.zf[dir="rtl"] .zf-lede,
.zf[dir="rtl"] .zf-body p,
.zf[dir="rtl"] .zf-pull p,
.zf[dir="rtl"] .zf-figs-title,
.zf[dir="rtl"] .zf-fig-value,
.zf[dir="rtl"] .zf-fig-unit,
.zf[dir="rtl"] .zf-fig-caption,
.zf[dir="rtl"] .zf-rail-year,
.zf[dir="rtl"] .zf-rail-tag,
.zf[dir="rtl"] .zf-gauge-label,
.zf[dir="rtl"] .zf-hint,
.zf[dir="rtl"] .zf-cta {
  font-family: 'Droid Arabic Kufi', sans-serif;
}
/* Kufi sits tall; the tight Latin leading clips its ascenders. */
.zf[dir="rtl"] .zf-h { line-height: 1.45; letter-spacing: 0; }
.zf[dir="rtl"] .zf-brow,
.zf[dir="rtl"] .zf-gauge-label { letter-spacing: 0; text-transform: none; }
/* The year numerals stay Latin-figured; Montserrat has no Arabic. */
.zf[dir="rtl"] .zf-year-n { font-family: 'Montserrat', sans-serif; }

/* --- Narrow screens ------------------------------------------------------ */

@media (max-width: 899px) {
  .zf.is-live .zf-card,
  .zf.is-live .zf-chapter--figures .zf-card {
    width: auto;
    margin-inline: clamp(1.25rem, 5vw, 3rem);
    align-self: flex-end;
    padding-bottom: clamp(2rem, 6vh, 4rem);
  }
  .zf.is-live .zf-chapter { align-items: flex-end; }
  /* One column has no room to spare: the copy has to fit the lower half of
     the screen or it rides up under the site nav. */
  .zf.is-live .zf-h { font-size: clamp(1.6rem, 6.4vw, 2.25rem); }
  .zf.is-live .zf-chapter--hero .zf-h { font-size: clamp(1.85rem, 7.6vw, 2.75rem); }
  .zf.is-live .zf-lede { font-size: 1rem; line-height: 1.5; }
  .zf.is-live .zf-body p { font-size: .9375rem; line-height: 1.6; }
  .zf.is-live .zf-fig-list { gap: .5rem; margin-top: 1rem; }
  .zf.is-live .zf-fig { padding: .7rem .75rem; }
  .zf.is-live .zf-fig-icon { display: none; }
  .zf.is-live .zf-fig-caption { display: none; }
  /* The copy owns the lower half on one column, so the scrim does too. */
  .zf-haze,
  .zf[dir="rtl"] .zf-haze {
    background: linear-gradient(to top,
      rgba(244, 236, 222, .97) 0%,
      rgba(244, 236, 222, .9) 34%,
      rgba(244, 236, 222, .3) 58%,
      rgba(244, 236, 222, 0) 74%);
  }
  .zf-year { inset-inline-end: 6vw; top: 22%; transform: none; }
  .zf-gauge { bottom: auto; top: 182px; inset-inline-end: auto; inset-inline-start: 5vw; }
  .zf-gauge-label { max-width: 7rem; font-size: 10px; }
  .zf.is-live .zf-rail { display: none; }
  .zf-fig-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .zf-fig-list { grid-template-columns: 1fr; }
}

/* --- Reduced motion ------------------------------------------------------ */

/* The scene does not boot at all under this preference, so `is-live` never
   lands. Nothing left to do but stop the two decorative loops. */
@media (prefers-reduced-motion: reduce) {
  .zf-hint svg, .zf-year-n.is-on { animation: none; }
}

/* --- ?perf HUD ----------------------------------------------------------- */

.zf-perf {
  position: fixed; inset-block-end: 8px; inset-inline-start: 8px; z-index: 99;
  padding: 4px 8px; border-radius: 3px;
  background: rgba(18, 48, 63, .85); color: #fff;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
