/**
 * nav.css — Hamburger nav con soporte de tema oscuro / claro.
 * Las variables se definen en :root (oscuro por defecto) y se
 * sobreescriben en html.theme-light (aplicado por nav.html).
 */

/* ══════════════════════════════════════════
   TOKENS DE COLOR (tema oscuro por defecto)
══════════════════════════════════════════ */
:root {
  --nav-btn-bg:         rgba(15, 23, 42, 0.92);
  --nav-btn-border:     rgba(255, 255, 255, 0.12);
  --nav-btn-hover:      rgba(30, 41, 59, 0.96);
  --nav-bar-color:      #f8fafc;
  --nav-drawer-from:    #0f172a;
  --nav-drawer-to:      #1e293b;
  --nav-drawer-shadow:  4px 0 24px rgba(0, 0, 0, 0.40);
  --nav-close-bg:       rgba(255, 255, 255, 0.08);
  --nav-close-border:   rgba(255, 255, 255, 0.15);
  --nav-close-color:    #f8fafc;
  --nav-divider:        rgba(255, 255, 255, 0.14);
  --nav-link-color:     #cbd5e1;
  --nav-link-hover-bg:  rgba(56, 189, 248, 0.12);
  --nav-link-hover-c:   #f8fafc;
  --nav-active-bg:      rgba(0, 142, 218, 0.20);
  --nav-active-color:   #38bdf8;
  --nav-active-border:  rgba(0, 142, 218, 0.30);
  --nav-theme-row-bg:   rgba(0, 0, 0, 0.22);
  --nav-theme-label-c:  #cbd5e1;
  --nav-theme-track:    rgba(30, 41, 59, 0.80);
  --nav-theme-border:   rgba(255, 255, 255, 0.12);
  --nav-backdrop-bg:    rgba(2, 6, 23, 0.55);
  --nav-shadow:         0 4px 12px rgba(0, 0, 0, 0.28);
}

/* ══════════════════════════════════════════
   TOKENS DE COLOR — TEMA CLARO
   Aplicado a html.theme-light por nav.html
══════════════════════════════════════════ */
html.theme-light {
  --nav-btn-bg:         rgba(255, 255, 255, 0.95);
  --nav-btn-border:     rgba(0, 0, 0, 0.10);
  --nav-btn-hover:      rgba(226, 232, 240, 0.98);
  --nav-bar-color:      #0f172a;
  --nav-drawer-from:    #f0f4f8;
  --nav-drawer-to:      #dce4ef;
  --nav-drawer-shadow:  4px 0 24px rgba(0, 0, 0, 0.14);
  --nav-close-bg:       rgba(0, 0, 0, 0.06);
  --nav-close-border:   rgba(0, 0, 0, 0.12);
  --nav-close-color:    #0f172a;
  --nav-divider:        rgba(0, 0, 0, 0.10);
  --nav-link-color:     #334155;
  --nav-link-hover-bg:  rgba(0, 85, 165, 0.09);
  --nav-link-hover-c:   #0f172a;
  --nav-active-bg:      rgba(0, 85, 165, 0.13);
  --nav-active-color:   #0055a5;
  --nav-active-border:  rgba(0, 85, 165, 0.28);
  --nav-theme-row-bg:   rgba(0, 0, 0, 0.05);
  --nav-theme-label-c:  #475569;
  --nav-theme-track:    rgba(200, 216, 235, 0.80);
  --nav-theme-border:   rgba(0, 0, 0, 0.10);
  --nav-backdrop-bg:    rgba(15, 23, 42, 0.38);
  --nav-shadow:         0 4px 12px rgba(0, 0, 0, 0.10);
}

/* ══════════════════════════════════════════
   CONTENEDOR PRINCIPAL
══════════════════════════════════════════ */
#main-nav,
.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1002;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  pointer-events: none;
}

/* ══════════════════════════════════════════
   BOTÓN HAMBURGER
══════════════════════════════════════════ */
.nav-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 46px;
  height: 46px;
  background: var(--nav-btn-bg);
  border: 1px solid var(--nav-btn-border);
  border-radius: 13px;
  cursor: pointer;
  /* z-index alto para estar siempre encima del visor 3D */
  z-index: 9998;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 11px 10px;
  box-shadow: var(--nav-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease,
              transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-toggle:hover {
  background: var(--nav-btn-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.nav-toggle:focus-visible {
  outline: none;
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.nav-toggle[aria-expanded="true"] {
  background: var(--nav-btn-hover);
}

/* Las 3 rayitas */
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--nav-bar-color);
  border-radius: 2px;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              width 0.2s ease,
              background 0.25s ease;
}

/* Animación → X cuando está abierto */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  width: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* ══════════════════════════════════════════
   DRAWER LATERAL
══════════════════════════════════════════ */
.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(175deg, var(--nav-drawer-from) 0%, var(--nav-drawer-to) 100%);
  z-index: 1002;
  pointer-events: auto;
  transform: translateX(-110%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.3s ease,
              box-shadow 0.3s ease;
  box-shadow: var(--nav-drawer-shadow);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.nav-drawer.open {
  transform: translateX(0);
}

.nav-drawer-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px 20px 28px;
}

/* Cabecera */
.nav-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.nav-close {
  width: 38px;
  height: 38px;
  background: var(--nav-close-bg);
  border: 1px solid var(--nav-close-border);
  border-radius: 10px;
  color: var(--nav-close-color);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-close:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
  transform: scale(1.07);
}

.nav-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
}

/* Divisor */
.nav-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--nav-divider), transparent);
  margin: 14px 0;
  transition: background 0.3s ease;
}

/* ══════════════════════════════════════════
   LINKS DE NAVEGACIÓN
══════════════════════════════════════════ */
.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  color: var(--nav-link-color);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.15s ease;
}

.nav-link:hover {
  background: var(--nav-link-hover-bg);
  color: var(--nav-link-hover-c);
  transform: translateX(3px);
}

.nav-link.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
  border-color: var(--nav-active-border);
  font-weight: 600;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  opacity: 1;
}

/* ── Spacer ── */
.nav-spacer {
  flex: 1;
  min-height: 20px;
}

/* ══════════════════════════════════════════
   TOGGLE TEMA CLARO / OSCURO
══════════════════════════════════════════ */
.nav-theme-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--nav-theme-row-bg);
  border-radius: 14px;
  border: 1px solid var(--nav-divider);
  margin-top: auto;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-theme-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--nav-theme-label-c);
  transition: color 0.3s ease;
}

/* Switch */
.nav-theme-btn {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--nav-theme-track);
  border: 1px solid var(--nav-theme-border);
  border-radius: 14px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.25s ease, border-color 0.25s ease;
}

/* Knob (sol / luna) */
.nav-theme-btn::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.25s ease;
}

/* En tema claro: knob se mueve a la derecha y cambia de color */
.nav-theme-btn.on::before {
  transform: translateX(24px);
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

.nav-theme-btn[aria-checked="true"] {
  background: rgba(100, 116, 139, 0.30);
}

.nav-theme-knob { display: none; }

/* ══════════════════════════════════════════
   BACKDROP
══════════════════════════════════════════ */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: var(--nav-backdrop-bg);
  opacity: 0;
  pointer-events: none;
  z-index: 1001;
  transition: opacity 0.28s ease, background 0.3s ease;
  overscroll-behavior: contain;
}

.nav-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
  /* Bloquear scroll del fondo SOLO cuando el menú está abierto */
  touch-action: none;
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE
══════════════════════════════════════════ */
@media (max-width: 480px) {
  .nav-toggle {
    top: 12px;
    left: 12px;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    padding: 10px 8px;
  }

  .nav-drawer {
    width: 88vw;
  }

  .nav-drawer-inner {
    padding: 16px 16px 24px;
  }

  .nav-link {
    padding: 13px 14px;
    font-size: 0.92rem;
  }

  .nav-theme-row {
    padding: 12px 14px;
  }
}