/* Modo presentación (layout `presentacion`). Doc: _docs/presentacion.md
   Solo lo carga ese layout; los colores son los tokens de main.css, así que
   sigue el tema claro/oscuro del sitio. */

body.presentacion {
  margin: 0;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
}

.pres {
  --pres-pad: clamp(16px, 2.4vw, 40px);
  --pres-index-w: min(300px, 82vw);
  position: fixed;
  inset: 0;
}

/* main.css da estilo a elementos sueltos (img redondeada y centrada, botones
   en versalitas, html con scroll). Aquí se neutraliza lo que afecta. */
html:has(body.presentacion) {
  overflow: hidden;
}

.pres img {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.pres button {
  margin: 0;
  min-width: 0;
  min-height: 0;
  font-family: inherit;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  box-shadow: none;
}

.pres h2,
.pres p {
  margin-block: 0;
}

/* --- Diapositivas ------------------------------------------------------ */

.pres-stage {
  position: absolute;
  inset: 0;
  transition: left 0.2s ease;
}

.pres-slide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(10px, 1.6vh, 20px);
  padding: var(--pres-pad);
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.pres-slide.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}

/* Imagen grande y, debajo, la fila de miniaturas. */
.pres-media {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  row-gap: 0.6rem;
  min-width: 0;
  min-height: 0;
}

.pres-thumbs {
  display: flex;
  gap: 0.5rem;
  height: 4.6rem;
  overflow: hidden;
}

.pres .pres-thumb {
  position: relative;
  flex: 0 1 auto;
  height: 100%;
  aspect-ratio: 4 / 3;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: var(--color-bg-muted);
  cursor: zoom-in;
}

.pres-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pres-thumb img:not([src]) {
  visibility: hidden;
}

.pres-thumb:hover img,
.pres-thumb:focus-visible img {
  opacity: 0.8;
}

.pres-thumb__more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 15, 15, 0.62);
  color: #fffcf0;
  font-size: 1.05rem;
}

.pres-figure {
  margin: 0;
  min-height: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  cursor: zoom-in;
}

/* Texto al lado: la imagen ocupa todo el alto disponible y el texto se apoya
   en su borde inferior, como una cartela. El tamaño de la figura lo fija
   presentacion.js (layoutSlide). */
.pres-slide--side {
  grid-template-rows: auto;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 2rem;
  align-content: center;
  align-items: end;
}

.pres-slide--side .pres-media {
  grid-template-rows: auto auto;
}

.pres-slide--side .pres-figure img {
  width: 100%;
  height: 100%;
}

.pres-figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.pres-caption {
  display: grid;
  gap: 0.35em;
  max-width: 62rem;
}

.pres-caption__head {
  display: grid;
  gap: 0.3em;
}

.pres-title {
  margin: 0;
  font-size: clamp(1.25rem, 2.3vw, 2.2rem);
  line-height: 1.15;
  font-weight: 600;
  color: var(--color-heading);
}

.pres-part {
  margin-left: 0.6em;
  font-size: 0.6em;
  font-weight: 400;
  color: var(--color-text-muted);
}

.pres-subtitle {
  margin: 0;
  max-width: 58rem;
  font-size: clamp(0.95rem, 1.35vw, 1.3rem);
  line-height: 1.35;
  color: var(--color-text-muted);
}

.pres-description {
  display: none;
  margin: 0.3em 0 0;
  font-size: clamp(0.95rem, 1.25vw, 1.2rem);
  line-height: 1.45;
}

.pres-show-text .pres-description {
  display: block;
}

.pres-link {
  justify-self: start;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.pres-link:hover,
.pres-link:focus-visible {
  color: var(--color-link-hover);
  border-bottom-color: currentColor;
}

/* Extras de la pieza: mapa y vídeos, que se abren en una capa. */
.pres-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4em;
}

.pres .pres-action {
  padding: 0.25em 0.8em;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: none;
  color: var(--color-text-muted);
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  line-height: 1.4;
  cursor: pointer;
}

.pres .pres-action:hover,
.pres .pres-action:focus-visible {
  background: var(--color-bg-muted);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.pres-slide--cover .pres-actions {
  display: none;
}

/* --- Capa de mapa y vídeo ---------------------------------------------- */

.pres-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  background: var(--color-bg);
}

.pres-overlay[hidden] {
  display: none;
}

.pres-overlay__frame {
  width: 100%;
  height: 100%;
}

/* El vídeo deja margen: es donde se hace clic para cerrar. */
.pres-overlay--video {
  padding: clamp(40px, 6vh, 72px) clamp(16px, 6vw, 96px);
  background: #100f0f;
}

.pres-overlay iframe,
.pres-overlay video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: none;
}

.pres-overlay video {
  object-fit: contain;
}

/* main.css redondea los iframes. Y un reproductor de página clara dentro de
   una página oscura recibe un fondo blanco opaco: con el mismo esquema de
   color vuelve a ser transparente y las franjas quedan negras. */
.pres-overlay iframe {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.pres-overlay--video iframe {
  color-scheme: light;
}

.pres .pres-overlay__close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--floating-control-bg, var(--color-bg-muted));
  color: var(--color-text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.pres-overlay__close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

/* En el mapa, arriba están sus propios controles. */
.pres .pres-overlay--map .pres-overlay__close {
  top: auto;
  right: auto;
  bottom: 12px;
  left: 12px;
}

/* Diapositiva sin imagen: el título ocupa la pantalla. */
.pres-slide--text {
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
}

.pres-slide--text .pres-caption {
  gap: 0.6em;
}

.pres-slide--text .pres-title {
  font-size: clamp(2rem, 5.2vw, 4.6rem);
  line-height: 1.05;
}

.pres-slide--text .pres-subtitle {
  font-size: clamp(1.1rem, 2vw, 1.9rem);
}

.pres-slide--text .pres-description {
  display: block;
  font-size: clamp(1.05rem, 1.7vw, 1.6rem);
}

/* Portada: nombre pequeño, título de la charla, lugar y fecha. */
.pres-eyebrow {
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.5rem);
  color: var(--color-text-muted);
}

.pres-slide--cover .pres-caption {
  position: relative;
  max-width: none;
}

.pres-slide--cover .pres-title {
  font-size: clamp(2.4rem, 6.4vw, 5.6rem);
  max-width: 14em;
}

.pres-slide--cover .pres-link {
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 0;
  margin-top: 1.2em;
  font-size: clamp(1rem, 1.6vw, 1.5rem);
}

.pres-slide--missing .pres-title {
  color: var(--color-code);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
}

.pres-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: var(--pres-pad);
  display: grid;
  place-content: center;
  max-width: 40rem;
  color: var(--color-text-muted);
}

/* --- Índice lateral ---------------------------------------------------- */

.pres-index {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 12px;
  width: var(--pres-index-w);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--drawer-surface, var(--color-bg));
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  z-index: 3;
}

.pres-index[hidden] {
  display: none;
}

.pres-index__head {
  flex: 0 0 auto;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--color-border);
}

.pres-index__head[hidden] {
  display: none;
}

.pres-index__author {
  margin: 0 0 2px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.pres-index__heading {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 600;
  color: var(--color-heading);
}

.pres-index__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pres-index__item {
  display: grid;
  grid-template-columns: 1.6em 64px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.pres-index__item:hover,
.pres-index__item:focus-visible {
  background: var(--color-bg-muted);
  /* main.css pone el texto de button:hover en blanco. */
  color: inherit;
}

.pres-index__item[aria-current="true"] {
  background: var(--color-bg-muted);
  box-shadow: inset 3px 0 0 var(--color-link-hover);
}

.pres-index__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.pres-index__thumb {
  width: 64px;
  height: 44px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--color-bg-muted);
  /* Filo fino: la webcard de la portada es casi del color del papel. */
  box-sizing: border-box;
  border: 0.3px solid var(--color-text-muted);
}

.pres-index__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pres-index__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.pres-index__foot {
  flex: 0 0 auto;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--color-border);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.pres-index__keys {
  margin: 0;
}

.pres-index__copy {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.pres-index__copy[hidden] {
  display: none;
}

/* En pantallas anchas el índice aparta la diapositiva en vez de taparla. */
@media (min-width: 900px) {
  .pres-index-open .pres-stage {
    left: calc(var(--pres-index-w) + 12px);
  }
}

/* En pantallas estrechas flota sobre la diapositiva, por debajo de la barra. */
@media (max-width: 899px) {
  .pres-index {
    top: 62px;
  }
}

/* --- Barra de controles ------------------------------------------------ */

.pres-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--floating-control-bg, var(--color-bg-muted));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: opacity 0.3s ease;
}

.pres-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-text);
  cursor: pointer;
}

.pres-btn:hover,
.pres-btn:focus-visible,
.pres-btn[aria-pressed="true"],
.pres-btn[aria-expanded="true"] {
  background: var(--color-bg-muted);
}

.pres-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pres-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pres-count {
  min-width: 4.2em;
  text-align: center;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.pres-status {
  padding: 0 8px 0 4px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pres-status:empty {
  display: none;
}

.pres-status.is-ready {
  color: #66800b; /* Flexoki green-600: «todo cargado» */
}

.pres-status.is-failed {
  color: var(--color-code);
}

.pres-idle .pres-bar {
  opacity: 0;
}

.pres-idle .pres-bar:focus-within {
  opacity: 1;
}

.pres-idle .pres-figure {
  cursor: none;
}

/* El visor va por encima de la barra y del índice. */
.presentacion .pswp {
  z-index: 10;
}

.pres-is-empty .pres-bar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .pres-slide,
  .pres-slide.is-active,
  .pres-stage,
  .pres-bar {
    transition: none;
  }
}

@media (max-width: 600px) {
  .pres-count {
    min-width: 3.4em;
  }

  .pres-status.is-loading {
    display: none;
  }
}
