/**
 * framework-scrolly.css — Phase 7 — SAFE-AI framework scrollytelling.
 *
 * Pinned-sticky column (.scrolly-sticky) + scroll-progress rail (.scrolly-rail).
 * Stages 1–4 render as ASSI card row (.stages.stages-4 > .stage × 4);
 * Stage 5 "Evolve" renders as full-width .stage-bar below — NOT the prototype's
 * 5-sequential-cards (per D-10 + PROJECT.md canonical structure).
 *
 * Pitfall 2: DO NOT add overflow: hidden on section.framework or any ancestor
 * of .scrolly-sticky — breaks position: sticky. Gradient glow handled by
 * ::before radial-gradient instead.
 *
 * Reduced-motion + mobile <900px (D-12): .scrolly-sticky drops to position: static
 * (handled by @media blocks below). Content remains fully visible.
 */

/* ---------- Framework section shell ---------- */
.framework {
  padding: 120px 0 96px; border-top: 1px solid var(--color-border);
  background: var(--color-background);
  position: relative;
  /* DO NOT ADD overflow: hidden — it breaks position: sticky for the
     scrollytelling frame (Pitfall 2). Gradient glow uses ::before below. */
}
.framework::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(1000px 400px at 50% 0%, rgba(0,212,170,0.06), transparent 60%);
}
.framework .top {
  display: grid; grid-template-columns: 1fr 1fr; gap: 72px; margin-bottom: 72px; align-items: end;
  position: relative;
}
.framework .top h2 { margin: 12px 0 0; max-width: 18ch; }
.framework .top .r p { font-size: 17px; line-height: 1.7; color: var(--color-foreground-muted); max-width: 52ch; margin: 0 0 18px; }
.framework .top .badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.framework .top .std {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--color-foreground-muted); padding: 5px 10px;
  border: 1px solid var(--color-border); border-radius: 4px;
}

/* ---------- Stages row (ASSI: 4 cards per D-10) ---------- */
.stages {
  position: relative;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
}
.stages.stages-4 { grid-template-columns: repeat(4, 1fr); }

/* Stage 5 "Evolve" — continuous horizontal bar under stages 1–4 (D-10) */
.stage-bar {
  position: relative;
  margin-top: 20px;
  padding: 22px 28px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 32px; align-items: center;
  background: linear-gradient(90deg, rgba(0,212,170,0.04), rgba(0,212,170,0.10) 50%, rgba(0,212,170,0.04));
  border: 1px solid rgba(0,212,170,0.25);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s ease, background .2s ease;
}
.stage-bar:hover, .stage-bar.active { border-color: var(--color-accent); }
.stage-bar .sb-left { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.stage-bar .num {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--color-accent);
}
.stage-bar .sb-title { display: flex; align-items: center; gap: 12px; }
.stage-bar .sb-title h3 { margin: 0; font-size: 22px; font-weight: 600; color: var(--color-foreground); }
.stage-bar .marker.sm {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--color-accent); background: rgba(0,212,170,0.08);
  display: inline-flex; align-items: center; justify-content: center; color: var(--color-accent);
}
.stage-bar .marker.sm svg { width: 18px; height: 18px; }
.stage-bar .sb-blurb {
  margin: 0; font-size: 14px; line-height: 1.55; color: var(--color-foreground-muted);
}
.stage-bar .sb-right .pill {
  display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  padding: 5px 10px; border-radius: 3px;
  background: var(--color-accent); color: #0A0A0F; text-transform: uppercase; font-weight: 600;
}
/* animated flow dots along the bar */
.stage-bar .sb-flow {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0,212,170,0.35), transparent);
  pointer-events: none;
}
.stage-bar .sb-flow span {
  position: absolute; top: -2px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-accent); box-shadow: 0 0 10px rgba(0,212,170,0.6);
  animation: sb-flow 6s linear infinite;
}
.stage-bar .sb-flow span:nth-child(2) { animation-delay: 1.5s; }
.stage-bar .sb-flow span:nth-child(3) { animation-delay: 3s; }
.stage-bar .sb-flow span:nth-child(4) { animation-delay: 4.5s; }
@keyframes sb-flow {
  0% { left: -2%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: 102%; opacity: 0; }
}

/* ---------- Individual stage cards ---------- */
.stage {
  position: relative;
  padding: 28px 24px 28px;
  border-left: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .2s ease;
}
.stage:first-child { border-left: none; }
.stage:hover { background: rgba(19,19,26,0.5); }
.stage.active { background: var(--color-card); }

.stage .num {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em;
  color: var(--color-accent); margin-bottom: 16px;
}
.stage .marker {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
  background: var(--color-background);
  transition: all .2s ease;
}
.stage.active .marker, .stage:hover .marker { border-color: var(--color-accent); background: rgba(0,212,170,0.08); }
.stage .marker svg { width: 20px; height: 20px; stroke: var(--color-accent); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.stage h3 { margin: 0 0 8px; font-size: 22px; font-weight: 600; color: var(--color-foreground); }
.stage .blurb { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: var(--color-foreground-muted); }
.stage .deliver { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--color-foreground-subtle); }
.stage .deliver strong { color: var(--color-foreground-muted); font-weight: 400; }
.stage .pill {
  display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  padding: 3px 7px; border-radius: 3px; margin-top: 14px;
  background: rgba(0,212,170,0.08); color: var(--color-accent); text-transform: uppercase;
}

/* ---------- Stage detail expanded row (shown when active) ---------- */
.stage-detail {
  margin-top: 48px;
  padding: 32px; background: var(--color-card);
  border: 1px solid var(--color-border); border-radius: 12px;
  display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 40px;
}
.stage-detail .big-num {
  font-family: var(--font-mono); font-size: 72px; line-height: 1; font-weight: 600;
  color: var(--color-accent); letter-spacing: -0.02em;
}
.stage-detail h4 {
  margin: 0 0 10px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em;
  color: var(--color-foreground-subtle); text-transform: uppercase;
}
.stage-detail ul { list-style: none; margin: 0; padding: 0; }
.stage-detail li {
  padding-left: 18px; position: relative; font-size: 14px; line-height: 1.5;
  color: var(--color-foreground); margin-bottom: 8px;
}
.stage-detail li::before {
  content: ''; position: absolute; left: 0; top: 9px; width: 6px; height: 6px;
  background: var(--color-accent); border-radius: 1px; transform: rotate(45deg);
}

/* ============================================================
   Scrollytelling frame (Framework)
   Outer .scrolly-frame is tall (~4.2× viewport per D-09). Inside,
   .scrolly-sticky pins at the top and JS advances the active stage +
   detail based on scroll position within the frame. A progress rail
   sits on the right.
   ============================================================ */
.scrolly-frame {
  position: relative;
  /* ~1 full viewport per stage, 5 stages total. Feels deliberate, not sluggish. */
  min-height: 420vh;
}
.scrolly-sticky {
  position: sticky;
  /* Sticky offset = header height (~77px after Phase 7 logo bump) + ~43px
     breathing room so the "STAGE 0n" labels aren't flush against the nav. */
  top: 120px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  /* Give content room but keep it in-viewport (top + bottom buffer = 140px) */
  max-height: calc(100vh - 140px);
}

/* Stage cards inside the scrolly become slimmer so detail has room */
.scrolly-sticky .stages { gap: 0; }
.scrolly-sticky .stage { padding: 20px 20px 20px; }
.scrolly-sticky .stage .marker { width: 36px; height: 36px; margin-bottom: 12px; }
.scrolly-sticky .stage h3 { font-size: 18px; margin-bottom: 4px; }
.scrolly-sticky .stage .blurb { font-size: 13px; margin-bottom: 10px; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.scrolly-sticky .stage .deliver { font-size: 11px; }
.scrolly-sticky .stage .pill { font-size: 10px; }

/* Stage detail becomes the hero of the sticky frame */
.scrolly-sticky .stage-detail {
  transition: opacity .35s ease, transform .35s ease;
  animation: stageFade .45s ease both;
}
@keyframes stageFade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Progress rail — sits along right edge inside the frame */
.scrolly-rail {
  position: absolute;
  top: 80px;
  right: -4px;
  width: 2px;
  height: calc(100% - 80px - 140px);
  pointer-events: none;
  z-index: 2;
}
.scrolly-rail .rail-track {
  position: absolute; inset: 0;
  background: var(--color-border);
}
.scrolly-rail .rail-fill {
  position: absolute; top: 0; left: 0; width: 100%;
  background: var(--color-accent);
  height: 0;
  transition: height .25s ease;
  box-shadow: 0 0 12px rgba(0,212,170,0.6);
}
.scrolly-rail .rail-dots {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: center;
}
.scrolly-rail .rail-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  transform: translateX(-4px);
  transition: all .2s ease;
}
.scrolly-rail .rail-dots span.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(0,212,170,0.18);
}

/* ---------- Responsive: drop sticky on small screens (D-12) ---------- */
@media (max-width: 900px) {
  .framework .top { grid-template-columns: 1fr; gap: 20px; }
  .stages, .stages.stages-4 { grid-template-columns: 1fr 1fr; }
  .stage-bar { grid-template-columns: 1fr; gap: 10px; }
  .stage-bar .sb-right { justify-self: start; }
  .stage { border-left: none; border-top: 1px solid var(--color-border); }
  .stage-detail { grid-template-columns: 1fr; gap: 20px; }
  .scrolly-frame { min-height: auto; }
  .scrolly-sticky { position: static; max-height: none; }
  .scrolly-rail { display: none; }
}

/* ---------- Respect reduced-motion: drop the pin, let content flow (D-12) ---------- */
@media (prefers-reduced-motion: reduce) {
  .scrolly-frame { min-height: auto; }
  .scrolly-sticky { position: static; max-height: none; }
  .scrolly-rail { display: none; }
  .scrolly-sticky .stage-detail { animation: none; }
}
