/* Głębia — RISK SPIKE. Jednorazowy kod spike'a (kontrakt R1: bez bundlera). */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }

/* ---------- tokeny ---------- */
:root {
  color-scheme: dark;
  --bg: #0d0c0b;
  --ink: #efe9e1;
  --muted: #b0a698;
  --line: rgba(239, 233, 225, 0.18);

  --warm-a: #1a0f0a;
  --warm-b: #3d1f0f;
  --warm-ink: #f2dcbb;
  --warm-accent: #d98e3f;

  --ice-a: #0a1420;
  --ice-b: #1a3a52;
  --ice-ink: #ddeefb;
  --ice-hi: rgba(190, 228, 255, 0.45);

  --still-bg: #e8e6e2;
  --still-ink: #1d1c1a;

  --page: clamp(1rem, 4vw, 4rem);
  --panel-radius: 0.9rem;
  --ritual-length: 300vh; /* długość scrolla sekcji sticky */
  --hinge-start: -85deg;  /* kąt startowy zawiasu; JS czyta tę wartość */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='%23n' opacity='0.55'/%3E%3C/svg%3E");
}

@media (max-width: 720px) {
  :root {
    --ritual-length: 220vh; /* mobile: krótszy przebieg */
    --hinge-start: -50deg;  /* mobile: mniejszy kąt startowy */
  }
}

/* ---------- baza ---------- */
html { background: var(--bg); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  min-width: 320px;
  overflow-x: clip;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
:focus-visible { outline: 3px solid var(--warm-accent); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  translate: 0 -300%;
  background: var(--ink);
  color: var(--bg);
  padding: 0.7rem 1rem;
  text-decoration: none;
}
.skip-link:focus { translate: 0; }

/* ---------- intro / outro ---------- */
.intro {
  display: grid;
  align-content: center;
  gap: 1.2rem;
  min-height: 86vh;
  padding: var(--page);
}
.eyebrow {
  color: var(--warm-accent);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.intro h1 {
  max-width: 14ch;
  font-size: clamp(2.4rem, 7vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.lede { max-width: 58ch; color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.2rem); }

.outro {
  display: grid;
  place-content: center;
  min-height: 55vh;
  padding: var(--page);
}
.outro p { max-width: 48ch; color: var(--muted); text-align: center; }

/* ---------- rytuał: stan bazowy (bez JS / reduced motion) ----------
   Panele statyczne, wyprostowane, pełna treść w kolejności. */
.ritual__pin {
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 1.6vh, 1rem);
  padding: clamp(0.8rem, 2vw, 1.4rem) var(--page);
}
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.steps a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  color: var(--ink);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}
.steps a[aria-current="step"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.stage { display: flex; flex-direction: column; gap: clamp(0.6rem, 1.6vh, 1rem); }

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1rem, 3vh, 2rem);
  min-height: 58vh;
  padding: clamp(1.1rem, 2.6vw, 2.4rem);
  border-radius: var(--panel-radius);
  overflow: hidden;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.05;
  pointer-events: none;
}
.panel__num { font-size: 0.78rem; letter-spacing: 0.16em; }
.panel__body { max-width: 62ch; display: grid; gap: 0.7rem; }
.panel h2 {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.03em;
}
.panel__body p { font-size: clamp(0.92rem, 1.6vw, 1.08rem); }

/* materiały termiczne */
.panel--warm {
  background: linear-gradient(160deg, var(--warm-a), var(--warm-b));
  color: var(--warm-ink);
}
.panel--warm .panel__num { color: var(--warm-accent); }

.panel--ice {
  background:
    linear-gradient(115deg, transparent 40%, rgba(190, 228, 255, 0.16) 46%, rgba(190, 228, 255, 0.04) 52%, transparent 58%),
    linear-gradient(150deg, var(--ice-a) 0%, #122a3e 55%, var(--ice-b) 100%);
  color: var(--ice-ink);
  box-shadow: inset 0 1px 0 var(--ice-hi), inset 0 0 70px rgba(140, 200, 255, 0.08);
}
.panel--ice .panel__num { color: #9fd2f5; }

.panel--still {
  background: var(--still-bg);
  color: var(--still-ink);
}
.panel--still::after { opacity: 0.07; }
.panel--still .panel__num { color: #8a857c; }

/* ---------- rytuał: tryb żywy (JS + brak reduced motion) ---------- */
.is-live .ritual { height: var(--ritual-length); }
.is-live .ritual__pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: clip;
}
.is-live .stage {
  flex: 1;
  min-height: 0;
  perspective: 1200px;
  perspective-origin: 50% 30%;
}
.is-live .panel {
  flex: 1;
  min-height: 0;
  transform-origin: 50% 0;
  transform: rotateX(var(--hinge-start));
  opacity: 0.22;
  backface-visibility: hidden;
}
/* will-change tylko gdy sekcja jest w kadrze (klasa nadawana przez IO) */
.is-live .stage.is-hot .panel { will-change: transform, opacity; }

/* pas bezpieczeństwa: nawet gdyby klasa is-live została przy reduced motion */
@media (prefers-reduced-motion: reduce) {
  .is-live .ritual { height: auto; }
  .is-live .ritual__pin { position: static; height: auto; overflow: visible; }
  .is-live .stage { perspective: none; }
  .is-live .panel { transform: none !important; opacity: 1 !important; flex: none; min-height: 58vh; }
}

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .panel { flex-direction: column; justify-content: space-between; min-height: 48vh; }
  .panel h2 { font-size: clamp(1.4rem, 6vw, 1.9rem); }
  .panel__body p { font-size: 0.9rem; }
  .steps a { padding: 0.45rem 0.7rem; font-size: 0.7rem; }
}
