/* ==========================================================================
   iON — the bulb: canvas, i-dot docks, glyph states, hero stage, intro dim, fallbacks.
   Markup comes from templates/_macros/bulb.twig and templates/_partials/logo.twig.
   Geometry: per font, from the --dot-left / --dot-top / --dot-cut tokens in main.css (measured on the
   real files by _tools/measure-fonts.mjs, 2026-10-12; headlines are General Sans 500: content-area
   ascent 1.01em · stem top 0.53em · dot 0.588–0.72em above the baseline · dot centre 0.119em).
   The tittle follows the logo bulb (44 × 63.5 units, 7 units above a 16-unit stem):
     width 0.28em · height 0.405em · bottom 0.56em above the baseline.
   ========================================================================== */

/* --- the WebGL layer --------------------------------------------------- */
.bulb-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 2147483000;
}
html.bulb-static .bulb-canvas,
html:not(.bulb-js) .bulb-canvas { display: none; }

/* --- headline lines (macro: "\n" in the text) --------------------------- */
.bulb-line { display: block; }

/* --- the i-dot dock ---------------------------------------------------- */
.bulb-i {
  position: relative;
  white-space: nowrap;
}
/* the real letter stays in the DOM; everything above 0.56em over the baseline (its dot) is masked */
.bulb-i__letter {
  -webkit-mask-image: linear-gradient(to bottom, transparent var(--dot-cut, 0.45em), #000 var(--dot-cut, 0.45em));
          mask-image: linear-gradient(to bottom, transparent var(--dot-cut, 0.45em), #000 var(--dot-cut, 0.45em));
}
.bulb-i__dot {
  position: absolute;
  left: var(--dot-left, -0.021em);   /* dot centre − half the tittle (per font, main.css) */
  top: var(--dot-top, 0.045em);      /* content-area ascent − tittle top 0.965em */
  width: 0.28em;
  height: 0.405em;
  pointer-events: none;
  opacity: var(--bulb-glyph-o, 1);
}
.bulb-glyph {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--amber, #FFC21A);
}
.bulb-glyph path,
.bulb-glyph rect {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0;
  transition: fill .5s ease, stroke .5s ease, stroke-width .5s ease;
}

/* unlit: before the bulb has visited (only while the journey drives the states) */
html.bulb-live .bulb-i[data-state="off"] .bulb-glyph,
html.bulb-intro:not(.bulb-live) .bulb-i[data-bulb-role="intro"] .bulb-glyph {
  color: inherit;
}
html.bulb-live .bulb-i[data-state="off"] .bulb-glyph :is(path, rect),
html.bulb-intro:not(.bulb-live) .bulb-i[data-bulb-role="intro"] .bulb-glyph :is(path, rect) {
  fill: color-mix(in srgb, currentColor 6%, transparent);
  stroke: color-mix(in srgb, currentColor 46%, transparent);
  stroke-width: 2.4;
}
/* the safety net: if the module never arrives, the intro glyph lights up with the dim clearing */
html.bulb-intro:not(.bulb-live) .bulb-i[data-bulb-role="intro"] .bulb-glyph {
  animation: bulb-glyph-on .4s ease 2.4s forwards;
}
@keyframes bulb-glyph-on { to { color: var(--amber, #FFC21A); } }

/* --- the hero stage ---------------------------------------------------- */
.bulb-stage {
  position: relative;
  min-height: 280px;
}
@media (width < 576px) and (height < 760px) {   /* short phones: the hero sets a 170px stage (main.css, Hero) */
  .bulb-stage { min-height: 0; }
}
.bulb-stage::before {                       /* warm light pool on the wall (fallback) — inside the box, never overflows */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(closest-side at 50% 44%, color-mix(in srgb, var(--amber, #FFC21A) 30%, transparent), transparent);
  opacity: 1;
  transition: opacity .6s ease;
}
html.bulb-webgl .bulb-stage::before,
html.bulb-intro .bulb-stage::before { opacity: 0; }
.bulb-stage__fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 86%;
  aspect-ratio: 44 / 63.5;
  translate: -50% -50%;
  transition: opacity .6s ease;
}
.bulb-stage__fallback .bulb-glyph {
  filter: drop-shadow(0 0 0.6rem color-mix(in srgb, var(--amber, #FFC21A) 70%, transparent));
}
html.bulb-webgl .bulb-stage__fallback,
html.bulb-intro .bulb-stage__fallback { opacity: 0; }
html.bulb-intro:not(.bulb-live):not(.bulb-webgl) .bulb-stage::before,
html.bulb-intro:not(.bulb-live):not(.bulb-webgl) .bulb-stage__fallback {
  animation: bulb-fallback-in .4s ease 2.4s forwards;
}
@keyframes bulb-fallback-in { to { opacity: 1; } }

/* --- the iON logo (templates/_partials/logo.twig) ---------------------- */
.ion-logo { display: block; height: 100%; width: auto; overflow: visible; }
.ion-logo--ink { color: var(--night, #111111); }
.ion-logo--paper { color: var(--paper, #FFFFFF); }

/* --- intro: the room is dim until the bulb switches on ----------------- */
html.bulb-intro::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147482990;                  /* under the bulb canvas, over everything else */
  pointer-events: none;
  background: rgb(17 17 17 / .58);
  animation: bulb-dim-safety .5s ease 2.4s forwards;
}
@keyframes bulb-dim-safety { to { opacity: 0; visibility: hidden; } }
html.bulb-intro-live::after { display: none; }
.bulb-dim {
  position: fixed;
  inset: 0;
  z-index: 2147482990;
  pointer-events: none;
  background: radial-gradient(circle at var(--bx, 50%) var(--by, 40%),
              rgb(17 17 17 / 0) var(--br, -30vmax),
              rgb(17 17 17 / .58) calc(var(--br, -30vmax) + 30vmax));
  transition: opacity .35s ease;
}
.bulb-dim.is-out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  html.bulb-intro::after, .bulb-dim { display: none; }
  .bulb-glyph :is(path, rect) { transition: none; }
}

/* --- the bulb is the light switch: lights off = dark scheme ------------------------------ */
html[data-scheme="dark"] .ion-logo--ink { color: var(--ink, #f2f2f2); }
html[data-scheme="dark"] .ion-logo--paper { color: var(--on-night, #f2f2f2); }   /* --paper is the dark ground in this scheme */

/* hero stage: drag to turn the bulb, click / tap / Space to switch the light */
.bulb-stage.is-interactive {
  cursor: grab;
  touch-action: pan-y;               /* vertical swipes still scroll the page; sideways swipes turn the bulb */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.bulb-stage.is-interactive.is-dragging { cursor: grabbing; }
.bulb-stage:focus-visible { outline: 2px solid var(--ink, #1a1a1a); outline-offset: 6px; border-radius: 16px; }
.bulb-stage__hint {
  position: absolute;
  left: 50%;
  bottom: 0;
  translate: -50% 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: 0;  /* Quicksand: no tracking */
  color: var(--graphite, #595959);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.bulb-stage.is-interactive:hover .bulb-stage__hint,
.bulb-stage.is-interactive:focus-visible .bulb-stage__hint,
.bulb-stage.is-interactive.show-hint .bulb-stage__hint { opacity: 1; }
.bulb-stage.is-dragging .bulb-stage__hint { opacity: 0; }
@media (width < 576px) {
  /* phones: under the stage, never across the bulb's base, and wrapping inside the column */
  .bulb-stage__hint { top: 100%; bottom: auto; left: 0; right: 0; translate: none; margin-top: 4px; white-space: normal; text-align: center; }
}

/* lights off means off everywhere: the logo bulbs and the nav, practice and menu i-dots show the unlit glyph */
html[data-scheme="dark"] .ion-logo__bulb :is(path, rect),
html[data-scheme="dark"] .idot__g .bulb-glyph :is(path, rect) {
  fill: color-mix(in srgb, currentColor 6%, transparent);
  stroke: color-mix(in srgb, currentColor 46%, transparent);
  stroke-width: 2.4;
}
html[data-scheme="dark"] .idot__g .bulb-glyph { color: inherit; filter: none; }
/* during the switch's view transition the glyphs take their new state at once (no half-way fill in a snapshot) */
html:is(.bulb-vt-on, .bulb-vt-off) .bulb-glyph :is(path, rect) { transition: none; }

/* static mode (no WebGL): the flat bulb still switches the light */
html.bulb-static[data-scheme="dark"] .bulb-stage__fallback .bulb-glyph { color: var(--graphite, #b0b0b0); filter: none; opacity: .5; }

/* the click target that follows the bulb wherever it rests (an i-dot, the header logo) */
.bulb-hit {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;                       /* above the sticky header (50), below the canvas */
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: none;
}
.bulb-hit.is-on { display: block; }

/* the light leaves or enters through the bulb (same-document view transition, journey.js) */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.bulb-vt-on::view-transition-new(root) {
  animation: bulb-light-out 820ms cubic-bezier(.16, 1, .3, 1) both;
}
html.bulb-vt-off::view-transition-old(root) {
  z-index: 2;
  animation: bulb-light-in 640ms cubic-bezier(.55, 0, .75, .06) both;
}
@keyframes bulb-light-out {
  from { clip-path: circle(0 at var(--bulb-vt-x, 50%) var(--bulb-vt-y, 50%)); }
  to   { clip-path: circle(var(--bulb-vt-r, 150vmax) at var(--bulb-vt-x, 50%) var(--bulb-vt-y, 50%)); }
}
@keyframes bulb-light-in {
  from { clip-path: circle(var(--bulb-vt-r, 150vmax) at var(--bulb-vt-x, 50%) var(--bulb-vt-y, 50%)); }
  to   { clip-path: circle(0 at var(--bulb-vt-x, 50%) var(--bulb-vt-y, 50%)); }
}
