/* ==========================================================================
   responsive.css - Repositorio de TecnoVilladiego
   --------------------------------------------------------------------------
   Capa de diseño responsivo y multiplataforma (Android / iOS / tablets).
   Se superpone al tema de eXeLearning sin modificarlo en escritorio.

   Estructura:
     0. COLORES EDITABLES (variables CSS)
     1. Ajustes globales seguros (todas las resoluciones)
     2. Botón hamburguesa (creado por responsive.js)
     3. Menú lateral drawer (#siteNav)  <= 1024px
     4. Cabecera, contenido y tipografía fluida
     5. Paginación como barra inferior fija
     6. Pie de página
     7. Modo PWA instalada (standalone) y ajustes iOS
     8. Teléfono pequeño <= 480px y apaisado bajo
   ========================================================================== */

/* ---- 0. COLORES EDITABLES -------------------------------------------------
   Opción A (recomendada): no toques nada. responsive.js detecta los colores
   de tu tema eXeLearning y adapta el menú automáticamente.

   Opción B (manual): edita los valores de abajo Y además abre responsive.js
   y cambia la línea  TV_AUTO_COLORES = true  por  false, para que tus
   colores no sean sobrescritos por la detección automática.
   -------------------------------------------------------------------------- */
:root {
  --tv-menu-bg: #ffffff;                 /* fondo del menú lateral            */
  --tv-menu-text: #1c3d5a;               /* texto de las opciones             */
  --tv-menu-sub-bg: #f6f9fc;             /* fondo de los submenús             */
  --tv-menu-line: rgba(127, 140, 155, 0.25); /* líneas separadoras            */
  --tv-menu-accent: #29abe0;             /* color de resalte (pág. actual)    */
  --tv-menu-accent-bg: rgba(41, 171, 224, 0.14); /* fondo del resalte        */
  --tv-btn-bg: #ffffff;                  /* fondo del botón hamburguesa       */
  --tv-btn-bar: #125291;                 /* color de las barras               */
  --tv-pill-next: #125291;               /* botón "Siguiente"                 */
  --tv-pill-prev: #5b7a99;               /* botón "Anterior"                  */
  --tv-blue: #125291;                    /* azul corporativo (usos varios)    */
  --tv-blue-light: #29abe0;              /* azul claro (foco, enlaces activos)*/
  --tv-drawer-w: min(320px, 86vw);       /* ancho del menú lateral            */
}

/* ---- 1. AJUSTES GLOBALES SEGUROS ---------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;   /* evita reescalados de texto al girar (iOS) */
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;               /* nunca scroll horizontal por sorpresa */
  -webkit-tap-highlight-color: rgba(41, 171, 224, 0.25); /* feedback táctil Android */
}

img, video {
  max-width: 100%;
  height: auto;                     /* imágenes fluidas */
}

iframe, object, embed {
  max-width: 100%;
}

p, li {
  overflow-wrap: break-word;        /* URLs y palabras largas no rompen el layout */
  word-wrap: break-word;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--tv-menu-accent, #29abe0);
  outline-offset: 2px;              /* accesibilidad: foco visible con teclado */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 2. BOTÓN HAMBURGUESA ------------------------------------------------ */
/* El botón lo inyecta responsive.js; oculto en escritorio. */

.nav-toggle {
  display: none;
}

/* ---- 3. MENÚ DRAWER (<= 1024px: tablets y móviles) ---------------------- */

@media (max-width: 1024px) {

  /* Botón hamburguesa: 48px (guía Android) y >= 44px (guía Apple) */
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(127, 140, 155, 0.35);
    border-radius: 12px;
    background: var(--tv-btn-bg, #ffffff);
    box-shadow: 0 2px 10px rgba(15, 35, 60, 0.22);
    cursor: pointer;
    z-index: 1002;
  }

  .nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--tv-btn-bar, #125291);
    transition: transform 0.25s ease, opacity 0.2s ease;
  }

  /* Animación a "X" con el menú abierto */
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
  }
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }
  body.nav-open .nav-toggle .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
  }

  /* Fondo oscurecido tras el drawer */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 35, 60, 0.5);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.25s ease;
  }
  .nav-backdrop[hidden] {
    display: none;
  }

  /* Drawer lateral con el menú del sitio */
  #siteNav {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--tv-drawer-w);
    margin: 0 !important;
    padding: calc(64px + env(safe-area-inset-top, 0px))
             calc(14px + env(safe-area-inset-right, 0px))
             calc(20px + env(safe-area-inset-bottom, 0px))
             calc(14px + env(safe-area-inset-left, 0px)) !important;
    background: var(--tv-menu-bg, #ffffff);
    box-shadow: 4px 0 24px rgba(15, 35, 60, 0.25);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1001;
    box-sizing: border-box;
  }

  body.nav-open #siteNav {
    transform: translateX(0);
  }

  body.nav-open {
    overflow: hidden;               /* bloquea el scroll de fondo */
  }

  /* Lista de navegación: filas grandes aptas para el pulgar */
  #siteNav ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #siteNav li {
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: 1px solid var(--tv-menu-line, rgba(127, 140, 155, 0.25));
    list-style: none !important;
    float: none !important;
    display: block !important;
  }

  #siteNav a,
  #siteNav a:link,
  #siteNav a:visited {
    display: block !important;
    box-sizing: border-box;
    min-height: 48px;               /* objetivo táctil cómodo */
    padding: 13px 14px !important;
    color: var(--tv-menu-text, #1c3d5a) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    letter-spacing: 0.02em;
    text-decoration: none !important;
    text-transform: none !important;
  }

  #siteNav a:active {
    background: var(--tv-menu-accent-bg, rgba(41, 171, 224, 0.18)) !important;
  }

  /* Submenús: segundo nivel con fondo suave y sangrado.
     display:block anula la regla del tema (.other-section {display:none}),
     que dejaba las subpáginas fuera del menú móvil. */
  #siteNav ul ul {
    display: block !important;
    background: var(--tv-menu-sub-bg, #f6f9fc);
    border-radius: 10px;
    margin: 2px 0 6px !important;
  }

  #siteNav ul ul a,
  #siteNav ul ul a:link,
  #siteNav ul ul a:visited {
    padding-left: 28px !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    min-height: 44px;
  }

  /* Página actual resaltada */
  #siteNav a.active,
  #siteNav li#active > a {
    color: var(--tv-menu-text, #1c3d5a) !important;
    background: var(--tv-menu-accent-bg, rgba(41, 171, 224, 0.14)) !important;
    box-shadow: inset 4px 0 0 var(--tv-menu-accent, #29abe0);
  }

  /* ---- 4. CABECERA Y CONTENIDO ---- */

  /* El tema da a la cabecera 40px de aire arriba, altura fija y un
     padding derecho enorme; en móvil se compacta para dejar sitio
     al botón hamburguesa (fijo, arriba a la izquierda). */
  #header,
  #emptyHeader {
    height: auto;
    min-height: 0;
    padding: 12px calc(58px + env(safe-area-inset-right, 0px))
             12px calc(58px + env(safe-area-inset-left, 0px));
  }

  #headerContent {
    font-size: clamp(1.05rem, 4.2vw, 1.45rem);
    line-height: 1.3;
    overflow-wrap: break-word;
  }

  #main-wrapper {
    width: auto !important;
    max-width: 100% !important;
    margin: 0 !important;
    background: #fff;               /* elimina la franja de la columna izquierda del tema */
    padding: 10px
             calc(12px + env(safe-area-inset-right, 0px))
             calc(84px + env(safe-area-inset-bottom, 0px))
             calc(12px + env(safe-area-inset-left, 0px)) !important;
  }

  #nodeTitle {
    font-size: clamp(1.35rem, 5.5vw, 2rem);
    line-height: 1.25;
    overflow-wrap: break-word;
  }

  .iDevice_content {
    font-size: 16px;                /* evita el auto-zoom de iOS en formularios */
    line-height: 1.6;
  }

  .iDevice_content hr {
    margin: 16px 0;
  }

  /* ---- 5. PAGINACIÓN: BARRA INFERIOR FIJA ---- */

  #topPagination {
    display: none !important;       /* redundante en móvil */
  }

  #bottomPagination {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 10px
             calc(14px + env(safe-area-inset-right, 0px))
             calc(10px + env(safe-area-inset-bottom, 0px))
             calc(14px + env(safe-area-inset-left, 0px));
    background: linear-gradient(to top, rgba(255, 255, 255, 0.96) 65%, rgba(255, 255, 255, 0));
    pointer-events: none;           /* la barra no bloquea el contenido */
    z-index: 900;
  }

  #bottomPagination .pagination {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    margin: 0 !important;
    padding: 0 !important;
    height: auto;                   
    position: static;
    pointer-events: auto;
  }

  /* El tema convierte estos enlaces en iconos absolutos de 32x32 con el
     texto recortado (clip:rect); se restauran como botones normales. */
  #bottomPagination a {
    position: static;
    left: auto;
    right: auto;
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    min-height: 48px;
    padding: 11px 22px;
    border-radius: 999px;
    background: var(--tv-pill-next, #125291);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none !important;
    box-shadow: 0 4px 14px rgba(15, 35, 60, 0.3);
    transition: transform 0.12s ease;
  }

  #bottomPagination a:active {
    transform: scale(0.96);
  }

  /* Des-recorta el texto del enlace (el tema lo esconde con clip:rect) */
  #bottomPagination a span,
  #bottomPagination a span span {
    position: static;
    clip: auto;
    width: auto;
    height: auto;
    overflow: visible;
    display: inline;
    line-height: 1.3;
  }

  /* Con solo "Siguiente", la píldora se alinea a la derecha */
  #bottomPagination a.next {
    margin-left: auto;
  }

  /* Enlaces "Anterior" en tono neutro */
  #bottomPagination a.prev {
    background: var(--tv-pill-prev, #5b7a99);
  }

  /* ---- 6. PIE ---- */

  #packageLicense {
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
    padding: 10px 14px;
  }

  /* La insignia de eXe va fija abajo a la derecha en el tema y choca
     con la barra de paginación: pasa a flujo normal como pastilla
     centrada (el tema la deja de 35x35 con el texto apretado). */
  #made-with-eXe {
    position: static;
    width: auto;
    text-align: center;
    margin: 14px 0 calc(72px + env(safe-area-inset-bottom, 0px));
    padding: 0 14px;
  }

  #made-with-eXe a {
    display: inline-block;
    width: auto;
    height: auto;
    line-height: 30px;
    padding: 0 12px 0 34px;
    background-position: 10px 50%;
    border-radius: 15px;
    box-shadow: rgba(0, 0, 0, 0.18) 0 2px 8px;
  }

  #made-with-eXe a span {
    padding-left: 0;
  }
}

/* ---- 8b. CONTENIDO EN PANTALLAS MUY ESTRECHAS (<= 640px) ----------------- */

@media (max-width: 640px) {
  /* Las tablas anchas hacen scroll horizontal en vez de romper la página. */
  .iDevice_content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  /* Tablas de maquetación del editor (sin clase): las columnas se apilan
     para que el texto no se corte por la derecha. Las tablas de datos de
     eXe (.exe-table, .exe-table-minimalist...) conservan sus columnas. */
  .iDevice_content table:not([class]) td,
  .iDevice_content table:not([class]) th {
    display: block;
    width: auto !important;
    box-sizing: border-box;
  }

  .iDevice_content td,
  .iDevice_content th {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Palabras largas dentro de celdas y títulos */
  #nodeTitle,
  .iDevice_content a {
    overflow-wrap: break-word;
  }
}

/* ---- 7. PWA INSTALADA (standalone) -------------------------------------- */

@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top, 0px);  /* respeta el notch (iPhone) */
  }
  #made-with-eXe {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* Soporte antiguo de iOS para modo pantalla completa */
@media (max-width: 1024px) {
  @supports (-webkit-touch-callout: none) and (not (translate: none)) {
    #siteNav { padding-top: 76px !important; }  /* más aire en iPhone con notch */
  }
}

/* ---- 8. TELÉFONO PEQUEÑO (<= 480px) -------------------------------------- */

@media (max-width: 480px) {
  :root {
    --tv-drawer-w: 88vw;
  }

  #headerContent {
    padding-top: 12px;
    padding-bottom: 12px;
    font-size: clamp(1rem, 4.6vw, 1.25rem);
  }

  #nodeTitle {
    font-size: clamp(1.25rem, 6vw, 1.6rem);
  }

  /* Enlaces gigantes de la portada (24pt en línea) a tamaño legible */
  .iDevice_content span {
    font-size: 1.15rem !important;
  }

  #bottomPagination a {
    padding: 10px 18px;
    font-size: 14px;
  }

  #packageLicense,
  #made-with-eXe {
    font-size: 11.5px;
  }
}

/* Apaisado con poca altura: menos aire en drawer y barra inferior */
@media (max-width: 1024px) and (max-height: 460px) {
  #siteNav {
    padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }
  .nav-toggle {
    top: calc(6px + env(safe-area-inset-top, 0px));
  }
  #bottomPagination {
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
  #bottomPagination a {
    min-height: 40px;
    padding: 8px 16px;
  }
}
