/* ============================================================
   engine.css — chrome estrutural do motor de slides. NEUTRO.
   Posiciona palco, TOC, progresso, controles, indicador de
   módulo, modo edição, overview, print e modo scroll. Toda cor,
   fonte e medida lê um token --deck-* com fallback discreto.
   A identidade visual mora no theme.css — nunca aqui.

   Tokens (defina no :root do seu theme.css; fallbacks entre parênteses):
     --deck-bg        fundo da página            (#0e0e12)
     --deck-fg        texto padrão               (#e8e8ee)
     --deck-accent    destaque / item ativo      (#6c5ce7)
     --deck-muted     chrome apagado             (rgba 255 255 255 / .45)
     --deck-line      bordas / fios              (rgba 255 255 255 / .16)
     --deck-elevated  fundo de controles         (rgba 255 255 255 / .06)
     --deck-danger    ações de apagar            (#e0566b)
     --deck-maxw      largura máx. do conteúdo   (1180px)
     --deck-pad       respiro das bordas         (clamp(1.5rem,5vw,5rem))
     --deck-font      fonte base                 (system-ui…)
     --deck-mono      fonte mono do chrome       (ui-monospace…)
     --deck-ease      easing das transições      (cubic-bezier(.22,1,.36,1))
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100vh; width: 100vw; overflow: hidden; }
body {
  background: var(--deck-bg, #0e0e12);
  color: var(--deck-fg, #e8e8ee);
  font-family: var(--deck-font, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* ---------- palco ---------- */
#deck { position: relative; width: 100%; height: 100%; perspective: 1200px; }
.slide {
  position: absolute; inset: 0; width: 100vw; height: 100vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: var(--deck-pad, clamp(1.5rem, 5vw, 5rem));
  opacity: 0; visibility: hidden; pointer-events: none;
  will-change: opacity, transform; overflow: hidden;
}
.slide.active { opacity: 1; visibility: visible; pointer-events: auto; z-index: 10; }
.wrap { width: 100%; max-width: var(--deck-maxw, 1180px); margin: 0 auto; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; }

/* notas de palco nunca aparecem no slide — só no presenter */
aside.notes { display: none !important; }

/* reveal: escondido até o motor animar (só quando o JS confirma que anima) */
body.js-anim .anim { opacity: 0; }

/* passos (data-step): ocultos até serem revelados sob demanda */
body.steps-live [data-step]:not(.step-on) { opacity: 0; pointer-events: none; }

/* ---------- barra de progresso ---------- */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 120;
  background: var(--deck-accent, #6c5ce7);
  transition: width .5s var(--deck-ease, cubic-bezier(.22, 1, .36, 1));
}

/* ---------- controles + contador ---------- */
#ui {
  position: fixed; bottom: 24px; right: 28px; z-index: 100;
  display: flex; gap: 12px; align-items: center;
  font-family: var(--deck-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.counter { font-size: .85rem; color: var(--deck-muted, rgba(255, 255, 255, .45)); letter-spacing: .05em; }
.counter #current-slide { color: var(--deck-accent, #6c5ce7); font-weight: 700; }
.nav-btn {
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--deck-line, rgba(255, 255, 255, .16));
  background: var(--deck-elevated, rgba(255, 255, 255, .06));
  color: var(--deck-fg, #e8e8ee); display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1; transition: all .2s var(--deck-ease, ease);
}
.nav-btn:hover { background: var(--deck-accent, #6c5ce7); color: #fff; border-color: var(--deck-accent, #6c5ce7); transform: translateY(-2px); }

/* ---------- dica de navegação (some após o 1º avanço) ---------- */
#hint {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 100;
  font-family: var(--deck-mono, monospace); font-size: .74rem;
  color: var(--deck-muted, rgba(255, 255, 255, .45)); letter-spacing: .05em;
  display: flex; align-items: center; gap: .5rem; transition: opacity .4s;
}

/* ---------- indicador de módulo / seção ---------- */
.module-indicator {
  position: fixed; top: 26px; right: 30px; z-index: 60; text-align: right;
  font-family: var(--deck-mono, monospace); pointer-events: none;
}
.module-indicator .module-name {
  color: var(--deck-accent, #6c5ce7); font-weight: 700; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .12em;
}
.module-indicator .lesson-name { color: var(--deck-muted, rgba(255, 255, 255, .45)); font-size: .72rem; margin-top: 2px; }

/* ---------- sumário lateral (TOC) ---------- */
#sidebar-nav {
  position: fixed; top: 50%; left: 24px; transform: translateY(-50%); z-index: 1000;
  height: 62vh; max-height: 520px; max-width: 80px; overflow: hidden;
  padding: 18px; border-radius: 14px;
  transition: max-width .5s var(--deck-ease, ease), background .3s ease;
}
.sidebar-inner { display: flex; flex-direction: column; gap: 9px; transition: transform .4s var(--deck-ease, ease); }
.sidebar-item { cursor: pointer; display: grid; grid-template-rows: 1fr; align-items: center; height: 13px; flex-shrink: 0; }
.sidebar-item::before {
  content: ''; grid-area: 1/1/2/2; height: 4px; width: 12px; border-radius: 4px;
  background: var(--deck-line, rgba(255, 255, 255, .18));
  transform-origin: left; transition: .3s ease;
}
.sidebar-item[data-level='module']::before { width: 32px; height: 5px; background: var(--deck-muted, rgba(255, 255, 255, .3)); }
.sidebar-item.active::before { background: var(--deck-accent, #6c5ce7); box-shadow: 0 0 12px var(--deck-accent, #6c5ce7); }
.sidebar-item[data-level='module'].active::before { width: 40px; }
.sidebar-tooltip {
  grid-area: 1/1/2/2; white-space: nowrap; opacity: 0; transform: translateX(-8px);
  font-family: var(--deck-font, sans-serif); font-size: .82rem;
  color: var(--deck-fg, #e8e8ee); pointer-events: none; transition: .4s ease;
}
@media (min-width: 769px) {
  #sidebar-nav:hover {
    max-width: 300px; overflow-y: auto;
    background: var(--deck-elevated, rgba(255, 255, 255, .06));
    backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
  }
  #sidebar-nav:hover .sidebar-item::before { opacity: 0; transform: scaleX(.4); }
  #sidebar-nav:hover .sidebar-tooltip { opacity: 1; transform: translateX(0); pointer-events: auto; }
  #sidebar-nav:hover .sidebar-item.active .sidebar-tooltip { color: var(--deck-accent, #6c5ce7); font-weight: 700; }
}
#sidebar-nav::-webkit-scrollbar { width: 4px; }
#sidebar-nav::-webkit-scrollbar-thumb { background: var(--deck-line, rgba(255, 255, 255, .16)); border-radius: 4px; }

/* ---------- modo edição (edit.js opcional) ---------- */
#edit-bar {
  position: fixed; bottom: 22px; left: 24px; z-index: 200;
  display: none; gap: 8px; align-items: center;
  font-family: var(--deck-mono, monospace);
}
body.editing #edit-bar { display: flex; }
.edit-btn {
  font-size: .78rem; font-weight: 700; cursor: pointer; border-radius: 10px; padding: .55em .9em;
  border: 1px solid var(--deck-line, rgba(255, 255, 255, .16));
  background: var(--deck-elevated, rgba(255, 255, 255, .06));
  color: var(--deck-fg, #e8e8ee);
  display: flex; align-items: center; gap: .4em; transition: all .2s var(--deck-ease, ease);
}
.edit-btn:hover { background: var(--deck-accent, #6c5ce7); color: #fff; border-color: var(--deck-accent, #6c5ce7); }
.edit-btn.ghost { opacity: .85; font-weight: 400; }
.edit-btn.on { background: var(--deck-accent, #6c5ce7); color: #fff; border-color: var(--deck-accent, #6c5ce7); }
#edit-bar .chip { font-size: .66rem; color: var(--deck-accent, #6c5ce7); display: flex; align-items: center; gap: .35em; }
#edit-bar .chip:empty { display: none; }
#edit-bar .chip::before { content: ''; width: .5em; height: .5em; border-radius: 50%; background: var(--deck-accent, #6c5ce7); }
body.editing [contenteditable='true'] { outline: 1.5px dashed var(--deck-accent, #6c5ce7); outline-offset: 3px; border-radius: 4px; cursor: text; }
body.editing [contenteditable='true']:focus { outline: 2px solid var(--deck-accent, #6c5ce7); }
body.editing #hint { opacity: .25; }
body.editing .module-indicator { opacity: .3; }
#del-el, #del-slide {
  position: fixed; z-index: 300; cursor: pointer; color: #fff; border: 0;
  background: var(--deck-danger, #e0566b); box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
#del-el { display: none; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center; font-size: 15px; line-height: 1; padding: 0; }
#del-slide { display: none; align-items: center; gap: .4em; border-radius: 10px; padding: .55em .85em; font-family: var(--deck-mono, monospace); font-size: .72rem; font-weight: 700; }
body.editing #del-slide { display: flex; top: 62px; right: 24px; }
#del-el:hover, #del-slide:hover { filter: brightness(1.1); }

/* ---------- modo corrido (?mode=scroll ou tecla "c") ---------- */
body.mode-scroll { overflow-y: auto; overflow-x: hidden; height: auto; width: auto; }
html:has(body.mode-scroll) { overflow: auto; height: auto; }
body.mode-scroll #deck { height: auto; perspective: none; }
body.mode-scroll .slide {
  position: relative; inset: auto; width: 100%; height: 100vh;
  opacity: 1 !important; visibility: visible !important; pointer-events: auto;
  transform: none !important; border-bottom: 1px solid var(--deck-line, rgba(255, 255, 255, .12));
}
body.mode-scroll .slide .anim, body.mode-scroll .slide [data-step] { opacity: 1 !important; transform: none !important; filter: none !important; }
body.mode-scroll #hint { display: none; }
body.mode-scroll .slide::before {
  content: attr(data-n) " · " attr(data-sidebar-label);
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30;
  font-family: var(--deck-mono, monospace); font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--deck-muted, rgba(255, 255, 255, .45));
  background: var(--deck-elevated, rgba(255, 255, 255, .06));
  border: 1px solid var(--deck-line, rgba(255, 255, 255, .16));
  padding: .4em .9em; border-radius: 999px; backdrop-filter: blur(6px); white-space: nowrap;
}

/* ---------- overview (tecla "o"): grade de todos os slides ---------- */
body.overview #deck {
  position: absolute; inset: 0; height: 100%; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-wrap: wrap; gap: 1.4vw; padding: 2.2vw;
  align-content: flex-start; background: var(--deck-bg, #0e0e12); perspective: none;
}
body.overview .slide {
  position: relative !important; inset: auto !important;
  visibility: visible !important; opacity: 1 !important;
  pointer-events: auto !important; cursor: pointer;
  zoom: .2; flex: 0 0 auto;
  outline: 5px solid var(--deck-line, rgba(255, 255, 255, .16)); outline-offset: 0;
  border-radius: 14px; transition: outline-color .12s ease;
}
body.overview .slide:hover { outline-color: var(--deck-accent, #6c5ce7); }
body.overview .slide.active { outline: 12px solid var(--deck-accent, #6c5ce7); }
body.overview .anim, body.overview [data-step] { opacity: 1 !important; transform: none !important; }
body.overview #ui, body.overview #hint, body.overview #sidebar-nav,
body.overview .module-indicator, body.overview #progress, body.overview #edit-bar { display: none !important; }

/* ---------- impressão → PDF (Ctrl/Cmd+P) ---------- */
@media print {
  @page { size: landscape; margin: 0; }
  html, body { height: auto !important; width: auto !important; overflow: visible !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  #deck { position: static !important; height: auto !important; perspective: none !important; }
  .slide {
    position: relative !important; inset: auto !important;
    visibility: visible !important; opacity: 1 !important; transform: none !important;
    width: 100% !important; height: 100vh !important;
    break-after: page; break-inside: avoid; page-break-after: always;
  }
  .slide:last-child { break-after: auto; page-break-after: auto; }
  .anim, [data-step] { opacity: 1 !important; transform: none !important; }
  aside.notes { display: none !important; }
  #ui, #hint, #sidebar-nav, .module-indicator, #progress, #edit-bar,
  #del-el, #del-slide, #wifi { display: none !important; }
}

/* ---------- responsivo ---------- */
@media (max-width: 768px) {
  #sidebar-nav { display: none; }
  #ui { bottom: 16px; right: 16px; }
}
.sidebar-item[data-level='section']::before { width: 20px; background: var(--deck-muted, rgba(255, 255, 255, .3)); opacity: .75; }
.sidebar-item[data-level='section'].active::before { width: 26px; opacity: 1; }
