:root {
    --bg: #0d1117;
    --bg-2: #161b22;
    --bg-3: #1f2630;
    --fg: #e6edf3;
    --muted: #9aa7b4;
    --line: #2b3440;
    --accent: #f6821f; /* Cloudflare orange */
    --accent-2: #fbad41;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --info: #58a6ff;
    --code-bg: #0a0e14;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme='light'] {
    --bg: #f7f8fa;
    --bg-2: #ffffff;
    --bg-3: #eef1f5;
    --fg: #14181f;
    --muted: #566272;
    --line: #d5dbe3;
    --code-bg: #f1f3f6;
    --shadow: 0 10px 30px rgba(20, 24, 31, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-size: clamp(14px, min(1.35vw, 2.4vh), 22px); /* scales with the smaller screen dimension so wide-but-short windows still fit */
    line-height: 1.5;
    overflow: hidden;
}

/* ---------- chrome ---------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: 44px; z-index: 20;
    display: flex; align-items: center; gap: 12px; padding: 0 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand b { color: var(--accent); }
.brand img { display: inline-block; vertical-align: -5px; margin-right: 8px; }
.crumb { color: var(--muted); font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.btn {
    background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
    padding: 4px 10px; font: inherit; font-size: 0.8em; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn[aria-pressed='true'] { background: var(--accent); color: #111; border-color: var(--accent); }
.progress { position: fixed; top: 44px; left: 0; height: 3px; background: var(--accent); width: 0; z-index: 21; transition: width 0.25s; }
.counter { position: fixed; right: 16px; bottom: 12px; z-index: 20; color: var(--muted); font-size: 0.8em; font-variant-numeric: tabular-nums; }
.nav { position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; gap: 8px; }

/* ---------- slides ---------- */
.deck { position: fixed; inset: 47px 0 0 0; }
.slide {
    --content-max: 1400px;
    --gutter: clamp(22px, 6vw, 110px);
    position: absolute; inset: 0; display: none; flex-direction: column; justify-content: center;
    /* The side padding centers one shared content column; children need no margin tricks,
       so every block (cards, callouts, tables, leads) keeps the same left and right edge. */
    padding: clamp(18px, 3.2vw, 56px) max(var(--gutter), calc((100% - var(--content-max)) / 2)) 54px;
    overflow-y: auto;
}
.slide.active { display: flex; animation: in 0.28s ease; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 2.5em; line-height: 1.1; margin: 0 0 0.3em; letter-spacing: -0.02em; }
h2 { font-size: 1.75em; line-height: 1.15; margin: 0 0 0.45em; letter-spacing: -0.01em; }
h2 .tag { font-size: 0.45em; vertical-align: middle; margin-left: 10px; }
h3 { font-size: 1.05em; margin: 0 0 0.35em; color: var(--accent-2); }
p { margin: 0.4em 0; }
.lead { font-size: 1.15em; color: var(--muted); max-width: 60ch; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72em; font-weight: 700; margin-bottom: 0.6em; }
.muted { color: var(--muted); }
small, .small { font-size: 0.8em; }
a { color: var(--info); }
ul, ol { margin: 0.3em 0; padding-left: 1.2em; }
li { margin: 0.22em 0; }
li::marker { color: var(--accent); }
code, kbd { font-family: var(--mono); font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.05em 0.4em; }
kbd { border-bottom-width: 2px; }
pre {
    background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
    font-family: var(--mono); font-size: 0.78em; line-height: 1.45; overflow-x: auto; margin: 0.5em 0;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; }

.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.card.accent { border-color: var(--accent); }
.grid > * { min-width: 0; } /* let grid items shrink; long code lines scroll inside <pre> instead of widening the page */
.card h3 { margin-top: 0; }
.stat { text-align: center; }
.stat .n { font-size: 2.3em; font-weight: 800; color: var(--accent); line-height: 1; }
.stat .l { color: var(--muted); font-size: 0.8em; margin-top: 4px; }

.tag, .pill {
    display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.72em; font-weight: 700; border: 1px solid var(--line);
    background: var(--bg-3); color: var(--muted); white-space: nowrap;
}
.pill.ok, .tag.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn, .tag.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad, .tag.bad { color: var(--bad); border-color: var(--bad); }
.pill.info, .tag.info { color: var(--info); border-color: var(--info); }
.pill.hot, .tag.hot { color: #111; background: var(--accent); border-color: var(--accent); }

table { border-collapse: collapse; width: 100%; font-size: 0.85em; background: var(--bg-2); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-3); color: var(--muted); font-weight: 700; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: 0; }

.callout { border-left: 4px solid var(--accent); background: var(--bg-2); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 0.6em 0; }
.callout.bad { border-color: var(--bad); }
.callout.ok { border-color: var(--ok); }
.callout.info { border-color: var(--info); }
.callout b:first-child { color: var(--accent-2); }

/* ---------- title ---------- */
.slide.title { align-items: flex-start; }
.slide.title h1 { font-size: 3.2em; }
.slide.title h1 span { color: var(--accent); }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 1.2em; }

/* ---------- steps / timeline ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 8px; }
.steps li {
    counter-increment: s; position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 8px 12px 8px 52px; margin: 0;
}
.steps li::before {
    content: counter(s); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #111; font-weight: 800;
    display: grid; place-items: center; font-size: 0.85em;
}
.steps.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- diagrams ---------- */
.diagram { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.diagram svg { width: 100%; height: auto; max-height: 58vh; display: block; } /* keeps the diagram inside short windows */
.diagram text { font-family: var(--sans); fill: var(--fg); font-size: 13px; }
.diagram .sm { font-size: 11px; fill: var(--muted); }
.diagram .box { fill: var(--bg-3); stroke: var(--line); stroke-width: 1.2; }
.diagram .cf { fill: color-mix(in srgb, var(--accent) 16%, var(--bg-3)); stroke: var(--accent); stroke-width: 1.4; }
.diagram .host { fill: transparent; stroke: var(--line); stroke-dasharray: 5 4; stroke-width: 1.2; }
.diagram .ok { fill: color-mix(in srgb, var(--ok) 14%, var(--bg-3)); stroke: var(--ok); stroke-width: 1.2; }
.diagram .ai { fill: color-mix(in srgb, var(--info) 14%, var(--bg-3)); stroke: var(--info); stroke-width: 1.2; }
.diagram .arrow { stroke: var(--muted); stroke-width: 1.6; fill: none; marker-end: url(#ah); }
.diagram .arrow.hot { stroke: var(--accent); stroke-width: 2; marker-end: url(#ah-hot); }
.diagram .arrow.dash { stroke-dasharray: 5 4; }
.diagram .lbl { font-size: 11px; fill: var(--accent-2); }
.diagram .title-t { font-weight: 700; font-size: 13px; }

.seq { display: grid; gap: 6px; font-size: 0.86em; }
.seq .row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: baseline; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.seq .who { color: var(--accent-2); font-weight: 700; }

.layers { display: grid; gap: 6px; }
.layer { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 0.88em; }
.layer .num { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--accent); color: var(--accent); display: grid; place-items: center; font-weight: 800; }

/* ---------- notes ---------- */
.notes { display: none; margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; color: var(--muted); font-size: 0.85em; }
body.show-notes .notes { display: block; }
body.show-notes .notes::before { content: 'Speaker notes'; display: block; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8em; margin-bottom: 4px; }

/* ---------- overview mode ---------- */
body.overview { overflow: auto; }
body.overview .deck { position: static; padding: 60px 18px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
body.overview .slide {
    position: relative; display: flex; inset: auto; height: 220px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px;
    background: var(--bg-2); padding: 14px; cursor: pointer; font-size: 9px; justify-content: flex-start; animation: none;
}
body.overview .slide.active { border-color: var(--accent); }
body.overview .slide .notes { display: none !important; }
body.overview .progress, body.overview .counter, body.overview .nav { display: none; }

@media (prefers-reduced-motion: reduce) { .slide.active { animation: none; } .progress { transition: none; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .cols-2, .cols-3, .cols-4, .steps.two { grid-template-columns: 1fr; }
    table { display: block; overflow-x: auto; }
    .seq .row { grid-template-columns: 1fr; gap: 2px; }
    .layer { grid-template-columns: 38px 1fr; }
    .layer .pill { display: none; }
    h1 { font-size: 1.9em; }
    .slide.title h1 { font-size: 2.2em; }
    .crumb { display: none; }
}

/* ---------- print / PDF: one slide per page ---------- */
@media print {
    :root { --bg: #fff; --bg-2: #fff; --bg-3: #f1f3f6; --fg: #111; --muted: #444; --line: #bbb; --code-bg: #f4f4f4; --shadow: none; }
    body { overflow: visible; font-size: 11pt; }
    .topbar, .progress, .counter, .nav { display: none !important; }
    .deck { position: static; }
    .slide { position: relative; display: flex !important; inset: auto; min-height: 100vh; page-break-after: always; break-after: page; animation: none; overflow: visible; padding: 24px 40px; }
    .notes { display: block !important; }
    .card { box-shadow: none; }
}
