/* ==========================================================================
   DECIDO CUIDARME - SISTEMA DE NAVEGACIÓN Y RESPONSIVE MÓVIL MODERNO
   Estilo: Google Antigravity / Modern SaaS UI
   Optimizado para celulares (320px - 768px), tablets y escritorio.
   ========================================================================== */

:root {
  --nav-height: 62px;
  --nav-font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --nav-bg: #ffffff;
  --nav-border: #e5e7eb;
  --nav-text: #374151;
  --nav-text-dark: #111827;
  --nav-text-muted: #6b7280;
  --nav-primary: #0d7568;
  --nav-primary-hover: #0f8576;
  --nav-hover-bg: #f3f4f6;
  --nav-dropdown-bg: #ffffff;
  --mobile-pad: 16px;
}

/* Base de navegación */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  width: 100%;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  font-family: var(--nav-font);
}
.site-header,
.site-header * {
  box-sizing: border-box;
}

.site-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1280px, calc(100% - 32px));
  height: var(--nav-height);
  margin: 0 auto;
  gap: 16px;
}

/* Izquierda: Marca y Menú de Enlaces */
.site-nav-start {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--nav-text-dark);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.015em;
  transition: opacity 0.15s ease;
  min-width: 0;
}
.site-brand:hover {
  opacity: 0.9;
}

.site-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f0fdf4;
  color: var(--nav-primary);
  flex-shrink: 0;
}

.site-brand-text {
  font-size: 16px;
  font-weight: 750;
  color: var(--nav-text-dark);
  white-space: nowrap;
}

/* Menú de Enlaces en Escritorio */
.site-nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mobile-menu-cta { display: none; }

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--nav-text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--nav-font);
  transition: color 0.14s ease, background-color 0.14s ease;
}
.nav-item:hover,
.nav-dropdown:hover > .nav-item,
.nav-dropdown.open > .nav-item {
  color: var(--nav-primary);
  background-color: var(--nav-hover-bg);
}

.nav-item.active {
  color: var(--nav-primary);
  background-color: var(--nav-hover-bg);
  font-weight: 700;
}

.chevron-icon {
  display: inline-block;
  width: 10px;
  height: 6px;
  transition: transform 0.2s ease;
  pointer-events: none;
  flex-shrink: 0;
}
.nav-dropdown:hover .chevron-icon,
.nav-dropdown.open .chevron-icon {
  transform: rotate(180deg);
}

/* Menús Desplegables (Dropdowns) */
.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 290px;
  padding: 8px;
  background: var(--nav-dropdown-bg);
  border: 1px solid var(--nav-border);
  border-radius: 12px;
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  pointer-events: none;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Menú ancho de dos columnas para Colegios */
.dropdown-menu-wide {
  flex-direction: row;
  min-width: 580px;
  padding: 12px;
  gap: 8px;
}
.dropdown-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dropdown-divider {
  width: 1px;
  background: var(--nav-border);
  margin: 4px 6px;
}

.dropdown-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 750;
  color: var(--nav-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 4px;
}
.school-mini-crest {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--nav-text-dark);
  transition: background-color 0.14s ease;
}
.dropdown-link:hover {
  background-color: #f8fafc;
}
.dropdown-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.dropdown-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dropdown-text strong {
  font-size: 13px;
  font-weight: 650;
  color: var(--nav-text-dark);
  line-height: 1.25;
}
.dropdown-text small {
  font-size: 11px;
  color: var(--nav-text-muted);
  line-height: 1.2;
}

/* Derecha: Botón Volver y CTA */
.site-nav-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}

/* Botón universal que siempre dirige a la página anterior */
.nav-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px solid var(--nav-border);
  color: #1f2937;
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
  flex-shrink: 0;
}
.nav-back-btn:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #000;
  transform: translateX(-2px);
}
.nav-back-btn .back-arrow {
  font-size: 14px;
  line-height: 1;
}

/* Botón CTA Jugar en grupo */
.nav-cta-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--nav-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(13, 117, 104, 0.2);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.nav-cta-btn:hover {
  background: var(--nav-primary-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* Botón hamburguesa animado para móviles */
.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--nav-border);
  background: #ffffff;
  color: var(--nav-text-dark);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.nav-mobile-toggle:hover {
  background-color: var(--nav-hover-bg);
}
.nav-mobile-toggle .bar {
  display: block;
  position: relative;
  width: 18px;
  height: 2px;
  background: var(--nav-text-dark);
  border-radius: 2px;
  transition: background 0.2s ease;
}
.nav-mobile-toggle .bar::before,
.nav-mobile-toggle .bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: var(--nav-text-dark);
  border-radius: 2px;
  transition: transform 0.22s ease;
}
.nav-mobile-toggle .bar::before {
  top: -6px;
}
.nav-mobile-toggle .bar::after {
  top: 6px;
}

/* Transformación de hamburguesa a "X" cuando está abierto */
.site-header.menu-open .nav-mobile-toggle .bar {
  background: transparent;
}
.site-header.menu-open .nav-mobile-toggle .bar::before {
  transform: translateY(6px) rotate(45deg);
}
.site-header.menu-open .nav-mobile-toggle .bar::after {
  transform: translateY(-6px) rotate(-45deg);
}
.site-header-spacer {
  visibility: hidden;
  pointer-events: none;
}

/* Telón de fondo (Backdrop) para móvil */
.site-nav-backdrop {
  position: fixed;
  inset: 0;
  top: var(--nav-height);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}
.site-nav-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

body.nav-locked {
  overflow: hidden !important;
}

/* Subnavegación de habilidades digitales con scroll táctil */
.platform-skill-subnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--nav-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  font-family: var(--nav-font);
}
.platform-skill-subnav::-webkit-scrollbar {
  display: none;
}
.skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  background: #fff;
  color: #4b5563;
  font: 600 12px/1 var(--nav-font);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.14s ease;
}
.skill-pill:hover {
  border-color: #9ca3af;
  background: #f3f4f6;
  color: #111827;
}
.skill-pill.active {
  background: var(--nav-primary);
  color: #fff;
  border-color: var(--nav-primary);
  font-weight: 750;
}

/* Barra de retorno universal para videojuegos (.game-return-bar) */
.game-return-bar {
  position: sticky;
  top: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 4px 16px;
  background: #111827;
  color: #f3f4f6;
  font-family: var(--nav-font);
  border-bottom: 2px solid #f8d969;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}
.game-return-bar * {
  box-sizing: border-box;
}
.game-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  background: #f8d969;
  color: #111827;
  font: 800 12px/1 var(--nav-font);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, background-color 0.12s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.game-return-btn:hover {
  background: #ffe382;
  transform: scale(1.02);
  color: #000;
}
.game-return-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 12px/1 var(--nav-font);
  color: #9ca3af;
}
.game-return-title strong {
  color: #fff;
}
.game-return-home {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 5px;
  color: #9ca3af;
  font: 600 11.5px/1 var(--nav-font);
  text-decoration: none;
  transition: color 0.12s ease, background-color 0.12s ease;
}
.game-return-home:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   OPTIMIZACIONES MÓVILES EXCLUSIVAS (CELULARES <= 860px)
   ========================================================================== */
@media (max-width: 1024px) {
  .site-nav-start {
    gap: 16px;
  }
  .dropdown-menu-wide {
    min-width: 500px;
  }
}

@media (max-width: 1024px) {
  :root {
    --nav-height: 58px;
  }
  .site-navbar {
    width: 100%;
    padding: 0 max(12px, env(safe-area-inset-left));
    gap: 6px;
  }
  .site-nav-start { flex: 1 1 auto; gap: 10px; }
  .site-nav-end { flex: 0 0 auto; min-width: 0; gap: 6px; }
  .site-brand-text {
    font-size: clamp(12px, 3.6vw, 15px);
  }
  .site-brand-logo {
    width: 30px;
    height: 30px;
  }

  .nav-mobile-toggle {
    display: inline-flex;
  }
  .site-nav-end > .nav-cta-btn {
    display: none;
  }

  /* Menú gaveta desplegable hacia abajo (Drawer) */
  .site-nav-menu {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    height: calc(100vh - var(--nav-height));
    height: calc(100dvh - var(--nav-height));
    max-height: calc(100dvh - var(--nav-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    border-bottom: 2px solid var(--nav-border);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px max(22px, env(safe-area-inset-bottom));
    gap: 6px;
    display: none;
    z-index: 10001;
  }
  .site-header.menu-open .site-nav-menu {
    display: flex;
    animation: slideDownMobile 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  .site-header.menu-open {
    position: fixed;
    inset: 0 0 auto;
    z-index: 110000;
  }
  .site-header.menu-open .nav-mobile-toggle {
    position: relative;
    z-index: 110002;
  }
  .site-header.menu-open .site-nav-menu { z-index: 110001; }
  .site-nav-backdrop { z-index: 109999; }
  @keyframes slideDownMobile {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .nav-item {
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: 9px;
  }
  .nav-dropdown {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-dropdown > .nav-item {
    width: 100%;
    background: #f8fafc;
  }
  .nav-dropdown.open > .nav-item {
    background: #edf7f5;
    color: var(--nav-primary);
  }

  /* Desplegables en móvil: expandibles fluidamente */
  .dropdown-menu,
  .dropdown-menu-wide {
    position: static;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 9px;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    display: none;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: min(58dvh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 4px 0 8px;
    padding: 6px;
  }
  .nav-dropdown.open .dropdown-menu {
    display: flex;
    flex-direction: column;
  }
  .dropdown-divider {
    display: none;
  }
  .dropdown-link {
    min-height: 46px;
    padding: 10px 12px;
  }
  .dropdown-text strong {
    font-size: 13.5px;
  }
  .dropdown-text small {
    font-size: 11px;
  }

  /* CTA dentro del menú móvil */
  .mobile-menu-cta {
    display: block;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--nav-border);
  }
  .mobile-menu-cta .nav-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    font-size: 14px;
    border-radius: 9px;
  }

  .platform-skill-subnav {
    justify-content: flex-start;
    padding: 8px 12px;
  }
}

/* Celulares pequeños (<= 520px) */
@media (max-width: 520px) {
  .nav-back-btn {
    max-width: 130px;
    padding: 0 10px;
    font-size: 11.5px;
  }
  .nav-back-btn .back-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .site-brand-text {
    font-size: 14px;
  }
}

@media (max-width: 860px) {
  .game-return-title { display: none; }
}

@media (max-width: 380px) {
  .site-brand { gap: 7px; }
  .site-brand-text { font-size: 12px; letter-spacing: -0.025em; }
  .site-brand-logo { width: 28px; height: 28px; }
  .nav-back-btn {
    max-width: 95px;
    padding: 0 8px;
  }
}

/* General mobile polish is limited to non-game pages. The shared navigation script
   adds .platform-page; pages under /juegos keep their existing layouts unchanged. */
@media (max-width: 768px) {
  :where(.platform-page) { max-width: 100%; overflow-x: clip; }

  :where(.platform-page) *,
  :where(.platform-page) *::before,
  :where(.platform-page) *::after { box-sizing: border-box; }

  :where(.platform-page) img,
  :where(.platform-page) video,
  :where(.platform-page) canvas,
  :where(.platform-page) svg { max-width: 100%; }
  :where(.platform-page) img { height: auto; }

  :where(.platform-page) iframe[src*="youtube"] {
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 10px;
  }

  :where(.platform-page) input,
  :where(.platform-page) select,
  :where(.platform-page) textarea { max-width: 100%; font-size: 16px; }

  :where(.platform-page) table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  :where(.platform-page) pre { max-width: 100%; overflow-x: auto; }

  :where(.platform-page) .choice,
  :where(.platform-page) .simulacro-option,
  :where(.platform-page) .pilllink,
  :where(.platform-page) .button,
  :where(.platform-page) .btn { min-height: 44px; touch-action: manipulation; }

  :where(.platform-page) .grid,
  :where(.platform-page) .learning-grid,
  :where(.platform-page) .audience-grid,
  :where(.platform-page) .summary,
  :where(.platform-page) .campaign-grid,
  :where(.platform-page) .concept-grid,
  :where(.platform-page) .villa-video-results,
  :where(.platform-page) .video-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    gap: clamp(12px, 3vw, 18px);
  }

  :where(.platform-page) .campaign-story-banner,
  :where(.platform-page) .hero-layout,
  :where(.platform-page) .hero.villa-retro-hero,
  :where(.platform-page) .about-hero { min-width: 0; }

  :where(.platform-page) .campaign-story-banner img,
  :where(.platform-page) .platform-illustration,
  :where(.platform-page) .module-hero-illustration,
  :where(.platform-page) .about-hero img {
    max-width: min(100%, 320px);
    height: auto;
    margin-inline: auto;
  }

  :where(.platform-page) .platform-footer { padding: 24px 16px 20px; text-align: center; }
  :where(.platform-page) .platform-footer-main {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  :where(.platform-page) .platform-footer-nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
}
