/* A-kassa story — builds on ../styles.css (tokens, fonts, header, labels).
 * Text column beside a sticky stage; the page turns dark for the waiting
 * and the pile (data-tone="dark" on the step).
 */

.story-page {
  --sig-text: var(--fg);
  background: var(--bg);
  color: var(--fg);
  transition:
    background-color var(--dur-slow) var(--ease-in-out),
    color var(--dur-slow) var(--ease-in-out);
}
.story-page[data-tone="dark"] {
  --fg: var(--paper);
  --bg: var(--ink);
  --fg-muted: var(--muted-dark);
  --line: var(--rule-dark);
  --sig-text: var(--signal);
  background: var(--ink);
  color: var(--paper);
}
/* While the surface changes, drawings ease their colours with the page so
 * nothing flashes (CSS variables themselves switch instantly). */
.tone-shift .stage * {
  transition:
    fill var(--dur-slow) var(--ease-in-out),
    stroke var(--dur-slow) var(--ease-in-out),
    background-color var(--dur-slow) var(--ease-in-out),
    color var(--dur-slow) var(--ease-in-out),
    opacity 450ms var(--ease-in-out) !important;
}

/* Header ------------------------------------------------------------------ */
.story-head {
  color: var(--ink);
  background: rgb(244 244 241 / 0.9);
  border-color: var(--rule);
}
.story-head .bar {
  gap: var(--s4);
}
.head-title {
  color: inherit;
  opacity: 0.7;
  white-space: nowrap;
}
.back-home {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 10px 14px 10px 0;
  margin-right: var(--s2);
  font: 450 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-right: 1px solid var(--rule);
}
.back-home span {
  transition: transform var(--dur-base) var(--ease-out);
}
.back-home:hover span {
  transform: translateX(-3px);
}
.story-head .language {
  margin-left: auto;
}
.read-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left;
}

/* Scene drawing primitives (SVG) ------------------------------------------ */
.story svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.m {
  font: 450 15px/1 var(--mono);
  letter-spacing: 0.06em;
  fill: var(--fg);
}
.m.s {
  font-size: 13px;
}
.serif {
  font: 400 27px/1 var(--serif);
  fill: var(--fg);
}
.serif.sm {
  font-size: 24px;
}
.big {
  font: 400 120px/1 var(--serif);
  letter-spacing: -0.02em;
  fill: var(--fg);
  font-variant-numeric: tabular-nums;
}
.law {
  font: 400 42px/1 var(--serif);
  fill: var(--fg);
  transition: opacity var(--dur-base) ease;
}
.ln {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.5;
}
.ln.faint,
.faint-g .ln {
  opacity: 0.35;
}
.ln.dash {
  stroke-dasharray: 5 5;
}
.ln.web {
  stroke-width: 1;
  opacity: 0.6;
}
.ln.sig-ln {
  stroke: var(--signal);
  stroke-width: 2.5;
}
.ln.thick {
  stroke-width: 4;
}
.paper {
  fill: var(--bg);
  stroke: var(--fg);
  stroke-width: 1.5;
}
.paper.strong {
  stroke-width: 2;
}
.box {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.5;
}
.dot,
.ink-fill {
  fill: var(--fg);
}
.sig-fill {
  fill: var(--signal);
}
.sig-t {
  fill: var(--sig-text);
}
.faint-t {
  fill: var(--fg-muted);
}
.missing {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2;
  stroke-dasharray: 8 6;
}
.cell {
  fill: transparent;
  stroke: var(--fg);
  stroke-width: 1;
  opacity: 0.3;
}
.cell.on {
  fill: var(--fg);
  opacity: 1;
}
.cell.last.on {
  fill: var(--signal);
  stroke: var(--signal);
}
.arm {
  fill: none;
  stroke: var(--fg);
  stroke-width: 10;
  stroke-linecap: square;
}
.arm.thin {
  stroke-width: 6;
}
.joint {
  fill: var(--bg);
  stroke: var(--fg);
  stroke-width: 2;
}
.sel {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2;
}
.pt-box {
  stroke: var(--fg);
  stroke-width: 1;
}
.pt {
  transition: transform var(--dur-base) var(--ease-out);
}
.slot {
  stroke: var(--fg);
  stroke-width: 1.5;
}
/* paper → ink in nine steps; 1–7 double as the seven scale points */
.grey-0 { fill: #f4f4f1; }
.grey-1 { fill: #d9d9d6; }
.grey-2 { fill: #bdbebb; }
.grey-3 { fill: #a1a2a0; }
.grey-4 { fill: #858684; }
.grey-5 { fill: #6a6a69; }
.grey-6 { fill: #4e4f4e; }
.grey-7 { fill: #2b2c2c; }
.grey-8 { fill: #0b0c0c; }

/* Stage scenes cross-fade */
.stage .scene {
  opacity: 0;
  transition: opacity 450ms var(--ease-in-out);
}
.stage .scene.active {
  opacity: 1;
}

/* Copy -------------------------------------------------------------------- */
.step-no {
  margin-bottom: var(--s4);
}
.prose {
  font: 400 clamp(24px, 2.3vw, 34px) / 1.35 var(--sans);
  letter-spacing: -0.015em;
  text-wrap: pretty;
}
.step-open .prose {
  font: 400 clamp(46px, 5.4vw, 88px) / 1 var(--serif);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.placeholder {
  margin-top: var(--s5);
  padding: var(--s4);
  border: 1px dashed currentColor;
}



/* Without JavaScript: a plain readable column, no stage ------------------- */
html:not(.js) .stage {
  display: none;
}
html:not(.js) .step {
  padding: var(--s7) var(--margin);
  max-width: 900px;
  margin: 0 auto;
}


/* Interactive scale: one vertical component --------------------------- */
.scale-block {
  --t: 1;
  --level: 0;
  width: min(100%, 560px);
}
.scale-end {
  margin: 0;
  padding: var(--s3) 0;
}
.scale {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
/* the spine runs through the swatches */
.scale::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: currentColor;
  opacity: 0.4;
}
.scale li {
  position: relative;
}
.scale button {
  display: grid;
  grid-template-columns: 44px 2em 1fr;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 56px;
  padding: 6px var(--s3) 6px 0;
  text-align: left;
  font-size: 17px;
  line-height: 1.35;
  transition: background-color var(--dur-fast) ease;
}
.scale .sw {
  width: 44px;
  height: 44px;
  border: 1px solid currentColor;
  position: relative;
}
.scale li:nth-child(1) .sw { background: #d9d9d6; }
.scale li:nth-child(2) .sw { background: #bdbebb; }
.scale li:nth-child(3) .sw { background: #a1a2a0; }
.scale li:nth-child(4) .sw { background: #858684; }
.scale li:nth-child(5) .sw { background: #6a6a69; }
.scale li:nth-child(6) .sw { background: #4e4f4e; }
.scale li:nth-child(7) .sw { background: #2b2c2c; }
.scale .n {
  font: 450 12px/1 var(--mono);
  color: var(--fg-muted);
  text-align: right;
}
.scale .lv {
  color: var(--fg-muted);
  transition: color var(--dur-fast) ease;
}
.scale button:hover .lv {
  color: var(--fg);
}
.scale li.reached .lv {
  color: var(--fg);
}
.scale button[aria-pressed="true"] .lv {
  color: var(--fg);
  font-weight: 560;
}
.scale button[aria-pressed="true"] .sw {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}
/* Two dashed signal-coloured lines cut across the scale, each with a
 * title: above the first, what is done today; below the second, what is
 * unthinkable today. */
.cut {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px -12px;
  padding: 6px 0;
  color: var(--fg);
}
.cut::before,
.cut::after {
  content: "";
  height: 2px;
  background: repeating-linear-gradient(to right, var(--signal) 0 7px, transparent 7px 12px);
}
.cut::before {
  flex: 0 0 64px;
}
.cut::after {
  flex: 1 1 24px;
}
.cut span {
  flex: 0 1 auto;
}
.scale button[aria-pressed="true"] .n {
  color: var(--fg);
}

/* In the stage (with JavaScript) the scale is the picture for its step:
 * it fades in and the rows arrive one by one as the reader scrolls. */
.stage .scale-block {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 450ms var(--ease-in-out),
    visibility 0s 450ms;
}
.stage .scale-block.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 450ms var(--ease-in-out);
}

/* Layout ---------------------------------------------------------------- */
.js .story {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--margin);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: calc(var(--gutter) * 2);
}
.js .steps {
  grid-column: 1;
  grid-row: 1;
}
.js .stage {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: var(--header);
  height: calc(100svh - var(--header));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6) 0;
}
.js .stage svg {
  max-height: 100%;
  max-width: min(100%, 76svh);
}
.js .step {
  min-height: 70svh;
  padding: 0 0 18svh;
}
.js .step .step-body {
  position: sticky;
  top: calc(var(--header) + 22svh);
  opacity: 0.28;
  transition: opacity var(--dur-base) ease;
}
.js .step.is-active .step-body {
  opacity: 1;
}
.js .step-long {
  min-height: 120svh;
}
.js .step-scale {
  min-height: 95svh;
}
.js .step-open {
  min-height: calc(100svh - var(--header));
  padding: 18svh 0 12svh;
}
.js .step-open .step-body {
  position: static;
}

@media (max-width: 899px) {
  .js .story {
    display: block;
    padding: 0;
  }
  .js .stage {
    padding: var(--s5) var(--margin) 40svh;
  }
  .js .steps {
    position: relative;
    z-index: 2;
    margin-top: calc(-1 * (100svh - var(--header)));
    padding: 0 var(--margin);
    pointer-events: none;
  }
  .js .step-body {
    pointer-events: auto;
  }
  .js .step {
    padding: 55svh 0 15svh;
    min-height: 105svh;
  }
  .js .step-long {
    min-height: 140svh;
  }
  .js .step .step-body {
    position: relative;
    top: auto;
  }
  .js .step .step-body,
  .js .step.is-active .step-body {
    opacity: 1;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--rule);
    padding: var(--s4);
    width: 100%;
  }
  .js .step-open .step-body,
  .js .step-open.is-active .step-body {
    background: transparent;
    color: inherit;
    border: 0;
    padding: 0;
  }
  .js .step-open {
    padding-top: 40svh;
  }
  .scale-block {
    margin-bottom: var(--s4);
  }
  .scale button {
    grid-template-columns: 36px 1.5em 1fr;
    min-height: 48px;
    font-size: 15px;
  }
  .scale .sw {
    width: 36px;
    height: 36px;
  }
  .scale::before {
    left: 17px;
  }
  .cut::before {
    flex-basis: 56px;
  }
}

@media (max-width: 760px) {
  .head-title {
    display: none;
  }
}

/* Reduced motion: final states, no transitions --------------------------- */
@media (prefers-reduced-motion: reduce) {
  .story-page,
  .stage .scene,
  .stage .scale-block,
  .js .step .step-body,
  .pt,
  .law {
    transition: none !important;
  }
}

.frame {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1;
  opacity: 0.4;
}

/* The scale step is long: its rows turn black one after another */
.js .step-scale {
  min-height: 230svh;
}
/* Steps 3–5 (between the two cut lines) are "maskinläggning": while one of
 * them is selected its text and the word in the copy turn orange (Adrian,
 * 2026-11-10). Note: orange on paper is 3.3:1, below 4.5:1 for the 17 px
 * step text; the copy word is large text (≥ 24 px) and passes. */
.scale li[data-mid] button[aria-pressed="true"] .lv {
  color: var(--signal);
}
/* The second paragraph of the scale step appears only once the reader has
 * scrolled to the middle of the scale (step 3), and is orange throughout:
 * large text, 3.3:1 on paper, passes for text ≥ 24 px. */
.prose-mid {
  color: var(--signal);
  margin-top: var(--s4);
}
.js .prose-mid {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
.js .mid-reached .prose-mid {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .js .prose-mid {
    transition: none;
    transform: none;
  }
}
@media (max-width: 899px) {
  .js .step-scale .step-body {
    position: sticky;
    top: calc(var(--header) + 8px);
  }
  .js .step-scale {
    padding-top: 30svh;
  }
}

/* ===== Prototype: a click-through in a "computer" ====================== */
.proto {
  padding: var(--s8) 0 var(--s9);
}
.device {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: var(--ink);
  border: 12px solid var(--ink);
  border-top-width: 0;
  color: var(--ink);
}
.device-bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 40px;
  color: var(--muted-dark);
  font: 450 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.device-dot {
  width: 8px;
  height: 8px;
  background: var(--signal);
}
.device-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.device-foot {
  position: relative;
  max-width: 820px;
  height: 56px;
  margin: 0 auto;
}
.device-foot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 90px;
  height: 40px;
  margin-left: -45px;
  background: var(--ink);
}
.device-foot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 280px;
  height: 16px;
  margin-left: -140px;
  background: var(--ink);
}
.screens {
  background: var(--white);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 3.2vw, 40px);
}
html:not(.proto-ready) .screen + .screen {
  border-top: 1px solid var(--rule);
}
.proto-ready .screen.is-on {
  animation: screen-in var(--dur-base) var(--ease-out);
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.sc-label {
  color: var(--muted);
  margin-bottom: var(--s2);
}
.sc-label .jump {
  color: var(--ink);
}
.sc-title {
  font: 400 clamp(28px, 3vw, 42px) / 1.05 var(--serif);
  letter-spacing: -0.015em;
  max-width: 22ch;
  text-wrap: balance;
  outline: none;
}
.sc-text {
  margin-top: var(--s3);
  font-size: clamp(17px, 1.3vw, 19px);
  max-width: 40ch;
}
.sc-actions {
  margin-top: auto;
  padding-top: var(--s5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  justify-content: space-between;
  align-items: flex-end;
}
.sc-actions .primary:only-child,
.sc-actions .ghost:only-child {
  margin-left: 0;
  margin-right: auto;
}
.sc-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--ink);
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    opacity var(--dur-fast) ease;
}
.sc-btn.primary {
  background: var(--ink);
  color: var(--paper);
  margin-left: auto;
}
/* two equal choices side by side (screen 5) */
.sc-pair {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s3);
}
.sc-pair .sc-btn.primary {
  margin-left: 0;
}
@media (hover: hover) {
  .sc-btn.primary:hover {
    background: var(--signal);
    border-color: var(--signal);
    color: var(--ink);
  }
}
.sc-btn.ghost {
  border-color: transparent;
  padding: 0;
}
.sc-btn.ghost:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}
.sc-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.sc-btn.primary:disabled:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* blurred stand-ins for forms: bars, not fields */
.ghost-form {
  margin-top: var(--s4);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4) var(--s6);
  max-width: 760px;
  filter: blur(1.6px);
  opacity: 0.85;
}
.g-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.month .g-row {
  flex-direction: row;
  align-items: center;
  gap: var(--s3);
}
.g-bar {
  display: block;
  width: var(--w, 70%);
  height: 14px;
  background: #c9c9c5;
}
.g-bar.sm {
  height: 8px;
  background: #dcdcd8;
}
.month .g-bar {
  flex: 1;
  height: 10px;
}
.g-box {
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid #9c9d98;
}
.g-box.on {
  background: var(--ink);
  border-color: var(--ink);
}
.month {
  border-left: 3px solid var(--signal);
  padding-left: var(--s4);
}

/* screen 3: the agents at work */
.spinner {
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--rule);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
.screen.is-done .spinner {
  animation: none;
  border-color: var(--signal);
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}
.work {
  list-style: none;
  margin: var(--s3) 0 0;
  padding: 0;
  font-size: 17px;
}
.work li {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 6px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.work li::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  flex: none;
}
.proto-ready .work li {
  opacity: 0.3;
}
.proto-ready .work li.is-now,
.proto-ready .work li.is-done {
  opacity: 1;
  color: var(--ink);
}
.work li.is-now::before {
  background: var(--signal);
  border-color: var(--signal);
  animation: blink 700ms steps(2) infinite;
}
.work li.is-done::before {
  background: var(--ink);
  border-color: var(--ink);
}
@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

/* screen 4: what to complete */
.todo {
  list-style: none;
  margin: var(--s4) 0 0;
  padding: 0;
  max-width: 760px;
}
.todo li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 17px;
}
.todo li:first-child {
  border-top: 1px solid var(--rule);
}
.todo li > span:first-child {
  flex: 1 1 260px;
}
.todo li > span:first-child::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: var(--s3);
  border: 1px solid var(--ink);
}
.dash-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 var(--s3);
  border: 1px dashed #9c9d98;
  color: var(--muted);
  font: 450 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: default;
  user-select: none;
}

/* screen 8 */
.screen[data-screen="8"] .sc-label {
  text-align: center;
}
.done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  max-width: none;
  margin: auto 0;
  font-size: clamp(56px, 7vw, 104px);
}
.screen[data-screen="8"] .sc-actions {
  margin-top: 0;
  justify-content: center;
}
.screen[data-screen="8"] .sc-actions .ghost:only-child {
  margin: 0;
}
.done-mark {
  width: 0.5em;
  height: 0.5em;
  background: var(--signal);
}

@media (max-width: 760px) {
  .proto {
    padding: var(--s7) 0 var(--s8);
  }
  .device {
    border-width: 0 6px 6px;
  }
  .ghost-form {
    grid-template-columns: 1fr;
  }
  .device-foot::after {
    width: 180px;
    margin-left: -90px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .work li.is-now::before,
  .proto-ready .screen.is-on {
    animation: none;
  }
}

/* One fixed screen size, so the computer does not change size between
 * screens (the tallest screen sets it). */
.proto-ready .screens {
  height: var(--screen-h, 460px);
  /* The slide-in of each screen (translateY) would otherwise flash a scrollbar. */
  overflow: hidden;
}

/* Header on narrow screens: keep the shared header on one line */
.story-head .back-home {
  white-space: nowrap;
}
@media (max-width: 560px) {
  .story-head .bar {
    gap: var(--s3);
  }
}
