/** theme/tokens.css — sole authority for kt-deck colour and typography.
 *
 * Self-hosted fonts: Inter (body/heading, 2 weights) + JetBrains Mono (code).
 * Modular scale: ratio 1.25 (Major Third), floor at caption (0.8em).
 * No text renders smaller than --kt-caption-size, ever.
 */

/* ── Self-hosted fonts (no Google Fonts, no CDN) ────────────────────────── */

@font-face {
  font-family: 'Inter';
  src: url('../vendor/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../vendor/fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../vendor/fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../vendor/fonts/JetBrainsMono-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Font families & weights ────────────────────────────────────────────── */

:root {
  --kt-font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --kt-font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --kt-weight-regular: 400;
  --kt-weight-bold: 700;

  /* ── Modular scale (ratio 1.25, floor at 0.8em) ────────────────────── */
  --kt-scale-ratio: 1.25;
  --kt-h1-size: 1.953125em;       /* 1.25^3 ≈ 1.953 — slide titles, step headers */
  --kt-h2-size: 1.5625em;         /* 1.25^2 — section headings */
  --kt-h3-size: 1.25em;           /* 1.25^1 — sub-headings, card strongs */
  --kt-body-size: 1em;            /* 1.25^0 — body text (base 30px) */
  --kt-caption-size: 0.8em;       /* 1/1.25 — HARD FLOOR: code, captions, footers, small */
  --kt-code-size: var(--kt-caption-size);  /* code never smaller than caption */

  --kt-base-size: 30px;           /* 1rem = 30px on the 1600×900 stage */
  --kt-small-size: var(--kt-caption-size);
  --kt-footer-size: var(--kt-caption-size);
  --kt-slide-number-size: var(--kt-caption-size);

  /* ── Line height: looser for body, tighter for headings ────────────── */
  --kt-heading-line-height: 1.15;
  --kt-body-line-height: 1.5;
  --kt-line-height: var(--kt-body-line-height);

  --kt-gutter: 3rem;              /* 1600 - 2*3rem*30px = ~1240px ≈ 66 chars @ 30px body */

  --kt-bg: #ffffff;
  --kt-fg: #0c141f;
  --kt-accent: #003366;
  --kt-accent-2: #0078b6;
  --kt-muted: #607080;
  --kt-surface: #f5f8fb;
  --kt-border: #d8e1e8;
  --kt-code-bg: #eef2f5;
  --kt-code-fg: #1d1a19;
  --kt-todo: #fff3cd;
  --kt-todo-fg: #856404;
  --kt-todo-border: #ffda79;

  /* Reveal overrides — tokens.css wins over white.css (loaded last) */
  --r-background-color: var(--kt-bg);
  --r-main-font: var(--kt-font-body);
  --r-main-font-size: var(--kt-base-size);
  --r-main-color: var(--kt-fg);
  --r-heading-font: var(--kt-font-body);
  --r-heading-color: var(--kt-accent);
  --r-heading-text-transform: none;
  --r-heading-font-weight: var(--kt-weight-bold);
  --r-heading-line-height: var(--kt-heading-line-height);
  --r-heading1-size: var(--kt-h1-size);
  --r-heading2-size: var(--kt-h2-size);
  --r-heading3-size: var(--kt-h3-size);
  --r-code-font: var(--kt-font-mono);
  --r-link-color: var(--kt-accent-2);
}

/* ── Base slide box ───────────────────────────────────────────────────── */

.reveal {
  font-family: var(--kt-font-body);
  font-size: var(--kt-base-size);
  font-weight: var(--kt-weight-regular);
  color: var(--kt-fg);
}

.reveal .slides {
  text-align: left;
}

/* ponytail: one shared slide system — single content left edge, no per-slide shifts. */
.reveal .slides section.kt-slide {
  box-sizing: border-box;
  width: 100%;
  height: 900px;
  max-width: none;
  margin: 0;
  padding: 1rem var(--kt-gutter) 2.5rem;
  text-align: left;
  font-family: var(--kt-font-body);
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: var(--kt-body-line-height);
}

.kt-slide {
  box-sizing: border-box;
  max-width: none;
  margin: 0;
  color: var(--kt-fg);
  font-family: var(--kt-font-body);
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: var(--kt-body-line-height);
}

.reveal .slides section.kt-slide > .kt-slide {
  margin: 0;
}

/* ── Typography scale ─────────────────────────────────────────────────── */

.kt-slide h1,
.kt-slide h2,
.kt-slide h3 {
  color: var(--kt-accent);
  font-family: var(--kt-font-body);
  font-weight: var(--kt-weight-bold);
  letter-spacing: -0.015em;
  line-height: var(--kt-heading-line-height);
  text-transform: none;
}

.kt-slide h1 {
  margin: 0 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--kt-accent-2);
  font-size: var(--kt-h1-size);
}

/* Title slide centering: first slide title is centered; all subsequent share left edge */
.reveal .slides > section:first-of-type h1,
.reveal .slides section.kt-title h1 {
  text-align: center;
}

.kt-slide h2 {
  margin: 0.45rem 0 0.25rem;
  font-size: var(--kt-h2-size);
}

.kt-slide h3 {
  margin: 0 0 0.25rem;
  font-size: var(--kt-h3-size);
}

.kt-slide p {
  margin: 0 0 0.4rem;
  line-height: var(--kt-body-line-height);
  text-align: left;
}

.kt-slide strong {
  font-weight: var(--kt-weight-bold);
}

.kt-slide ul,
.kt-slide ol {
  margin: 0.3rem 0 0.7rem 1.1rem;
  line-height: var(--kt-body-line-height);
}

.kt-slide li {
  margin-bottom: 0.25rem;
  padding-left: 0.15rem;
  text-align: left;
}

.kt-slide span.fragment:not(.kt-muted) {
  display: block;
  margin: 0.18rem 0;
  text-align: left;
}

/* ── Code (monospace) ─────────────────────────────────────────────────── */

.kt-slide pre {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0.4rem 0 0.6rem;
  padding: 0.5rem 0.65rem;
  overflow-x: auto;
  background: var(--kt-code-bg);
  border: 0;
  border-left: 3px solid var(--kt-accent);
  border-radius: 4px;
  box-shadow: none;
  color: var(--kt-code-fg);
  font-family: var(--kt-font-mono);
  font-size: var(--kt-code-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.35;
  text-align: left;
}

.kt-slide code {
  padding: 0.08em 0.24em;
  background: var(--kt-code-bg);
  border: 0;
  border-radius: 3px;
  color: var(--kt-code-fg);
  font-family: var(--kt-font-mono);
  font-size: var(--kt-code-size);
  font-weight: var(--kt-weight-regular);
}

.kt-slide pre code {
  padding: 0;
  background: transparent;
  font-size: inherit;
}

/* ── Tables ───────────────────────────────────────────────────────────── */

.kt-slide table.kt-table {
  width: 100%;
  margin: 0.3rem 0 0.45rem;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 3px solid var(--kt-accent-2);
  border-bottom: 1px solid var(--kt-border);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.25;
  text-align: left;
}

.reveal table.kt-table th,
.reveal table.kt-table td {
  padding: 0.22rem 0.4rem;
  border: 0;
  border-bottom: 1px solid var(--kt-border);
  text-align: left;
  vertical-align: top;
}

.reveal table.kt-table th {
  background: var(--kt-bg);
  color: var(--kt-fg);
  font-weight: var(--kt-weight-bold);
}

.reveal table.kt-table tr:nth-child(even) td {
  background: var(--kt-surface);
}

/* Numeric columns: right-aligned with tabular-nums.
 * ponytail: add class="kt-num" to <th> and <td> cells in numeric columns. */
.kt-slide table.kt-table .kt-num,
.reveal table.kt-table .kt-num,
.kt-slide table.kt-table th.kt-num,
.reveal table.kt-table th.kt-num,
.kt-slide table.kt-table td.kt-num,
.reveal table.kt-table td.kt-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Utility text classes ─────────────────────────────────────────────── */

.kt-small {
  font-size: var(--kt-caption-size);
  line-height: var(--kt-body-line-height);
}

.kt-muted {
  color: var(--kt-muted);
}

.kt-todo {
  box-sizing: border-box;
  margin: 0.3rem 0;
  padding: 0.35rem 0.5rem;
  background: var(--kt-todo);
  border-left: 5px solid var(--kt-todo-border);
  border-radius: 0 4px 4px 0;
  color: var(--kt-todo-fg);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-bold);
  line-height: 1.3;
}

/* ── Slide number & controls ──────────────────────────────────────────── */

.reveal .slide-number {
  right: auto;
  bottom: 17px;
  left: 18px;
  width: 32px;
  padding: 0;
  background: transparent;
  color: var(--kt-muted);
  font-family: var(--kt-font-body);
  font-size: var(--kt-slide-number-size);
  font-weight: var(--kt-weight-bold);
  line-height: 1.1;
  text-align: center;
}

.reveal .controls {
  color: var(--kt-accent-2);
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.reveal .slides section.kt-slide .kt-footer {
  position: absolute;
  right: calc(var(--kt-gutter) + 4rem);
  bottom: 0.75rem;
  left: var(--kt-gutter);
  margin: 0;
  padding-top: 0.3rem;
  border-top: 1px solid var(--kt-border);
  background: var(--kt-bg);
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.2;
  text-align: right;
}

/* ── Key hint (navigation hint) ────────────────────────────────────────── */

.kt-keyhint {
  position: absolute;
  right: calc(var(--kt-gutter) + 4rem);
  bottom: 3.2rem;
  left: var(--kt-gutter);
  margin: 0;
  color: var(--kt-muted);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.3;
  text-align: right;
}

.kt-keyhint kbd {
  padding: 0.04em 0.34em;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  font-family: var(--kt-font-mono);
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-bold);
}

/* ── Interaction cue ──────────────────────────────────────────────────── */

.kt-interaction-cue {
  margin-bottom: 0.4rem;
  color: var(--kt-accent);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-bold);
  line-height: 1.3;
  text-align: left;
}

/* ── Layout: cards & grids ────────────────────────────────────────────── */

.kt-flex,
.kt-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.6rem;
  align-items: stretch;
  margin: 0.25rem 0 0.5rem;
}

.kt-flex > div,
.kt-split > div {
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-left: 4px solid var(--kt-accent-2);
  border-radius: 6px;
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.3;
  text-align: left;
}

.kt-host-list {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 0.16rem 0.45rem;
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
}

.kt-host-list code {
  font-size: var(--kt-code-size);
}

/* ── Diagrams & thumbnails ───────────────────────────────────────────── */

/* ponytail: .reveal prefix needed to beat white.css `.reveal img{max-height:95%}`. */
.reveal .kt-diagram {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 240px;
  margin: 0;
  object-fit: contain;
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  box-shadow: none;
}

.kt-architecture {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
  align-items: stretch;
  margin-top: 0.3rem;
}

.kt-architecture figure {
  margin: 0;
}

.reveal .kt-architecture figure img {
  display: block;
  width: 100%;
  max-height: 600px;
  margin: 0;
  object-fit: contain;
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  box-shadow: none;
}

.kt-architecture figcaption {
  margin-top: 0.25rem;
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.3;
}

.kt-architecture-facts {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 0.65rem;
}

.kt-architecture-facts > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.65rem 0.75rem;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-left: 4px solid var(--kt-accent-2);
  border-radius: 6px;
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.3;
}

.kt-architecture-facts strong {
  color: var(--kt-accent);
  font-weight: var(--kt-weight-bold);
}

.kt-figure {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.55rem;
}

.reveal .kt-thumbnail {
  display: block;
  width: 38%;
  max-height: 180px;
  margin: 0;
  object-fit: contain;
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  box-shadow: none;
}

.kt-caption {
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.3;
}

/* ── Vertical (nested) slides ─────────────────────────────────────────── */

.reveal .slides section.kt-slide > section {
  box-sizing: border-box;
  width: 100%;
  height: 900px;
  padding: 1.25rem var(--kt-gutter) 2.8rem;
}

/* ── Assurance strip ──────────────────────────────────────────────────── */

.kt-assurance-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin: 0.1rem 0 0.45rem;
}

.kt-assurance-strip > div {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.32rem 0.5rem;
  background: var(--kt-surface);
  border-top: 3px solid var(--kt-accent-2);
}

.kt-assurance-strip span {
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
}

.kt-assurance-strip strong {
  color: var(--kt-accent);
  font-size: var(--kt-h2-size);
  font-weight: var(--kt-weight-bold);
  line-height: 1.05;
}

/* ── Failure walkthrough ──────────────────────────────────────────────── */

.kt-failure-sequence {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.kt-failure-hero {
  margin-top: 0.6rem;
}

.kt-failure-hero figure {
  margin: 0;
}

.reveal .kt-failure-hero img {
  display: block;
  width: 62%;
  max-width: 62%;
  max-height: 470px;
  margin: 0;
  object-fit: contain;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-radius: 6px;
  box-shadow: none;
}

.kt-failure-hero figcaption {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  max-width: 62%;
  margin-top: 0.4rem;
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.25;
}

.kt-failure-hero figcaption strong {
  color: var(--kt-accent);
  font-size: var(--kt-h2-size);
  font-weight: var(--kt-weight-bold);
}

.kt-failure-hero figcaption span {
  color: var(--kt-muted);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
}

.kt-failure-frame {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: var(--kt-bg);
  border: 1px solid var(--kt-border);
  border-radius: 6px;
}

.reveal .kt-failure-frame img {
  display: block;
  width: 100%;
  height: 185px;
  margin: 0;
  object-fit: contain;
  background: var(--kt-surface);
  border: 0;
  border-bottom: 1px solid var(--kt-border);
  box-shadow: none;
}

.kt-failure-frame figcaption {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.35rem 0.45rem 0.42rem;
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.25;
}

.kt-failure-frame figcaption strong {
  color: var(--kt-accent);
  font-weight: var(--kt-weight-bold);
}

.kt-failure-frame figcaption span {
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
}

.kt-failure-note {
  padding: 0.32rem 0.5rem;
  background: var(--kt-todo);
  border-left: 5px solid var(--kt-todo-border);
  color: var(--kt-todo-fg);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-bold);
  line-height: 1.25;
}

/* ── Step headers (vertical walkthrough) ─────────────────────────────── */

.kt-step-head {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--kt-accent-2);
}

.kt-step-head strong {
  color: var(--kt-accent);
  font-size: var(--kt-h1-size);
  font-weight: var(--kt-weight-bold);
}

.kt-step-head span {
  color: var(--kt-muted);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
}

.kt-step-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.kt-step-body > div {
  box-sizing: border-box;
  min-width: 0;
  padding: 0.8rem 1rem;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-left: 4px solid var(--kt-accent-2);
  border-radius: 6px;
  font-size: var(--kt-body-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.4;
}

.kt-step-body pre {
  width: 100%;
  margin: 0.45rem 0 0;
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
}

/* ── Placement stack ──────────────────────────────────────────────────── */

.kt-placement-stack {
  display: grid;
  grid-template-rows: 1fr 1fr auto;
  gap: 0.45rem;
  height: 720px;
}

.kt-placement-stack figure {
  min-width: 0;
  margin: 0;
}

.kt-placement-stack figcaption {
  margin-bottom: 0.2rem;
  color: var(--kt-muted);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.2;
}

.kt-placement-stack figcaption strong {
  color: var(--kt-fg);
  font-weight: var(--kt-weight-bold);
}

.reveal .kt-placement-dev img {
  display: block;
  width: 100%;
  max-height: 225px;
  margin: 0;
  object-fit: contain;
  object-position: top center;
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  box-shadow: none;
}

.kt-placement-prod {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}

.reveal .kt-placement-prod img {
  display: block;
  width: 100%;
  max-height: 315px;
  margin: 0;
  object-fit: contain;
  object-position: top center;
  border: 1px solid var(--kt-border);
  border-radius: 4px;
  box-shadow: none;
}

.kt-placement-rule {
  padding: 0.35rem 0.55rem;
  background: var(--kt-surface);
  border-left: 4px solid var(--kt-accent-2);
  font-size: var(--kt-caption-size);
  font-weight: var(--kt-weight-regular);
  line-height: 1.25;
}

/* ── Evidence crops ──────────────────────────────────────────────────── */

.kt-evidence {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 0.8rem;
  align-items: start;
  margin-top: 0.5rem;
}

.kt-evidence figure {
  margin: 0;
}

.reveal .kt-evidence img {
  display: block;
  width: 100%;
  max-height: 430px;
  margin: 0;
  object-fit: contain;
  object-position: top;
  background: var(--kt-surface);
  border: 1px solid var(--kt-border);
  border-radius: 6px;
  box-shadow: none;
}

.kt-evidence figcaption {
  margin-top: 0.25rem;
  color: var(--kt-muted);
  font-size: var(--kt-footer-size);
  font-weight: var(--kt-weight-regular);
}

.kt-evidence-read > * {
  margin: 0 0 0.4rem;
}

/* ── Print ────────────────────────────────────────────────────────────── */

@media print {
  .kt-flex,
  .kt-split,
  .kt-table,
  .kt-todo,
  .kt-evidence,
  .kt-step-body {
    break-inside: avoid;
  }
}
