/* Horizon direction: the home, contact and 404 pages.
   Loaded after base.css on those pages only.

   Three states, one design:
   - no class on <html>: no JavaScript, or the still tier (tier 0). The
     field is a pre-rendered image; below the hero the page is a column of
     text and static figures.
   - html.hz-live: the live field runs (tiers 1 and 2). On the home page
     each beat and chapter takes a screen and the field moves behind them.
   - html.hz-drawn: the live field has drawn its first frame and replaces
     the still image.
   horizon.js sets --hz-hh on <html> to the measured header height. */

/* ---------- Stage: the field's layer behind the page ---------- */

.hz-stage {
  position: absolute;
  inset: 0 0 auto 0;
  height: 100svh;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 62%, transparent);
  mask-image: linear-gradient(#000 62%, transparent);
}
.hz-stage--home {
  display: none;
  position: fixed;
  inset: 0;
  height: auto;
  -webkit-mask-image: none;
  mask-image: none;
}
.hz-live .hz-stage--home { display: block; }
.hz-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}

/* The horizon of the quiet pages: centre and ring radius. The still image
   and the live field both read their geometry from this box. */
.hz-focus {
  --hz-ring: min(5.6vw, 8.6svh);
  position: absolute;
  left: calc(71% - var(--hz-ring));
  top: calc(var(--hz-hh, 72px) + (100svh - var(--hz-hh, 72px)) * 0.47 - var(--hz-ring));
  width: calc(var(--hz-ring) * 2);
  height: calc(var(--hz-ring) * 2);
}
.hz-focus__still {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--hz-ring) * 13);
  aspect-ratio: 1;
  translate: -50% -50%;
  background: url("/static/horizon/field-horizon.jpg") center / 100% 100% no-repeat;
}
.hz-drawn .hz-focus__still,
.hz-drawn .hz-door__still { display: none; }

/* The top of the reading area: text scrolling under the header fades
   instead of being cut. Live home page only; horizon.js fades it in as the
   page leaves the doorway. On a wide screen it is one and a half display
   lines tall and opaque in its first third, so a leaving line is gone
   before it reaches the header. */
.hz-veil { display: none; }
.hz-live .hz-veil {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  top: var(--hz-hh, 72px);
  height: 28px;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(var(--dn-void), rgba(4, 7, 15, 0));
}
@media (min-width: 1000px) {
  .hz-live .hz-veil {
    height: calc(var(--fs-display) * 1.56);
    background: linear-gradient(var(--dn-void) 0, var(--dn-void) 33%, rgba(4, 7, 15, 0));
  }
}

/* ---------- Head of a page ---------- */

.hz-hero {
  position: relative;
  display: grid;
  align-items: center;
  min-height: calc(100svh - var(--hz-hh, 72px));
  padding: 48px var(--gutter) 88px;
}
.hz-copy {
  position: relative;
  z-index: 2;
  max-width: min(40rem, 50vw);
}
.hz-eyebrow { margin-bottom: 1.6rem; }
.hz-title {
  font-size: var(--fs-display);
  max-width: 12.5em;
}
.hz-lead {
  margin-top: 2rem;
  max-width: 30rem;
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--text-soft);
}
.hz-lead .line { display: block; }
.hz-lead .line + .line { margin-top: 0.55em; }
.hz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.1rem;
  margin-top: 2.6rem;
}

/* The home hero: the doorway, its ring aligned with the field's. The
   ring's centre is at (0.474, 0.443) of the image, radius 0.1194 of its
   width (measured on the kit's hero image). */
.hz-hero--home {
  --door: min(calc(100svh - var(--hz-hh, 72px)), 52vw);
  overflow: clip;
}
.hz-hero__door {
  position: absolute;
  z-index: 0;
  left: calc(70% - var(--door) * 0.474);
  top: calc(50% - var(--door) * 0.443);
  width: var(--door);
  height: var(--door);
  pointer-events: none;
}
.hz-door {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}
.hz-door__still {
  position: absolute;
  left: -92.6%;
  top: -95.7%;
  width: 280%;
  height: 280%;
  background: url("/static/horizon/field-door.jpg") center / 100% 100% no-repeat;
}
.hz-door__img {
  position: absolute;
  inset: 0;
  background: url("/static/brand/doorway-960.jpg") center / 100% 100% no-repeat;
  background-image: image-set(url("/static/brand/doorway-960.jpg") 1x, url("/static/brand/doorway-1600.jpg") 2x);
  mix-blend-mode: lighten;
  -webkit-mask-image: radial-gradient(closest-side circle at 47.4% 44.3%, #000 78%, transparent 100%);
  mask-image: radial-gradient(closest-side circle at 47.4% 44.3%, #000 78%, transparent 100%);
}
/* Without the live field: a scrim keeps the still quiet behind the text,
   and the still fades out at the bottom of the hero. */
html:not(.hz-live) .hz-hero--home::before,
html:not(.hz-live) .hz-hero--home::after {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
html:not(.hz-live) .hz-hero--home::before {
  inset: 0;
  background: linear-gradient(90deg, rgba(4, 7, 15, 0.86) 0%, rgba(4, 7, 15, 0.7) 30%, rgba(4, 7, 15, 0.18) 48%, rgba(4, 7, 15, 0) 58%);
}
html:not(.hz-live) .hz-hero--home::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: 24svh;
  background: linear-gradient(rgba(4, 7, 15, 0), var(--dn-void));
}

/* The cue: a small ring with a falling tick. It plays three times. */
.hz-cue {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  bottom: 28px;
  width: 18px;
  height: 44px;
}
.hz-cue::before,
.hz-cue::after {
  content: "";
  position: absolute;
}
.hz-cue::before {
  left: 3px;
  top: 0;
  width: 12px;
  height: 12px;
  border: 1px solid var(--dn-gold);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(236, 191, 119, 0.5);
}
.hz-cue::after {
  left: 8.5px;
  top: 18px;
  width: 1px;
  height: 22px;
  background: linear-gradient(var(--dn-gold), rgba(236, 191, 119, 0));
  transform-origin: top;
  animation: hz-cue 2.4s cubic-bezier(0.5, 0, 0.3, 1) 3;
}
@keyframes hz-cue {
  0% { transform: scaleY(0); transform-origin: top; }
  45% { transform: scaleY(1); transform-origin: top; }
  55% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ---------- Beats: the lead after its first line, one line each ---------- */

.hz-beats {
  position: relative;
  display: grid;
  gap: 3rem 4rem;
  align-items: center;
  padding: clamp(3rem, 8vh, 6rem) var(--gutter) clamp(2rem, 6vh, 4rem);
}
.hz-beats__lines { display: grid; gap: 1.1em; font-size: var(--fs-beat); }
.hz-beats { --fs-beat: clamp(1.8rem, 0.95rem + 2.9vw, 3.6rem); }
.hz-beat__text {
  position: relative;
  z-index: 2;
  width: fit-content;
  max-width: 13.5em;
  font-size: var(--fs-beat);
  color: var(--text);
}
.hz-beat__text--question { font-style: italic; font-weight: 340; }

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

.hz-chapter {
  position: relative;
  padding: clamp(4rem, 10vh, 7rem) var(--gutter);
}
.hz-chapter__body {
  position: relative;
  z-index: 2;
  max-width: var(--measure);
}
.hz-para { color: var(--text-soft); }
.hz-para + .hz-para { margin-top: 1.1em; }
.hz-page--home .hz-para { font-size: var(--fs-lead); line-height: 1.55; }
/* A level-1 line is set apart: in italic, and as a pull quote when it
   opens its paragraph. */
.hz-para .line[data-level="1"] { font-style: italic; color: var(--text); }
.hz-para > .line[data-level="1"]:first-child {
  display: block;
  margin-bottom: 1.1rem;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72;
  font-weight: 340;
  font-size: clamp(1.35rem, 0.95rem + 1.35vw, 2.1rem);
  line-height: 1.28;
  letter-spacing: 0.012em;
  text-wrap: pretty;
}
.hz-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-top: 2rem;
}
.hz-items { display: grid; gap: 2rem; margin-top: 2.2rem; }

/* ---------- Static figures (without the live field) ---------- */

.hz-fig { width: min(100%, 340px); }
.hz-fig svg { width: 100%; height: auto; overflow: visible; }
.hz-fig figcaption {
  margin-top: 1rem;
  font-family: var(--font-label);
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  color: var(--dn-steel-on-dark);
}
.hz-m-mesh { fill: none; stroke: var(--dn-steel-on-dark); stroke-width: 1; stroke-dasharray: 2 5; opacity: 0.7; }
.hz-m-path { fill: none; stroke: var(--dn-orange); stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(202, 120, 69, 0.8)); }
.hz-m-node { fill: var(--dn-void); stroke: var(--dn-ring); stroke-width: 1.6; filter: drop-shadow(0 0 5px rgba(236, 191, 119, 0.9)); }
.hz-c-path { fill: none; stroke: var(--dn-ice); stroke-width: 1.3; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(78, 127, 170, 0.95)); }
.hz-fig--horizon svg {
  -webkit-mask-image: radial-gradient(closest-side circle, #000 62%, transparent 100%);
  mask-image: radial-gradient(closest-side circle, #000 62%, transparent 100%);
}
.hz-h-disc { fill: #000; }
.hz-h-out, .hz-h-in { fill: none; stroke-width: 1.2; stroke-linejoin: round; }
.hz-h-out { stroke: var(--dn-orange); filter: drop-shadow(0 0 3px rgba(202, 120, 69, 0.9)); }
.hz-h-in { stroke: var(--dn-brick); opacity: 0.9; }
.hz-h-ring { fill: none; stroke: var(--dn-ring); stroke-width: 2; filter: drop-shadow(0 0 6px var(--dn-gold)) drop-shadow(0 0 14px var(--dn-orange)); }

/* The scales: three scales around a small horizon. */
.hz-scales { overflow: visible; }
.hz-s-shade { fill: var(--dn-void); opacity: 0.72; }
.hz-s-base { fill: none; stroke: var(--dn-steel-on-dark); stroke-width: 0.35; opacity: 0.55; }
.hz-s-ticks, .hz-s-major { fill: none; stroke: var(--dn-steel-on-dark); }
.hz-s-ticks { stroke-width: 3.2; opacity: 0.75; }
.hz-s-major { stroke-width: 6.5; opacity: 0.95; stroke: var(--dn-ice); }
.hz-s-index {
  fill: none;
  stroke: var(--dn-gold);
  stroke-width: 2.2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px var(--dn-orange));
}
.hz-s-reading { fill: none; stroke: var(--dn-gold); stroke-width: 0.8; opacity: 0.55; }
.hz-s-horizon {
  fill: #000;
  stroke: var(--dn-ring);
  stroke-width: 1.6;
  filter: drop-shadow(0 0 4px var(--dn-gold)) drop-shadow(0 0 10px var(--dn-orange));
}
/* In the live field the scales stand in the stage, placed by the script. */
.hz-stage .hz-scales {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
}

@media (min-width: 1000px) {
  .hz-beats { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); }
  .hz-fig--scales { width: min(100%, 420px); justify-self: center; }
  .hz-chapter {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
    align-items: center;
    gap: 4rem;
  }
  .hz-fig { width: min(100%, 380px); justify-self: center; }
}

/* ---------- The live home page ---------- */

.hz-live .hz-fig { display: none; }
.hz-live .hz-fig:has(figcaption) { display: block; }
.hz-live .hz-beats { display: block; padding: 0; }
.hz-live .hz-beats__lines { display: block; }
.hz-live .hz-beat {
  display: grid;
  align-content: center;
  min-height: calc(100svh - var(--hz-hh, 72px));
  padding: 0 var(--gutter);
}
.hz-live .hz-beat__text { max-width: min(13.5em, 46vw); }
.hz-live .hz-page--home .hz-chapter {
  display: grid;
  align-content: center;
  min-height: calc(100svh - var(--hz-hh, 72px));
  grid-template-columns: none;
}
.hz-live .hz-page--home .hz-chapter__body { max-width: min(var(--measure), 44vw); }
/* The last chapter ends the page with the footer in view: horizon.js sets
   --hz-fh to the footer's height. */
.hz-live .hz-page--home .hz-chapter:last-child {
  min-height: calc(100svh - var(--hz-hh, 72px) - var(--hz-fh, 0px));
}

/* ---------- The quiet pages ---------- */

.hz-hero--calm { min-height: calc(94svh - var(--hz-hh, 72px)); }
/* A page without sections (contact, 404): main, the page and its head fill
   the screen between the header and the footer (body is a 100svh column),
   so a page shorter than the screen ends with the whole footer in view.
   No script is needed. */
main:has(> .hz-page--calm) { display: flex; flex-direction: column; }
.hz-page--calm { flex: 1 0 auto; display: flex; flex-direction: column; }
.hz-page--calm:not(:has(.hz-chapter)) .hz-hero--calm { flex: 1 0 auto; min-height: 0; }
.hz-hero--calm .hz-copy { max-width: min(42rem, 54vw); }
.hz-page--calm .hz-chapter { border-top: 1px solid var(--hairline); }
@media (min-width: 1000px) {
  .hz-page--calm .hz-chapter { display: block; }
  .hz-page--calm .hz-chapter__body {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: 4rem;
    max-width: none;
  }
  .hz-page--calm .hz-chapter__body > * { grid-column: 2; max-width: var(--measure); }
  .hz-page--calm .hz-h2 { grid-column: 1; grid-row: 1 / span 6; margin-bottom: 0; }
  .hz-page--calm .hz-chapter__body > .hz-para:first-of-type { padding-top: calc(11px + 1.4rem + 0.35em); }
}

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

@media (max-width: 760px) {
  .hz-copy,
  .hz-hero--calm .hz-copy { max-width: none; }
  .hz-hero { align-items: end; padding-bottom: 88px; }

  .hz-hero--home {
    --door: 100vw;
    align-items: start;
    padding-top: calc(var(--door) * 0.78);
  }
  .hz-hero__door {
    left: calc(50% - var(--door) * 0.474);
    top: calc(var(--door) * -0.05);
  }
  /* The scrim is dark where the copy starts (door × 0.78), and clear above
     the foot of the doorway. */
  html:not(.hz-live) .hz-hero--home::before {
    background: linear-gradient(180deg, rgba(4, 7, 15, 0) 0, rgba(4, 7, 15, 0) calc(var(--door) * 0.68), rgba(4, 7, 15, 0.86) calc(var(--door) * 0.76), rgba(4, 7, 15, 0.9) 100%);
  }
  .hz-cue { bottom: 24px; }

  .hz-focus {
    --hz-ring: min(15vw, 10svh);
    left: calc(50% - var(--hz-ring));
    top: calc(var(--hz-hh, 96px) + 19svh - var(--hz-ring));
  }
  .hz-hero--calm { padding-top: calc(38svh); align-items: start; }

  .hz-live .hz-beat,
  .hz-live .hz-page--home .hz-chapter { align-content: end; padding-bottom: clamp(24px, 6svh, 56px); }
  .hz-live .hz-beat__text,
  .hz-live .hz-page--home .hz-chapter__body { max-width: none; }
  .hz-fig { margin-top: 2.4rem; }
}

/* ---------- Debug overlay (?perf=1) ---------- */

.hz-perf {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 30;
  padding: 6px 9px;
  font: 12px/1.45 var(--font-label);
  color: var(--dn-plasma);
  background: rgba(4, 7, 15, 0.88);
  border: 1px solid var(--hairline);
  white-space: pre;
}
