/* ==========================================================================
   Marco del reproductor: cabecera con logos, recuadro, barra, pie, diálogos
   ========================================================================== */

/* --- Cabecera con logos (siempre visible) -------------------------------- */

.marca {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem clamp(1rem, 3vw, 2rem);
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  background: var(--papel);
  border-bottom: 1px solid var(--linea);
}

.patrocinio {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.patrocinio--financia { align-items: flex-start; }

.patrocinio__rotulo {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tinta-suave);
  line-height: 1;
}

.logo-prodiversa {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--rojo);
  text-decoration: none;
}
.logo-prodiversa img { width: 46px; height: 46px; }
.logo-prodiversa__nombre {
  display: flex;
  flex-direction: column;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.logo-prodiversa__nombre small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--tinta-suave);
}

.logo-junta { height: 54px; width: auto; }

.marca__titulo {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--violeta-900);
  text-wrap: balance;
}

@media (max-width: 1100px) {
  .marca { grid-template-columns: auto auto; justify-content: space-between; }
  .marca__titulo { display: none; }
}
@media (max-width: 720px) {
  .marca { gap: 0.75rem; }
  .logo-prodiversa img { width: 30px; height: 30px; }
  .logo-prodiversa__nombre { font-size: 1.05rem; }
  .logo-prodiversa__nombre small { display: none; }
  .logo-junta { height: 30px; }
}
@media (max-width: 440px) {
  .logo-junta { height: 27px; }
  .logo-prodiversa img { width: 26px; height: 26px; }
  .logo-prodiversa__nombre { font-size: 0.95rem; }
}

/* --- Escenario y recuadro ------------------------------------------------ */

.escenario {
  display: flex;
  justify-content: center;
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem);
  padding-bottom: calc(clamp(0.75rem, 2vw, 1.5rem) + env(safe-area-inset-bottom, 0px));
}

.recuadro {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1180px;
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: 24px;
  box-shadow: var(--sombra);
  overflow: clip;
}
.recuadro::before {
  content: "";
  flex: none;
  height: 6px;
  background: linear-gradient(90deg, var(--violeta) 0 50%, var(--verde) 50% 100%);
}

/* En pantallas amplias el recuadro ocupa el alto disponible y el contenido
   se desplaza dentro (comportamiento tipo SCORM). */
@media (min-width: 721px) and (min-height: 560px) {
  body {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .escenario { flex: 1; min-height: 0; }
  .recuadro { height: 100%; }
  .pantalla { overflow-y: auto; overscroll-behavior: contain; }
  /* Pantallas de poco contenido: centradas en vertical, para que no quede todo
     arriba y el recuadro medio vacío. Con margin auto, si el contenido no cabe
     vuelve a empezar arriba (y se desplaza como siempre). */
  .pantalla:has(> .pantalla__interior) { display: flex; flex-direction: column; }
  .pantalla > .pantalla__interior { width: 100%; margin: auto; }
}

/* --- Barra superior del recuadro ---------------------------------------- */

.recuadro__barra {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--linea-suave);
}

.recuadro__bloque {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.recuadro__bloque span {
  display: inline-block;
  max-width: 100%;
  padding: 0.25em 0.85em;
  border-radius: 999px;
  background: var(--acento-suave);
  color: var(--acento-fuerte);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.recuadro__acciones { display: flex; gap: 0.25rem; }

.boton-barra {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tinta-suave);
  font-weight: 800;
  font-size: 0.92rem;
}
.boton-barra:hover { background: var(--linea-suave); color: var(--tinta); }
.boton-barra[aria-pressed="true"] { background: var(--acento-suave); color: var(--acento-fuerte); }

@media (max-width: 640px) {
  .boton-barra__texto { display: none; }
  .boton-barra { padding: 0.4rem 0.7rem; }
}

/* --- Zona de la pantalla ------------------------------------------------- */

.pantalla {
  flex: 1;
  min-height: 0;
  scroll-padding-top: 1rem;
}

.pantalla__interior {
  max-width: 52rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 3rem) clamp(2rem, 4vw, 3.5rem);
}

/* Entrada suave de cada pantalla */
.pantalla > * { animation: aparecer 0.35s ease-out both; }
@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Pie de navegación --------------------------------------------------- */

.recuadro__pie {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--linea-suave);
  background: var(--papel);
}

.progreso {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-width: 0;
}
.progreso__barra {
  flex: 1;
  max-width: 380px;
  height: 8px;
  border-radius: 999px;
  background: var(--linea-suave);
  overflow: hidden;
}
.progreso__relleno {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--acento);
  transition: width 0.35s ease, background-color 0.35s;
}
.progreso__texto {
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tinta-suave);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .escenario { padding-inline: 0.75rem; }
  .recuadro { border-radius: 18px; }
  .recuadro__pie {
    position: sticky;
    bottom: 0;
    z-index: 5;
    gap: 0.5rem;
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 18px rgb(38 32 46 / 0.06);
  }
}
@media (max-width: 480px) {
  .recuadro__pie .boton span { display: none; }
  .recuadro__pie .boton { padding-inline: 0.8em; }
  .progreso__barra { display: none; }
}

/* --- Modo proyector ------------------------------------------------------ */

html.modo-proyector { font-size: 118%; }
html.modo-proyector .pantalla__interior { max-width: 60rem; }
html.modo-proyector .escenario { padding: 0.75rem; }
html.modo-proyector .recuadro { max-width: none; }

/* --- Diálogos ------------------------------------------------------------ */

.dialogo {
  padding: 0;
  border: 0;
  background: var(--papel);
  color: var(--tinta);
  box-shadow: var(--sombra-alta);
}
.dialogo::backdrop { background: rgb(38 32 46 / 0.45); }

.dialogo[open] { display: flex; flex-direction: column; }

.dialogo--modal {
  width: min(760px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  border-radius: 22px;
}

.dialogo--cajon {
  /* Cajón de altura completa: ocupa todo el alto de la ventana aunque los
     bloques estén plegados y sobre sitio debajo. */
  margin: 0 auto 0 0;
  width: min(400px, 90vw);
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0 22px 22px 0;
}
.dialogo--cajon[open] { animation: entrar-izq 0.25s ease-out; }
@keyframes entrar-izq { from { transform: translateX(-100%); } to { transform: none; } }

.dialogo__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem 1.5rem;
  border-bottom: 1px solid var(--linea-suave);
}
.dialogo__titulo {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--violeta-900);
}
.dialogo__cuerpo {
  /* `flex: 1 1 auto`, no `flex: 1`: el cuerpo parte del alto de su contenido.
     Con `flex: 1` (base 0%) y un diálogo sin alto definido —«Mi proyecto» solo
     tiene max-height— el cuerpo colapsa y el diálogo se queda en la cabecera. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.5rem 1.5rem;
}

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

.indice, .indice ol { list-style: none; margin: 0; padding: 0; }

.indice__bloque { padding: 0.6rem 0; border-bottom: 1px solid var(--linea-suave); }
.indice__bloque:last-child { border-bottom: 0; }

.indice__bloque-titulo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--acento-fuerte);
}
.indice__bloque-titulo::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--acento);
}

/* Bloques plegables: <details> nativo, sin el triángulo del navegador. */
.indice__desplegable > summary { list-style: none; cursor: pointer; }
.indice__desplegable > summary::-webkit-details-marker { display: none; }
.indice__desplegable > summary::marker { content: ""; }
.indice__desplegable > summary:hover { color: var(--acento-fuerte); }
.indice__desplegable > summary:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: var(--radio-s);
}
.indice__flecha {
  flex: none;
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  color: var(--acento);
  transition: transform 0.2s;
}
.indice__desplegable[open] > summary .indice__flecha { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .indice__flecha { transition: none; } }

.indice__bloque--pendiente .indice__bloque-titulo { color: var(--tinta-suave); font-weight: 700; }
.indice__bloque--pendiente .indice__bloque-titulo::before { background: var(--linea); }
.indice__pendiente {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tinta-suave);
  white-space: nowrap;
}
.indice__pendiente .icono { width: 0.9rem; height: 0.9rem; }

.indice__enlace {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.35rem 0.7rem 0.35rem 1.4rem;
  border-radius: var(--radio-s);
  color: var(--tinta);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.3;
}
.indice__enlace:hover { background: var(--acento-muy-suave); }
.indice__enlace[aria-current="page"] {
  background: var(--acento-suave);
  color: var(--acento-fuerte);
  font-weight: 800;
}
.indice__visto { margin-left: auto; color: var(--verde); width: 1.1rem; height: 1.1rem; }
