/* The apertures: each section opens like a disc from the orrery.
   One handover language for the home page and the worlds: a section that
   changes ground is an aperture (.ecl), inset in the page so the ground
   around it stays in view, with the section's sigil in a thin ring on its
   top edge. The ring is the disc's origin: as the aperture scrolls into
   view its ground and everything on it open as a circle from the ring,
   occluding the page's ground, and close again on the way back up. The
   edge of the growing disc carries a thin bright limb. Crisp geometry,
   never a blob. The compositor does the opening: nothing repaints and no
   style is recomputed while it runs (see "the opening" below).
   Markup:
     <section class="ecl …">
       <span class="ecl-ring" aria-hidden="true"><svg class="nts-sigil"><use href="#sigil-…"/></svg></span>
       <div class="ecl-win"><div class="ecl-disc"><div class="ecl-in"> … the section's content … </div></div></div>
     </section>
   .ecl-win is the card (its rounded corners clip, and never move), .ecl-disc
   the disc, .ecl-in the card's ground and content (it holds the padding,
   so the three boxes coincide).
   On the home the apertures are the world windows (.world) and the two
   NTS bands; inside a world they are its bands (.band). Colours come from
   --ecl-bg (the aperture's ground), --ecl-fg (its marks) and --ecl-out
   (the ground around it): worlds set them from --w-*, bands from --band-*.
   Scroll-driven where animation-timeline: view() exists and html.js is
   set, until the disc is complete (then .is-open latches it); everywhere
   else, and under reduced motion, every disc is open.
   Loaded after orrery.css. Nothing here redefines a --pal-*, --code-* or --w-* token. */

/* the disc opens while the aperture's top edge (where the ring sits) climbs
   from --ecl-open-start to --ecl-open-end, both in vh of travel after the
   edge enters at the bottom of the viewport. nts.js reads --ecl-open-end (vh
   only) to latch the aperture. The ring travels from 75% down the screen to
   30% while the disc opens, at every width: a window can be taller than the
   screen, so a run counted from the moment its edge enters would finish
   before the card is in view */
:root { --ecl-open-start: 25vh; --ecl-open-end: 70vh; }

:root {
  --ecl-inset: clamp(16px, 2.5vw, 2rem);   /* the page's ground around an aperture: never under the 16px gutter floor */
  --ecl-radius: clamp(1.25rem, 5vw, 2.75rem);
  --ecl-ring: 3.25rem;
  --ecl-gap: clamp(3rem, 8vw, 5rem);        /* between a section and the next aperture */
}
main { --ecl-out: var(--w-bg); }

/* ---------- the aperture ---------- */
.ecl { position: relative; isolation: isolate; width: min(100% - 2 * var(--ecl-inset), 88rem); margin-inline: auto; }
.ecl-win { position: relative; overflow: clip; border-radius: var(--ecl-radius); color: var(--ecl-fg-text, inherit); }
.ecl-in { display: flow-root; background: var(--ecl-bg); }
/* the ring on the top edge: the section's sigil on a small disc of the
   aperture's own ground, a thin ring of its marks, and a halo of the page's
   ground so it sits cleanly on the seam. Every ring is a bead (orrery.css),
   on the seam's ground. */
.ecl-ring {
  position: absolute; z-index: 4; left: 50%; top: 0; translate: -50% -50%;
  width: var(--ecl-ring); height: var(--ecl-ring); border-radius: 50%;
  pointer-events: none;
}
.ecl-ring.bead-face { --ground: var(--ecl-out); }

/* ---------- the opening ----------
   Scrolling opens the disc from the ring while the aperture's top edge
   climbs through --ecl-open-start/-end; once open it stays open (.is-open,
   nts.js, latches it). Every part runs its own animation of a compositor
   property (scale, opacity) on the aperture's view timeline, over
   the same range, so the compositor runs the whole opening: no inheriting
   variable restyles the subtree, no mask or gradient repaints the card.
   - The disc: .ecl-disc is scaled from the ring point and clipped to a
     circle of radius --ecl-r, the card's farthest corner from the ring
     (nts.js measures it on resize), so its edge is a circle of radius
     scale x --ecl-r. The clip is fixed in the disc's own frame: it scales
     with the disc and is never redrawn. .ecl-in, inside it, is scaled by
     the inverse around the same point, so the ground and the content stay
     put and the edge passes over them. The inverse is keyframed densely
     (ecl-in) so the two stay each other's inverse to a fraction of a pixel
     up to a 1500px radius. The disc never reaches scale 0 (it rests at
     .001, under the ring): disc x inner stays 1, so a figure that sizes
     itself with getBoundingClientRect (which counts transforms) still
     reads its real size while its aperture is closed.
   - The limb: .ecl-win::before, a disc of the limb colour behind the
     ground, scaled a step ahead of it (ecl-limb vs ecl-disc, .22% of the
     radius), so a ring of about 2px (1.2-2.5px from a phone band to a
     desk window) shows round the ground at every size, with no stroke to
     thicken as it grows. It is gone under the corners when complete.
   - A band's words fade in (ecl-words) on a sub-range of the same
     timeline. The ring's sigil sits still.
   Where there is no view timeline, no --ecl-r (no ResizeObserver) or
   reduced motion, every disc is open. */
@supports (animation-timeline: view()) {
  .js .ecl { view-timeline: --ecl block; }
  .js :is(.ecl-disc, .ecl-in, .band.ecl .ecl-in > .wrap), .js .ecl-win::before {
    animation-duration: auto; animation-timing-function: linear; animation-fill-mode: both;
    animation-timeline: --ecl; animation-range: cover var(--ecl-open-start) cover var(--ecl-open-end);
  }
  .js .ecl-disc { animation-name: ecl-disc; transform-origin: 50% 0; clip-path: circle(var(--ecl-r) at 50% 0); }
  .js .ecl-in { animation-name: ecl-in; transform-origin: 50% 0; }
  /* the limb: a disc centred on the ring point; with no --ecl-r it has no size */
  .js .ecl-win::before {
    content: ""; position: absolute; left: calc(50% - var(--ecl-r)); top: calc(-1 * var(--ecl-r)); width: calc(2 * var(--ecl-r)); aspect-ratio: 1;
    border-radius: 50%; background: var(--ecl-limb, var(--ecl-fg)); opacity: .9; pointer-events: none;
    animation-name: ecl-limb;
  }
  /* a band's words: from progress --ecl-hold, over --ecl-show of the range */
  .js .band.ecl .ecl-in > .wrap {
    animation-name: ecl-words;
    animation-range:
      cover calc(var(--ecl-open-start) + var(--ecl-hold, .8) * (var(--ecl-open-end) - var(--ecl-open-start)))
      cover calc(var(--ecl-open-start) + (var(--ecl-hold, .8) + var(--ecl-show, .17)) * (var(--ecl-open-end) - var(--ecl-open-start)));
  }
}
@keyframes ecl-limb { from { scale: 0; } to { scale: 1; } }
@keyframes ecl-disc { from, .32% { scale: .001; } to { scale: .9978; } }
/* 1 / ecl-disc, generated: offsets step by sqrt(1.2 a / 1500) at scale a */
@keyframes ecl-in {
  0% { scale: 1000; } 0.32% { scale: 1000.0000; } 0.41% { scale: 526.3158; } 0.53% { scale: 322.5806; } 0.69% { scale: 212.7660; } 0.88% { scale: 151.5152; }
  1.12% { scale: 111.1111; } 1.38% { scale: 86.2069; } 1.69% { scale: 68.0272; } 2.03% { scale: 55.2486; } 2.41% { scale: 45.6621; } 2.83% { scale: 38.3142; }
  3.29% { scale: 32.5733; } 3.78% { scale: 28.0899; } 4.32% { scale: 24.3902; } 4.89% { scale: 21.4133; } 5.5% { scale: 18.9394; } 6.15% { scale: 16.8634; }
  6.84% { scale: 15.1057; } 7.57% { scale: 13.6054; } 8.33% { scale: 12.3305; } 9.14% { scale: 11.2108; } 9.98% { scale: 10.2459; } 10.87% { scale: 9.3897; }
  11.79% { scale: 8.6430; } 12.75% { scale: 7.9808; } 13.75% { scale: 7.3910; } 14.79% { scale: 6.8634; } 15.87% { scale: 6.3898; } 16.99% { scale: 5.9630; }
  18.15% { scale: 5.5772; } 19.35% { scale: 5.2274; } 20.59% { scale: 4.9092; } 21.86% { scale: 4.6211; } 23.18% { scale: 4.3554; } 24.53% { scale: 4.1135; }
  25.93% { scale: 3.8895; } 27.36% { scale: 3.6846; } 28.83% { scale: 3.4953; } 30.35% { scale: 3.3190; } 31.9% { scale: 3.1566; } 33.49% { scale: 3.0057; }
  35.12% { scale: 2.8653; } 36.79% { scale: 2.7345; } 38.51% { scale: 2.6116; } 40.26% { scale: 2.4975; } 42.04% { scale: 2.3912; } 43.87% { scale: 2.2910; }
  45.74% { scale: 2.1968; } 47.65% { scale: 2.1084; } 49.6% { scale: 2.0251; } 51.59% { scale: 1.9467; } 53.61% { scale: 1.8730; } 55.68% { scale: 1.8031; }
  57.79% { scale: 1.7370; } 59.93% { scale: 1.6748; } 62.12% { scale: 1.6155; } 64.34% { scale: 1.5596; } 66.61% { scale: 1.5063; } 68.91% { scale: 1.4558; }
  71.26% { scale: 1.4077; } 73.64% { scale: 1.3620; } 76.07% { scale: 1.3184; } 78.53% { scale: 1.2770; } 81.03% { scale: 1.2375; } 83.57% { scale: 1.1998; }
  86.16% { scale: 1.1636; } 88.78% { scale: 1.1292; } 91.44% { scale: 1.0963; } 94.14% { scale: 1.0647; } 96.88% { scale: 1.0346; } 99.66% { scale: 1.0056; }
  100% { scale: 1.0022; }
}
@keyframes ecl-words { from { opacity: 0; } to { opacity: 1; } }

/* ---------- home: the windows into the worlds ---------- */
.world.ecl { overflow: visible; --ecl-bg: var(--w-bg); --ecl-fg: var(--w-accent); --ecl-limb: var(--w-accent); padding: 0; }
/* the top padding keeps the ring on the seam clear of the orb's dashed orbit */
.world.ecl .ecl-in { padding: clamp(3.75rem, 7vw, 5rem) 0 clamp(3rem, 8vw, 6rem); color: var(--w-fg); }
.world.ecl .ecl-in > .wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); }
@media (min-width: 760px) { .world.ecl .ecl-in { padding-inline: clamp(1rem, 3vw, 3rem); } }
/* the handover is the breathing space between a section and the next
   aperture: the page's own ground, where the ring sits */
.handover { height: var(--ecl-gap); background: none; opacity: 1; }
@media (min-width: 900px) { .handover { height: var(--ecl-gap); } }

/* the NTS apertures: the home's words band (plywood) and the ledger (ink) */
.band.ecl { background: none; color: inherit; --ecl-bg: var(--band-bg, var(--w-bg-2)); --ecl-fg: var(--band-fg, var(--w-fg)); }
.band.ecl .ecl-win { color: var(--band-fg, var(--w-fg)); }
/* a band's words sit right at its top edge, where the disc is still small:
   they come in whole once the disc has passed them, so no line is ever
   shown cut by the edge (ecl-words, above). --ecl-hold is the progress at
   which they start to show, --ecl-show how much progress the fade takes: a
   short band's words reach its far corners (hold .8), a tall ledger's top
   rows are under the disc almost at once (hold .15). The home windows show
   their orb first and need no hold. */
.words.ecl { padding: 0; overflow: visible; --ecl-hold: .55; --ecl-show: .15; }
.words.ecl .ecl-in { padding: clamp(3rem, 8vw, 6rem) 0; }
.words.ecl .ecl-win::before { opacity: .7; }
/* the ledger, on the home and /events/: a black plate (its --w-* set is in
   nts.css, section 1). Bone text and sigils; ochre for what is yet to come:
   the ring's star, the heading's, the upcoming dates. Selection and focus
   follow the plate, not the bands' shared defaults. */
.ledger-ap { --ecl-hold: .15; --ecl-show: .2; --band-bg: var(--pal-ink); --band-fg: var(--pal-bone); --ecl-limb: var(--code-events); padding: 0; margin-top: var(--ecl-gap); margin-bottom: var(--section); }
.ledger-ap .ecl-in { padding: clamp(2.5rem, 6vw, 4rem) 0; }
.ledger-ap .sect-head .nts-sigil { color: var(--code-events); }
.ledger-ap ::selection { background: var(--w-selection); color: var(--w-selection-fg); }
.ledger-ap :focus-visible { outline-color: var(--w-fg); }
.ledger-ap .ledger li { border-color: var(--w-line); }
.ledger-ap .ledger .nts-sigil { color: var(--w-accent); }
.ledger-ap .ledger li.upcoming .when { color: var(--w-accent-text); }
/* each tag carries its initiative's code dot; the tag names the kind */
.ledger-ap .ledger .kind { --kind-bg: color-mix(in srgb, var(--pal-bone) 12%, var(--pal-ink)); --kind-fg: var(--pal-bone); }
.ledger-ap .ledger .kind::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .45em; border-radius: 50%; vertical-align: .02em; background: var(--kind-dot); }
.ledger-ap li[data-of="nts"] { --kind-dot: var(--code-events); }
/* nts:dots */
.ledger-ap li[data-of="embers"] { --kind-dot: var(--code-embers); }
.ledger-ap li[data-of="philo"] { --kind-dot: var(--code-philo); }
.ledger-ap li[data-of="intersect"] { --kind-dot: var(--code-intersect); }
/* /nts:dots */

/* ---------- inside the worlds: the bands ---------- */
.band.ecl.sect-band { margin-block: var(--section); }
.band.ecl .ecl-in > .wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); }
/* EMBERS: the summon band keeps its fire; the ring carries the fire triangle in night */
.embers-summon.ecl { padding: 0; --ecl-limb: #ffe9d0; }
.embers-summon.ecl .ecl-in { padding: clamp(3rem, 7vw, 4.5rem) 0; }
/* NOT NOT PHILO: the volumes are a disc of the deeper grey with the engraved
   rings; "Next volume" keeps its charcoal */
.philo-volumes { --band-bg: var(--w-bg-2); --band-fg: var(--w-fg); --ecl-limb: #e5174a; --ecl-hold: .3; --ecl-show: .15; }
.philo-volumes .ecl-in { padding: clamp(2.5rem, 6vw, 4rem) 0; }
.philo-volumes .ecl-in > .wrap > h2 { margin: 0; }
.philo-volumes .volumes { margin-top: 1.5rem; }
.philo-next.ecl { padding: 0; margin-top: var(--ecl-gap); --ecl-limb: #e5174a; }
.philo-next.ecl .ecl-in { padding: clamp(3rem, 7vw, 4.5rem) 0; }
.philo-next.ecl .ecl-win::before { opacity: 1; }
/* INTERSECT: the correspondence sits on a lifted black (bg-2 is too close to
   the ground to read as a disc; fixed, with plywood while the page is still
   in the NTS colours before the bleed), phosphor ring */
.intersect-corr { --band-bg: #2a2925; --band-fg: var(--w-fg); --ecl-limb: #ff3b63; --ecl-hold: .4; --ecl-show: .15; }
html[data-bleed-state="before"] .intersect-corr { --band-bg: var(--pal-plywood); }
.intersect-corr .ecl-win::before { opacity: 1; }
.intersect-corr .ecl-in { padding: clamp(2.5rem, 6vw, 4rem) 0; }
.intersect-corr .ecl-win .sect-head { margin-bottom: 1.5rem; }
.intersect-corr .corr th, .intersect-corr .corr td { border-color: var(--w-line-strong); }
/* EVENTS: the whole ledger is one aperture of paper-2 under the star */
.events-ap { margin-top: 1.5rem; }

/* latched open by nts.js once the disc is complete, whichever way the page
   scrolls; open, too, under reduced motion and in print. With no animation
   every part is at rest: scale 1, no turn, full opacity */
.js .ecl.is-open :is(.ecl-disc, .ecl-in, .ecl-ring .nts-sigil, .ecl-in > .wrap) { animation: none; }
.js .ecl.is-open .ecl-disc { clip-path: none; }
.js .ecl.is-open .ecl-win::before { content: none; }
@media (prefers-reduced-motion: reduce) {
  .js .ecl :is(.ecl-disc, .ecl-in, .ecl-ring .nts-sigil, .ecl-in > .wrap) { animation: none !important; }
  .js .ecl .ecl-disc { clip-path: none; }
  .js .ecl .ecl-win::before { content: none; }
}
@media print {
  .ecl :is(.ecl-disc, .ecl-in, .ecl-ring .nts-sigil, .ecl-in > .wrap) { animation: none !important; }
  .ecl .ecl-disc { clip-path: none; }
  .ecl .ecl-win::before { content: none; }
}

/* orrery.css blooms the ground out of the orb with a ::before; here the aperture is the ground */
.world.ecl::before { content: none; }
