/* scada.pdigger.com: the SM1 design paper, on top of pd.css. No inline styles: the CSP forbids them.
   Blue marks work on the graphics processor and the data the API gives; orange marks CPU work. */

.section--soft { background: var(--paper-2); }
.secno { font-family: var(--font-mono); color: var(--ink); font-weight: 700; margin-right: 2px; }
.section--dark .secno { color: var(--hmi-ink); }
.section--dark .lead { color: var(--hmi-muted); }

/* ─── Hero ─── */
.hero { position: relative; padding: calc(var(--header-h) + clamp(28px, 5vw, 64px)) 0 clamp(36px, 5vw, 64px); overflow: clip; }
.hero::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 40px 40px; -webkit-mask-image: radial-gradient(ellipse 70% 70% at 70% 40%, #000 20%, transparent 75%); mask-image: radial-gradient(ellipse 70% 70% at 70% 40%, #000 20%, transparent 75%); pointer-events: none; }
.hero__grid { position: relative; display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: clamp(28px, 4.5vw, 72px); align-items: center; }
.hero__copy { display: grid; gap: 24px; justify-items: start; }
.hero .display { font-size: clamp(2.9rem, 5.9vw, 5.8rem); }
.hero .display .serif { font-weight: 450; }
.hero__copy .lead { max-width: 30ch; }
.facts { list-style: none; padding: 0; margin-top: clamp(32px, 4.5vw, 56px); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.facts li { position: relative; display: grid; align-content: start; gap: 6px; padding: 16px 44px 18px 18px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.facts b { font-size: clamp(2.1rem, 3.2vw, 2.9rem); font-weight: 850; letter-spacing: -0.045em; line-height: 0.9; }
.facts span { color: var(--muted); font-size: 0.95rem; line-height: 1.3; }
.facts .info { position: absolute; right: 14px; top: 14px; margin: 0; }

/* ─── Abstract and contents ─── */
.section--abstract { border-block: 1px solid var(--line); }
.abstract { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 80px); align-items: start; }
.abstract__text { display: grid; gap: 14px; }
.abstract__text .h3 { font-size: clamp(1.5rem, 2.4vw, 2.1rem); max-width: 26ch; }
.abstract__text p:not(.kicker) { font-family: var(--font-serif); font-size: clamp(1.1rem, 1.4vw, 1.28rem); line-height: 1.55; color: var(--ink-2); max-width: 60ch; }
.toc { display: grid; gap: 12px; }
.toc ol { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.toc a { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 650; }
.toc a:hover { color: var(--data); }
.toc b { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); font-weight: 700; }

/* ─── Figures ─── */
.fig.card { padding: clamp(14px, 2vw, 26px); }
.fig__scroll { position: relative; }
.fig__inner { position: relative; }
.s-halo { fill: none; stroke: var(--surface); stroke-width: 9; }
.s-glass { fill: color-mix(in srgb, var(--data) 26%, #1b1f24); }
.s-big { font-size: 22px; font-weight: 850; letter-spacing: -0.02em; }
.s-inv { fill: color-mix(in srgb, var(--paper) 72%, transparent); font-size: 13px; }
.s-inv--t { fill: var(--paper); font-size: 17px; font-weight: 800; }
.s-blocks { fill: none; stroke: var(--data); stroke-width: 10; stroke-linecap: round; }
.s-teal { fill: var(--teal); }
.m-plus { fill: var(--paper); font-size: 20px; font-weight: 800; }
.hs--tap { left: 41.8%; top: 7.4%; }
.hs--sm1 { left: 23.96%; top: 75%; }
.hs--api { left: 65%; top: 77.5%; }

.trio { list-style: none; padding: 0; margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.trio--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.trio__item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 16px 20px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.trio__n { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.015em; line-height: 1.2; }

/* ─── Principles ─── */
.principles { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pr { display: grid; align-content: start; gap: 12px; padding: 22px 20px 24px; border-radius: var(--radius-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.pr__icon { width: 46px; height: 46px; }
.pi-s { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pi-faint { stroke: var(--faint); }
.pi-a { fill: var(--data); }
.pi-d { fill: var(--accent); }
.pi-ok { fill: var(--teal); }
.pi-a-s { fill: none; stroke: var(--data); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pr__n { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; color: var(--data); }
.pr__t { font-size: clamp(1.2rem, 1.5vw, 1.38rem); line-height: 1.12; letter-spacing: -0.02em; }

/* ─── One reading: eight steps ─── */
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.st { --c: var(--data); position: relative; display: grid; align-content: start; gap: 4px; padding: 16px 18px 18px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 70%, transparent); }
.st--cpu { --c: var(--accent); }
.st:not(:nth-child(4n))::after { content: '→'; position: absolute; z-index: 1; right: -14px; top: 50%; width: 24px; height: 24px; margin-top: -12px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 0.8rem; font-weight: 800; line-height: 1; }
.st__n { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; color: var(--c); }
.st__t { font-size: 1.18rem; line-height: 1.15; letter-spacing: -0.015em; }
.st__s { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }
.legend { display: flex; gap: 18px; margin: 14px 0 clamp(36px, 5vw, 64px); font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend span::before { content: ''; width: 18px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 2px var(--data); }
.legend .legend__cpu::before { box-shadow: inset 0 0 0 2px var(--accent); }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.split__text { display: grid; gap: 14px; justify-items: start; }
.split__text .muted { font-size: 1.08rem; }
.heads { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.heads li { padding: 5px 11px 6px; border-radius: 999px; background: var(--data-soft); color: var(--ink); font-weight: 650; font-size: 0.92rem; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--data) 40%, transparent); }

/* ─── Where to look ─── */
.look { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(18px, 3vw, 40px); align-items: start; margin-bottom: clamp(24px, 3.5vw, 44px); }
.t-screen { fill: #16191d; }
.t-l4 { fill: none; stroke: rgb(233 230 225 / 0.07); stroke-width: 1; }
.t-l3 { fill: none; stroke: rgb(233 230 225 / 0.13); stroke-width: 1; }
.t-l2 { fill: none; stroke: rgb(233 230 225 / 0.22); stroke-width: 1.5; }
.t-l1 { fill: none; stroke: rgb(233 230 225 / 0.34); stroke-width: 2; }
.t-change { fill: color-mix(in srgb, #2c66c9 82%, transparent); stroke: #7ea8f0; stroke-width: 1.5; }
.t-pointer { fill: color-mix(in srgb, #0e6f73 88%, transparent); stroke: #3fbfc2; stroke-width: 1.5; }
.t-pointer--next { fill: color-mix(in srgb, #0e6f73 50%, transparent); }
.t-stale { fill: rgb(255 182 39 / 0.12); stroke: #ffb627; stroke-width: 2; }
.t-survey { fill: rgb(233 230 225 / 0.05); stroke: #c9cdd2; stroke-width: 2; stroke-dasharray: 6 5; }
.t-cursor { fill: #fff; stroke: #111; stroke-width: 1.2; stroke-linejoin: round; }
.t-legend text { fill: var(--ink-2); font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.t-legend .t-note { fill: var(--muted); font-weight: 500; }
.t-legend .t-stale { fill: rgb(255 182 39 / 0.3); }
.t-legend .t-survey { fill: transparent; stroke: var(--muted); }
.look__side { display: grid; gap: 14px; }
.lanes { list-style: none; padding: 0; display: grid; gap: 6px; }
.lane { --c: var(--data); position: relative; display: grid; grid-template-columns: 6.2rem 1fr auto; align-items: center; gap: 10px; padding: 11px 12px 11px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.lane::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.lane b { font-weight: 800; }
.lane span { color: var(--muted); font-size: 0.95rem; line-height: 1.3; }
.lane .info { margin: 0; }
.lane--pointer { --c: var(--teal); }
.lane--refresh { --c: var(--accent); }
.lane--stale { --c: var(--amber); }
.lane--survey { --c: var(--faint); }
.budget { display: grid; gap: 12px; padding: 18px 20px 20px; border-radius: 18px; background: var(--ink); color: var(--paper); }
.budget__t { font-weight: 800; font-size: 1.1rem; }
.budget__k { display: inline-flex; gap: 4px; padding: 4px; width: max-content; border-radius: 999px; background: rgb(255 255 255 / 0.08); }
.budget__k button { min-width: 52px; min-height: 36px; padding: 5px 12px; border: 0; border-radius: 999px; background: transparent; color: inherit; font-family: var(--font-mono); font-weight: 700; }
.budget__k button[aria-pressed='true'] { background: var(--paper); color: var(--ink); }
.budget__bar { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; min-height: 18px; }
.budget__bar span { aspect-ratio: 1; border-radius: 3px; background: var(--data); animation: k-in 0.4s var(--ease) both; }
.budget__bar span:nth-child(16n + 1) { box-shadow: -3px 0 0 0 var(--ink); }
@keyframes k-in { from { opacity: 0; transform: scale(0.4); } }
.budget__note { font-size: 0.93rem; color: color-mix(in srgb, var(--paper) 70%, transparent); }
.budget__note span { font-weight: 800; color: var(--paper); }
.look__film { max-width: 980px; }

/* ─── World (dark) ─── */
.section--dark .loop { background: var(--hmi-2); box-shadow: 0 0 0 1px var(--hmi-line); }
.section--dark .loop__bar { background: var(--hmi-2); border-top-color: var(--hmi-line); }
.section--dark .loop__bar .loop__label { color: var(--hmi-muted); }
.section--dark .loop__bar button { color: var(--hmi-ink); }
.section--dark .loop__bar button:hover { background: rgb(255 255 255 / 0.08); }
.section--dark .loop__bar button[aria-pressed='true'] { background: var(--hmi-ink); color: var(--hmi); }
.wc { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wc li { position: relative; display: grid; gap: 4px; padding: 14px 40px 16px 16px; border-radius: 16px; background: rgb(255 255 255 / 0.04); box-shadow: inset 0 0 0 1px var(--hmi-line); }
.wc b { font-weight: 800; font-size: 1.05rem; }
.wc span { color: var(--hmi-muted); font-size: 0.93rem; line-height: 1.3; }
.wc .info { position: absolute; right: 12px; top: 12px; margin: 0; }
.learned { margin-top: clamp(28px, 4vw, 48px); display: grid; gap: 10px; padding: 20px 22px; border-radius: var(--radius-l); background: rgb(255 255 255 / 0.04); box-shadow: inset 0 0 0 1px var(--hmi-line); }
.learned__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.learned__plant { width: 6rem; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--hmi-muted); }
.learned__word { min-width: 6.5rem; font-weight: 800; font-size: 1.1rem; }
.learned__arrow { color: var(--hmi-muted); }
.lamp { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.35), 0 0 0 2px rgb(255 255 255 / 0.12); }
.lamp--green { background: #33c26b; box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.3), 0 0 14px rgb(51 194 107 / 0.55); }
.lamp--grey { background: #6b7178; }
.lamp--red { background: #e5483b; box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.3), 0 0 14px rgb(229 72 59 / 0.5); }
.learned .fig__cap { margin-top: 6px; color: var(--hmi-muted); }
.learned .fig__n { color: var(--hmi-ink); }

/* ─── What it reads: one stage, five films ─── */
.viewer { display: grid; grid-template-columns: minmax(200px, 0.32fr) minmax(0, 1fr); gap: clamp(14px, 2vw, 28px); align-items: start; }
.viewer__tabs { display: grid; gap: 6px; }
.viewer__tabs button { display: grid; gap: 2px; justify-items: start; padding: 13px 16px 14px; border: 0; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); text-align: left; transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.viewer__tabs button:hover { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.viewer__tabs b { font-weight: 800; font-size: 1.1rem; }
.viewer__tabs span { color: var(--muted); font-size: 0.93rem; }
.viewer__tabs button[aria-selected='true'] { background: var(--ink); color: var(--paper); box-shadow: none; }
.viewer__tabs button[aria-selected='true'] span { color: color-mix(in srgb, var(--paper) 70%, transparent); }
.viewer__stage { display: grid; gap: 14px; }
.viewer__note { max-width: 70ch; color: var(--ink-2); }
.viewer__note b { color: var(--ink); }

/* ─── Scene API ─── */
.api { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: clamp(24px, 3.5vw, 44px); }
.api__step { display: grid; align-content: start; gap: 10px; min-width: 0; }
.api__n { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--data); }
.api__t { font-size: 1.22rem; line-height: 1.15; letter-spacing: -0.015em; min-height: 2.3em; }
.api .code { font-size: 0.78rem; }
.api__film { max-width: 980px; }

/* ─── Workflows ─── */
.flow__title { margin: 0 0 12px; font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin-bottom: clamp(28px, 4vw, 48px); counter-reset: flow; }
.flow__step { position: relative; display: grid; align-content: start; gap: 6px; padding: 18px 22px 20px 20px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); counter-increment: flow; }
.flow__step:first-child { border-radius: 18px 0 0 18px; }
.flow__step:last-child { border-radius: 0 18px 18px 0; }
.flow__step::before { content: counter(flow, decimal-leading-zero); font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--accent-ink); }
.flow__step:not(:last-child)::after { content: ''; position: absolute; z-index: 1; right: -9px; top: 50%; width: 16px; height: 16px; margin-top: -8px; background: var(--surface); transform: rotate(45deg); box-shadow: 1px -1px 0 0 var(--line); }
.flow--build .flow__step::before { color: var(--data); }
.flow__step b { font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em; }
.flow__step span { color: var(--muted); font-size: 0.95rem; line-height: 1.3; }
.flow__step .info { position: absolute; right: 12px; top: 14px; margin: 0; }
.pilot { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr) auto; gap: clamp(18px, 3vw, 40px); align-items: center; padding: clamp(20px, 3vw, 34px); }
.pilot__steps { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; }
.pilot__steps li { display: flex; align-items: center; gap: 10px; font-weight: 700; line-height: 1.25; }
.pilot__steps b { font-family: var(--font-mono); font-size: 0.74rem; color: var(--accent-ink); }

/* ─── Judged ─── */
.judge { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.judge__item { display: grid; align-content: start; gap: 8px; padding: 20px; border-radius: var(--radius-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.judge__item b { font-weight: 800; font-size: 1.18rem; letter-spacing: -0.015em; }
.judge__item span { color: var(--ink-2); line-height: 1.45; }
.limits { display: grid; gap: 10px; padding: clamp(20px, 3vw, 30px); }
.limits__t { font-family: var(--font-serif); font-style: italic; font-size: clamp(1.3rem, 2vw, 1.7rem); line-height: 1.25; letter-spacing: -0.015em; max-width: 46ch; }

/* ─── Specification ─── */
.spec { width: 100%; border-collapse: collapse; }
.spec th, .spec td { padding: 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.spec th { width: 9rem; padding-right: 18px; font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.spec td { font-size: 1.04rem; color: var(--ink-2); }

/* ─── Call to action ─── */
.cta { display: grid; grid-template-columns: minmax(0, 1.3fr) auto; gap: 28px; align-items: end; padding: clamp(26px, 4vw, 52px); background: var(--ink); color: var(--paper); }
.cta .kicker { color: color-mix(in srgb, var(--paper) 65%, transparent); }
.cta .lead { color: color-mix(in srgb, var(--paper) 78%, transparent); margin-top: 14px; }
.cta__actions { display: grid; gap: 10px; justify-items: start; }
.cta .button--ghost { --b-fg: var(--paper); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--paper) 35%, transparent); }

/* ─── 404 ─── */
.lost { min-height: 70svh; display: grid; align-content: center; justify-items: start; gap: 22px; padding-top: calc(var(--header-h) + 40px); }

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .principles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .judge { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trio--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pilot { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .flow__step, .flow__step:first-child, .flow__step:last-child { border-radius: 18px; }
  .flow__step::after { display: none; }
}
@media (max-width: 960px) {
  .hero__grid, .abstract, .split, .look, .viewer, .cta { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st:not(:nth-child(4n))::after { display: none; }
  .api { grid-template-columns: minmax(0, 1fr); }
  .api__t { min-height: 0; }
  .viewer__tabs { grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: 4px; }
  .fig__scroll { overflow-x: auto; }
  .fig__scroll > svg, .fig__inner { min-width: 720px; }
  .look__tree .fig__scroll > svg { min-width: 560px; }
}
@media (max-width: 640px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .principles, .judge, .trio, .trio--4, .wc, .flow, .pilot__steps, .toc ol { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .lane { grid-template-columns: 5.4rem 1fr auto; }
  .spec th { width: 6.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .budget__bar span { animation: none; }
}
@media print {
  .hero::before { display: none; }
  .viewer__tabs, .budget__k { display: none !important; }
  .viewer__note[hidden] { display: block; }
}
