/* ==========================================================================
   /kaboom — the server that explodes. Used only by kaboom.html; the canvas
   engine lives in kaboom.js. The hero and the scroll stage are always a dark
   "server room" (in both themes); the incident report below follows the theme.
   ========================================================================== */

/* Full-screen effects canvas: above page backgrounds, below hero/HUD text
   and the status bar. Sized by kaboom.js (divided by --z like #bgCanvas). */
#kbCanvas{ position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; }
.kb-flash{ position: fixed; inset: 0; z-index: 9; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 55%, #fff 0%, #ffe9b8 35%, #ff9a3c 100%); }

.kb-dark{
  --kb-ink: #F3F1EC;
  --kb-muted: #A3A9A6;
  color: var(--kb-ink);
  background:
    radial-gradient(ellipse 70% 60% at 50% 55%, rgba(255,110,40,.10), transparent 70%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    #08090A;
  background-size: auto, 28px 28px, 28px 28px, auto;
}

/* ---------- 1) hero ---------- */
.kb-hero{
  position: relative;
  min-height: calc(100vh / var(--z) - 53px);
  min-height: calc(100svh / var(--z) - 53px);
  display: grid; place-items: center;
  text-align: center;
  overflow: hidden;
  padding: 40px 16px 90px;
}
.kb-hero-inner{ position: relative; z-index: 6; max-width: 760px; }
.kb-back{ color: var(--kb-muted); font-family: var(--mono); font-size: 13px; text-decoration: none; }
.kb-back:hover, .kb-back:focus-visible{ color: var(--kb-ink); text-decoration: underline; }
.kb-eyebrow{ margin-top: 18px; font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: #FF9A3C; }

/* countdown (only while counting) */
.kb-countdown{ display: none; flex-direction: column; align-items: center; margin-top: 18px; }
.kb-hero.counting .kb-countdown{ display: flex; }
.kb-count-label{ font-family: var(--mono); font-size: 14px; letter-spacing: .3em; text-transform: uppercase; color: #fff; background: #C81E12; padding: 6px 14px; border-radius: 999px; box-shadow: 0 0 24px rgba(255,59,47,.7); }
/* while counting, the countdown sits right on top of the rack: only it shows */
.kb-hero.counting .kb-back, .kb-hero.counting .kb-eyebrow{ visibility: hidden; }
.kb-count-num{
  font-family: var(--mono); font-weight: 700; line-height: 1;
  font-size: clamp(120px, 26vw, 240px);
  color: #FF3B2F;
  -webkit-text-stroke: 6px #140302; paint-order: stroke fill;
  text-shadow: 0 0 30px rgba(255,59,47,.8), 0 0 90px rgba(255,59,47,.45);
}
.kb-count-num.tick{ animation: kbTick .9s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes kbTick{ 0%{ transform: scale(2.4); opacity: 0; } 30%{ opacity: 1; } 100%{ transform: scale(1); opacity: 1; } }

/* siren: a red light sweeping around the room while counting */
.kb-siren{
  position: absolute; inset: -50%; z-index: 0; pointer-events: none; opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(255,40,30,.55) 85%, transparent 100%);
  transition: opacity .3s;
}
.kb-hero.alarm .kb-siren{ opacity: 1; animation: kbSpin 1.1s linear infinite; }
.kb-hero.alarm{ box-shadow: inset 0 0 120px rgba(255,30,20,.45); }
@keyframes kbSpin{ to{ transform: rotate(360deg); } }

/* title + text appear after the boom */
.kb-title, .kb-lede, .kb-actions{ visibility: hidden; }
.kb-hero.boomed .kb-title, .kb-hero.boomed .kb-lede, .kb-hero.boomed .kb-actions{ visibility: visible; }
.kb-title{
  margin: 8px 0 0;
  font-family: var(--sans); font-weight: 700; line-height: .9; letter-spacing: -.02em;
  font-size: clamp(56px, 15vw, 190px);
  white-space: nowrap;
  margin-left: -40px; margin-right: -40px;
  filter: drop-shadow(0 0 24px rgba(255,120,30,.55)) drop-shadow(0 6px 0 #5A0E00);
}
.kb-title span{
  display: inline-block;
  background: linear-gradient(180deg, #FFF6C2 0%, #FFD23F 30%, #FF8A1F 62%, #E0281A 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kb-hero.boomed .kb-title span{ animation: kbSlam .7s cubic-bezier(.2,1.6,.4,1) both, kbWobble 2.6s ease-in-out .9s infinite; }
.kb-title span:nth-child(1){ --r: -40deg; --d: .05s; }
.kb-title span:nth-child(2){ --r:  25deg; --d: .12s; }
.kb-title span:nth-child(3){ --r: -15deg; --d: .19s; }
.kb-title span:nth-child(4){ --r:  50deg; --d: .26s; }
.kb-title span:nth-child(5){ --r: -30deg; --d: .33s; }
.kb-title span:nth-child(6){ --r:  35deg; --d: .40s; }
.kb-hero.boomed .kb-title span{ animation-delay: var(--d), calc(var(--d) + .9s); }
@keyframes kbSlam{ 0%{ transform: translateY(-60px) scale(5) rotate(var(--r)); opacity: 0; } 100%{ transform: none; opacity: 1; } }
@keyframes kbWobble{ 0%,100%{ transform: none; } 25%{ transform: translateY(-4px) rotate(-3deg); } 75%{ transform: translateY(3px) rotate(3deg); } }

.kb-lede{ margin: 22px auto 0; max-width: 560px; font-size: 18px; color: var(--kb-ink); opacity: .9; }
.kb-hero.boomed .kb-lede{ animation: kbFadeUp .6s ease .7s both; }
.kb-actions{ margin-top: 26px; display: flex; gap: 16px; justify-content: center; align-items: center; flex-wrap: wrap; }
.kb-hero.boomed .kb-actions{ animation: kbFadeUp .6s ease 1s both; }
@keyframes kbFadeUp{ from{ opacity: 0; transform: translateY(14px); } to{ opacity: 1; transform: none; } }
.kb-btn{
  font-family: var(--mono); font-size: 14px; font-weight: 600; cursor: pointer;
  color: #1A0A00; background: linear-gradient(180deg, #FFD23F, #FF8A1F);
  border: 0; border-radius: 999px; padding: 11px 22px;
  box-shadow: 0 4px 0 #9A3A00, 0 0 24px rgba(255,138,31,.45);
  transition: transform .1s, box-shadow .1s;
}
.kb-btn:hover{ transform: translateY(-1px); }
.kb-btn:active{ transform: translateY(3px); box-shadow: 0 1px 0 #9A3A00, 0 0 24px rgba(255,138,31,.45); }
.kb-tip{ font-family: var(--mono); font-size: 13px; color: var(--kb-muted); }

.kb-scroll{
  position: absolute; left: 0; right: 0; bottom: 22px; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--kb-muted);
  opacity: 0; transition: opacity .6s 1.4s;
}
.kb-hero.boomed .kb-scroll{ opacity: 1; }
.kb-scroll b{ font-size: 22px; color: #FF9A3C; animation: kbBounce 1.2s ease-in-out infinite; }
@keyframes kbBounce{ 0%,100%{ transform: none; } 50%{ transform: translateY(8px); } }

/* ---------- 2) scroll stage ---------- */
.kb-stage{ position: relative; height: calc(560vh / var(--z)); }
.kb-sticky{
  --heat: 0;
  position: sticky; top: 0;
  height: calc(100vh / var(--z));
  height: calc(100svh / var(--z));
  overflow: hidden;
  box-shadow: inset 0 0 calc(var(--heat) * 220px) rgba(255,50,10,calc(var(--heat) * .65));
}
.kb-hazard{
  position: absolute; left: 0; right: 0; height: 16px; z-index: 6; pointer-events: none;
  background: repeating-linear-gradient(-45deg, #FFC400 0 18px, #111 18px 36px);
  opacity: 0; transition: opacity .3s;
}
.kb-hazard-top{ top: var(--bar, 53px); }
.kb-hazard-bottom{ bottom: 0; }
.kb-sticky.hot .kb-hazard{ opacity: .9; animation: kbHazard .6s linear infinite; }
@keyframes kbHazard{ to{ background-position: 51px 0; } }

.kb-vcr{
  position: absolute; top: 80px; left: 4%; z-index: 6;
  font-family: var(--mono); font-weight: 700; font-size: 20px; letter-spacing: .08em;
  color: #fff; text-shadow: 2px 0 #FF2A6D, -2px 0 #2AF5FF;
}
.kb-vcr.rew{ animation: kbVcrBlink 1s steps(2) infinite; }
.kb-vcr.rec{ color: #FF3B2F; text-shadow: 0 0 12px rgba(255,59,47,.8); }
@keyframes kbVcrBlink{ 50%{ opacity: .25; } }
/* VHS-ish rewind lines while scrubbing back in time */
.kb-sticky.rewinding::after{
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.05) 0 2px, transparent 2px 6px);
  animation: kbRoll .35s linear infinite;
}
@keyframes kbRoll{ to{ background-position: 0 24px; } }

.kb-hud{
  position: absolute; z-index: 6; left: 4%; top: 50%; transform: translateY(-50%);
  width: 270px; display: grid; gap: 12px;
}
.kb-phase{
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.45); color: #8FE3B3;
}
.kb-phase.warm{ color: #FFD23F; border-color: rgba(255,210,63,.4); }
.kb-phase.hot{ color: #FF8A1F; border-color: rgba(255,138,31,.5); }
.kb-phase.crit{ color: #fff; background: #C81E12; border-color: #FF5A47; animation: kbPulse .5s ease-in-out infinite alternate; }
.kb-phase.boom{ color: #1A0A00; background: #FFD23F; border-color: #FFD23F; }
.kb-phase.rewind{ color: #7DD3FC; border-color: rgba(125,211,252,.4); }
@keyframes kbPulse{ to{ box-shadow: 0 0 24px rgba(255,59,47,.8); } }
.kb-meter{
  padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  display: grid; gap: 2px;
}
.kb-meter-label{ font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--kb-muted); }
.kb-meter-val{ font-family: var(--mono); font-weight: 700; font-size: 22px; color: var(--kb-ink); font-variant-numeric: tabular-nums; }
.kb-bar{ height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 4px; }
.kb-bar i{ display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #34D399, #FFD23F 50%, #FF3B2F); }

.kb-log{
  position: absolute; z-index: 6; right: 4%; top: 50%; transform: translateY(-50%);
  width: 360px; height: 320px; display: flex; flex-direction: column;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(5,6,7,.78); backdrop-filter: blur(4px);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  overflow: hidden;
}
.kb-log-head{ display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.08); color: var(--kb-muted); }
.kb-log-head i{ width: 9px; height: 9px; border-radius: 50%; background: #FF5F57; }
.kb-log-head i:nth-child(2){ background: #FEBC2E; }
.kb-log-head i:nth-child(3){ background: #28C840; }
.kb-log-head span{ margin-left: 6px; }
.kb-log-body{ flex: 1; padding: 10px 12px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.kb-log-body div{ color: #C9D1CD; animation: kbLogIn .25s ease both; }
.kb-log-body .ts{ color: #6B7570; }
.kb-log-body .ok{ color: #8FE3B3; }
.kb-log-body .warn{ color: #FFD23F; }
.kb-log-body .err{ color: #FF6B5E; font-weight: 700; }
@keyframes kbLogIn{ from{ opacity: 0; transform: translateX(-8px); } to{ opacity: 1; transform: none; } }

@media (max-width: 899px){
  .kb-vcr{ top: calc(var(--bar, 53px) + 22px); right: 16px; left: auto; font-size: 13px; }
  .kb-hud{ left: 16px; right: 16px; top: calc(var(--bar, 53px) + 14px); transform: none; width: auto; grid-template-columns: 1fr 1fr; gap: 8px; }
  .kb-phase{ grid-column: 1 / -1; font-size: 13px; padding: 6px 10px; margin-right: 90px; }
  .kb-meter{ padding: 7px 10px; }
  .kb-meter-label{ font-size: 10px; }
  .kb-meter-val{ font-size: 16px; }
  .kb-log{ left: 16px; right: 16px; top: auto; bottom: 24px; transform: none; width: auto; height: 118px; font-size: 11px; }
  .kb-log-head{ padding: 5px 10px; }
  .kb-log-body{ padding: 6px 10px; }
}

/* ---------- 3) aftermath ---------- */
.kb-after{ padding-top: 64px; padding-bottom: 40px; }
.kb-section{ margin-bottom: 64px; }
.kb-grid{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 800px){ .kb-grid{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px){ .kb-grid{ grid-template-columns: 1fr; } }
.kb-card{
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px;
  transition: border-color .2s, transform .2s;
}
.kb-card:hover{ border-color: #FF8A1F; transform: translateY(-2px) rotate(-.4deg); }
.kb-card h3{ margin: 0 0 6px; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #E2661B; }
:root[data-theme="dark"] .kb-card h3, :root:not([data-theme="light"]) .kb-card h3{ color: #FF9A3C; }
.kb-card p{ margin: 0; color: var(--ink); }
.kb-card p.kb-big{ font-family: var(--mono); font-weight: 700; font-size: 26px; font-variant-numeric: tabular-nums; }

.kb-danger{ display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 30px 0 10px; }
.kb-button-wrap{
  position: relative; width: 230px; height: 230px; border-radius: 50%;
  display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, #FFC400 0 16px, #151515 16px 32px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  perspective: 700px;
}
.kb-button-wrap::before{ content: ""; position: absolute; inset: 18px; border-radius: 50%; background: #1A1D1C; box-shadow: inset 0 4px 12px rgba(0,0,0,.6); }
.kb-red{
  position: relative; z-index: 1;
  width: 160px; height: 160px; border-radius: 50%; border: 0; cursor: pointer;
  font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .04em; color: #fff;
  background: radial-gradient(circle at 35% 30%, #FF7B6B, #E0201A 45%, #8A0A05);
  box-shadow: 0 10px 0 #5C0603, 0 14px 24px rgba(0,0,0,.5);
  transform: translateY(-6px);
  transition: transform .08s, box-shadow .08s;
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}
.kb-red:not(:disabled):hover{ filter: brightness(1.08); }
.kb-red:active{ transform: translateY(2px); box-shadow: 0 2px 0 #5C0603, 0 4px 10px rgba(0,0,0,.5); }
.kb-red:disabled{ cursor: default; }
.kb-cover{
  position: absolute; z-index: 2; inset: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255,255,255,.55);
  background: linear-gradient(160deg, rgba(200,230,255,.35), rgba(160,200,240,.12) 55%, rgba(255,255,255,.25));
  color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  transform-origin: 50% 0;
  transition: transform .45s cubic-bezier(.3,1.4,.5,1), opacity .3s;
  display: grid; place-items: end center; padding-bottom: 22px;
}
.kb-cover:hover{ background-color: rgba(255,255,255,.08); }
.kb-button-wrap.open .kb-cover{ transform: rotateX(118deg); opacity: .55; pointer-events: none; }
.kb-pressed{ margin: 0; font-family: var(--mono); font-size: 14px; color: var(--muted); text-align: center; min-height: 1.6em; }

.kb-real{ text-align: center; font-family: var(--mono); font-size: 14px; }
.kb-real a{ color: var(--ink); }

/* Respect reduced motion: no siren spin, no letter slam/wobble, no rolling lines */
@media (prefers-reduced-motion: reduce){
  .kb-hero.alarm .kb-siren, .kb-sticky.hot .kb-hazard, .kb-sticky.rewinding::after, .kb-scroll b, .kb-vcr.rew, .kb-phase.crit{ animation: none; }
  .kb-hero.boomed .kb-title span, .kb-count-num.tick{ animation: none; }
}
