/* Talk deck: light theme. Every size is in rem, and the root size follows the screen (1/80 of the
   width, capped by the height), so the deck keeps one layout from a laptop to a meeting-room display:
   on a 1920 × 1080 screen 1rem ≈ 24px. Smallest text anywhere is 0.8rem. */
:root {
    --bg: #f7f8fa;
    --bg-2: #fafbfc;
    --panel: #ffffff;
    --panel-2: #ffffff;
    --line: #e4e7eb;
    --ink: #1f2933;
    --ink-2: #3e4c59;
    --muted: #616e7c;
    --accent: #2680c2;
    --accent-soft: #e6f1fa;
    --driver: #d53f8c;
    --system: #2680c2;
    --goal: #2f9e6e;
    --warn: #b7791f;
    --bad: #c53030;
    --good: #1f8a5b;
    --violet: #805ad5;
    --radius: 0.6rem;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { font-size: min(1.25vw, 2.2vh); }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 1.05rem;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.3rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 650; font-size: 0.8rem; color: var(--ink-2); }
.brand b { color: var(--ink); }
.slide-nav { display: flex; gap: 0.3rem; align-items: center; margin-left: auto; }
.slide-nav button { width: 2rem; font-size: 1rem; line-height: 1; }
.slide-nav select { min-width: 13rem; }
.progress { position: absolute; left: 0; bottom: -1px; height: 3px; background: var(--accent); transition: width 0.25s; }

button, select, input[type="number"] {
    font: inherit; font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--line); border-radius: 0.4rem;
    background: var(--panel-2); color: var(--ink);
    cursor: pointer;
}
button:hover, select:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { accent-color: var(--accent); width: 8rem; }
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--accent); }
.hidden { display: none !important; }

#deck { flex: 1; overflow: hidden; position: relative; }
.slide { display: none; height: 100%; overflow-y: auto; }
.slide.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.slide-inner { max-width: 78rem; margin: 0 auto; padding: 1.1rem 2rem 1.2rem; }

h1 { font-size: 2.6rem; line-height: 1.1; margin: 0.3rem 0 0.8rem; letter-spacing: -0.015em; }
h2 { font-size: 1.9rem; line-height: 1.15; margin: 0 0 0.7rem; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; margin: 0 0 0.4rem; color: var(--ink); }
p { margin: 0 0 0.6rem; }
em { color: var(--ink); }
code { font-family: var(--mono); font-size: 0.86em; background: #eef1f4; padding: 1px 6px; border-radius: 5px; }
.kicker { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; color: var(--accent); font-weight: 650; margin: 0 0 0.2rem; }
.lede { font-size: 1.25rem; color: var(--ink-2); max-width: 60rem; }
.note { color: var(--muted); font-size: 0.9rem; }
.small { font-size: 0.95rem; color: var(--ink-2); }
.hl-driver { color: var(--driver); font-weight: 600; }
.hl-system { color: var(--system); font-weight: 600; }
.hl-goal { color: var(--goal); font-weight: 600; }
.hl-warn { color: var(--warn); font-weight: 600; }

.title-slide { padding-top: 3.5rem; }
.title-slide h1 { font-size: 3.2rem; max-width: 62rem; }
.title-points { margin-top: 1.6rem; }
.title-points .card p { margin: 0.5rem 0 0; font-size: 1.05rem; }
.title-points .tag { font-size: 0.85rem; }
.title-slide .who { margin-top: 2rem; color: var(--muted); font-size: 1.1rem; }
.section-slide { padding-top: 9rem; }
.section-slide h1 { font-size: 3rem; }
.section-num { font-family: var(--mono); color: var(--accent); font-size: 1rem; letter-spacing: 0.1em; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.3rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); }
.grid-2.wide-right { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; }
.card.accent { border-color: #b3d4ee; background: linear-gradient(180deg, var(--accent-soft), var(--panel)); }
.card.driver { border-color: #f4c2d9; background: linear-gradient(180deg, #fdf0f6, var(--panel)); }
.card.system { border-color: #b3d4ee; background: linear-gradient(180deg, var(--accent-soft), var(--panel)); }
.card ul, .card ol { margin: 0; padding-left: 1.2rem; }
.card li { margin-bottom: 0.35rem; }
.card p:last-child { margin-bottom: 0; }
.big-quote { font-size: 1.45rem; line-height: 1.3; color: var(--ink); border-left: 4px solid var(--accent); padding: 0.2rem 0 0.2rem 1rem; margin: 0.9rem 0; max-width: 64rem; }
ul.points { padding-left: 1.2rem; }
ul.points li { margin-bottom: 0.45rem; }

table.t { border-collapse: collapse; width: 100%; font-size: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.t th, table.t td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 0.85rem; background: var(--bg-2); }
table.t tr:last-child td { border-bottom: none; }
table.t td.num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.bar { display: inline-block; height: 0.55rem; border-radius: 4px; vertical-align: middle; margin-right: 0.35rem; }

canvas.view { width: 100%; display: block; background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius); }
.h-road { height: 24rem; }
.h-road-sm { height: 23rem; }
.h-road-cmp { height: 16rem; }
.h-xt { height: 11rem; }
.h-widget { height: 20rem; }
.caption { font-size: 0.9rem; color: var(--muted); margin: 0.35rem 0 0; }

.transport { display: flex; gap: 0.6rem; align-items: center; margin: 0.5rem 0; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-2); }
.transport input[type="range"][data-scrub] { flex: 1; min-width: 8rem; }
.transport [data-time] { font-family: var(--mono); font-size: 0.85rem; color: var(--ink); min-width: 7rem; }
.controls { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin: 0.3rem 0 0.6rem; font-size: 0.85rem; color: var(--ink-2); }
.controls label { display: flex; align-items: center; gap: 0.35rem; }
.controls output { font-family: var(--mono); color: var(--ink); min-width: 2.5rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 0.45rem; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; padding: 0.25rem 0.65rem; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* Colour keys under the figures: big swatches instead of tiny in-chart legends */
.key { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; font-size: 0.9rem; color: var(--ink-2); margin: 0.4rem 0 0; }
.key span { display: inline-flex; align-items: center; gap: 0.4rem; }
.key i { display: inline-block; width: 1.6rem; height: 0.3rem; border-radius: 2px; }
.key i.dash { height: 0; border-top: 0.25rem dashed; background: none !important; }
.key i.box { width: 0.9rem; height: 0.9rem; border-radius: 3px; }

.matrix td, .matrix th { text-align: center !important; }
.matrix td.rowh { text-align: left !important; font-weight: 600; }

.assumption { display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.assumption:last-child { border-bottom: none; }
.assumption .id { font-family: var(--mono); color: var(--accent); font-weight: 650; }
.assumption .risk { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }

.eq-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin: 0.5rem 0; }
.eq-block .katex-display { margin: 0.3rem 0; }
.katex { font-size: 1.1em; }
.map-table td:first-child { font-weight: 600; color: var(--ink); }

/* Background illustrations (scenes.js) */
.scene svg { width: 100%; height: auto; display: block; }
#scene-levels { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem 0.6rem; }
#scene-proximity { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem; }
.design-steps { margin: 0; padding-left: 1.3rem; }
.design-steps li { margin-bottom: 0.3rem; }

/* Figures with callouts: the bubbles are positioned over the canvas by callouts.js */
.fig { position: relative; }
.callout {
    position: absolute; z-index: 3; pointer-events: none;
    background: #fffbea; color: #1f2933; border: 2px solid #e0a82e; border-radius: 0.6rem;
    padding: 0.3rem 0.65rem; font-size: 0.95rem; font-weight: 600; line-height: 1.25;
    box-shadow: 0 6px 18px rgba(31, 41, 51, 0.16);
    width: max-content; max-width: 15rem;
    opacity: 0; transition: opacity 0.25s;
}
.callout.show { opacity: 1; }
.callout::after { content: ""; position: absolute; width: 0; height: 0; border: 0.55rem solid transparent; }
.callout[data-dir="up"] { transform: translate(-50%, calc(-100% - 0.9rem)); }
.callout[data-dir="up"]::after { left: calc(50% - 0.55rem); top: 100%; border-top-color: #e0a82e; }
.callout[data-dir="down"] { transform: translate(-50%, 0.9rem); }
.callout[data-dir="down"]::after { left: calc(50% - 0.55rem); bottom: 100%; border-bottom-color: #e0a82e; }
.callout[data-dir="left"] { transform: translate(calc(-100% - 0.9rem), -50%); }
.callout[data-dir="left"]::after { top: calc(50% - 0.55rem); left: 100%; border-left-color: #e0a82e; }
.callout[data-dir="right"] { transform: translate(0.9rem, -50%); }
.callout[data-dir="right"]::after { top: calc(50% - 0.55rem); right: 100%; border-right-color: #e0a82e; }
.callout.leader::after { display: none; }
.callout.leader[data-dir="left"] { transform: translate(-100%, -50%); }
.callout.leader[data-dir="right"] { transform: translate(0, -50%); }
.callout-line { position: absolute; z-index: 2; height: 0; border-top: 2.5px dashed #e0a82e; transform-origin: 0 0; pointer-events: none; opacity: 0; transition: opacity 0.25s; }
.callout-line.show { opacity: 1; }
.callout-dot {
    position: absolute; z-index: 2; pointer-events: none; width: 1rem; height: 1rem; margin: -0.5rem 0 0 -0.5rem;
    border-radius: 50%; border: 3px solid #e0a82e; opacity: 0; transition: opacity 0.25s;
}
.callout-dot.show { opacity: 1; animation: ping 1.2s ease-out infinite; }
@keyframes ping { 0% { transform: scale(0.6); } 100% { transform: scale(1.8); opacity: 0; } }

/* Loop diagram, in the style of Murray-Smith et al. (2025) Fig. 4 */
.loop svg { width: 100%; height: auto; display: block; background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius); }
.loop text { font-family: "Libertinus Serif", Georgia, "Times New Roman", serif; fill: #1d1d1f; }
.loop .f4-title { font-size: 19px; font-weight: 600; }
.loop .f4-label { font-size: 19px; font-weight: 600; }
.loop .f4-small { font-size: 16.5px; }
.loop .f4-val { font-size: 16px; font-family: var(--mono); fill: #2b6cb0; font-weight: 600; }
.loop .f4-agent { fill: #fdf4ea; stroke: #1d1d1f; stroke-width: 3; }
.loop .f4-driver { fill: #fdf0f6; stroke: #1d1d1f; stroke-width: 3; }
.loop .f4-user { fill: #f5f5fd; stroke: #1d1d1f; stroke-width: 1.6; stroke-dasharray: 6 4; }
.loop .f4-nonaif { fill: #ffffff; stroke: #1d1d1f; stroke-width: 1.4; stroke-dasharray: 2 3; }
.loop .f4-outline { fill: none; stroke: #1d1d1f; stroke-width: 1.4; }
.loop .f4-dashed { fill: #f5f5fd; stroke: #1d1d1f; stroke-width: 1.2; stroke-dasharray: 4 3; }
.loop .f4-sense { fill: #f5b862; stroke: #8a5a1a; stroke-width: 1.2; }
.loop .f4-act { fill: #b4bdf0; stroke: #4a55a0; stroke-width: 1.2; }
.loop .f4-box-sensor { fill: #fffaf2; stroke: #1d1d1f; stroke-width: 1.2; }
.loop .f4-box-internal { fill: #f8f7e2; stroke: #1d1d1f; stroke-width: 1.2; }
.loop .f4-box-action { fill: #e9edfb; stroke: #1d1d1f; stroke-width: 1.2; }
.loop .f4-edge { fill: none; stroke: #1d1d1f; stroke-width: 1.4; transition: stroke 0.2s, stroke-width 0.2s; }
.loop .f4-nonaif-line { stroke: #1d1d1f; stroke-width: 1.4; stroke-dasharray: 2 3; }
.loop .f4-dashed-line { stroke: #1d1d1f; stroke-width: 1.4; stroke-dasharray: 6 4; }
.loop [data-el] { transition: fill 0.2s, stroke 0.2s, stroke-width 0.2s; }
.loop .on.f4-box-sensor, .loop .on.f4-box-internal, .loop .on.f4-box-action, .loop .on.f4-nonaif { fill: #fff3b0; stroke: #d69e2e; stroke-width: 3.5; }
.loop .on.f4-sense, .loop .on.f4-act { stroke: #d69e2e; stroke-width: 4; }
.loop .on.f4-edge { stroke: #d69e2e; stroke-width: 4; }
.loop .on.f4-user { stroke: #d69e2e; stroke-width: 3; }
.stage-text { min-height: 5rem; font-size: 1rem; }
.loop-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1rem; align-items: start; }
.loop .stack { gap: 0.5rem; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; }

.discussion { padding-left: 1.4rem; }
.discussion li { margin-bottom: 0.8rem; }
.discussion li b { color: var(--ink); }
.refs { font-size: 0.8rem; color: var(--ink-2); padding-left: 1.2rem; columns: 2; column-gap: 2rem; }
.refs li { margin-bottom: 0.3rem; break-inside: avoid; }

/* Inferring intent: a big figure and three short steps */
.inv-layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.75fr); }
.h-inv { height: 27rem; }
.steps .card p { margin: 0; }
.steps-card { display: flex; flex-direction: column; gap: 0.55rem; }
.step-row { display: grid; grid-template-columns: 1.9rem 1fr; align-items: start; }
.step-row .step { margin-top: 0.1rem; }
.steps { gap: 0.6rem; }
.steps .card { padding: 0.6rem 0.9rem; }
.steps .katex-display { margin: 0.4rem 0; }
.step { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.85rem; margin-right: 0.4rem; vertical-align: 0.1rem; }

/* Results slide: compact table, highlighted cells, and the RQ panel */
td.hot { background: #fff3b0; }
.readout-big { font-size: 1.3rem; font-weight: 700; color: var(--violet); margin: 0.4rem 0 0; }
#res-table table.t th, #res-table table.t td { padding: 0.2rem 0.6rem; }
.rq-panel { margin-top: 0.7rem; gap: 0.8rem; }
.rq-panel .card { padding: 0.6rem 0.8rem; }
.rq-panel h3 { font-size: 1rem; margin: 0 0 0.3rem; }
.rq-panel p { margin: 0; }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0 0.5rem; border-radius: 999px; margin-right: 0.3rem; }
.tag.good { background: #e3f5ec; color: #1f8a5b; }
.tag.warn { background: #fdf3dc; color: #a2681a; }
.tag.bad { background: #fde8e8; color: #b83232; }

/* Narrow windows (a laptop preview, not the talk): stack the columns */
@media (max-aspect-ratio: 4/3) {
    .grid-2, .grid-3, .grid-2.wide-left, .grid-2.wide-right, .loop-layout { grid-template-columns: minmax(0, 1fr); }
}
