/* Figures for The Truth Behind AI Doomerism. Builds on the shared .wa-art system in writing/article.css. */

/* Figure chrome */
.writing-article-page .dm-figure .dm-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; margin: 0 0 1rem; color: var(--muted); font: 0.75rem/1.4 var(--sans); }
.writing-article-page .dm-figure .dm-meta strong { color: var(--foreground); font-weight: 500; }
.writing-article-page .dm-figure .dm-readout,
.writing-article-page .dm-figure .dm-status { margin: 0.9rem 0 0; color: var(--body); font: 0.8125rem/1.5 var(--sans); }
.writing-article-page .dm-figure .dm-flag { margin: 0.9rem 0 0; color: var(--muted); font: 0.75rem/1.5 var(--sans); }
.writing-article-page .dm-figure .dm-flag b { color: var(--foreground); font-weight: 500; }
.writing-article-page .dm-figure .dm-flag--outside { margin: 0.75rem 0 0; }
.writing-article-page .dm-figure .dm-pane__title { margin: 0 0 0.6rem; color: var(--muted); font: 0.75rem/1.4 var(--sans); }

/* Accessible data tables */
.writing-article-page .dm-figure .dm-data { margin: 0.75rem 0 0; color: var(--muted); font: 0.8125rem/1.5 var(--sans); }
.writing-article-page .dm-figure .dm-data summary { width: fit-content; cursor: pointer; }
.writing-article-page .dm-figure .dm-data summary:focus-visible { outline: 2px solid var(--article-accent); outline-offset: 2px; }
.writing-article-page .dm-figure .dm-data__scroll { margin-top: 0.5rem; overflow-x: auto; }
.writing-article-page .dm-figure .dm-data table { width: 100%; border-collapse: collapse; font: 0.75rem/1.45 var(--sans); font-variant-numeric: tabular-nums; }
.writing-article-page .dm-figure .dm-data :is(th, td) { padding: 0.35rem 0.75rem 0.35rem 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.writing-article-page .dm-figure .dm-data thead th { color: var(--foreground); font-weight: 500; }
.writing-article-page .dm-figure .dm-data tbody th { color: var(--body); font-weight: 400; }
.writing-article-page .dm-grid .doomerism-demand-table { margin-top: 1rem; }

/* Controls: native radios and a range input */
.writing-article-page .dm-figure .dm-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; min-width: 0; margin: 0 0 1rem; padding: 0; border: 0; }
.dm-controls legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Segmented control: a quiet track with a raised chip for the current choice. */
.dm-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 8px; background: #ebebe6; }
.dm-pill { position: relative; display: inline-flex; align-items: center; min-height: 2rem; padding: 0.3rem 0.85rem; border-radius: 6px; background: transparent; color: var(--muted); font: 0.8125rem/1.3 var(--sans); cursor: pointer; }
.dm-pill input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.dm-pill:hover { color: var(--foreground); }
.dm-pill:has(input:checked) { background: #fff; color: var(--foreground); font-weight: 500; box-shadow: 0 0 0 1px #d8d8d1, 0 1px 2px rgba(27, 27, 26, 0.08); }
.dm-pill:has(input:focus-visible) { outline: 2px solid var(--article-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .dm-pill { transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
}

/* Step narration sits above the chart it describes. */
.writing-article-page .dm-figure .dm-step { display: flex; gap: 0.75rem; margin: 0 0 1rem; color: var(--foreground); font: 0.8125rem/1.5 var(--sans); }
.dm-step__n { flex: none; min-width: 2.25rem; color: var(--faint); font: 0.75rem/1.65 var(--mono); font-variant-numeric: tabular-nums; }

/* Captions: explanation first, then a quieter source line. */
.writing-article-page .dm-figure figcaption .dm-source { display: block; margin-top: 0.4rem; color: var(--faint); font-size: 0.75rem; }

/* Let the chart panel run past the text column on wide screens, as tables and plots already do. */
@media screen and (min-width: 77.5rem) {
  .writing-article-page .dm-figure > .wa-art { width: calc(100% + 6rem); margin-inline: -3rem; padding-inline: 1.5rem; }
}

.writing-article-page .dm-figure .dm-slider { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 0.35rem 1rem; margin: 0 0 1rem; }
.writing-article-page .dm-figure .dm-slider[hidden] { display: none; }
.dm-slider label { color: var(--foreground); font: 0.8125rem/1.4 var(--sans); }
.dm-slider label small { display: block; color: var(--muted); font-size: 0.75rem; }
.dm-slider output { color: var(--foreground); font: 500 0.9375rem/1.4 var(--sans); font-variant-numeric: tabular-nums; }
.dm-slider input[type="range"] { grid-column: 1 / -1; width: 100%; height: 1.75rem; margin: 0; accent-color: var(--article-accent); cursor: pointer; }
.dm-slider input[type="range"]:focus-visible { outline: 2px solid var(--article-accent); outline-offset: 3px; }
.dm-reset { justify-self: start; padding: 0.25rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); font: 0.75rem/1.3 var(--sans); cursor: pointer; }
.dm-reset:hover { color: var(--foreground); }
.dm-reset:focus-visible { outline: 2px solid var(--article-accent); outline-offset: 2px; }

/* Switchable panes. Without :has() support, every pane shows and the controls hide. */
.dm-switch .dm-pane + .dm-pane { margin-top: 1.5rem; }
@supports selector(:has(*)) {
  .dm-switch:has(input[value="onsite"]:checked) .dm-pane:not([data-view="onsite"]),
  .dm-switch:has(input[value="power"]:checked) .dm-pane:not([data-view="power"]),
  .dm-switch:has(input[value="practice"]:checked) .dm-pane:not([data-view="practice"]),
  .dm-switch:has(input[value="exam"]:checked) .dm-pane:not([data-view="exam"]) { display: none; }
  .dm-switch .dm-pane + .dm-pane { margin-top: 0; }
}
@supports not selector(:has(*)) {
  .dm-switch .dm-controls { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .dm-switch .dm-pane { animation: dm-pane-in 240ms ease-out; }
  @keyframes dm-pane-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}

/* Water cards */
.dm-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1.1rem; }
.dm-card { min-width: 0; padding: 0.75rem 0.85rem; border: 1px solid var(--border); border-radius: 4px; background: #fff; font: 0.75rem/1.45 var(--sans); }
.writing-article-page .dm-figure .dm-card__title { margin: 0 0 0.55rem; color: var(--foreground); font: 500 0.8125rem/1.35 var(--sans); }
.dm-card dl { display: grid; grid-template-columns: 4.75rem minmax(0, 1fr); gap: 0.3rem 0.6rem; margin: 0; }
.dm-card dt { color: var(--muted); }
.dm-card dd { margin: 0; color: var(--body); }
.dm-card dt.dm-in { margin-top: 0.35rem; padding-top: 0.45rem; border-top: 1px solid var(--border); grid-column: 1 / -1; color: var(--foreground); }
.dm-card dd.dm-in { grid-column: 1 / -1; }
.dm-card dt.dm-in--power { margin-top: 0.1rem; }
@supports selector(:has(*)) {
  .dm-water:has(input[value="onsite"]:checked) .dm-in--power,
  .dm-water:has(input[value="power"]:checked) .dm-in--onsite { opacity: 0.5; }
  .dm-water:has(input[value="onsite"]:checked) dd.dm-in--onsite,
  .dm-water:has(input[value="power"]:checked) dd.dm-in--power { color: var(--foreground); font-weight: 500; }
}
@media (max-width: 36rem) {
  .dm-cards { grid-template-columns: minmax(0, 1fr); }
}

/* SVG marks used by these figures */
.dm-halo { paint-order: stroke; stroke: #fbfbf8; stroke-width: 4px; stroke-linejoin: round; }
.dm-hatch-bg { fill: #fbfbf8; }
.dm-hatch-line { stroke: var(--article-accent); stroke-width: 1.6; }
.dm-topup, .dm-proj { stroke: var(--article-accent); stroke-width: 1; }
.dm-floor { stroke: #1b1b1a; stroke-width: 1.25; stroke-dasharray: 2 2; }
.dm-dmark { stroke: #1b1b1a; stroke-width: 1.5; }
.dm-node { fill: #f4f4f1; stroke: #d6d6cf; stroke-width: 1; }
.dm-node--focus { fill: color-mix(in srgb, var(--article-accent) 7%, #fff); stroke: var(--article-accent); stroke-width: 1.3; }
.dm-inset, .dm-unknown { fill: #f4f4f1; stroke: #d6d6cf; }
.dm-unknown { stroke: #8a8984; stroke-dasharray: 3 2; }
.dm-open { fill: #fbfbf8; stroke: var(--article-accent); stroke-width: 1.5; }
.dm-arrowhead { fill: #5c5c58; }
.dm-flow { fill: none; stroke: #5c5c58; stroke-width: 1.5; }
.dm-flow--w { stroke-width: 2.25; }
.dm-flow--c { stroke: var(--article-accent); stroke-width: 2; stroke-dasharray: 5 3; }
.dm-flow--d { stroke-dasharray: 1.5 3.5; stroke-linecap: round; stroke-width: 2; }
.dm-flow--e { stroke-dasharray: 7 2 1.5 2; }
.dm-stress { fill: color-mix(in srgb, var(--article-accent) 9%, #fbfbf8); stroke: var(--article-accent); stroke-dasharray: 3 2; }
.dm-stress-link { stroke: var(--article-accent); stroke-dasharray: 2 2; }
.dm-zero { stroke: #5c5c58; stroke-width: 1; }
.dm-zero-tick { stroke: #5c5c58; stroke-width: 1.5; }
.dm-ghost { fill: #fbfbf8; stroke: #8a8984; stroke-width: 1.25; stroke-dasharray: 2 1.5; }
.dm-ghost-link { stroke: #b9b8b2; stroke-dasharray: 2 2; }
.dm-ci { fill: var(--article-accent); }
.dm-ci-cap { stroke: var(--article-accent); stroke-width: 1.25; }
.dm-sq { fill: #fbfbf8; stroke: #5c5c58; stroke-width: 1.75; }
.dm-dash { stroke-dasharray: 4 3; stroke-width: 1.75; }
.dm-bracket { fill: none; stroke: #1b1b1a; }
.dm-group { font: 500 10.5px var(--sans); fill: #686864; letter-spacing: 0.04em; text-transform: uppercase; }
.dm-diamond { fill: #fff; stroke: #1b1b1a; stroke-width: 1.5; }
.dm-outcome { fill: #fff; stroke: #1b1b1a; stroke-dasharray: 4 3; }
.dm-stop { fill: none; stroke: var(--article-accent); stroke-width: 2; }
.dm-ev-link { stroke: #c9c9c1; }

@media print {
  .dm-switch .dm-pane { display: block !important; }
  .dm-switch .dm-controls, .dm-slider { display: none !important; }
}
