:root {
  --bg: #0b0b0c;
  --panel: #17181a;
  --panel-2: #202124;
  --line: #2d2e31;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --faint: #5f6368;
  --blue: #4285f4;
  --red: #ea4335;
  --yellow: #fbbc04;
  --green: #34a853;
  --hud: 52px;
  --notes-w: 25rem;
  --pad: 1.75rem;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- progress */
#progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: #1b1c1e;
  z-index: 40;
}
#progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue) 0%, var(--red) 33%, var(--yellow) 66%, var(--green) 100%);
  background-size: 100vw 100%;
  transition: width .22s cubic-bezier(.4, 0, .2, 1);
}

/* ------------------------------------------------------------------- stage */
#stage {
  position: fixed;
  inset: 3px 0 var(--hud) 0;
  display: grid;
  place-items: center;
  padding: var(--pad);
  transition: right .28s cubic-bezier(.4, 0, .2, 1);
}
body.notes-open #stage { right: var(--notes-w); }

#frame {
  position: relative;
  width: 100%;
  max-width: calc((100vh - 3px - var(--hud) - var(--pad) * 2) * 16 / 9);
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
}
body.notes-open #frame {
  max-width: calc((100vh - 3px - var(--hud) - var(--pad) * 2) * 16 / 9);
}
#slide-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
#fallback[hidden] { display: none; }

/* three dots, only while a page is actually being rasterised */
#loading {
  position: absolute;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  display: none;
  gap: .35rem;
}
#frame.busy #loading { display: flex; }
#loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bdc1c6;
  animation: pulse 1s infinite ease-in-out;
}
#loading span:nth-child(2) { animation-delay: .15s; }
#loading span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------- edge nav */
.edge {
  position: fixed;
  top: 3px;
  bottom: var(--hud);
  width: clamp(64px, 12vw, 150px);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .18s, background .18s;
  z-index: 20;
  padding: 0;
}
.edge svg { width: 34px; height: 34px; }
.edge-prev { left: 0; }
.edge-next { right: 0; }
body.notes-open .edge-next { right: var(--notes-w); }
.edge:hover, .edge:focus-visible {
  opacity: 1;
  background: linear-gradient(90deg, rgba(0, 0, 0, .45), transparent);
  outline: none;
}
.edge-next:hover, .edge-next:focus-visible {
  background: linear-gradient(270deg, rgba(0, 0, 0, .45), transparent);
}
.edge[disabled] { opacity: 0 !important; cursor: default; pointer-events: none; }
body.overview-open .edge { display: none; }

/* ---------------------------------------------------------------- the HUD */
#hud {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--hud);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  z-index: 30;
}

#badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .01em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: help;
}
#badge .dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 168, 83, .18);
}

#tools { display: flex; align-items: center; gap: .25rem; }
.tool {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.tool svg { width: 18px; height: 18px; fill: currentColor; }
.tool svg [fill="none"] { fill: none; }
.tool:hover, .tool:focus-visible { background: var(--panel-2); color: var(--text); outline: none; }
.tool[aria-pressed="true"] { background: var(--panel-2); color: var(--yellow); }

#counter {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#counter-now { color: var(--text); }
#counter .sep { margin: 0 .35em; color: var(--faint); }

/* ------------------------------------------------------------ notes panel */
#notes {
  position: fixed;
  top: 3px;
  right: 0;
  bottom: var(--hud);
  width: var(--notes-w);
  background: var(--panel);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  z-index: 25;
}
body.notes-open #notes { transform: none; }
#notes header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--line);
}
#notes h2 { margin: 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
#notes-body { padding: 1.1rem 1.25rem 2rem; overflow-y: auto; }
#notes-body h3 { margin: 0 0 .85rem; font-size: 15.5px; line-height: 1.35; color: var(--text); }
#notes-body p { margin: 0 0 .85rem; font-size: 13.5px; line-height: 1.65; color: #c8cbd0; }
#notes-body .empty { color: var(--faint); font-style: italic; }

.close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 .25rem;
  border-radius: 6px;
}
.close:hover, .close:focus-visible { color: var(--text); outline: none; }

/* ---------------------------------------------------------------- overview */
#overview {
  position: fixed;
  inset: 3px 0 var(--hud) 0;
  background: var(--bg);
  z-index: 35;
  display: flex;
  flex-direction: column;
}
#overview[hidden] { display: none; }
#overview header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
#overview h2 { margin: 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
#overview-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
  padding: 1.5rem;
  align-content: start;
}
.thumb {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}
.thumb-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 7px;
  background: #e8eaed;
  border: 2px solid transparent;
  opacity: .35;
  transition: border-color .15s, transform .15s, opacity .25s;
}
.thumb-canvas.ready { opacity: 1; }
.thumb:hover .thumb-canvas, .thumb:focus-visible .thumb-canvas { border-color: var(--blue); transform: translateY(-2px); }
.thumb.current .thumb-canvas { border-color: var(--yellow); }
.thumb figcaption, .thumb .cap {
  display: flex;
  gap: .5rem;
  margin-top: .45rem;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.thumb .num { color: var(--faint); font-family: var(--mono); flex: none; }
.thumb:focus-visible { outline: none; }

/* -------------------------------------------------------------------- help */
#help {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1.5rem;
}
#help[hidden] { display: none; }
#help .sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  width: min(30rem, 100%);
}
#help h2 { margin: 0 0 1rem; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1.25rem; margin: 0 0 1.1rem; align-items: baseline; }
#help dt { white-space: nowrap; }
#help dd { margin: 0; font-size: 14px; color: #c8cbd0; }
kbd {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: .15em .45em;
  color: var(--text);
}
#help .hint { font-size: 12.5px; color: var(--faint); line-height: 1.6; margin: 0 0 1.1rem; }
.close-wide {
  width: 100%;
  padding: .6rem;
  border: 0;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.close-wide:hover { background: #2a2b2e; }

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  padding: 1rem;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  text-align: center;
  z-index: 60;
}
.noscript a { color: #fff; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 820px) {
  :root { --pad: .75rem; --notes-w: 100%; }
  #tools { gap: 0; }
  #badge { max-width: 46vw; font-size: 10.5px; }
  .edge { opacity: .5; width: 56px; }
  .edge svg { width: 26px; height: 26px; }
  body.notes-open #stage { right: 0; }
  body.notes-open .edge-next { right: 0; }
  #overview-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; padding: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
