/* layout.css — contenedor, cabecera, navegación y footer */

.container {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 18px 16px 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.legal-page .container {
  padding-bottom: 18px;
}

/* Header */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(225, 235, 255, .95);
  border-bottom: 1px solid var(--line);
  transition: transform .28s ease, background .28s ease, box-shadow .28s ease;
  will-change: transform;
}

.header.is-hidden {
  transform: translateY(-110%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  width: min(1100px, 100%);
  margin: 0 auto;
  position: relative;
}

/* Mobile hamburger */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .70);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(2, 6, 23, .08);
  cursor: pointer;
  margin-right: 5px;
}

.nav-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .22), 0 10px 26px rgba(2, 6, 23, .10);
}

.nav-toggle-bars {
  position: relative;
  width: 20px;
  height: 2px;
  background: rgba(11, 18, 32, .78);
  border-radius: 2px;
  transition: background .2s ease;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: rgba(11, 18, 32, .78);
  border-radius: 2px;
  transition: transform .2s ease, top .2s ease, opacity .2s ease;
}

.nav-toggle-bars::before {
  top: -6px;
}

.nav-toggle-bars::after {
  top: 6px;
}

.header.menu-open .nav-toggle-bars {
  background: transparent;
}

.header.menu-open .nav-toggle-bars::before {
  top: 0;
  transform: rotate(45deg);
}

.header.menu-open .nav-toggle-bars::after {
  top: 0;
  transform: rotate(-45deg);
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }

  .nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    box-shadow: 0 22px 70px rgba(2, 6, 23, .12);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    /* Allow scrolling the full mobile menu when content is taller than viewport */
    max-height: calc(100dvh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .nav.is-open {
    display: flex;
  }

  .nav a,
  .nav .nav-link {
    width: 100%;
    justify-content: space-between;
    padding: 12px 12px;
    border-radius: 14px;
  }

  .dropdown-menu {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: 100%;
    min-width: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 6px 0 0 0;
    max-height: none;
    overflow-y: visible;
  }

  .dropdown-menu a {
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 600;
  }

  .brand {
    width: 44% !important;
    padding-left: 10px;
  }
}

.nav {
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (min-width: 861px) {
  .nav {
    display: flex;
  }
}

/* Hard guard: mobile menu is closed unless explicitly opened via .is-open */
@media (max-width: 860px) {
  .header .nav {
    display: none !important;
  }

  .header .nav.is-open {
    display: flex !important;
  }
}

.nav a,
.nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  transition: all .25s ease;
  position: relative;
}

.nav a::after,
.nav .nav-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  transition: width .3s ease;
}

.nav a:hover,
.nav .nav-link:hover {
  background: rgba(15, 23, 42, .06);
  color: var(--accent);
}

.nav a.is-current,
.nav .nav-link.is-current {
  background: rgba(37, 99, 235, .10);
  color: var(--accent);
  border-color: rgba(37, 99, 235, .18);
}

.nav a:hover::after,
.nav .nav-link:hover::after {
  width: calc(100% - 24px);
}

.nav a:focus-visible,
.nav .nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
  border-color: rgba(37, 99, 235, .35);
}

.nav-item {
  position: relative;
}

.nav-dropdown {
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.dropdown > .nav-dropdown .chev {
  transition: transform .22s ease, opacity .22s ease;
}

.dropdown.open > .nav-dropdown {
  background: rgba(37, 99, 235, .14);
  color: var(--accent);
  border-color: rgba(37, 99, 235, .28);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .10);
}

.dropdown.open > .nav-dropdown .chev {
  transform: rotate(180deg);
  opacity: 1;
}

.chev {
  opacity: .7;
  font-size: .9em;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(92vw, 380px);
  min-width: 260px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(2, 6, 23, .14);
  display: none;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, .35) transparent;
}

.mega-menu {
  width: min(92vw, 760px);
  min-width: 620px;
  padding: 14px;
}

.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 4px 0 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .24);
  background: rgba(248, 250, 252, .72);
}

.menu-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 10px 6px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #2f4fa3;
  background: linear-gradient(180deg, rgba(59, 130, 246, .12), rgba(59, 130, 246, .06));
  border: 1px solid rgba(59, 130, 246, .20);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.menu-group-title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: .8;
}

.dropdown-menu::-webkit-scrollbar {
  width: 10px;
}

.dropdown-menu::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, .28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, .42);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.35;
}

.dropdown-menu a:hover {
  background: rgba(15, 23, 42, .06);
}

.mega-menu a {
  padding: 9px 12px;
  font-weight: 700;
}

.menu-divider {
  margin: 8px 0;
  border: none;
  border-top: 1px solid #e2e8f0;
}

@media (max-width: 720px) {
  .header-inner {
    padding: 10px 12px;
  }

  .nav {
    justify-content: flex-start;
  }

  .dropdown-menu {
    left: 0;
    right: auto;
    width: min(92vw, 320px);
  }

  .mega-menu {
    min-width: 0;
    width: min(92vw, 340px);
  }
}

/* Mobile dropdown fix: always open downward, centered and fully visible */
@media (max-width: 860px) {
  .header .nav .dropdown {
    width: 100%;
    display: block;
  }

  .header .nav .dropdown > .nav-dropdown {
    width: 100%;
    justify-content: space-between;
  }

  .header .nav .dropdown-menu {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: min(52dvh, 360px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin-top: 6px;
    padding: 8px;
  }

  .header .nav .dropdown:focus-within .dropdown-menu {
    display: block;
  }

  .header .nav .mega-menu-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .header .nav .menu-group {
    gap: 2px;
    padding: 2px 0 6px;
    border-radius: 12px;
  }

  .header .nav .menu-group-title {
    margin: 2px 8px 6px;
  }

  .header .nav .dropdown-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
  }

  /* Stability override: keep submenu in normal flow under "Guías" */
  .header .nav {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
  }

  .header .nav .nav-item {
    width: 100%;
  }

  .header .nav .dropdown.open .dropdown-menu {
    display: block;
    position: static !important;
    width: 100% !important;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .2px;
  flex: 0 0 auto;
  width: auto;
  max-width: min(360px, 42vw);
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: var(--shadow2);
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #ffffff;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  font-size: 14px;
  color: rgba(11, 18, 32, .70);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.nav a:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, .65);
  color: var(--text);
}

#logotipo{
  height: 54px;
  width: auto;
  max-width: 100%;
}

@media (max-width: 860px) {
  #logotipo {
    height: 42px;
  }
}

@media (max-width: 480px) {
  #logotipo {
    height: 36px;
  }
}

/* Nav search button */
.nav-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: rgba(11, 18, 32, .70);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
  flex-shrink: 0;
}

.nav-search-btn:hover {
  background: rgba(255, 255, 255, .65);
  border-color: var(--line);
  color: var(--text);
}

.nav-search-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .22);
}

/* Nav search overlay */
.nav-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 72px;
  animation: fadeIn .14s ease;
}

.nav-search-panel {
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 28px 72px rgba(15, 23, 42, .28);
  padding: 14px;
  margin: 0 16px;
}

.nav-search-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid rgba(15, 23, 42, .12);
  border-radius: 12px;
  padding: 9px 10px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.nav-search-panel-header:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .13);
}

#navSearchOverlayInput {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  outline: none;
  color: var(--text);
}

.nav-search-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 6px;
  transition: color .15s ease;
}

.nav-search-close:hover { color: var(--text); }

.nav-search-overlay-results {
  display: grid;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  margin-top: 8px;
  overscroll-behavior: contain;
}

.nav-search-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-search-key {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid rgba(15, 23, 42, .2);
  border-radius: 5px;
  font-size: 11px;
  background: #f8fafc;
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 520px) {
  .nav-search-overlay {
    padding-top: 56px;
  }

  .nav-search-panel {
    margin: 0 10px;
  }

  .nav-search-hint {
    display: none;
  }
}

/* Guías en header */
.guias-home {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  padding: 12px 14px;
  box-shadow: var(--shadow2);
}

.guias-home h2 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: .2px;
  font-weight: 800;
}

.guias-home ul {
  margin: 0;
  padding-left: 18px;
  color: rgba(11, 18, 32, .78);
  font-size: 13px;
  line-height: 1.35;
}

.guias-home a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer */
/* Footer */
.footer {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
  padding: 48px 20px 32px;
  background: linear-gradient(180deg, #1a3a52 0%, #122a3e 100%);
  color: rgba(255, 255, 255, .85);
  font-size: 14px;
  border-top: 3px solid rgba(37, 99, 235, .4);
  position: relative;
  margin-left: 0;
  margin-right: 0;
}

.footer::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 5%;
  width: 90%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .6), transparent);
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}

.footer-section h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.footer-section a {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, .85);
  text-decoration: none;
  transition: all .25s ease;
  position: relative;
  font-weight: 500;
}

.footer-section a::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width .3s ease;
}

.footer-section a:hover {
  color: #ffffff;
}

.footer-section a:hover::after {
  width: 100%;
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  text-align: center;
  color: rgba(255, 255, 255, .7);
  font-size: 13px;
}

.footer-bottom p {
  margin: 0;
}

@media (max-width: 860px) {
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

@media (max-width: 520px) {
  .footer-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
  }

  .footer-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    align-content: start;
  }

  .footer-section h3 {
    grid-column: 1 / -1;
  }

  .footer {
    padding: 24px 14px 18px;
    margin-top: 32px;
  }

  .footer-content {
    margin-bottom: 18px;
  }

  .footer-section h3 {
    margin-bottom: 8px;
    font-size: 12px;
    letter-spacing: 0.5px;
  }

  .footer-section a {
    margin-bottom: 0;
    font-size: 13px;
    line-height: 1.25;
  }

  .footer-bottom {
    padding-top: 14px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .footer-content {
    grid-template-columns: 1fr;
  }

  .footer-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Footer width guard to avoid horizontal overflow on mobile */
.footer {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.dropdown-divider {
  margin: 8px 0;
  border: 0;
  border-top: 1px solid #e2e8f0;
}
