/* ============================================
   PROPERUS SCROLL STORY
   Drei Szenen, choreografiert über Scroll:
   1. Chaos — Icons schwirren, Counter tickt hoch
   2. Engine — alles wird absorbiert
   3. Ruhe — alles aufgeräumt, Counter 0
   ============================================ */

.scroll-story {
  position: relative;
  width: 100%;
  height: 360vh;            /* Pin-Distanz: ~3.6× Viewport */
  background: var(--c-bg-deep);
  isolation: isolate;
  overflow: clip;
}

/* The pinned stage */
.ss__pin {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- BACKGROUND ---------- */
.ss__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(184, 50, 50, 0) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(184, 126, 95, 0) 0%, transparent 60%),
    var(--c-bg-deep);
  transition: background 0.6s ease;
}

.ss__bg-grid {
  position: absolute;
  inset: 0;
  background-size: 56px 56px;
  background-image:
    linear-gradient(to right, rgba(212, 151, 111, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(212, 151, 111, 0.05) 1px, transparent 1px);
  -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, black 0%, transparent 75%);
  opacity: 0.5;
}

.ss__bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0;
  pointer-events: none;
}
.ss__bg-orb--red {
  width: 50rem;
  height: 50rem;
  top: -20rem;
  left: -15rem;
  background: radial-gradient(circle, rgba(184, 60, 50, 0.4), transparent 65%);
}
.ss__bg-orb--gold {
  width: 50rem;
  height: 50rem;
  bottom: -20rem;
  right: -15rem;
  background: radial-gradient(circle, rgba(212, 151, 111, 0.5), transparent 65%);
}

/* ---------- STAGE (the icons + engine live here) ---------- */
.ss__stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- FLOATING ICONS ---------- */
.ss__icon {
  position: absolute;
  --x: 50%;
  --y: 50%;
  --rot: 0deg;
  --baseX: 0px;
  --baseY: 0px;
  left: var(--x);
  top: var(--y);
  width: clamp(2.6rem, 4.5vw, 3.6rem);
  height: clamp(2.6rem, 4.5vw, 3.6rem);
  transform: translate(-50%, -50%) rotate(var(--rot));
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(28, 22, 18, 0.95), rgba(18, 14, 11, 0.98));
  border: 1px solid rgba(212, 151, 111, 0.22);
  color: rgba(212, 151, 111, 0.88);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  will-change: transform, opacity;
}

.ss__icon svg {
  width: 55%;
  height: 55%;
  stroke-width: 1.8;
}

/* When chaos is active — red accents + shake */
.ss__icon.is-chaos {
  border-color: rgba(220, 80, 60, 0.5);
  color: rgba(255, 140, 120, 0.95);
  animation: ss-shake 1.4s ease-in-out infinite alternate;
}
@keyframes ss-shake {
  0%   { transform: translate(-50%, -50%) rotate(calc(var(--rot) - 1deg)) translate(-1px, -1px); }
  100% { transform: translate(-50%, -50%) rotate(calc(var(--rot) + 1deg)) translate(1px, 1px); }
}

/* Stagger shake delay per icon */
.ss__icon:nth-child(1) { animation-delay: 0.14s; }
.ss__icon:nth-child(2) { animation-delay: 0.50s; }
.ss__icon:nth-child(3) { animation-delay: 0.87s; }
.ss__icon:nth-child(4) { animation-delay: 0.20s; }
.ss__icon:nth-child(5) { animation-delay: 0.62s; }
.ss__icon:nth-child(6) { animation-delay: 0.95s; }
.ss__icon:nth-child(7) { animation-delay: 0.34s; }
.ss__icon:nth-child(8) { animation-delay: 0.76s; }
.ss__icon:nth-child(9) { animation-delay: 0.45s; }
.ss__icon:nth-child(10) { animation-delay: 0.84s; }

/* ---------- ENGINE (center sphere) ---------- */
.ss__engine {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(280px, 36vw, 460px);
  height: clamp(280px, 36vw, 460px);
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  will-change: transform, opacity;
}

.ss__engine svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ss__ring {
  fill: none;
  stroke-linecap: round;
  transform-origin: 200px 200px;
}
.ss__ring--1 {
  stroke: rgba(212, 151, 111, 0.22);
  stroke-width: 1.2;
  stroke-dasharray: 6 14;
  animation: ss-spin 30s linear infinite;
}
.ss__ring--2 {
  stroke: rgba(212, 151, 111, 0.35);
  stroke-width: 1.4;
  stroke-dasharray: 130 60;
  animation: ss-spin-rev 22s linear infinite;
}
.ss__ring--3 {
  stroke: rgba(212, 151, 111, 0.5);
  stroke-width: 1.2;
  stroke-dasharray: 4 7;
  animation: ss-spin 16s linear infinite;
}
@keyframes ss-spin     { to { transform: rotate(360deg); } }
@keyframes ss-spin-rev { to { transform: rotate(-360deg); } }

.ss__core {
  fill: rgba(184, 126, 95, 0.1);
  stroke: rgba(212, 151, 111, 0.55);
  stroke-width: 1.5;
  transform-origin: 200px 200px;
  animation: ss-core-pulse 2.4s ease-in-out infinite;
}
.ss__core-inner {
  fill: rgba(212, 151, 111, 0.85);
  filter: drop-shadow(0 0 22px rgba(212, 151, 111, 0.7));
  transform-origin: 200px 200px;
  animation: ss-core-pulse 2.4s ease-in-out infinite reverse;
}
@keyframes ss-core-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.08); opacity: 0.7; }
}

.ss__engine-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.22em;
  font-weight: 600;
  color: var(--c-text-primary);
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

/* ---------- CAPTIONS ---------- */
.ss__captions {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6vw 8vh;
  text-align: center;
}

.ss__caption {
  position: absolute;
  bottom: 8vh;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  width: min(680px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  will-change: transform, opacity;
}

.ss__overline {
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  font-weight: 600;
  color: rgba(212, 151, 111, 0.75);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.ss__caption h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
  max-width: 18ch;
  color: var(--c-text-primary);
}

.ss__caption h2 em {
  font-style: italic;
  font-weight: 500;
  background: linear-gradient(135deg, #E8C9A8, #D4976F);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ss__caption p {
  font-size: clamp(0.95rem, 1.3vw, 1.05rem);
  color: rgba(250, 250, 250, 0.7);
  margin: 0;
  max-width: 36ch;
  line-height: 1.6;
}

.ss__counter {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: rgba(255, 140, 120, 0.95);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-top: 0.4rem !important;
}

/* ---------- TOP HEADER (overline + scene marker) ---------- */
.ss__header {
  position: absolute;
  top: calc(var(--nav-height, 72px) + 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.ss__scene-label {
  font-family: var(--font-body);
  font-size: 0.6rem;
  letter-spacing: 0.32em;
  font-weight: 600;
  color: rgba(212, 151, 111, 0.6);
  text-transform: uppercase;
}

.ss__scene-num {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--c-text-primary);
  text-transform: uppercase;
}

/* ---------- PROGRESS BAR (right edge) ---------- */
.ss__progress {
  position: absolute;
  right: 2.4vw;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 30vh;
  background: rgba(212, 151, 111, 0.12);
  z-index: 5;
  pointer-events: none;
  border-radius: 2px;
  overflow: hidden;
}

.ss__progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg,
    rgba(232, 201, 168, 0.9),
    rgba(212, 151, 111, 0.7),
    rgba(184, 126, 95, 0.5));
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(212, 151, 111, 0.4);
}

.ss__progress-marks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.ss__progress-mark {
  width: 6px;
  height: 1px;
  background: rgba(212, 151, 111, 0.5);
  margin-left: -2px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 767px) {
  .scroll-story { height: 320vh; }
  .ss__icon { width: 2.4rem; height: 2.4rem; border-radius: 10px; }
  .ss__caption { bottom: 6vh; }
  .ss__progress { right: 1rem; height: 24vh; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  .scroll-story { height: auto; min-height: 80vh; padding: 6rem 0; }
  .ss__pin { position: relative; height: auto; }
  .ss__icon { animation: none !important; }
  .ss__caption {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none !important;
    opacity: 1 !important;
    margin: 2rem auto;
  }
  .ss__caption--1, .ss__caption--2 { display: none; }
  .ss__engine { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
