/* Worked examples page. Additive to styles.css; reuses the existing tokens. */

.ex-page-head .lede { max-width: 70ch; }
.ex-boundary {
  display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid rgba(21, 50, 91, .16); font-size: 13px; line-height: 1.5; color: var(--ink-2);
}
.ex-boundary span { max-width: 52ch; }
.ex-boundary b { color: var(--ink); }

.ex-switch-bar {
  position: sticky; top: 74px; z-index: 20; margin: 0 0 26px; padding: 12px;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: var(--r-card);
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.ex-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-switch label { position: relative; display: inline-flex; cursor: pointer; }
.ex-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ex-switch span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--field-line); border-radius: 999px; background: #fff;
  font-size: 14px; line-height: 1.25; color: var(--ink-2);
}
.ex-switch input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.ex-switch input:focus-visible + span { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.ex-switch .ex-num { font-family: var(--mono, ui-monospace, monospace); font-size: 11px; letter-spacing: .08em; opacity: .75; }
.ex-readout { margin: 10px 4px 0; font-size: 13px; line-height: 1.5; color: var(--muted); min-height: 20px; }

.js [data-cases] .ex-case { display: none; }
.js [data-cases] .ex-case.is-active { display: block; }

.ex-case { padding-top: 10px; }
.ex-case-head { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.ex-case-head h2 { margin-top: 10px; }
.ex-case-head .ex-question {
  padding: 18px 20px; border: 1px solid var(--line); border-left: 3px solid var(--navy);
  border-radius: var(--r-card); background: var(--bg-2); font-size: 15px; line-height: 1.55;
}
.ex-case-head .ex-question b { display: block; margin-bottom: 6px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.ex-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ex-kicker .chip { background: #fff; }

.ex-band {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 26px 0 8px;
  border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--line);
}
.ex-band div { background: #fff; padding: 14px 16px; }
.ex-band b { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.ex-band span { font-size: 14px; line-height: 1.45; color: var(--ink-2); }

.ex-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 22px; margin-top: 22px; align-items: start; }
.ex-grid > * { min-width: 0; }
.ex-grid-figure { grid-template-columns: minmax(0, 1fr); }
.ex-grid-figure .ex-stack { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.ex-stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.ex-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--r-card); background: #fff; }
.ex-card h3 { font-size: 20px; }
.ex-card h4 { margin-top: 16px; font-size: 15px; }
.ex-card p, .ex-card li { font-size: 15px; line-height: 1.55; }
.ex-card p + p { margin-top: 10px; }
.ex-card .small { font-size: 13px; }

.ex-figure { margin: 0; min-width: 0; }
.ex-figure-scroll {
  overflow-x: auto; max-width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: var(--r-card); background: #fbfcff;
  -webkit-overflow-scrolling: touch;
}
.ex-diagram { min-width: 760px; padding: 8px; }
.ex-diagram svg { display: block; width: 100%; height: auto; }
.ex-figcaption { margin-top: 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.ex-figcaption b { color: var(--ink-2); }

.ex-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.ex-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ex-legend i { width: 18px; height: 0; border-top: 2px solid #3d6fd4; }
.ex-legend .ret i { border-top-color: #a2543a; }
.ex-legend .ctl i { border-top: 2px dashed #15325b; }
.ex-legend .pwr i { border-top: 2px dotted #5a6b80; }
.ex-legend .valve i { width: 9px; height: 9px; border: 1.5px solid var(--ink); transform: rotate(45deg); }
.ex-legend .bound i { width: 18px; border-top: 2px dashed #8591a3; }

.ex-svg { font-family: var(--sans, Geist, system-ui, sans-serif); }
.ex-svg .pipe { fill: none; stroke-width: 2.2; }
.ex-svg .pipe.supply { stroke: #3d6fd4; }
.ex-svg .pipe.return { stroke: #a2543a; }
.ex-svg .pipe.ctl { stroke: #15325b; stroke-width: 1.5; stroke-dasharray: 6 4; }
.ex-svg .pipe.pwr { stroke: #5a6b80; stroke-width: 1.5; stroke-dasharray: 2 4; }
.ex-svg .pipe.bypass { stroke: #8591a3; stroke-width: 1.4; stroke-dasharray: 5 4; }
.ex-svg .node { fill: #fff; stroke: #8591a3; stroke-width: 1.3; }
.ex-svg .node-focus { fill: #fff; stroke: #15325b; stroke-width: 2.2; }
.ex-svg .node-amber { fill: #fdf1d6; stroke: #e39b12; stroke-width: 1.8; }
.ex-svg .node-shared { fill: #f3f5f9; stroke: #15325b; stroke-width: 1.6; stroke-dasharray: 5 4; }
.ex-svg .node-load { fill: #eef3fc; stroke: #9db4d6; stroke-width: 1.2; }
.ex-svg .t { font-size: 12px; fill: #2b3a4d; }
.ex-svg .t-id { font-size: 13px; font-weight: 600; fill: #0e1a2b; letter-spacing: .02em; }
.ex-svg .t-small { font-size: 11.5px; fill: #55606e; }
.ex-svg .t-amber { font-size: 11.5px; fill: #7a5200; font-weight: 600; }
.ex-svg .t-boundary { font-size: 10px; fill: #8591a3; letter-spacing: .12em; }
.ex-svg .wire-run { fill: none; stroke: #8591a3; stroke-width: 1.2; }
.ex-svg .valve { fill: #fff; stroke: #0e1a2b; stroke-width: 1.4; }
.ex-svg .valve-ams { fill: #fdf1d6; stroke: #e39b12; stroke-width: 1.6; }
.ex-svg .arrow { fill: #3d6fd4; }
.ex-svg .arrow-amber { fill: #e39b12; }
.ex-svg .boundary { fill: none; stroke: #8591a3; stroke-width: 1; stroke-dasharray: 5 5; }
.ex-svg .focus-ring { fill: none; stroke: #e39b12; stroke-width: 1.2; stroke-dasharray: 3 3; }
.ex-svg .measure { fill: #15325b; }

.ex-chart-block { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: #fff; }
.ex-chart-block h3 { font-size: 17px; }
.ex-chart-block .ex-chart-note { margin-top: 5px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.ex-chart-scroll { overflow-x: auto; max-width: 100%; min-width: 0; margin-top: 12px; -webkit-overflow-scrolling: touch; }
.ex-chart svg { display: block; min-width: 560px; width: 100%; height: auto; }
.ex-svg-axis { font-family: var(--mono, ui-monospace, monospace); font-size: 9.5px; fill: #55606e; }
.ex-svg-label { font-size: 10px; fill: #55606e; letter-spacing: .06em; text-transform: uppercase; }
.ex-svg-note { font-size: 9px; fill: #2f7a4a; }
.ex-svg-event { font-size: 9px; fill: #7a5200; }
.ex-svg-point { fill: #15325b; stroke: #fff; stroke-width: 1.2; }
.ex-svg-point.has-event { fill: #e39b12; stroke: #7a5200; stroke-width: 1.4; }

.ex-data { margin-top: 12px; font-size: 13px; }
.ex-data summary { cursor: pointer; color: var(--navy); font-size: 13px; }
.ex-data table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.ex-data caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.ex-data th, .ex-data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ex-data th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.ex-data td.num { font-family: var(--mono, ui-monospace, monospace); white-space: nowrap; }

.ex-obs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ex-obs th, .ex-obs td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.45; }
.ex-obs th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--bg-2); }
.ex-obs td:first-child { font-family: var(--mono, ui-monospace, monospace); white-space: nowrap; color: var(--ink); }
.ex-obs-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); }

.ex-dependency { width: 100%; border-collapse: collapse; font-size: 14px; }
.ex-dependency th, .ex-dependency td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.5; }
.ex-dependency tr:last-child th, .ex-dependency tr:last-child td { border-bottom: 0; }
.ex-dependency th { width: 120px; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

.ex-run-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ex-run-bar label { position: relative; display: inline-flex; cursor: pointer; }
.ex-run-bar input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ex-run-bar span { display: inline-flex; min-height: 38px; align-items: center; padding: 7px 13px; border: 1px solid var(--field-line); border-radius: 999px; background: #fff; font-size: 13px; color: var(--ink-2); }
.ex-run-bar input:checked + span { background: var(--blue-soft); border-color: var(--navy); color: var(--ink); font-weight: 500; }
.ex-run-bar input:focus-visible + span { outline: 3px solid var(--blue-soft); outline-offset: 2px; }

.ex-result { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: #fff; }
.ex-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.ex-result h3 { font-size: 18px; }
.ex-result .ex-reason { margin-top: 10px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.ex-result .rows { margin-top: 14px; }
.ex-result .row { padding: 9px 0; }
.ex-result .row dt { font-size: 11px; }
.ex-result .row dd { font-size: 14px; }
.ex-checks { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ex-checks h4 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ex-checks ul { margin-top: 8px; display: grid; gap: 7px; }
.ex-checks li { font-size: 13.5px; line-height: 1.5; }
.ex-checks li.is-done { color: #2f7a4a; }
.ex-next { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--bg-2); font-size: 14px; line-height: 1.55; }
.ex-next b { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.ex-unresolved { margin-top: 14px; }
.ex-unresolved li { font-size: 14px; line-height: 1.5; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ex-unresolved li:last-child { border-bottom: 0; }
.ex-limits { margin-top: 14px; padding: 16px; border: 1px solid var(--amber-line); border-radius: var(--r-card); background: var(--amber-bg); }
.ex-limits h4 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--amber-ink); }
.ex-limits li { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }

.ex-footnote { margin-top: 28px; font-size: 13px; line-height: 1.6; color: var(--muted); max-width: 88ch; }

@media (max-width: 1000px) {
  .ex-case-head, .ex-grid { grid-template-columns: 1fr; }
  .ex-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .ex-switch-bar { position: static; }
  .ex-band { grid-template-columns: 1fr; }
  .ex-switch span { min-height: 40px; padding: 7px 12px; font-size: 13px; }
  .ex-card, .ex-result, .ex-chart-block { padding: 16px; }
  .ex-diagram { min-width: 720px; }
}
@media (prefers-reduced-motion: reduce) {
  .ex-switch-bar { backdrop-filter: none; }
}

/* Keep long actions and diagram scrollers inside the mobile page. */
.ex-grid-figure, .ex-grid-figure > *, .ex-stack { min-width: 0; }
.page-head .btn, .ex-final .btn { max-width: 100%; white-space: normal; text-align: center; }
@media (max-width: 759px) {
  .ex-grid-figure { grid-template-columns: minmax(0, 1fr); }
  .ex-switch-bar { position: static; }
  .ex-chart-block { min-width: 0; overflow-x: auto; }
  .ex-chart-svg { min-width: 580px; }
}

.ex-chart-events { margin: 12px 0 0 24px; font-size: 13px; line-height: 1.6; color: var(--ink-2); list-style: decimal; }
