/* Cartopolis brand: slate blue, accent orange, amber, cream (the app's theme). */
:root {
  --slate-0: #141e24;
  --slate-1: #1b2830;
  --slate-2: #2e424e;
  --slate-3: #4a6170;
  --orange: #fd6012;
  --amber: #fd9212;
  --cream: #f2efea;
  --muted: #b9c3c9;
  --pad: clamp(1.25rem, 4vw, 4rem);
  --fs: clamp(15px, 1.3vw + 0.6vh, 30px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--slate-0);
  color: var(--cream);
  font: 400 var(--fs)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#deck { position: relative; height: 100%; }

.slide {
  position: absolute;
  inset: 0;
  padding: var(--pad) var(--pad) calc(var(--pad) + 2.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: radial-gradient(120% 120% at 100% 0%, var(--slate-2) 0%, var(--slate-1) 45%, var(--slate-0) 100%);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateX(2%);
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.slide.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .35s ease, transform .35s ease;
}
.slide.before { transform: translateX(-2%); }
.slide > * { max-width: 72rem; width: 100%; margin-left: auto; margin-right: auto; }

/* ── type ── */
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.12; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 4.2em; }
h2 { font-size: 2.15em; }
h3 { font-size: 1.1em; color: var(--amber); }
p { margin: 0 0 .8em; }
em { font-style: normal; color: var(--orange); }
b { color: #fff; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--amber); }
a { color: var(--amber); }
.kicker {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72em;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: .9em;
}
.lede { font-size: 1.45em; color: var(--muted); }
.lede-sm { font-size: 1.15em; color: var(--muted); }
.small { font-size: .8em; color: var(--muted); }
.aside { margin-top: 1.2em; color: var(--muted); }

blockquote {
  margin: 1em 0;
  padding: .2em 0 .2em 1em;
  border-left: 3px solid var(--orange);
  color: var(--cream);
  font-style: italic;
}
blockquote cite { display: block; margin-top: .4em; font-style: normal; color: var(--muted); font-size: .9em; }

/* ── lists ── */
ul, ol { margin: 0; padding-left: 1.2em; }
li { margin: .35em 0; }
.facts { list-style: none; padding: 0; }
.facts li { position: relative; padding-left: 1.3em; margin: .7em 0; }
.facts li::before { content: ""; position: absolute; left: 0; top: .55em; width: .55em; height: .55em; border-radius: 50%; background: var(--orange); }
.facts.tight li { margin: .45em 0; }
.big li { margin: .8em 0; padding-left: .3em; }
.big li::marker, .rules li::marker { color: var(--orange); font-weight: 700; }
.rules li { margin: .75em 0; padding-left: .3em; font-size: 1.05em; }

/* ── layouts ── */
.cols { display: grid; gap: 1.4em; margin-top: .6em; }
.cols.two { grid-template-columns: repeat(2, 1fr); }
.cols.three { grid-template-columns: repeat(3, 1fr); }
.split > * { max-width: none; }
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2.5em; align-items: center; align-content: center; }
.split > .kicker { grid-column: 1 / -1; }

.card {
  background: rgba(46, 66, 78, .55);
  border: 1px solid rgba(242, 239, 234, .08);
  border-radius: 14px;
  padding: 1.1em 1.3em;
}
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

figure { margin: 0; }
figure img {
  width: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
figcaption { margin-top: .6em; font-size: .75em; color: var(--muted); }

/* ── cover & part slides ── */
.cover, .part {
  background:
    linear-gradient(90deg, rgba(20, 30, 36, .92) 0%, rgba(20, 30, 36, .55) 55%, rgba(20, 30, 36, .15) 100%),
    var(--bg, none) center / cover no-repeat,
    var(--slate-1);
}
.cover .cover-text { max-width: 72rem; }
.cover h1 { color: #fff; }
.cover .by { margin-top: 2em; color: var(--muted); }
.cover .links { margin-top: 1.5em; font-size: 1.1em; line-height: 1.8; }
.part h2 { font-size: 5em; color: #fff; }
.part:not([style]) { background: linear-gradient(135deg, var(--slate-2), var(--slate-0)); }

/* ── timeline ── */
.timeline { list-style: none; padding: 0; margin-top: .4em; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6.4em; top: .4em; bottom: .4em; width: 2px; background: var(--slate-3); }
.timeline li {
  display: grid;
  grid-template-columns: 5.6em 1.6em 14em 1fr;
  align-items: baseline;
  margin: .32em 0;
}
.timeline li::before {
  content: "";
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  width: .7em; height: .7em;
  border-radius: 50%;
  background: var(--slate-1);
  border: 2px solid var(--amber);
}
.timeline .when { grid-column: 1; grid-row: 1; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9em; }
.timeline b { grid-column: 3; grid-row: 1; }
.timeline span:last-child { grid-column: 4; grid-row: 1; color: var(--muted); }
.timeline .now::before { background: var(--orange); border-color: var(--orange); box-shadow: 0 0 0 5px rgba(253, 96, 18, .25); }
.timeline .now b { color: var(--orange); }
.timeline .origin::before { background: var(--amber); }
.timeline .origin b { color: var(--amber); }
.timeline .origin { margin-bottom: .8em; }

/* ── threads table ── */
.threads { width: 100%; border-collapse: collapse; font-size: .9em; }
.threads th { text-align: left; color: var(--orange); font-size: .8em; text-transform: uppercase; letter-spacing: .1em; padding: .4em .6em; border-bottom: 2px solid var(--slate-3); }
.threads td { padding: .55em .6em; border-bottom: 1px solid rgba(242, 239, 234, .08); vertical-align: top; }
.threads td:first-child { font-weight: 700; color: #fff; }
.threads td:nth-child(2) { color: var(--muted); }

/* ── architecture ── */
.arch {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "client link sim"
    "data   data atlas";
  gap: 1em 1.2em;
  align-items: stretch;
  margin-top: .4em;
}
.arch .box { border-radius: 14px; padding: .9em 1.1em; background: rgba(46, 66, 78, .6); border: 1px solid rgba(242, 239, 234, .1); }
.arch .box p { margin: 0 0 .3em; }
.arch .client { grid-area: client; border-top: 4px solid var(--orange); }
.arch .sim { grid-area: sim; border-top: 4px solid var(--amber); }
.arch .atlas { grid-area: atlas; border-top: 4px solid var(--cream); }
.arch .data { grid-area: data; border-top: 4px solid var(--slate-3); }
.arch .link { grid-area: link; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 2em; color: var(--orange); }
.arch .link span { font-size: .32em; color: var(--muted); text-align: center; line-height: 1.3; }

/* ── stats & chart ── */
.stat { font-size: 1.1em; margin: 0 0 .2em; color: var(--muted); }
.stat b { font-size: 2.2em; color: var(--orange); margin-right: .2em; font-variant-numeric: tabular-nums; }
.stat + p:not(.stat) { margin-top: 1em; }

.chart .bars {
  --max: 692;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: .35em;
  height: 13em;
  padding-top: 1.4em;
  border-bottom: 1px solid var(--slate-3);
}
.chart .bars div {
  position: relative;
  height: calc(var(--v) / var(--max) * 100%);
  min-height: 2px;
  background: var(--orange);
  border-radius: 4px 4px 0 0;
}
.chart .bars div::before {
  content: attr(data-n);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: .2em;
  font-size: .6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart .bars div::after {
  content: attr(data-m);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: .35em;
  font-size: .6em;
  color: var(--muted);
}
.chart figcaption { margin-top: 2em; }

/* ── speaker notes (press N) ── */
.notes { display: none; }
body.show-notes .slide.active .notes {
  display: block;
  margin-top: 1.5em;
  padding: .8em 1em;
  border-radius: 10px;
  background: rgba(253, 146, 18, .12);
  border: 1px dashed var(--amber);
  font-size: .8em;
  color: var(--cream);
}
.split .notes { grid-column: 1 / -1; }

/* ── navigation chrome ── */
#hud {
  position: fixed;
  right: 1rem;
  bottom: .9rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 14px;
  color: var(--muted);
  z-index: 10;
}
#hud button {
  width: 2.4rem; height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(242, 239, 234, .2);
  background: rgba(27, 40, 48, .7);
  color: var(--cream);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
#hud button:hover { border-color: var(--orange); color: var(--orange); }
#count { font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: center; }
#progress { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(242, 239, 234, .08); z-index: 10; }
#progress div { height: 100%; width: 0; background: var(--orange); transition: width .3s ease; }

/* ── narrow screens: stack everything ── */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .slide { justify-content: flex-start; padding-top: calc(var(--pad) + 1rem); }
  h1 { font-size: 3em; }
  h2 { font-size: 1.6em; }
  .part h2 { font-size: 3.2em; }
  .split, .cols.two, .cols.three { grid-template-columns: 1fr; gap: 1.2em; }
  .split { align-content: start; }
  .arch .link span { font-size: .5em; }
  .timeline::before { left: 4.9em; }
  .timeline li { grid-template-columns: 4.3em 1.4em 1fr; }
  .timeline span:last-child { grid-column: 3; grid-row: 2; font-size: .85em; }
  .threads thead { display: none; }
  .threads tr { display: block; padding: .5em 0; border-bottom: 1px solid rgba(242, 239, 234, .12); }
  .threads td { display: block; border: 0; padding: .1em 0; }
  .threads td:nth-child(2)::before { content: "Tried in: "; }
  .threads td:nth-child(3)::before { content: "Now: "; color: var(--orange); }
  .arch { grid-template-columns: 1fr; grid-template-areas: "client" "link" "sim" "atlas" "data"; }
  .arch .link { flex-direction: row; gap: .4em; font-size: 1.4em; }
  .chart .bars { height: 9em; }
  .cover, .part { background:
      linear-gradient(180deg, rgba(20, 30, 36, .55) 0%, rgba(20, 30, 36, .92) 70%),
      var(--bg, none) center / cover no-repeat,
      var(--slate-1); justify-content: flex-end; }
}

/* ── print / PDF: one slide per page ── */
@media print {
  @page { size: 16in 9in; margin: 0; }
  html, body { overflow: visible; height: auto; background: var(--slate-0); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #deck { height: auto; }
  .slide { position: relative; inset: auto; height: 9in; opacity: 1; visibility: visible; transform: none; page-break-after: always; break-after: page; overflow: hidden; }
  #hud, #progress, .notes { display: none !important; }
}

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