/* ─────────────────────────────────────────────────────────────────
    5. SISTEMA SPA — PÁGINAS
───────────────────────────────────────────────────────────────── */
.page {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.page.page-active {
  display: flex;
  opacity: 1;
  animation: none;
}

.page.page-out {
  display: flex;
  pointer-events: none;
  animation: none;
}

/* Páginas claras — blanco dominante */
.light-page {
  background: var(--bg);
}

/* Fondo con imagen difuminada (Unidades, Contacto) */
.light-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.light-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(18px) saturate(.1) brightness(1.05);
  transform: scale(1.05);
}

.light-bg-ov {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(250, 250, 248, .97) 0%, rgba(250, 250, 248, .82) 30%, rgba(250, 250, 248, .65) 60%, rgba(250, 250, 248, .4) 100%);
}

/* dark-page: fondo gris texturado sin imagen */
.dark-page .light-bg-img {
  display: none;
}

.dark-page .light-bg-ov {
  position: absolute;
  inset: 0;
  background: var(--grey-base);
  background-image: var(--grain);
  background-size: 200px 200px;
}

.dark-page .eyebrow {
  color: rgba(255, 255, 255, .4);
}

.dark-page .page-header h2 {
  color: #fff !important;
}

.dark-page .page-header {
  border-bottom-color: rgba(255, 255, 255, .09);
}

.dark-page .page-header-count {
  color: rgba(255, 255, 255, .06);
}

.dark-page .clist-item {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .1);
}

.dark-page .clist-item:hover {
  background: rgba(255, 255, 255, .11);
  border-color: rgba(255, 255, 255, .2);
}

.dark-page .clist-label {
  color: rgba(255, 255, 255, .38);
}

.dark-page .clist-val {
  color: rgba(255, 255, 255, .88);
}

.dark-page .clist-arr {
  color: rgba(255, 255, 255, .22);
}

.dark-page .clist-item:hover .clist-arr {
  color: rgba(255, 255, 255, .7);
}

.dark-page .clist-icon {
  color: rgba(255, 255, 255, .45);
}

.dark-page .clist-item:hover .clist-icon {
  color: rgba(255, 255, 255, .88);
}

.dark-page .clist-item::before {
  background: var(--accent);
}

.dark-page .cform-title {
  color: rgba(255, 255, 255, .88);
}

.dark-page .cform-label {
  color: rgba(255, 255, 255, .38);
}

.dark-page .cform-input {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .88);
}

.dark-page .cform-input::placeholder {
  color: rgba(255, 255, 255, .25);
}

.dark-page .cform-input:focus {
  border-color: rgba(255, 255, 255, .35);
}

.dark-page .cform-note {
  color: rgba(255, 255, 255, .3);
}

.dark-page .page-footer {
  border-top-color: rgba(255, 255, 255, .07);
}

.dark-page .footer-copy {
  color: rgba(255, 255, 255, .2);
}

.dark-page .terminos-text {
  color: rgba(255, 255, 255, .58);
}

#page-unidades.dark-page .unit-card {
  background: #F5F1EB;
  border: 2px solid var(--accent-ui-border);
}

/* Page inner — scroll interno */
.page-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  padding: max(96px, var(--fixed-controls-safe-top)) 56px 56px;
  margin: 0 auto;
  overflow-y: auto;
  height: 100dvh;
  max-height: 100dvh;
  scroll-padding-top: max(96px, var(--fixed-controls-safe-top));
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  box-sizing: border-box;
}

.page-inner::-webkit-scrollbar {
  width: 3px;
}

.page-inner::-webkit-scrollbar-thumb {
  background: var(--accent-border);
}

/* Header reutilizable */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 44px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--accent-border);
}

.page-header h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 300;
  letter-spacing: -.02em;
  color: var(--ink);
}

.page-header-count {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(3rem, 8vw, 4.5rem);
  font-weight: 200;
  color: var(--accent-border2);
  line-height: 1;
  letter-spacing: -.04em;
}

/* Page footer */
/* ─────────────────────────────────────────────────────────────────
    PAGINACIÓN DE UNIDADES
───────────────────────────────────────────────────────────────── */
.units-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 4px;
}

.units-pagination[hidden] {
  display: none;
}

.upag-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: .58rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: #ffffff;
  color: #111111;
  border: none;
  box-shadow: 0 0 0 2px var(--accent-ui-border);
  cursor: pointer;
  transition: background .2s, box-shadow .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}

.upag-btn:hover:not(:disabled) {
  background: var(--accent-faint);
  border-color: var(--accent-strong);
  color: var(--accent-btn);
}

.upag-btn:disabled {
  opacity: .35;
  cursor: default;
}

.upag-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.upag-page {
  font-family: 'DM Sans', sans-serif;
  font-size: .75rem;
  font-weight: 500;
  color: var(--accent-strong);
  letter-spacing: .04em;
}

.upag-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.upag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-faint2);
  transition: width .25s, background .25s, border-radius .25s;
}

.upag-dot.active {
  width: 18px;
  border-radius: 3px;
  background: var(--accent);
}

.page-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 0 16px;
  margin-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, .07);
}

.footer-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.footer-copy {
  font-size: .55rem;
  letter-spacing: .22em;
  color: var(--ink);
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────────────────────────
    6. LOADER
───────────────────────────────────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: #0A0A0A;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .6s ease, visibility .6s;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loader-logo {
  width: 120px;
  max-width: 50vw;
  filter: brightness(0) invert(1) opacity(.8);
  animation: loaderPulse 1.8s ease-in-out infinite;
}

.loader-bar {
  width: 120px;
  height: 1px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
  border-radius: 1px;
}

.loader-progress {
  height: 100%;
  background: linear-gradient(to right, var(--accent-faint2), var(--accent));
  width: 0%;
  transition: width .1s linear;
}

.loader-text {
  font-size: .52rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .2);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
}

/* ─────────────────────────────────────────────────────────────────
    7. MENÚ LATERAL
───────────────────────────────────────────────────────────────── */
.menu-btn {
  position: fixed;
  top: var(--ui-btn-top, calc(22px + env(safe-area-inset-top)));
  left: var(--ui-btn-edge, 22px);
  z-index: 3100;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(240, 240, 238, .92);
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 50%;
  color: #1A1A18;
  cursor: pointer;
  transition: background .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease), left .35s var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 0 2px var(--accent-ui-border);
}

.menu-btn:hover {
  transform: scale(1.05);
}

.menu-btn:active {
  transform: scale(.96);
}

.menu-btn-icon {
  width: 20px;
  height: 20px;
  transition: transform .4s var(--ease);
}

.menu-btn-closed {
  display: block;
  opacity: 1;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}

.menu-btn-open {
  display: none;
  opacity: 0;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}

.menu-btn.active .menu-btn-closed {
  opacity: 0;
  display: none;
}

.menu-btn.active .menu-btn-open {
  display: block;
  opacity: 1;
}

.menu-btn.active {
  left: calc(var(--menu-panel-width) - 21px);
}

/* ─────────────────────────────────────────────────────────────────
    BACK BUTTON
    Posición: a la derecha del .menu-btn, sigue su movimiento al abrir menú.
    Oculto en hero, visible en el resto de páginas.
───────────────────────────────────────────────────────────────── */
.back-btn {
  position: fixed;
  top: var(--ui-btn-top, calc(22px + env(safe-area-inset-top)));
  left: calc(var(--ui-btn-edge, 22px) + var(--ui-btn-size, 42px) + var(--ui-btn-gap, 10px));
  z-index: 3300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity .2s var(--ease),
    left .35s var(--ease),
    background .15s,
    transform .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 0 2px var(--accent-ui-border);
}

/* Visible fuera del hero */
.back-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Sigue al menu-btn cuando el panel está abierto */
.back-btn.menu-open {
  left: calc(var(--menu-panel-width) - 21px + var(--ui-btn-size, 42px) + var(--ui-btn-gap, 10px));
}

.back-btn:active {
  transform: scale(.96) !important;
}

/* ─────────────────────────────────────────────────────────────────
    OVERLAY Y PANEL LATERAL
───────────────────────────────────────────────────────────────── */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  transition: opacity .3s;
}

.menu-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--menu-panel-width);
  height: var(--app-height);
  background: #ffffff;
  background-image: none;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .35s var(--ease);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #e8e8e4;
}

.side-menu.active {
  transform: translateX(0);
}

.side-menu::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--accent-strong);
  opacity: 0;
  transition: opacity .35s var(--ease) .1s;
  z-index: 1;
}

.side-menu.active::before {
  opacity: 1;
}

.side-menu::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 0;
  background: linear-gradient(to bottom, transparent, var(--accent-dim), transparent);
  transition: height .7s var(--ease) .1s;
}

.side-menu.active::after {
  height: 100%;
}

.menu-header {
  padding: 44px 22px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--accent-dim);
  gap: 8px;
  flex-shrink: 0;
  border-radius: 0 0 22px 22px;
  border: 1px solid var(--accent-strong);
  border-top: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

.menu-logo-link {
  display: block;
  text-decoration: none;
}

.menu-logo {
  width: 60px;
  transition: transform .35s var(--ease);
}

.menu-logo:hover {
  transform: scale(1.04);
}

.menu-tagline {
  margin-top: 10px;
  font-size: .65rem;
  letter-spacing: .3em;
  color: #111111;
  text-transform: uppercase;
}

.menu-nav {
  flex: 1;
  padding: 14px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}

.menu-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid #e8e8e4;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #111111;
  transition: color .2s, background .2s;
  text-decoration: none;
}

.menu-nav a:hover {
  color: var(--accent-strong);
  background: var(--accent-faint);
}

.menu-nav a.menu-active {
  color: var(--accent-strong);
  font-weight: 500;
  background: var(--accent-faint2);
  border-radius: 4px;
}

/* Único uso del acento en el menú: borde izquierdo del item activo */
.menu-nav a.menu-active {
  border-left: 3px solid var(--accent-strong);
  padding-left: 10px;
}

.menu-nav a.menu-active .menu-icon {
  background: var(--accent);
  color: #fff;
}

.menu-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-strong);
  background: var(--accent-faint2);
  border-radius: 6px;
  transition: color .2s, background .2s;
}

.menu-icon svg {
  width: 14px;
  height: 14px;
}

.menu-nav a:hover .menu-icon {
  background: var(--accent);
  color: #fff;
}

.mt {
  flex: 1;
}

.menu-footer {
  padding: 14px 22px 20px;
  border-top: 1px solid #e8e8e4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.menu-copy {
  font-size: .55rem;
  letter-spacing: .18em;
  color: #111111;
  text-transform: uppercase;
}

/* Landscape: menú compacto */
@media (max-height: 500px) {
  .menu-header {
    padding: 16px 18px 10px;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 10px;
    flex-shrink: 0;
  }

  .menu-logo {
    width: 28px !important;
  }

  .menu-tagline {
    display: none;
  }

  .menu-nav {
    padding: 2px 14px 4px;
    gap: 0;
    flex: 1;
    overflow-y: auto;
  }

  .menu-nav a {
    padding: 5px 8px;
    font-size: .72rem;
    letter-spacing: -.01em;
    gap: 8px;
  }

  .menu-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
  }

  .menu-icon svg {
    width: 11px;
    height: 11px;
  }

  .menu-footer {
    padding: 4px 18px 8px;
    flex-shrink: 0;
  }
}

/* iPhone SE (pantallas ≤ 680px de alto) — menú compacto */
@media (max-height: 680px) and (min-height: 501px) {
  .menu-nav {
    padding: 8px 18px 4px;
    gap: 0;
  }

  .menu-nav a {
    padding: 7px 8px;
    font-size: .74rem;
    gap: 10px;
  }

  .menu-icon {
    width: 23px;
    height: 23px;
    border-radius: 5px;
  }

  .menu-icon svg {
    width: 12px;
    height: 12px;
  }

  .menu-footer {
    padding: 6px 22px 12px;
  }
}
