/* Slidyo design engine: stage, player chrome, highlight and pointer.
   Themes only style the slide content (inside .slide); everything here is shared. */

:root {
  --stage-w: 1920px;
  --stage-h: 1080px;
  --chrome-bg: #0e0d13;
  --chrome-fg: #f4f2fb;
  --chrome-muted: #9a96ad;
  --chrome-line: rgba(255, 255, 255, 0.1);
  --chrome-accent: #7c5cff;
  --hl-color: #ffcf33; /* highlight ring; themes override */
  --pointer-color: #7c5cff;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body.dz {
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  font-family: "DM Sans", system-ui, sans-serif;
  overflow: hidden;
}

/* ---------- stage ---------- */

.dz-viewport {
  position: fixed;
  inset: 0 0 64px 0;
  overflow: hidden;
}

/* Centred with a transform, not grid alignment: an item wider than its container falls back to
   start alignment and the scale would then push it off-centre. */
.dz-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--stage-w);
  height: var(--stage-h);
  transform: translate(-50%, -50%) scale(var(--dz-scale, 0.5));
  transform-origin: center center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
  isolation: isolate;
}

.slide.is-current,
.slide.is-leaving { visibility: visible; }
/* Nothing inside an off-screen slide may show itself: third-party widgets (MapLibre's attribution
   box, for one) set `visibility: visible` on their parts and would escape the hidden slide. */
body:not(.dz-grid) .slide:not(.is-current):not(.is-leaving) * { visibility: hidden !important; }
.slide.is-leaving { z-index: 1; }
.slide.is-current { z-index: 2; }

/* Narration scripts are data, never shown (a theme rule like `ol { display: grid }` would beat `hidden`). */
.slide .narration { display: none !important; }

/* Elements wait hidden until the engine plays them (no flash before the entrance). */
.dz-animate .slide.is-current [data-role]:not(.dz-in),
.dz-animate .slide.is-current [data-item]:not(.dz-in) { opacity: 0; }

/* ---------- static (thumbnail / print) ---------- */

body.dz-static .dz-viewport { inset: 0; }
body.dz-static .dz-stage { box-shadow: none; border-radius: 0; }
body.dz-static .dz-bar,
body.dz-static .dz-caption,
body.dz-static .dz-pointer { display: none !important; }

/* Grid overview: every slide side by side */
body.dz-grid { overflow: auto; }
body.dz-grid .dz-viewport { position: static; padding: 32px; }
body.dz-grid .dz-stage { position: static; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; width: auto; height: auto; transform: none; box-shadow: none; overflow: visible; }
@media (max-width: 900px) { body.dz-grid .dz-stage { grid-template-columns: 1fr; } }
body.dz-grid .dz-cell { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 6px; cursor: pointer; outline: 1px solid var(--chrome-line); }
body.dz-grid .dz-cell .slide { visibility: visible; width: var(--stage-w); height: var(--stage-h); transform: scale(var(--dz-cell-scale, 0.2)); transform-origin: 0 0; inset: auto; top: 0; left: 0; }
body.dz-grid .dz-cell > .dz-cell-label { position: absolute; left: 8px; bottom: 8px; z-index: 5; font: 600 12px/1 "DM Sans", sans-serif; background: rgba(0,0,0,.65); color: #fff; padding: 5px 7px; border-radius: 4px; }
body.dz-grid .dz-bar { display: none; }

/* ---------- player bar ---------- */

.dz-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--chrome-bg);
  border-top: 1px solid var(--chrome-line);
  font-size: 13px;
  z-index: 20;
}

.dz-bar button,
.dz-bar select {
  height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border: 1px solid var(--chrome-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--chrome-fg);
  font: inherit;
  cursor: pointer;
}
.dz-bar button:hover { background: rgba(255, 255, 255, 0.1); }
.dz-bar button[aria-pressed="true"] { background: var(--chrome-accent); border-color: transparent; }
.dz-bar .dz-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.dz-bar .dz-count { color: var(--chrome-muted); font-variant-numeric: tabular-nums; min-width: 5ch; text-align: center; }
.dz-bar .dz-spacer { flex: 1; }
.dz-bar a { color: var(--chrome-muted); text-decoration: none; }
.dz-bar a:hover { color: var(--chrome-fg); }

.dz-progress {
  position: fixed;
  left: 0; bottom: 64px;
  height: 2px;
  width: calc(var(--dz-progress, 0) * 100%);
  background: var(--chrome-accent);
  transition: width 0.4s ease;
  z-index: 21;
}

/* settings panel */
.dz-settings {
  position: fixed;
  right: 16px; bottom: 76px;
  width: 300px;
  padding: 16px;
  border-radius: 12px;
  background: #18161f;
  border: 1px solid var(--chrome-line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 30;
  font-size: 13px;
}
.dz-settings.is-open { display: grid; gap: 12px; }
.dz-settings h3 { margin: 0; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--chrome-muted); }
.dz-settings label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.dz-settings select { height: 30px; border-radius: 6px; border: 1px solid var(--chrome-line); background: #0e0d13; color: var(--chrome-fg); font: inherit; padding: 0 6px; }
.dz-settings .dz-reset { justify-self: start; background: none; border: 0; color: var(--chrome-muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- narration caption ---------- */

.dz-caption {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  max-width: min(900px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(10, 9, 14, 0.82);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: clamp(14px, 1.6vw, 19px);
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 25;
}
.dz-caption.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.dz-caption .w { opacity: 0.38; transition: opacity 0.18s ease; }
.dz-caption .w.is-said { opacity: 1; }

/* ---------- AI pointer + highlight (live inside the stage, in slide pixels) ---------- */

.dz-pointer {
  position: absolute;
  left: 0; top: 0;
  width: 44px; height: 44px;
  margin: -6px 0 0 -6px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}
.dz-pointer.is-on { opacity: 1; }
.dz-pointer svg { width: 100%; height: 100%; display: block; }
.dz-pointer .dz-pulse {
  position: absolute; left: 6px; top: 6px;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--pointer-color);
  opacity: 0.5;
  animation: dz-pulse 1.4s ease-out infinite;
}
@keyframes dz-pulse { from { transform: scale(1); opacity: 0.55; } to { transform: scale(4.2); opacity: 0; } }

.dz-hl {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  border-radius: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.dz-hl.is-on { opacity: 1; }
.dz-hl[data-style="ring"] { box-shadow: 0 0 0 4px var(--hl-color), 0 0 0 14px color-mix(in srgb, var(--hl-color) 22%, transparent); }
.dz-hl[data-style="underline"] { border-radius: 0; border-bottom: 8px solid var(--hl-color); }
/* Marker: a translucent band with a solid edge, readable on light and dark slides alike. */
.dz-hl[data-style="marker"] { border-radius: 6px; background: color-mix(in srgb, var(--hl-color) 30%, transparent); box-shadow: inset 0 -10px 0 color-mix(in srgb, var(--hl-color) 85%, transparent); }
/* spotlight dims the rest of the slide */
.dz-hl[data-style="spotlight"] { box-shadow: 0 0 0 4px var(--hl-color), 0 0 0 9999px rgba(8, 8, 12, 0.48); }

@media (max-width: 720px) {
  .dz-bar .dz-title, .dz-bar .dz-hide-sm { display: none; }
  .dz-bar { gap: 6px; padding: 0 8px; }
}
