/* ==========================================================================
   Skillful Energy: logo intro overlay (#sk-intro)
   Load after tokens.css. Every name here starts with sk-intro.
   The overlay is hidden unless the inline <head> snippet put
   .sk-intro-play on <html>, so it never flashes on a reload or under
   reduced motion. Timings come from the --intro-* tokens; the fallbacks
   keep the overlay safe if tokens.css is missing.

   Timeline (default tokens, ms from first paint):
     0    - 900   S outline draws (stroke-dashoffset)
     700  - 1020  S fills maroon, outline fades
     940  - 1460  gold pulse runs round the inner edge of the mark
     1000 - 1480  wordmark fades in (SKILLFUL, then ENERGY DEVELOPMENT)
     1620 - 2040  maroon bloom grows from the mark and covers the screen
     2040 - 2200  overlay fades out over the maroon hero
     2440         CSS failsafe: overlay hidden even if logo-intro.js never ran
                  (--intro-max minus 60 ms, so it lands inside the 2.5 s ceiling)
   ========================================================================== */

#sk-intro {
  display: none;
}

html.sk-intro-play #sk-intro {
  /* timings, from tokens.css */
  --sk-intro-t-draw: var(--intro-draw, 900ms);
  --sk-intro-t-fill: var(--intro-fill, 320ms);
  --sk-intro-t-pulse: var(--intro-pulse, 520ms);
  --sk-intro-t-word: var(--intro-wordmark, 420ms);
  --sk-intro-t-bloom: var(--intro-dissolve, 420ms);
  --sk-intro-t-total: var(--intro-total, 2200ms);
  --sk-intro-t-max: var(--intro-max, 2500ms);
  --sk-intro-t-out: 160ms;
  /* start times */
  --sk-intro-at-fill: calc(var(--sk-intro-t-draw) - 200ms);
  --sk-intro-at-pulse: calc(var(--sk-intro-t-draw) + 40ms);
  --sk-intro-at-word: calc(var(--sk-intro-at-pulse) + 60ms);
  --sk-intro-at-out: calc(var(--sk-intro-t-total) - var(--sk-intro-t-out));
  --sk-intro-at-bloom: calc(var(--sk-intro-at-out) - var(--sk-intro-t-bloom));
  /* curves */
  --sk-intro-ease-out: var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
  --sk-intro-ease-pulse: cubic-bezier(0.5, 0, 0.25, 1);
  --sk-intro-ease-soft: cubic-bezier(0.65, 0, 0.35, 1);
  /* lockup height: 140px on desktop, fits a 375px phone with 24px margins */
  --sk-intro-h: clamp(3.5rem, calc((100vw - 3rem) / 4.287), 8.75rem);

  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  contain: strict;
  background: var(--c-warm-white, #F3EFEE);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
  /* 1: the planned fade-out.
     2: hidden (so no longer blocking clicks) the moment the fade ends.
     3: the hard failsafe just inside --intro-max, whatever the tokens say.
     2 and 3 hold "hidden" across the whole keyframe range: Chrome can stop a
     finished 1 ms animation a hair short of 100%, so an end-only keyframe
     is not reliable. */
  animation:
    sk-intro-out var(--sk-intro-t-out) linear var(--sk-intro-at-out) both,
    sk-intro-gone 1ms linear var(--sk-intro-t-total) forwards,
    sk-intro-failsafe 1ms linear calc(var(--sk-intro-t-max) - 60ms) forwards;
}

/* Scroll lock: added and always removed by logo-intro.js, never by CSS alone,
   so a missing script can't leave the page locked. The stable gutter keeps
   the layout from shifting when the scrollbar comes back. */
html.sk-intro-lock {
  overflow: hidden;
  scrollbar-gutter: stable;
}

.sk-intro-stage {
  position: relative;
  width: calc(var(--sk-intro-h) * 4.287);
  height: var(--sk-intro-h);
}

.sk-intro-logo {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ---- 1. outline draws ------------------------------------------------- */
.sk-intro-draw {
  fill: none;
  stroke: var(--c-maroon, #4F0C0E);
  stroke-width: 14;
  stroke-linejoin: round;
  stroke-dasharray: 1 1;          /* each subpath has pathLength="1" */
  stroke-dashoffset: 1;
  animation:
    sk-intro-draw var(--sk-intro-t-draw) var(--sk-intro-ease-soft) 0ms both,
    sk-intro-fade-out var(--sk-intro-t-fill) var(--sk-intro-ease-out) var(--sk-intro-at-fill) both;
}

/* ---- 2. fill ---------------------------------------------------------- */
.sk-intro-fill {
  fill: var(--c-maroon, #4F0C0E);
  opacity: 0;
  animation: sk-intro-fade-in var(--sk-intro-t-fill) var(--sk-intro-ease-out) var(--sk-intro-at-fill) both;
}

/* ---- 3. gold pulse, clipped to the mark so it reads on maroon --------- */
.sk-intro-pulse {
  fill: none;
  stroke: var(--c-gold, #D3C585);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sk-intro-pulse-head {
  stroke-width: 56;
  stroke-dasharray: 0.07 1.3;
  stroke-dashoffset: 0.09;
  animation: sk-intro-run var(--sk-intro-t-pulse) var(--sk-intro-ease-pulse) var(--sk-intro-at-pulse) both;
}
.sk-intro-pulse-tail {
  stroke-width: 36;
  stroke-opacity: 0.45;
  stroke-dasharray: 0.2 1.3;
  stroke-dashoffset: 0.22;
  animation: sk-intro-run-tail var(--sk-intro-t-pulse) var(--sk-intro-ease-pulse) var(--sk-intro-at-pulse) both;
}
/* the drop is a shorter subpath, so its dash is a larger share of it */
.sk-intro-pulse-head.sk-intro-on-drop {
  stroke-dasharray: 0.18 1.3;
  stroke-dashoffset: 0.2;
  animation-name: sk-intro-run-drop;
}
.sk-intro-pulse-tail.sk-intro-on-drop {
  stroke-dasharray: 0.4 1.3;
  stroke-dashoffset: 0.42;
  animation-name: sk-intro-run-drop-tail;
}

/* ---- 4. wordmark ------------------------------------------------------ */
.sk-intro-word {
  fill: var(--c-graphite, #32312F);
  opacity: 0;
  animation: sk-intro-word var(--sk-intro-t-word) var(--sk-intro-ease-out) var(--sk-intro-at-word) both;
}
.sk-intro-word-2 {
  animation-delay: calc(var(--sk-intro-at-word) + 60ms);
}

/* ---- 5. bloom: maroon disc from the mark's centre, covers the viewport -- */
.sk-intro-bloom {
  position: absolute;
  left: 13.0277%;                 /* mark centre: 558.5 / 4287 */
  top: 50%;
  width: 100vmax;
  height: 100vmax;
  margin: -50vmax 0 0 -50vmax;
  border-radius: 50%;
  background: var(--c-maroon, #4F0C0E);
  transform: scale(0);           /* scale 2 = radius 100vmax: covers any viewport from this origin */
  will-change: transform;
  pointer-events: none;
  animation: sk-intro-bloom var(--sk-intro-t-bloom) var(--sk-intro-ease-soft) var(--sk-intro-at-bloom) both;
}

/* ---- keyframes -------------------------------------------------------- */
@keyframes sk-intro-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes sk-intro-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sk-intro-fade-out { from { opacity: 1; } to { opacity: 0; } }
/* head and tail move the same distance, start just before the path and end past it */
@keyframes sk-intro-run { from { stroke-dashoffset: 0.09; } to { stroke-dashoffset: -1.16; } }
@keyframes sk-intro-run-tail { from { stroke-dashoffset: 0.22; } to { stroke-dashoffset: -1.03; } }
@keyframes sk-intro-run-drop { from { stroke-dashoffset: 0.2; } to { stroke-dashoffset: -1.25; } }
@keyframes sk-intro-run-drop-tail { from { stroke-dashoffset: 0.42; } to { stroke-dashoffset: -1.03; } }
@keyframes sk-intro-word {
  from { opacity: 0; transform: translateX(-36px); }
  to { opacity: 1; transform: none; }
}
@keyframes sk-intro-bloom { from { transform: scale(0); } to { transform: scale(2); } }
@keyframes sk-intro-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes sk-intro-gone { from, to { visibility: hidden; opacity: 0; } }
@keyframes sk-intro-failsafe { from, to { visibility: hidden; opacity: 0; } }

/* never under reduced motion or in print, whatever the classes say */
@media (prefers-reduced-motion: reduce) {
  #sk-intro { display: none !important; }
}
@media print {
  #sk-intro { display: none !important; }
}
