/* ==========================================================================
   RAHAZO · layout.css
   Topbar, header + navegacion, secciones, grids y footer
   Depende de: tokens.css, base.css
   Partials: partials/topbar.html · partials/header.html · partials/footer.html
   ========================================================================== */

/* --- TOPBAR (HOME_MAP 01) ---------------------------------------------- */
.topbar {
  background: var(--bg-deep);
  border-bottom: var(--border-w) solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--topbar-h);
}

.topbar__since {
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text);
}

.topbar__since strong {
  color: var(--brand-on-dark);
}

.topbar__links {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}

.topbar a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: var(--fw-semibold);
}

.topbar a:hover {
  color: var(--text);
}

.topbar__phone {
  color: var(--cta) !important;
}

@media (max-width: 599px) {
  .topbar__hide-sm { display: none; }
}

/* --- HEADER (HOME_MAP 02) ---------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(17, 18, 20, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: var(--border-w) solid transparent;
  transition:
    border-color var(--dur) ease,
    box-shadow var(--dur) ease,
    background-color var(--dur) ease;
}

.site-header.is-scrolled {
  background: rgba(11, 12, 13, 0.96);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.brand__logo {
  width: auto;
  height: 52px;
  transition: height var(--dur) var(--ease-out);
}

.site-header.is-scrolled .brand__logo {
  height: 44px;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-left: auto;
}

.header-phone {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-bold);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.header-phone svg {
  width: 18px;
  height: 18px;
  color: var(--cta);
}

/* --- NAV: escritorio --------------------------------------------------- */
.nav__list {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  padding: 0;
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
}

.nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

/* Escritorio estrecho: el telefono del header queda solo como icono */
@media (min-width: 1100px) and (max-width: 1319px) {
  .header-phone__label { display: none; }
  .nav__link { padding-inline: var(--sp-2); letter-spacing: 0.04em; }
}

.nav__link:hover,
.nav__item:focus-within > .nav__link,
.nav__link[aria-current] {
  color: var(--text);
}

/* 'page' = pagina actual · 'true' = seccion padre de la pagina actual */
.nav__link[aria-current] {
  box-shadow: inset 0 -2px 0 var(--brand);
}

.nav__sub-toggle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: -6px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.nav__sub-toggle::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--dur) var(--ease-out);
}

.nav__sub-toggle[aria-expanded='true']::before {
  transform: translateY(2px) rotate(-135deg);
}

.nav__submenu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: var(--z-dropdown);
  min-width: 260px;
  padding: var(--sp-2);
  list-style: none;
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out),
    visibility 0s linear var(--dur);
}

.nav__item.is-open > .nav__submenu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

@media (hover: hover) and (min-width: 1100px) {
  .nav__item.has-submenu:hover > .nav__submenu {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
}

.nav__sublink {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.nav__sublink small {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
}

.nav__sublink:hover,
.nav__sublink[aria-current='page'] {
  background: var(--surface-hover);
  color: var(--text);
}

.nav__mobile-extra {
  display: none;
}

/* --- NAV TOGGLE (hamburguesa) ------------------------------------------ */
.nav-toggle {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
}

.nav-toggle__bar {
  position: absolute;
  left: 11px;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition:
    transform var(--dur) var(--ease-out),
    opacity var(--dur-fast) ease;
}

.nav-toggle__bar:nth-child(1) { top: 14px; }
.nav-toggle__bar:nth-child(2) { top: 20px; }
.nav-toggle__bar:nth-child(3) { top: 26px; }

.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* --- NAV: movil / tablet (drawer) -------------------------------------- */
@media (max-width: 1099px) {
  /* backdrop-filter crea un containing block y encogeria el drawer fijo */
  .site-header,
  .site-header.is-scrolled {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--bg-deep);
  }

  .nav-toggle {
    display: inline-block;
  }

  .header-phone__label {
    display: none;
  }

  .nav {
    position: fixed;
    inset: calc(var(--header-h)) 0 0 auto;
    z-index: var(--z-drawer);
    width: min(420px, 100%);
    padding: var(--sp-5) var(--gutter) var(--sp-7);
    overflow-y: auto;
    background: var(--bg-deep);
    border-left: var(--border-w) solid var(--border);
    transform: translateX(100%);
    visibility: hidden;
    transition:
      transform var(--dur) var(--ease-out),
      visibility 0s linear var(--dur);
  }

  .nav.is-open {
    transform: none;
    visibility: visible;
    transition-delay: 0s;
  }

  .nav-backdrop {
    position: fixed;
    inset: calc(var(--header-h)) 0 0 0;
    z-index: calc(var(--z-drawer) - 1);
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) ease, visibility 0s linear var(--dur);
  }

  .nav-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  .nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: var(--border-w) solid var(--border);
  }

  .nav__link {
    flex: 1;
    padding: var(--sp-4) 0;
    font-size: var(--fs-base);
  }

  .nav__link[aria-current] {
    box-shadow: none;
    color: var(--brand-on-dark);
  }

  .nav__sub-toggle {
    width: 44px;
    height: 44px;
    margin: 0;
  }

  .nav__submenu {
    position: static;
    flex-basis: 100%;
    min-width: 0;
    padding: 0 0 var(--sp-3);
    background: none;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
  }

  .nav__item.is-open > .nav__submenu {
    display: block;
  }

  .nav__sublink {
    padding: var(--sp-3) var(--sp-4);
    border-left: 2px solid var(--border);
    border-radius: 0;
  }

  .nav__mobile-extra {
    display: grid;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
  }

  .site-header__actions .btn--cta {
    display: none;
  }
}

@media (max-width: 599px) {
  :root { --header-h: 64px; }
  .brand__logo { height: 40px; }
  .site-header.is-scrolled .brand__logo { height: 36px; }
}

/* --- SECCIONES --------------------------------------------------------- */
.section {
  position: relative;
  padding-block: var(--section-y);
}

.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.section--surface { background: var(--surface); }
.section--deep { background: var(--bg-deep); }
.section--corporate { background: var(--corporate); }
.section--brand { background: var(--brand); color: var(--on-brand); }

.section--light {
  background: var(--blanco-hueso);
  color: var(--negro-asfalto);
  color-scheme: light;
}

.section--light .lead,
.section--light .text-muted { color: #4A4F57; }
.section--light .eyebrow { color: var(--brand); }
.section--light a:not(.btn) { color: var(--azul-carretera); }

.section--brand .eyebrow,
.section--brand .lead { color: var(--on-brand); }

.section--divider {
  border-top: var(--border-w) solid var(--border);
}

.section__head {
  display: grid;
  gap: var(--sp-3);
  max-width: 760px;
  margin-bottom: var(--sp-7);
}

.section__head--center {
  margin-inline: auto;
  text-align: center;
  justify-items: center;
}

.section__head--split {
  max-width: none;
  grid-template-columns: 1fr auto;
  align-items: end;
}

@media (max-width: 899px) {
  .section__head--split { grid-template-columns: 1fr; }
}

.section__title span {
  color: var(--brand-on-dark);
}

.section--light .section__title span { color: var(--brand); }

.section__foot {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-7);
}

/* --- GRIDS ------------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--sp-5);
}

.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }

@media (max-width: 1099px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 699px) {
  .grid--2,
  .grid--3,
  .grid--4 { grid-template-columns: 1fr; }
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: clamp(var(--sp-6), 5vw, var(--sp-9));
}

.split--reverse > :first-child { order: 2; }

@media (max-width: 899px) {
  .split { grid-template-columns: 1fr; }
  .split--reverse > :first-child { order: 0; }
}

/* --- FOOTER (HOME_MAP 16) ---------------------------------------------- */
.site-footer {
  background: var(--bg-deep);
  border-top: 3px solid var(--brand);
  padding-top: var(--sp-8);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: var(--sp-7);
}

@media (max-width: 999px) {
  .footer__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 599px) {
  .footer__grid { grid-template-columns: 1fr; gap: var(--sp-6); }
}

.footer__logo {
  width: auto;
  height: 56px;
  margin-bottom: var(--sp-4);
}

.footer__about {
  max-width: 36ch;
}

.footer__contact {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  list-style: none;
  padding: 0;
}

.footer__contact a {
  color: var(--text);
  font-weight: var(--fw-semibold);
  text-decoration: none;
}

.footer__contact a:hover { color: var(--cta); }

.footer__title {
  margin-bottom: var(--sp-4);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text);
}

.footer__links {
  display: grid;
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
}

.footer__links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer__links a:hover { color: var(--text); }

.footer__social {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.footer__social a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}

.footer__social a:hover {
  color: var(--on-brand);
  background: var(--brand);
  border-color: var(--brand);
}

.footer__social svg { width: 18px; height: 18px; }

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
  padding-block: var(--sp-5);
  border-top: var(--border-w) solid var(--border);
}

.footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  list-style: none;
  padding: 0;
}

.footer__legal a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer__legal a:hover { color: var(--text); }

.footer__credit {
  padding-block: var(--sp-5);
  border-top: var(--border-w) solid var(--border);
  font-size: var(--fs-xs);
  text-align: center;
  color: rgba(148, 152, 159, 0.7);
}

.footer__credit strong { color: var(--brand-on-dark); }
.footer__credit a { color: inherit; }

/* --- MAIN -------------------------------------------------------------- */
main {
  display: block;
}

main:focus {
  outline: none;
}

.footer__credit p { margin: 0; }
.footer__credit p + p { margin-top: 2px; }
.footer__credit p:nth-child(3) { margin-top: var(--sp-2); }

/* El boton flotante de WhatsApp no tapa el credito en movil */
@media (max-width: 720px) {
  .site-footer { padding-bottom: 88px; }
}
