/* ==========================================================================
   Story — one document followed through the assessment, driven by scroll.
   The section is tall; the inner stage is sticky, so scrolling "plays" it.
   ========================================================================== */

.story {
  position: relative;
  height: 700vh;
  border-top: 1px solid var(--line);
}
.story__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 640px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.story__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.72fr);
  gap: clamp(24px, 3.6vw, 70px);
  align-items: center;
}

/* Stage ------------------------------------------------------------------ */
.stage {
  position: relative;
  height: min(78vh, 800px);
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1fr);
  gap: clamp(16px, 2.2vw, 34px);
}

/* The document sheet */
.doc {
  position: relative;
  height: 100%;
  padding: clamp(18px, 2vw, 30px) clamp(16px, 1.8vw, 26px) clamp(18px, 2vw, 30px) clamp(40px, 3.4vw, 52px);
  background: #fffdf8;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  box-shadow:
    -3.5px 4px 0 0 rgba(138, 120, 100, 0.5),
    -7px 8px 0 0 rgba(205, 191, 168, 0.6),
    0 40px 70px -40px rgba(40, 28, 10, 0.5);
  will-change: transform, opacity;
}

.doc__tab {
  position: absolute;
  top: -13px;
  left: 22px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.doc__secs {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.sec {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: calc(var(--split, 0) * 12px);
  border-left: 2px solid rgba(155, 148, 135, calc(var(--split, 0) * 0.8));
  opacity: var(--op, 1);
  border-radius: 2px;
  outline: 2px solid rgba(154, 90, 78, calc(var(--hi, 0) * 0.85));
  outline-offset: 7px;
}
.sec__n {
  position: absolute;
  left: calc(-1 * clamp(40px, 3.4vw, 52px) + 6px);
  top: -2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: var(--split, 0);
}
.sec.is-high::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 3px #fffdf8;
  opacity: var(--mark, 0);
  transform: scale(var(--mark, 0));
}
.ln { height: 7px; border-radius: 4px; background: rgb(217, 210, 195); width: var(--w, 80%); }
.ln--h { height: 11px; }

.beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 70px;
  margin-top: -35px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, transparent, var(--bc, rgba(166, 124, 71, 0.3)) 50%, transparent);
}
.beam::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1.5px; background: var(--bl, #a67c47); }

.stamp {
  position: absolute;
  right: 7%;
  bottom: 9%;
  padding: 9px 14px;
  border: 3px solid var(--green-deep);
  border-radius: 6px;
  color: var(--green-deep);
  font-family: var(--font-mono);
  font-size: clamp(11px, 1vw, 15px);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: rgba(255, 253, 248, 0.9);
  opacity: 0;
  pointer-events: none;
  transform: rotate(-7deg);
}

/* Panels ------------------------------------------------------------------ */
.panels { position: relative; align-self: center; height: min(100%, 580px); }
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 1.8vw, 28px);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(250, 247, 240, 0.9);
  box-shadow: 0 30px 60px -44px rgba(40, 28, 10, 0.45);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.panel__tag { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.panel__title { margin-top: 8px; font-size: clamp(22px, 2vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.panel .rv { opacity: var(--ro, 0); transform: translate3d(0, calc((1 - var(--ro, 0)) * 12px), 0); }

.kv { margin: 16px 0 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px dashed var(--line-soft); }
.kv dt { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv dd { margin: 0; font-size: clamp(14px, 1.15vw, 17px); font-weight: 500; text-align: right; }
.hash { font-family: var(--font-mono); font-size: clamp(12px, 1vw, 15px) !important; letter-spacing: 0.04em; color: var(--gold); min-width: 12ch; }
.hash::after { content: "▌"; opacity: 0.6; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.note { margin-top: auto; padding-top: 14px; font-size: clamp(13px, 1.05vw, 15px); line-height: 1.5; color: var(--muted); }

/* probes (seven checks) */
.probes { margin: 14px 0 0; display: grid; }
.probe {
  display: grid;
  grid-template-columns: 22px 1fr 84px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line-soft);
  opacity: var(--po, 0.3);
}
.probe__dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; transition: background 0.3s, border-color 0.3s; }
.probe__dot svg { width: 9px; height: 9px; stroke: #fff; stroke-width: 3.4; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.probe.is-active .probe__dot { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(166, 124, 71, 0.2); }
.probe.is-done .probe__dot { background: var(--st-live); border-color: var(--st-live); }
.probe.is-done.is-empty .probe__dot { background: transparent; border: 2px dashed var(--line); }
.probe.is-done .probe__dot svg { opacity: 1; }
.probe.is-done.is-empty .probe__dot svg { opacity: 0; }
.probe__name { font-size: clamp(14px, 1.15vw, 16.5px); font-weight: 600; letter-spacing: -0.01em; }
.probe__out { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; color: var(--muted); }
.probe__bar { height: 6px; border-radius: 3px; background: var(--paper-3); overflow: hidden; }
.probe__bar i { display: block; height: 100%; width: calc(var(--pf, 0) * 100%); background: var(--gold); border-radius: 3px; }
.probe.is-empty .probe__bar { background: repeating-linear-gradient(90deg, var(--line-soft) 0 4px, transparent 4px 8px); }

/* legend rows (attribute) */
.legs { margin: 14px 0 0; display: grid; gap: 4px; }
.leg { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: baseline; gap: 12px; padding: 13px 0; border-bottom: 1px dashed var(--line-soft); }
.leg i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); align-self: center; }
.leg span { font-size: clamp(15px, 1.25vw, 18px); font-weight: 600; }
.leg b { font-family: var(--font-display); font-size: clamp(28px, 2.6vw, 40px); font-weight: 400; line-height: 1; }
.leg em { font-style: normal; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* fusion bars */
.fzs { margin: 18px 0 0; display: grid; gap: 14px; }
.fz__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.fz__top span { font-size: clamp(14px, 1.15vw, 17px); font-weight: 600; }
.fz__top b { font-family: var(--font-display); font-size: clamp(26px, 2.4vw, 38px); font-weight: 400; line-height: 1; }
.fz__bar { height: 10px; border-radius: 5px; background: var(--paper-3); overflow: hidden; }
.fz__bar i { display: block; height: 100%; width: 0; background: var(--c); border-radius: 5px; }

/* alert */
.alertbox {
  margin-top: 16px;
  padding: 16px 18px;
  border-left: 4px solid var(--generated);
  border-radius: 0 8px 8px 0;
  background: rgba(154, 90, 78, 0.1);
}
.alertbox strong { display: flex; align-items: center; gap: 9px; color: var(--generated); font-size: clamp(16px, 1.35vw, 20px); }
.alertbox svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.alertbox p { margin-top: 6px; font-size: clamp(14px, 1.1vw, 16px); line-height: 1.5; color: var(--ink-2); }

/* reviewer note */
.noteBox {
  margin-top: 14px;
  min-height: 92px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  font-size: clamp(14px, 1.1vw, 16px);
  line-height: 1.5;
}
.noteBox::after { content: "▌"; color: var(--gold); animation: caret 1s steps(2) infinite; }
.mini { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 8px; }
.mini i { display: block; height: 100%; }
.recorded { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--green-deep); font-weight: 600; font-size: clamp(14px, 1.1vw, 16px); }
.recorded svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Side ---------------------------------------------------------------------- */
.story__side { min-width: 0; }
.story__title {
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(42px, 4.8vw, 80px);
  line-height: 0.94;
}
.steps { margin: clamp(16px, 2vw, 30px) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.step {
  display: block;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  text-align: left;
  color: var(--muted);
  transition: color 0.4s;
}
.step__row { display: flex; align-items: baseline; gap: 14px; }
.step__n { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; color: var(--line); transition: color 0.4s; }
.step__t { font-size: clamp(16px, 1.35vw, 20px); font-weight: 650; letter-spacing: -0.01em; }
.step__x {
  display: block;
  max-height: 0;
  margin-left: 30px;
  overflow: hidden;
  font-size: clamp(13.5px, 1.05vw, 15.5px);
  line-height: 1.5;
  color: var(--muted);
  opacity: 0;
  transition: max-height 0.7s var(--ease-out), opacity 0.5s, margin 0.5s;
}
.step.is-active { color: var(--ink); }
.step.is-active .step__n { color: var(--gold); }
.step.is-active .step__x { max-height: 110px; opacity: 1; margin-top: 6px; }
.step.is-done .step__n { color: var(--st-live); }
.story__progress { margin-top: 16px; height: 2px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.story__progress i { display: block; height: 100%; width: 100%; background: var(--gold); transform: scaleX(0); transform-origin: 0 50%; }
.story__hint { margin-top: 12px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* Narrow screens: stage on top, compact step list below ------------------------ */
@media (max-width: 960px) {
  .story { height: 620vh; }
  /* top padding clears the floating dock; svh keeps the stage steady while mobile browser bars move */
  .story__sticky { align-items: flex-start; padding-top: 92px; height: 100vh; height: 100svh; min-height: 560px; }
  .story__grid { grid-template-columns: 1fr; gap: 14px; }
  .stage { height: calc(100vh - 92px - 150px); height: calc(100svh - 92px - 150px); min-height: 400px; grid-template-columns: 1fr; grid-template-rows: 0.8fr 1.2fr; gap: 12px; }
  /* slimmer document lines so all ten sections fit the shorter sheet without overlapping */
  .sec { gap: 3px; }
  .ln { height: 5px; }
  .ln--h { height: 8px; }
  .doc { padding-top: 16px; padding-bottom: 16px; }
  .fzs { margin-top: 10px; gap: 8px; }
  .fz__top { margin-bottom: 4px; }
  .fz__top b { font-size: 24px; }
  .fz__bar { height: 7px; }
  .legs { margin-top: 8px; }
  .sec .ln:last-child { display: none; }
  .panels { height: 100%; }
  .doc { padding-left: 38px; }
  .story__side .eyebrow, .story__title, .story__hint { display: none; }
  .steps { margin-top: 0; border-top: 0; }
  .step { display: none; padding: 6px 0; border: 0; }
  .step.is-active { display: block; }
  .panel { padding: 14px 16px; }
  .panel__title { font-size: 20px; }
  .kv > div { padding: 7px 0; }
  .probe { padding: 3px 0; grid-template-columns: 20px 1fr 56px; gap: 8px; }
  .probe__name { font-size: 13px; }
  .panel__tag { display: none; }
  .panel__title { margin-top: 0; }
  .probe__out { display: none; }
  .leg { padding: 8px 0; }
  .note { display: none; }
}

/* Phones and tablets held sideways: too short to stack, so doc and panel sit side by side */
@media (max-width: 960px) and (orientation: landscape) and (max-height: 560px) {
  .story__sticky { padding-top: 76px; min-height: 0; }
  .stage { height: calc(100vh - 92px); height: calc(100svh - 92px); min-height: 0; grid-template-columns: 0.85fr 1fr; grid-template-rows: 1fr; }
  .story__side { display: none; }
  .sec .ln:not(.ln--h) { display: none; }
}
