/* ═══════════════════════════════════════════════════════════════════
   DEMIN CONSCIENTE — Biblioteca · Sistema de presentaciones
   Compartido por las 5 microclases (y, adaptado, por los protocolos).

   Fuentes: docs/biblioteca/specs/05 (design system) · 06 (slide system)
   · Motion System V1 · DESIGN.md. No es una identidad nueva: tokens y
   formas del ecosistema (halo, arco, dorado como único acento).

   Lienzo fijo 1920×1080 escalado a la ventana → la grabación se ve
   idéntica en cualquier pantalla. Todas las medidas en px del lienzo.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --dark: #1C1A18;
  --gold: #C9A84C;
  --gold-soft: #E3C988;
  --cream: #F2EDE4;
  --off-white: #EDE8DF;
  --warm-gray: #6B6259;
  --ink-muted: rgba(242, 237, 228, 0.66);
  --ink-quiet: rgba(242, 237, 228, 0.46);
  --rule: rgba(201, 168, 76, 0.22);
  --rule-strong: rgba(201, 168, 76, 0.55);

  /* Tipografía — ver decisión D1 (Bauder Bodoni no existe en el repo).
     Para cambiar la editorial en las 5 microclases: solo esta línea. */
  --font-editorial: 'Playfair Display', 'Didot', 'Bodoni 72', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Motion System V1 */
  --ease-reveal: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-breath: cubic-bezier(0.45, 0, 0.55, 1);
  --t-reveal: 900ms;
  --t-breath: 6s;
  --t-route: 2400ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--dark); }
body {
  color: var(--cream);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Escenario ─────────────────────────────────────────────────── */
/* El viewport es el contenedor del lienzo: en el portal vive dentro de un
   marco 16:9; en modo presentación, el portal lo lleva a pantalla completa. */
.viewport {
  position: absolute; inset: 0;
  overflow: hidden;
  background: var(--dark);
}
/* Centrado absoluto + escala desde el centro. (Con grid/place-items, un hijo
   de 1920px más ancho que la ventana se alinea a la izquierda y la escala lo
   descentra: solo se veía bien con zoom del navegador al 33%.) */
.stage {
  position: absolute; left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: center center;
  overflow: hidden;
  background: var(--dark);
}

.slide {
  position: absolute; inset: 0;
  padding: 140px 180px;
  display: flex; flex-direction: column; justify-content: center;
  opacity: 0; visibility: hidden;
}
.slide.is-active { opacity: 1; visibility: visible; }
html.has-motion .slide { transition: opacity 700ms var(--ease-reveal), visibility 0s linear 700ms; }
html.has-motion .slide.is-active { transition: opacity 700ms var(--ease-reveal), visibility 0s; }
.slide--center { align-items: center; text-align: center; }
.slide--split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 120px;
  align-items: center;
}

/* Luz ambiental: radial dorado ≤ 0.08 (DESIGN.md). */
.slide::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 60% at 50% 46%, rgba(201,168,76,0.06), transparent 70%);
}
.slide > * { position: relative; }

/* ─── Tipografía ───────────────────────────────────────────────── */
.mark {
  font-family: var(--font-mono);
  font-size: 22px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold); margin: 0;
}
.display {
  font-family: var(--font-editorial); font-weight: 400;
  letter-spacing: -0.01em; line-height: 1.05; margin: 0;
  text-wrap: balance;
}
.display--xl { font-size: 150px; }
.display--l  { font-size: 112px; line-height: 1.08; }
.display--m  { font-size: 84px;  line-height: 1.14; }
.italic {
  font-family: var(--font-editorial); font-style: italic; font-weight: 400;
  font-size: 58px; line-height: 1.3; margin: 0; color: var(--cream);
}
.italic--quiet { color: var(--ink-muted); }
.lead { font-size: 44px; line-height: 1.4; margin: 0; color: var(--cream); }
.micro { font-size: 30px; line-height: 1.45; margin: 0; color: var(--ink-muted); max-width: 30ch; }
.slide--center .micro { margin-inline: auto; }
.micro--line { max-width: none; }

.stack > * + * { margin-top: 40px; }
.stack--tight > * + * { margin-top: 20px; }
.rule { width: 96px; height: 1px; background: var(--rule-strong); border: 0; margin: 56px 0; }
.slide--center .rule { margin-inline: auto; }

/* Pasos editoriales: número mono + frase. Nunca viñetas ni tarjetas. */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: grid; grid-template-columns: 88px 1fr; align-items: baseline;
  font-size: 50px; line-height: 1.3; padding: 26px 0;
  border-top: 1px solid var(--rule);
}
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps .n { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.12em; color: var(--gold); }

/* Palabras en fila separadas por punto medio dorado. */
.words { display: flex; flex-wrap: wrap; gap: 0 56px; align-items: baseline; margin: 0; padding: 0; list-style: none; }
.slide--center .words { justify-content: center; }
.words li { font-family: var(--font-editorial); font-size: 92px; line-height: 1.2; }
.words li + li::before { content: "·"; color: var(--gold); margin-right: 56px; }

/* Pares término → definición (diferencias). */
.pairs { margin: 0; }
.pairs div {
  display: grid; grid-template-columns: 520px 1fr; align-items: baseline;
  padding: 34px 0; border-top: 1px solid var(--rule);
}
.pairs div:last-child { border-bottom: 1px solid var(--rule); }
.pairs dt { font-family: var(--font-editorial); font-size: 64px; margin: 0; }
.pairs dd { font-size: 44px; margin: 0; color: var(--ink-muted); }
.pairs--wide div { grid-template-columns: 760px 1fr; }
/* Protocolos agrupados por categoría: la lista de nombres ocupa lo que necesite. */
.pairs--group div { grid-template-columns: minmax(0, 1fr) auto; column-gap: 80px; padding: 24px 0; }
.pairs--group dd { text-align: right; }
.pairs dd strong { color: var(--cream); font-weight: 500; }

/* ─── Halo (patrón umbral del ecosistema) ──────────────────────── */
.halo {
  position: absolute; left: 50%; top: 50%;
  width: 980px; height: 980px; margin: -490px 0 0 -490px;
  pointer-events: none; color: var(--gold);
}
.halo svg { width: 100%; height: 100%; overflow: visible; }
.halo circle { fill: none; stroke: currentColor; stroke-width: 0.35; }
.halo circle:nth-child(1) { opacity: 0.18; }
.halo circle:nth-child(2) { opacity: 0.12; }
.halo circle:nth-child(3) { opacity: 0.08; }

/* ─── Diagrama de ruta (perfil + vía aérea) ────────────────────── */
.route { width: 100%; max-width: 760px; justify-self: center; }
.route svg { display: block; width: 100%; height: auto; max-height: 700px; overflow: visible; }
.route .face { fill: none; stroke: var(--cream); stroke-opacity: 0.5; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.route .cavity { fill: none; stroke: var(--cream); stroke-opacity: 0.16; stroke-width: 2; stroke-dasharray: 2 10; stroke-linecap: round; }
.route .path { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.route .path--in { stroke: var(--gold); }
.route .path--out { stroke: var(--cream); stroke-dasharray: 1 16; stroke-width: 6; }
.route .tag { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.16em; text-transform: uppercase; }
.route .tag--in { fill: var(--gold); }
.route .tag--out { fill: var(--cream); }
.route .arrow { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.route .arrow--in { stroke: var(--gold); }
.route .arrow--out { stroke: var(--cream); }
/* Línea del aire en el tiempo (retenciones): crema continua; la pausa es .path--in dorada. */
.route .path--line { stroke: var(--cream); stroke-opacity: 0.85; }

/* ─── Chrome: contador discreto (H lo oculta para grabar) ──────── */
.chrome {
  position: absolute; left: 180px; right: 180px; bottom: 64px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-quiet);
  pointer-events: none;
}
.chrome__progress { position: absolute; left: 0; right: 0; bottom: -24px; height: 1px; background: var(--rule); }
.chrome__progress i { display: block; height: 100%; background: var(--gold); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
html.has-motion .chrome__progress i { transition: transform 700ms var(--ease-reveal); }
body.hide-chrome .chrome { opacity: 0; }

/* ═══ MOTION ═══════════════════════════════════════════════════════
   Todo el movimiento vive bajo html.has-motion (sin reduced motion).
   Estados, no decoración:
   · .r      REVEAL al entrar la slide (escalonado con --i)
   · .frag   REVEAL por paso del facilitador (→)
   · .halo   BREATH solo en umbral y cierre
   · .path   MORPH: la ruta se traza cuando su paso entra
   · [data-motion="PAUSE"] no tiene loops ni halo: silencio visual
   ═══════════════════════════════════════════════════════════════ */

.frag { opacity: 0; }
.frag.is-in { opacity: 1; }

html.has-motion .slide.is-active .r {
  animation: reveal var(--t-reveal) var(--ease-reveal) backwards;
  animation-delay: calc(250ms + var(--i, 0) * 650ms);
}
html.has-motion .frag { transform: translateY(20px); filter: blur(4px); transition: opacity var(--t-reveal) var(--ease-reveal), transform var(--t-reveal) var(--ease-reveal), filter var(--t-reveal) var(--ease-reveal); }
html.has-motion .frag.is-in { transform: none; filter: none; }

html.has-motion .slide.is-active .halo svg {
  animation: breath var(--t-breath) var(--ease-breath) infinite;
  animation-delay: 1.8s;
  transform-origin: center;
}

/* Ruta: pathLength=1 → dasharray/offset normalizados. La salida es
   punteada, así que su "trazo" se revela con una máscara que avanza. */
.route .path--in, .route .path--line { stroke-dasharray: 1; stroke-dashoffset: 1; }
.route [data-draw].is-in .path--in, .route [data-draw].is-in .path--line { stroke-dashoffset: 0; }
.route .mask-out { stroke-dasharray: 1; stroke-dashoffset: 1; fill: none; stroke: #fff; stroke-width: 40; stroke-linecap: round; }
.route [data-draw].is-in .mask-out { stroke-dashoffset: 0; }
.route [data-draw] .arrow, .route [data-draw] .tag { opacity: 0; }
.route [data-draw].is-in .arrow, .route [data-draw].is-in .tag { opacity: 1; }
html.has-motion .route .path--in,
html.has-motion .route .path--line,
html.has-motion .route .mask-out { transition: stroke-dashoffset var(--t-route) var(--ease-breath); }
html.has-motion .route [data-draw] .arrow,
html.has-motion .route [data-draw] .tag { transition: opacity 600ms var(--ease-reveal); }
html.has-motion .route [data-draw].is-in .arrow,
html.has-motion .route [data-draw].is-in .tag { transition-delay: calc(var(--t-route) - 400ms); }
/* El grupo de la ruta no se desenfoca: se "dibuja". */
html.has-motion .route .frag { transform: none; filter: none; opacity: 1; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(20px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes breath {
  0%, 100% { transform: scale(0.96); }
  50%      { transform: scale(1); }
}

/* ═══ Capas FACILITADOR y VALIDACIÓN ══════════════════════════════
   Nunca visibles para el alumno. N / V las abre como panel lateral
   (ensayo en una pantalla); P abre la vista de presentador. */
.slide > aside { display: none; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 44vw);
  background: #14120F; border-left: 1px solid var(--rule);
  color: var(--cream); font-family: var(--font-sans); font-size: 15px; line-height: 1.55;
  padding: 28px 30px 60px; overflow-y: auto; z-index: 20;
  transform: translateX(100%); transition: transform 350ms var(--ease-reveal);
}
.drawer.is-open { transform: none; }
.drawer h2 { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin: 0 0 4px; font-weight: 500; }
.drawer .drawer__title { font-family: var(--font-editorial); font-size: 24px; margin: 0 0 22px; }
.note { margin: 0 0 18px; }
.note__label { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-soft); margin-bottom: 4px; }
.note p { margin: 0 0 8px; }
.note--decir { font-size: 17px; }
.cue { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--dark); background: var(--gold); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.drawer--validation { background: #101A16; }
.drawer--validation .note__label { color: #9DC7B4; }
.pending { color: #F0B98A; }

/* Ayuda de teclado */
.help {
  position: fixed; left: 24px; bottom: 24px; z-index: 30;
  background: #14120F; border: 1px solid var(--rule); border-radius: 10px;
  padding: 16px 20px; font-size: 14px; line-height: 1.8; color: var(--ink-muted);
}
.help kbd { font-family: var(--font-mono); color: var(--gold); margin-right: 8px; }

/* ─── Vista de presentador (?presenter) ────────────────────────── */
body.presenter { overflow: auto; background: #100F0D; }
.pv { display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr;
  gap: 18px; padding: 18px; min-height: 100vh; background: #100F0D; }
.pv-frame { position: relative; overflow: hidden; background: var(--dark); border: 1px solid var(--rule); border-radius: 8px; }
.pv-frame .stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pv-frame .chrome { display: flex; }
.pv-current { grid-column: 1; grid-row: 1 / span 2; aspect-ratio: 16 / 9; }
.pv-next { grid-column: 2; grid-row: 1; aspect-ratio: 16 / 9; opacity: 0.8; }
.pv-meta { grid-column: 2; grid-row: 2; font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.1em; color: var(--ink-muted); display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.pv-meta strong { color: var(--gold); font-weight: 500; font-size: 22px; letter-spacing: 0.04em; }
.drawer.pv-notes { grid-column: 1 / span 2; grid-row: 3; position: static; width: auto; transform: none; border: 1px solid var(--rule); border-radius: 8px; display: grid; grid-template-columns: 1.35fr 1fr; gap: 36px; overflow: visible; }
.pv-validation { border-left: 1px solid var(--rule); padding-left: 30px; }
.pv-validation h2 { color: #9DC7B4; margin-bottom: 18px; }
.pv-validation .note__label { color: #9DC7B4; }
/* La vista previa "Siguiente" muestra el estado final, sin movimiento. */
.pv-next *, .pv-next *::before, .pv-next *::after { animation: none !important; transition: none !important; }
.pv-notes > div { min-width: 0; }
.pv-label { position: absolute; left: 10px; top: 8px; z-index: 2; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; color: var(--ink-quiet); text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  .drawer { transition: none; }
}
