/* Approach: six steps with a rail between the nodes and a large illustration per step.
   Load after styles.css and components.css. Colours come from tokens.css only. */

.ap-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ap { gap: var(--space-grid, 24px); }

/* The node row and its rail. The fill follows the step that story.js marks as now. */
.ap-row { position: relative; gap: 14px; --ap-at: 0; }
.ap-row:has(.ap-node[data-step="2"][data-state="now"]) { --ap-at: 1; }
.ap-row:has(.ap-node[data-step="3"][data-state="now"]) { --ap-at: 2; }
.ap-row:has(.ap-node[data-step="4"][data-state="now"]) { --ap-at: 3; }
.ap-row:has(.ap-node[data-step="5"][data-state="now"]) { --ap-at: 4; }
.ap-row:has(.ap-node[data-step="6"][data-state="now"]) { --ap-at: 5; }
.ap-rail { position: absolute; left: calc(100% / 12); right: calc(100% / 12); top: 50%; height: var(--bit-size); margin-top: calc(var(--bit-size) / -2); pointer-events: none; }
.ap-rail .bits-rule { position: absolute; inset: 0; opacity: 0.5; }
.ap-rail-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--ap-at) * 20%);
  border-radius: var(--radius-pill); background: var(--grad-bar); box-shadow: var(--glow-accent-sm);
  transition: width var(--dur-3) var(--ease-out);
}

.ap-node {
  position: relative; z-index: 1; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  background: var(--glass-3); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-color: var(--border); box-shadow: var(--sheen);
  transition: border-color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.ap-node:hover { transform: translateY(-2px); box-shadow: var(--sheen), var(--glow-accent-sm); }
.ap-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ap-node small { grid-column: 2; grid-row: 1; }
.ap-node b { grid-column: 2; grid-row: 2; }
.ap-glyph {
  grid-column: 1; grid-row: 1 / span 2; width: 34px; height: 34px; padding: 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--glass-1); color: var(--text-muted);
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.ap-node[data-state="done"] .ap-glyph { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--wash-ok); }
.ap-node[data-state="now"] { background: var(--grad-wash), var(--glass-3); box-shadow: var(--sheen), 0 0 0 1px var(--accent), var(--glow-accent); }
.ap-node[data-state="now"] .ap-glyph { color: var(--accent); border-color: var(--accent); background: var(--wash-accent); box-shadow: var(--glow-accent-sm); }

/* The panel: the illustration over the full width, text and example below it in two columns. */
.ap-panel { padding: clamp(18px, 3vw, 36px); gap: 18px; }
.ap-step { grid-template-columns: minmax(0, 1fr); gap: clamp(18px, 2.4vw, 30px); align-items: start; }
.ap-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px clamp(20px, 3vw, 44px); align-items: start; }
.ap-text { display: grid; gap: 12px; align-content: start; }
.ap-body > .ap-example { margin-top: 0; }
.ap-step[hidden] { display: none; }

.ap-fig {
  position: relative; margin: 0; padding: 18px; display: grid; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-lg, var(--radius));
  background: var(--grad-wash), var(--glass-1); box-shadow: var(--sheen);
}
.ap-fig .tag { justify-self: start; }
.ap-fig figcaption { font-size: var(--text-note); color: var(--text-muted); max-width: 52em; }
.ap-fig .ap-ill:not(.ap-map) { max-width: 760px; justify-self: center; }
/* A step where people act: a photo, and the drawing as a card that overlaps its lower right corner.
   The photo is a generated image and carries that label. The card is solid, so its labels read on any photo. */
.ap-fig[data-kind="photo"] { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 0; align-items: end; }
.ap-photo {
  grid-column: 1 / 9; grid-row: 1; position: relative; align-self: stretch; aspect-ratio: 3 / 2; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
}
.ap-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* The label of a generated photo: small white text in its lower left corner, clear of the step card,
   no box. It stays visible for the transparency it gives, and white with a shadow reads on any photo. */
.ap-photo .tag[data-state] { position: absolute; left: 10px; right: auto; bottom: 7px; padding: 0; border: 0; border-radius: 0; background: none;
  font-size: 9px; letter-spacing: 0.06em; color: #fff; opacity: 0.85; text-shadow: 0 1px 2px rgb(0 0 0 / 0.7); }
.ap-card {
  grid-column: 7 / 13; grid-row: 1; position: relative; z-index: 1; margin-bottom: 22px; display: grid; gap: 10px; padding: 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--sheen), var(--shadow-sheet);
}
.ap-fig[data-kind="photo"] figcaption { grid-column: 1 / -1; }
.ap-scroll { overflow-x: auto; }
.ap-scroll-note { display: none; margin: 0; font-size: var(--text-label); font-family: var(--font-mono); color: var(--text-muted); }
.ap-judge { margin: 0; }
.ap-roles .chip[data-kind="agent"] { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 50%, transparent); }


.ap-body h3 { font-size: var(--text-h3); margin: 0; }
.ap-body p { color: var(--text-muted); margin: 0; }
.ap-no { font-family: var(--font-mono); font-size: var(--text-label); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--accent); }
.ap-body .label { margin: 8px 0 0; }
.ap-roles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ap-roles .chip { color: var(--text); background: var(--glass-1); }
.ap-body .facts { margin-top: 4px; grid-template-columns: 1fr; }

/* The example from the sample workflow. Hidden until approach.js has filled it from IO_STORY. */
.ap-example {
  position: relative; display: grid; gap: 12px; margin-top: 6px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--glass-2); box-shadow: var(--sheen);
}
.ap-example:not([data-filled]) { display: none; }
.ap-example::after {
  --t: color-mix(in srgb, var(--accent) 78%, transparent);
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  background:
    linear-gradient(var(--t), var(--t)) left top / 10px 1px no-repeat, linear-gradient(var(--t), var(--t)) left top / 1px 10px no-repeat,
    linear-gradient(var(--t), var(--t)) right bottom / 10px 1px no-repeat, linear-gradient(var(--t), var(--t)) right bottom / 1px 10px no-repeat;
}
.ap-example .tag { justify-self: start; }
.ap-example dl { margin: 0; display: grid; gap: 10px; }
.ap-example dt { font-family: var(--font-mono); font-size: var(--text-label); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-muted); }
.ap-example dd { margin: 2px 0 0; font-size: var(--text-note); color: var(--text); }
.ap-src { margin: 0; font-size: var(--text-note); color: var(--text-muted); max-width: 52em; }
.ap-src:empty { display: none; }

/* The illustrations. Every shape takes its colour from a class, the root sets none for both. */
.ap-ill { display: block; width: 100%; height: auto; color: var(--text-muted); fill: none; stroke: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ap-ill .ln { stroke: var(--border-strong); }
.ap-ill .mu { stroke: currentColor; }
.ap-ill .ac { stroke: var(--accent); }
.ap-ill .a2 { stroke: var(--accent-2); }
.ap-ill .okc { stroke: var(--ok); }
.ap-ill .wt { stroke: var(--wait); }
.ap-ill .thin { stroke-width: 1; }
.ap-ill .wide { stroke-width: 2.4; }
.ap-ill .sig { stroke-width: 2.2; }
.ap-ill .gauge { stroke-width: 10; }
.ap-ill .dash { stroke-dasharray: 4 5; }
.ap-ill .g { fill: var(--glass-2); }
.ap-ill .f1 { fill: var(--glass-1); }
.ap-ill .fa { fill: var(--wash-accent); }
.ap-ill .f2 { fill: color-mix(in srgb, var(--accent-2) 10%, transparent); }
.ap-ill .fo { fill: var(--wash-ok); }
.ap-ill .fw { fill: var(--wash-wait); }
.ap-ill .d-ac { fill: var(--accent); stroke: none; }
.ap-ill .d-a2 { fill: var(--accent-2); stroke: none; }
.ap-ill .d-wt { fill: var(--wait); stroke: none; }
.ap-ill .d-mu { fill: currentColor; stroke: none; }
.ap-ill .glow { filter: drop-shadow(0 0 calc(8px * var(--glow)) color-mix(in srgb, var(--accent) 55%, transparent)); }
.ap-ill text { stroke: none; }
.ap-ill .t { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; fill: var(--text-muted); }
.ap-ill .tx { fill: var(--text); }
/* German labels are longer: the agent names of step 3 run without letter spacing. */
:lang(de) .ap-ill .tx { letter-spacing: 0; }
.ap-ill .ta { fill: var(--accent); }
.ap-ill .t-a2 { fill: var(--accent-2); }
.ap-ill .t-wt { fill: var(--wait); }
.ap-ill .tb { font-family: var(--font-display); font-weight: 600; font-size: 17px; fill: var(--text); }
.ap-ill .tk text { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.02em; fill: var(--text); }
.ap-ill .flow { stroke-width: 2.4; stroke-dasharray: 3 9; }
.ap-ill .ap-flow { animation: ap-flow 1.6s linear infinite; }
.ap-ill .ap-kappa rect { fill: var(--glass-1); stroke: var(--border-strong); }
.ap-ill .ap-kappa rect[data-on] { fill: var(--accent); stroke: var(--accent); }
.ap-ill .ap-hatch { fill: var(--wash-wait); stroke: color-mix(in srgb, var(--wait) 45%, transparent); stroke-dasharray: 3 4; }
.ap-ill .ap-mark { --k: var(--accent); fill: color-mix(in srgb, var(--k) 14%, transparent); stroke: color-mix(in srgb, var(--k) 55%, transparent); }
.ap-ill .ap-map-ico { --k: var(--accent); color: var(--k); fill: none; stroke: currentColor; stroke-width: 1.7; }
.ap-ill [data-kind="norms"] { --k: var(--accent-2); }
.ap-ill [data-kind="extended"] { --k: var(--ok); }
.ap-ill [data-kind="experts"] { --k: var(--wait); }
.ap-ill [data-kind="systems"] { --k: var(--primary); }
.ap-ill .ap-map-head { font-family: var(--font-mono); font-size: 10.5px; fill: var(--text); }
.ap-ill .ap-map-gate { font-size: 9px; letter-spacing: 0.02em; }
.ap-ill .ap-map-no { font-size: 9.5px; fill: var(--accent); }
.ap-ill .ap-thread { opacity: 0.7; }
.ap-ill .ap-map-row { letter-spacing: 0.06em; }
@keyframes ap-flow { to { stroke-dashoffset: -24; } }

/* At rest every animation holds where it is. */
html[data-motion="off"] .ap-ill .ap-flow { animation-play-state: paused; }
html[data-motion="off"] .ap-rail-fill,
html[data-motion="off"] .ap-node { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .ap-ill .ap-flow { animation: none; }
  .ap-rail-fill, .ap-node { transition: none; }
  .ap-node:hover { transform: none; }
}

@media (max-width: 1080px) {
  .ap-rail { display: none; }
  .ap-step { grid-template-columns: 1fr; }
  .ap-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ap-map { min-width: 600px; }
  .ap-scroll-note { display: block; }
}

/* The workflow map table: dotted empty cells; one card per phase on a narrow screen. */
#workflow .wmap td[data-empty] { border-color: transparent; background: none; text-align: center; vertical-align: middle; }
#workflow .wmap td[data-empty]::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); }
#workflow .wmap td[data-need] { --k: var(--accent); border-color: color-mix(in srgb, var(--k) 55%, transparent); background: color-mix(in srgb, var(--k) 11%, transparent); }
#workflow .wmap td[data-need]::before { background: var(--k); }
#workflow .wmap td[data-kind="norms"] { --k: var(--accent-2); }
#workflow .wmap td[data-kind="extended"] { --k: var(--ok); }
#workflow .wmap td[data-kind="experts"] { --k: var(--wait); }
#workflow .wmap td[data-kind="systems"] { --k: var(--primary); }
#workflow .wmap tr[data-kind="gate"] th { color: var(--wait); }
@media (max-width: 760px) {
  .ap-fig[data-kind="photo"] { grid-template-columns: minmax(0, 1fr); }
  .ap-photo, .ap-card { grid-column: 1; grid-row: auto; }
  .ap-card { margin-bottom: 0; }
  #workflow .table-wrap { overflow: visible; }
  #workflow .wmap { min-width: 0; border-spacing: 0; }
  #workflow .wmap thead { display: none; }
  #workflow .wmap, #workflow .wmap tbody, #workflow .wmap tr, #workflow .wmap th, #workflow .wmap td { display: block; width: auto; }
  #workflow .wmap tr { margin-bottom: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--glass-1); }
  #workflow .wmap tbody th { padding: 0 0 8px; white-space: normal; }
  #workflow .wmap td { margin-top: 6px; }
  #workflow .wmap td[data-empty] { display: none; }
  #workflow .wmap td[data-need]::after { content: attr(data-label); display: block; order: -1; margin-top: 4px; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--k); }
}
@media (max-width: 560px) {
  .ap-node { grid-template-columns: 1fr; padding: 12px; }
  .ap-glyph { grid-row: 1; width: 30px; height: 30px; }
  .ap-node small { grid-column: 1; grid-row: 2; }
  .ap-node b { grid-column: 1; grid-row: 3; font-size: 1rem; }
  .ap-fig { padding: 12px; }
}
