/* ==========================================================================
   Basenine Labs — study v4: pinned scroll story
   Seven disconnected tools to ship one page, then they collapse into one system.
   Builds on /v2/v2.css and /v3/v3.css.
   ========================================================================== */

/* ---------- Pin ---------- */

.page > .story { height: 560vh; padding-block: 0; }
.story-pin {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  padding: clamp(104px, 13vh, 136px) 0 26px;
  overflow: hidden;
}

.story-head { display: grid; justify-items: center; gap: 12px; margin-bottom: clamp(14px, 2.4vh, 28px); text-align: center; }
.story-title,
.story-sub { display: grid; justify-items: center; max-width: none; }
.story-title { font-size: clamp(30px, 3.2vw, 44px); }
.story-title > span,
.story-sub > span { grid-area: 1 / 1; transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
.st-after { opacity: 0; transform: translateY(10px); }
.story.is-resolved .st-before { opacity: 0; transform: translateY(-10px); }
.story.is-resolved .st-after { opacity: 1; transform: none; }

/* ---------- Stage ---------- */

.story-stage {
  position: relative;
  width: min(var(--content), calc(100% - 2 * var(--gutter)));
  height: 100%;
  margin-inline: auto;
}
.story-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.story-lines path { fill: none; stroke: rgba(30, 30, 30, 0.36); stroke-width: 1; stroke-dasharray: 3 5; }
.story-lines path.red { stroke: var(--signal); stroke-width: 1.6; }

/* ---------- Tool cards ---------- */

.sc {
  position: absolute;
  top: var(--y);
  left: var(--x);
  z-index: 1;
  display: grid;
  gap: 8px;
  width: var(--w);
  padding: 11px 12px 12px;
  border: 0.75px solid var(--rule);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 18px 40px -26px rgba(30, 30, 30, 0.35);
  transition: opacity 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
  will-change: transform, opacity;
}
.sc.is-dim { opacity: 0.36; }
.sc.is-active {
  z-index: 2;
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal), 0 26px 50px -28px rgba(255, 59, 48, 0.5);
}

.sc-bar { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 7px; border-bottom: 0.75px solid var(--rule-soft); }
.sc-title { font-size: 13px; line-height: 1.3; letter-spacing: -0.02em; }
.sc-msg { color: var(--ink); font-size: 12.5px; line-height: 1.4; letter-spacing: -0.01em; }
.ln { display: block; height: 5px; border-radius: 3px; background: rgba(30, 30, 30, 0.09); }
.ln--short { width: 60%; }

.sc-code { display: grid; gap: 5px; padding: 8px; border-radius: 6px; background: var(--ink); }
.sc-code span { height: 5px; border-radius: 3px; background: rgba(244, 244, 236, 0.25); }
.sc-code span:nth-child(2) { width: 70%; background: rgba(255, 59, 48, 0.75); }
.sc-code span:nth-child(3) { width: 45%; }

.frames { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.frames span { aspect-ratio: 3 / 4; border: 0.75px solid var(--rule); border-radius: 4px; background: #fafaf5; }
.frames span:nth-child(2) { background: linear-gradient(var(--signal) 0 22%, #fafaf5 22%); }

.pill {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(30, 30, 30, 0.07);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.sc-bubble { grid-template-columns: 26px minmax(0, 1fr); align-items: start; border-radius: 14px; }
.av { width: 26px; height: 26px; border-radius: 6px; background: var(--signal); }
.sc-bubble-body { display: grid; gap: 4px; }

.bld { display: grid; grid-template-columns: 18% minmax(0, 1fr) 20%; gap: 6px; height: 86px; }
.bld-side { border-radius: 4px; background: rgba(30, 30, 30, 0.06); }
.bld-canvas { display: grid; align-content: start; gap: 5px; padding: 6px; border: 0.75px solid var(--rule); border-radius: 4px; }
.bld-canvas i { height: 14px; border-radius: 3px; background: rgba(30, 30, 30, 0.1); }
.bld-canvas i:first-child { height: 22px; background: rgba(30, 30, 30, 0.18); }

.sc-warn { grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 12px; }
.phone { display: grid; align-content: start; gap: 3px; width: 36px; height: 62px; padding: 6px 5px; border: 1px solid var(--ink); border-radius: 7px; }
.phone i { height: 6px; border-radius: 2px; background: rgba(30, 30, 30, 0.15); }
.phone i.over { width: 160%; background: var(--signal); }

.badge {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--signal);
  color: var(--white);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  text-align: center;
}

.sheet { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75px; border: 0.75px solid var(--rule); background: var(--rule); }
.sheet i { height: 12px; background: var(--white); }
.sheet i:nth-child(-n + 4) { background: #f0f0e8; }

/* ---------- Caption pill ---------- */

.story-cap {
  position: absolute;
  bottom: 4px;
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.3s var(--ease);
}
.story-count { color: var(--signal); font-family: "DM Mono", ui-monospace, monospace; font-size: 11px; }
.story.is-resolved .story-cap { opacity: 0; }

/* ---------- The one system ---------- */

.story-one {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: min(440px, 92%);
  overflow: hidden;
  border-radius: 18px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 40px 80px -40px rgba(30, 30, 30, 0.6);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
}
.one-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 0.75px solid rgba(244, 244, 236, 0.12);
}
.one-body {
  display: grid;
  gap: 6px;
  padding: 16px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.65;
}
.one-body p { margin: 0; }
.one-body .t-you, .one-body .t-ok { color: var(--signal); }
.one-l { color: rgba(244, 244, 236, 0.8); opacity: 0; }
.one-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 0.75px solid rgba(244, 244, 236, 0.12);
}
.one-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
}
.one-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); animation: sys-live 1.6s infinite; }

/* ---------- Screen-reader story (visible in static mode) ---------- */

.story-list {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  list-style: none;
}

/* ---------- Static mode: mobile, or reduced motion ---------- */

.page > .story.story--static { height: auto; padding-block: var(--section-y); }
.story--static .story-pin { position: static; display: flex; flex-direction: column; height: auto; padding: 0; overflow: visible; }
.story--static .story-list { order: 2; }
.story--static .story-stage { order: 3; height: auto; }
.story--static .sc,
.story--static .story-lines,
.story--static .story-cap { display: none; }
.story--static .story-one { position: relative; top: auto; left: auto; margin: 36px auto 0; opacity: 1; transform: none; }
.story--static .one-l { opacity: 1; }
.story--static .story-list {
  position: static;
  display: grid;
  width: auto;
  max-width: 560px;
  height: auto;
  margin: 28px auto 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
.story--static .story-list li {
  position: relative;
  padding: 14px 0 14px 28px;
  border-left: 0.75px dashed rgba(30, 30, 30, 0.4);
  font-size: 17px;
  letter-spacing: -0.02em;
}
.story--static .story-list li::before {
  content: "";
  position: absolute;
  top: 21px;
  left: -5px;
  width: 9px;
  height: 9px;
  background: var(--signal);
}
.story--static .story-list .mono { margin-right: 8px; color: var(--signal-dark); }
.story--static .story-list-end { border-left-style: solid; font-size: 20px; }

/* ---------- After the story ---------- */

.story-next-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px 28px; text-align: center; }
.story-next-link { text-decoration: underline; text-decoration-thickness: 0.75px; text-underline-offset: 4px; }
