/* ─────────────────────────────────────────────────────────────
   player.css — estilos del reproductor (y del lienzo del editor).
   Todo lo que está dentro de .slide se mide en cqw: la slide es
   el contenedor, así que la composición escala idéntica en
   cualquier pantalla. 1 unidad de lienzo = 100/1600 cqw.
   ───────────────────────────────────────────────────────────── */

:root {
  --c-bg: #dce2df;
  --c-surface: #fafbf9;
  --c-text: #1d2b27;
  --c-muted: #5e6e68;
  --c-accent: #2f52e0;
  --c-border: #1d2b27;
  --f-display: 'Helvetica Neue', Arial, sans-serif;
  --f-body: 'Helvetica Neue', Arial, sans-serif;
  --frame-bw: 3;
  --frame-radius: 0;
  --u: calc(100cqw / 1600); /* 1 unidad de lienzo (solo válida dentro de .slide) */
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.is-presenting, html.is-presenting body { overflow: hidden; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 3px; }

/* ── Landing ─────────────────────────────────────────────── */

.landing {
  width: min(1280px, 100% - 2 * max(20px, env(safe-area-inset-left), env(safe-area-inset-right)));
  margin: 0 auto;
  padding: clamp(48px, 12vh, 140px) 0 clamp(40px, 8vh, 96px);
}
.landing-meta { margin: 0 0 1.5rem; color: var(--c-muted); font-size: 1rem; }
.landing-title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7.5vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  max-width: 17ch;
  text-wrap: balance;
}
.landing-subtitle {
  margin: 1.25rem 0 0;
  font-family: var(--f-display);
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  line-height: 1.2;
  max-width: 32ch;
}
.landing-description { margin: 1.5rem 0 0; max-width: 60ch; color: var(--c-muted); font-size: 1.075rem; }
.landing-meta:empty, .landing-subtitle:empty, .landing-description:empty { display: none; }

.start-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  margin-top: 2.5rem;
  padding: 1em 1.6em;
  border: 0;
  border-radius: 999px;
  background: var(--c-text);
  color: var(--c-surface);
  font: 600 1.05rem/1 var(--f-body);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.start-button:hover { background: var(--c-accent); }
.start-button:active { transform: scale(0.98); }
.start-button svg { width: 0.9em; height: 0.9em; fill: currentColor; }

/* ── Modo scroll ─────────────────────────────────────────── */

.deck {
  width: min(1280px, 100% - 2 * max(20px, env(safe-area-inset-left), env(safe-area-inset-right)));
  margin: 0 auto;
  padding-bottom: 12vh;
  display: grid;
  gap: clamp(28px, 6vw, 72px);
}
.deck .slide { cursor: zoom-in; border-radius: 2px; }
.deck .slide:focus-visible { outline-offset: 8px; }

/* ── Anatomía de una slide ───────────────────────────────── */

.slide {
  container-type: inline-size;
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.slide-header {
  height: calc(88 * var(--u));
  flex-shrink: 0;
  display: grid;
  align-items: end;
}
.slide-header-content {
  display: flex;
  align-items: flex-end;
  gap: calc(24 * var(--u));
  min-width: 0;
  width: 100%;
  padding-bottom: calc(4 * var(--u));
}
.slide-header-content .title-host {
  flex: 1;
  min-width: 0;
}
.slide-header-content .title-host .slide-title { width: 100%; }
.slide-section {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: calc(56 * var(--u));
  line-height: 1;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}
.slide-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: calc(40 * var(--u));
  line-height: 1.15;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0 calc(8 * var(--u));
  border-bottom: calc(2 * var(--u)) solid color-mix(in srgb, var(--c-border) 28%, transparent);
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-top: calc(24 * var(--u));
  background: var(--c-surface);
  border-radius: calc(var(--frame-radius) * var(--u));
  overflow: hidden;
}
.frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border: calc(var(--frame-bw) * var(--u)) solid var(--c-border);
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
}

.canvas, .canvas-host { position: absolute; inset: 0; }

.el { position: absolute; overflow: hidden; z-index: 0; }

.el--text { color: var(--c-text); }
.el--text.has-fill .el-text {
  display: inline-block;
  max-width: 100%;
  background: var(--text-fill, var(--c-surface));
  padding: 0.18em 0.45em 0.28em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.el-text { font-family: var(--f-body); line-height: 1.42; }
.el-text > :first-child { margin-top: 0; }
.el-text > :last-child { margin-bottom: 0; }
.el-text p { margin: 0 0 0.65em; }
.el-text ul, .el-text ol { margin: 0 0 0.65em; padding: 0; list-style: none; }
.el-text ol { counter-reset: deck-ol; }
.el-text li { position: relative; margin: 0 0 0.35em; padding-left: 1.2em; }
.el-text ul > li::before {
  content: '';
  position: absolute;
  left: 0.15em;
  top: 0.56em;
  width: 0.34em;
  height: 0.34em;
  border-radius: 50%;
  background: var(--c-accent);
}
.el-text ol > li { counter-increment: deck-ol; padding-left: 1.5em; }
.el-text ol > li::before {
  content: counter(deck-ol);
  position: absolute;
  left: 0;
  font-family: var(--f-display);
  font-weight: 800;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
}
.el-text h3 {
  margin: 0 0 0.45em;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.3em;
  line-height: 1.15;
}
.el-text strong { font-weight: 700; }

.el--video video,
.el--image img {
  display: block;
  width: 100%;
  height: 100%;
  background: color-mix(in srgb, var(--c-muted) 14%, var(--c-surface));
}

.section-cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 calc(120 * var(--u));
  text-shadow: 0 2px 24px color-mix(in srgb, var(--c-surface) 70%, transparent);
}
.section-cover-num {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: calc(300 * var(--u));
  line-height: 0.82;
  letter-spacing: -0.045em;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
}
.section-cover-title {
  margin-top: calc(40 * var(--u));
  max-width: 22ch;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: calc(76 * var(--u));
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.slide-footer {
  height: calc(48 * var(--u));
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(24 * var(--u));
}
.slide-watermark,
.slide-number {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: calc(24 * var(--u));
  color: var(--c-muted);
}
.slide-watermark {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slide-number {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* ── Modo presentación ───────────────────────────────────── */

.stage {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--c-bg);
  padding:
    max(2vh, env(safe-area-inset-top))
    max(2.5vw, env(safe-area-inset-right))
    max(2vh, env(safe-area-inset-bottom))
    max(2.5vw, env(safe-area-inset-left));
  outline: none;
  touch-action: pan-y pinch-zoom;
}
.stage[hidden] { display: none; }
.stage-slide { width: 100%; }
.stage .frame {
  box-shadow: 0 calc(16 * var(--u)) calc(40 * var(--u)) rgb(0 0 0 / 0.14);
}

.layer-host { display: grid; min-width: 0; }
.stage .slide-header-content > .layer-host { align-items: baseline; }
.layer-host > * { grid-area: 1 / 1; }
.slide-footer .watermark-host { justify-items: start; min-width: 0; }
.slide-footer .number-host { justify-items: end; margin-left: auto; }
.canvas-host > .canvas { position: absolute; inset: 0; }
.is-leaving { pointer-events: none; }

.nav {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: calc(56 * var(--u));
  height: calc(56 * var(--u));
  translate: 0 -50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--c-border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--c-surface) 82%, transparent);
  color: var(--c-text);
  font: 700 calc(36 * var(--u)) / 1 var(--f-display);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}
.nav span { margin-top: -0.12em; }
.nav:hover, .nav:focus-visible { opacity: 1; }
.nav--prev { left: calc(12 * var(--u)); }
.nav--next { right: calc(12 * var(--u)); }
/* En pantallas táctiles se navega deslizando o tocando los laterales del cuadro. */
@media (pointer: coarse) { .nav { display: none; } }
.stage.is-first .nav--prev, .stage.is-last .nav--next { visibility: hidden; }

.stage-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--c-text);
  font-size: 18px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}
.stage-close:hover, .stage-close:focus-visible { opacity: 1; }

/* Aviso de girar el móvil (solo táctil y en vertical) */
.rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  background: var(--c-bg);
  text-align: center;
  font-family: var(--f-display);
}
.rotate-hint p { margin: 0; font-size: 1.25rem; font-weight: 700; max-width: 16ch; }
.rotate-hint-icon {
  width: 44px;
  height: 76px;
  border: 3px solid var(--c-text);
  border-radius: 9px;
  animation: deck-rotate 2.4s ease-in-out infinite;
}
.rotate-hint-dismiss {
  margin-top: 6px;
  border: 0;
  background: none;
  color: var(--c-muted);
  font: 500 0.95rem var(--f-body);
  text-decoration: underline;
  cursor: pointer;
}
@keyframes deck-rotate {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
@media (orientation: portrait) and (pointer: coarse) {
  .stage:not(.rotate-dismissed) .rotate-hint { display: flex; }
}

/* Aviso en modo scroll para móviles en vertical */
.scroll-hint { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 760px) {
  .scroll-hint {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    translate: -50% 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 10px 10px 18px;
    border-radius: 999px;
    background: var(--c-text);
    color: var(--c-surface);
    font-size: 0.9rem;
    line-height: 1.25;
  }
  .scroll-hint button {
    flex: none;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--c-surface) 18%, transparent);
    color: inherit;
    cursor: pointer;
  }
  html.is-presenting .scroll-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-hint-icon { animation: none; transform: rotate(-90deg); }
  .start-button, .nav, .stage-close { transition: none; }
}

@media print {
  .stage, .scroll-hint, .start-button { display: none !important; }
  body { background: #fff; }
  .deck { width: 100%; gap: 0; }
  .deck .slide { break-inside: avoid; break-after: page; }
}
