/* ==========================================================================
   Cromo del sitio · diseño "Órbita grafito" (T-56). Se carga después de styles.css.
   Cabecera flotante en píldora de vidrio, desplegables, menú móvil, buscador,
   banda de cierre, pie y botón flotante de WhatsApp. Solo tokens.
   ========================================================================== */

/* ---------- Cabecera ---------- */
.site-header { position: sticky; top: 0; z-index: var(--z-header); height: var(--header-h); pointer-events: none; }
/* En el inicio la barra flota sobre el hero (no ocupa alto en el flujo) */
.site-header--overlay { margin-bottom: calc(-1 * var(--header-h)); }
.site-header__in { position: relative; padding: .75rem clamp(.75rem, 3vw, 2rem) 0; }
.navbar {
    pointer-events: auto;
    max-width: 73.75rem; margin: 0 auto; padding: .5rem .5rem .5rem .75rem;
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    border-radius: 1.125rem; box-shadow: var(--shadow-float);
}
.brand { display: flex; align-items: center; flex: none; min-height: var(--tap); border-radius: var(--r-md); }
.brand img { display: block; width: auto; height: 3rem; }
.logo--light { display: none !important; }
:root[data-theme="light"] .site-header .logo--dark { display: none !important; }
:root[data-theme="light"] .site-header .logo--light { display: block !important; }

/* Enlaces y botones de la barra (clase .nl del diseño) */
.nl {
    display: inline-flex; align-items: center; gap: .375rem; min-height: var(--tap); padding: .625rem .75rem;
    border: 1px solid transparent; border-radius: .625rem; background: none; cursor: pointer;
    color: var(--text-strong); font: inherit; font-size: 1rem; font-weight: var(--fw-medium); text-decoration: none; white-space: nowrap;
    transition: background-color .2s ease, border-color .2s ease;
}
.nl:hover { background: var(--accent-soft); }
.nl--line { border-color: var(--glass-line); font-weight: var(--fw-semibold); }
.nl__caret { width: .875rem; height: .875rem; transition: transform .25s var(--ease-out); }
.nl[aria-expanded="true"] .nl__caret { transform: rotate(180deg); }
.nav-item.is-current > .nl { box-shadow: inset 0 -2px 0 var(--accent-fill); }

.main-nav { min-width: 0; }
.main-nav > ul { display: flex; align-items: center; gap: 2px; }
.nav-item { position: relative; }

/* Panel desplegable (.menu + .mi del diseño) */
.nav-panel {
    position: absolute; left: 50%; top: calc(100% + .75rem); z-index: 5;
    width: 21.25rem; padding: .625rem; border-radius: var(--r-lg);
    background: var(--menu-bg); border: 1px solid var(--glass-line); box-shadow: var(--shadow-menu);
    -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
    opacity: 0; visibility: hidden; transform: translate(-50%, -8px);
    transition: opacity .22s ease, transform .22s var(--ease-out), visibility 0s linear .22s;
}
.nav-panel::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: .875rem; } /* puente para el mouse */
.nav-panel--c2 { width: 37.5rem; }
.nav-item.is-open > .nav-panel,
.no-js .nav-item:focus-within > .nav-panel { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
@media (hover: hover) and (pointer: fine) {
    .nav-item:hover > .nav-panel { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
}
/* El último desplegable se alinea a la derecha para no salirse de la pantalla */
.main-nav .nav-item:last-child > .nav-panel { left: auto; right: 0; transform: translateY(-8px); }
.main-nav .nav-item:last-child.is-open > .nav-panel,
.no-js .main-nav .nav-item:last-child:focus-within > .nav-panel { transform: none; }
@media (hover: hover) and (pointer: fine) { .main-nav .nav-item:last-child:hover > .nav-panel { transform: none; } }

.nav-panel__grid { display: grid; gap: 2px; }
.nav-panel--c2 .nav-panel__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mi { display: flex; gap: var(--sp-3); padding: .75rem; border-radius: var(--r-md); color: var(--text-strong); text-decoration: none; transition: background-color .2s ease; }
.mi:hover, .mi:focus-visible { background: var(--accent-soft); }
.mi__n { flex: none; display: flex; align-items: center; justify-content: center; width: 2.125rem; height: 2.125rem; border-radius: .625rem; background: var(--accent-soft); color: var(--accent); font-size: .8125rem; font-weight: var(--fw-bold); }
.mi__t { display: block; font-size: 1rem; font-weight: var(--fw-semibold); line-height: 1.35; }
.mi__d { display: block; margin-top: 2px; font-size: 1rem; line-height: 1.4; color: var(--text-muted); }
.nav-panel__all { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); margin-top: .375rem; padding: .5rem .75rem 0; border-top: 1px solid var(--glass-line); color: var(--accent); font-weight: var(--fw-semibold); text-decoration: none; }
.nav-panel__all .icon { width: 1rem; height: 1rem; transition: transform var(--dur-fast) var(--ease-out); }
.nav-panel__all:hover .icon { transform: translateX(3px); }

/* Acciones: buscar, tema, consulta, menú */
.header-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid var(--glass-line); background: transparent; color: var(--text-strong); cursor: pointer; transition: background-color .2s ease; }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn .icon { width: 1.25rem; height: 1.25rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
.menu-toggle { display: none; }
.menu-toggle .icon { width: 1.25rem; height: 1.25rem; }
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] .icon-open { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }

/* ---------- Menú móvil (tarjeta bajo la barra) ---------- */
.mobile-menu {
    pointer-events: auto;
    position: absolute; left: clamp(.75rem, 3vw, 2rem); right: clamp(.75rem, 3vw, 2rem); top: calc(100% + .625rem);
    max-width: 73.75rem; margin-inline: auto; padding: .875rem;
    max-height: calc(100dvh - var(--header-h) - 1.5rem); overflow-y: auto; overscroll-behavior: contain;
    border-radius: var(--r-lg); background: var(--menu-bg); border: 1px solid var(--glass-line); box-shadow: var(--shadow-menu);
    -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
}
.mobile-menu[hidden] { display: none; }
/* Sin JS (QA T-56, H-02 y H-13): el enlace "Menú" abre la tarjeta con :target y se ocultan los botones que dependen de JS. */
.has-js .menu-toggle--nojs, .no-js button.menu-toggle, .no-js .theme-toggle { display: none; }
.no-js .mobile-menu:target { display: block; }
body.menu-open { overflow: hidden; } /* bloquea el scroll del fondo con el menú abierto (H-03) */
.mobile-search { margin: 0 0 var(--sp-2); }
.mobile-search input { min-height: var(--tap); }
.mobile-search button { width: var(--tap); min-height: var(--tap); background: var(--accent-fill); color: var(--on-accent); border-color: transparent; }
.mobile-links li { border-bottom: 1px solid var(--line); }
.mobile-links summary, .mobile-links__plain {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    min-height: 3.25rem; padding: 0 .625rem; cursor: pointer; list-style: none;
    font-family: var(--font-display); font-size: 1.25rem; font-weight: var(--fw-semibold); color: var(--text-strong); text-decoration: none;
}
.mobile-links summary::-webkit-details-marker { display: none; }
.mobile-links summary .icon { width: 1.1rem; height: 1.1rem; color: var(--text-muted); transition: transform var(--dur-ui) var(--ease-out); }
.mobile-links details[open] > summary .icon { transform: rotate(180deg); color: var(--accent); }
.mobile-links summary[aria-current] > span { box-shadow: 0 2px 0 var(--accent-fill); }
.mobile-sub { display: grid; padding: 0 0 var(--sp-3) .625rem; }
.mobile-sub a { display: flex; align-items: center; min-height: var(--tap); padding: 0 .625rem; border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.mobile-sub a:hover { background: var(--accent-soft); }
.mobile-sub .mobile-sub__all { color: var(--accent); font-weight: var(--fw-semibold); gap: var(--sp-2); }
.mobile-sub__all .icon { width: 1rem; height: 1rem; }
.mobile-menu-foot { display: grid; gap: var(--sp-2); margin-top: var(--sp-4); }
.mobile-menu-foot .btn { width: 100%; }

@media (max-width: 1180px) {
    .main-nav { display: none; }
    .menu-toggle { display: inline-flex; }
}
@media (max-width: 640px) {
    .header-cta, .header-search { display: none; }
    .brand img { height: 2.5rem; }
    .navbar { padding: .375rem .375rem .375rem .625rem; }
    .menu-toggle__txt { display: none; }
    .menu-toggle { width: var(--tap); justify-content: center; padding: 0; }
}

/* ---------- Buscador (ventana) ---------- */
.search-dialog { border-radius: var(--r-xl); background: var(--menu-bg); }
.search-dialog::backdrop { background: var(--shade); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.search-dialog__form:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.search-dialog__form input::placeholder { color: var(--text-dim); }
.search-dialog__close { border-radius: var(--r-pill); }
.search-dialog__close kbd { font: inherit; font-size: .75rem; line-height: 1; padding: .2rem .35rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--text-dim); }
.search-dialog__status { padding: var(--sp-3) var(--sp-5); }
.search-dialog__list:empty { display: none; }
@media (max-width: 600px) { .search-dialog__close kbd { display: none; } }

/* ---------- Banda de cierre (#o-cta) ---------- */
.cta-band { position: relative; overflow: hidden; padding-block: clamp(4.5rem, 8vw, 6.25rem); background: var(--glow); }
.cta-band__in { position: relative; }
.cta-band__title { max-width: 55rem; font-size: clamp(2.375rem, 1.2rem + 4.6vw, 5.5rem); }
.cta-band__title em { font-style: normal; color: var(--accent); }
.cta-band__lead { margin-top: var(--sp-5); max-width: 35rem; font-size: var(--fs-lg); line-height: 1.6; color: var(--text-muted); }
.cta-band__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: 1.875rem; }
.cta-band__ring { position: absolute; left: 86%; top: 50%; width: 32.5rem; height: 32.5rem; border-radius: 50%; border: 1px solid var(--accent-fill); transform: translate(-50%, -50%); }
.cta-band__dot { position: absolute; left: 50%; top: 0; width: .625rem; height: .625rem; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); }
@media (prefers-reduced-motion: no-preference) { .cta-band__ring { animation: orbit 60s linear infinite; } }
@keyframes orbit { to { transform: translate(-50%, -50%) rotate(360deg); } }
@media (max-width: 1020px) { .cta-band__ring { display: none; } }
@media (max-width: 480px) { .cta-band__actions .btn { width: 100%; white-space: normal; } }

/* ---------- Pie ---------- */
.site-footer { padding: 5rem 0 2.25rem; border-top: 1px solid var(--line); color: var(--text-muted); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.75rem), 1fr)); gap: var(--sp-10); }
.footer-brand__logo { display: inline-block; border-radius: var(--r-sm); }
.footer-brand__logo img { display: block; width: 15rem; max-width: 100%; height: auto; }
.footer-brand p { margin-top: var(--sp-5); font-size: var(--fs-base); line-height: 1.6; }
.footer-title { font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--accent); }
.footer-links, .footer-contact { margin-top: var(--sp-3); font-size: var(--fs-base); }
.footer-links a { display: flex; align-items: center; min-height: var(--tap); text-decoration: none; transition: color var(--dur-fast) ease; }
.footer-links a:hover, .footer-contact a:hover { color: var(--accent); }
.footer-contact li { display: flex; align-items: flex-start; gap: var(--sp-3); padding-block: .625rem; line-height: 1.45; }
.footer-contact .icon { flex: none; width: 1.1em; height: 1.1em; margin-top: .2em; color: var(--accent); }
.footer-contact a { display: inline-flex; flex-direction: column; justify-content: center; min-height: var(--tap); text-decoration: none; }
.footer-contact li { align-items: center; }
.footer-contact strong { display: block; color: var(--text-strong); font-weight: var(--fw-semibold); }
.footer-contact a span { display: block; }
.footer-legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-3); margin-top: 3.5rem; padding: 1.375rem 0 5.5rem; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-muted); }
.footer-legal a { color: var(--text-strong); text-underline-offset: 3px; }
.footer-legal__link { display: inline-flex; align-items: center; min-height: var(--tap); }
@media (min-width: 900px) { .footer-legal { padding-bottom: 0; } }

/* ---------- WhatsApp flotante ---------- */
.wa-float {
    position: fixed; right: 1.5rem; bottom: max(1.5rem, env(safe-area-inset-bottom)); z-index: var(--z-actionbar);
    display: flex; align-items: center; justify-content: center; width: 3.75rem; height: 3.75rem; border-radius: 50%;
    background: var(--cta); color: var(--on-cta); box-shadow: 0 14px 30px -12px var(--shade); text-decoration: none;
    transition: transform .25s var(--ease-out), opacity .25s ease, visibility 0s linear 0s;
}
.wa-float:hover { background: var(--cta-hover); transform: scale(1.07); }
.wa-float .icon { width: 1.75rem; height: 1.75rem; }
.wa-float__pulse { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--cta); pointer-events: none; }
.wa-float-label {
    position: absolute; right: 4.5rem; top: 50%; padding: .5rem .75rem; border-radius: .625rem; white-space: nowrap;
    background: var(--menu-bg); color: var(--text-strong); border: 1px solid var(--glass-line); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
    opacity: 0; pointer-events: none; transform: translate(6px, -50%); transition: opacity .25s ease, transform .25s ease;
}
.wa-float:hover .wa-float-label, .wa-float:focus-visible .wa-float-label { opacity: 1; transform: translate(0, -50%); }
/* Se aparta cuando hay en pantalla un CTA o aviso que taparía (data-wa-avoid) o con el menú abierto */
.wa-float.is-away, body.menu-open .wa-float { opacity: 0; visibility: hidden; transform: scale(.8); pointer-events: none; transition: transform .25s var(--ease-out), opacity .25s ease, visibility 0s linear .25s; }
@media (max-width: 640px) {
    .wa-float { right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); width: 3.5rem; height: 3.5rem; }
    .wa-float-label { display: none; }
    .no-js .wa-float { display: none; } /* sin JS no se puede apartar: los CTA de la página bastan */
}
@media (prefers-reduced-motion: no-preference) {
    .wa-float__pulse { animation: wa-pulse 2.4s ease-out infinite; }
}
@keyframes wa-pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .nav-panel, .nl, .nl__caret, .wa-float, .wa-float-label, .mobile-links summary .icon, .nav-panel__all .icon { transition: none; }
    .wa-float:hover { transform: none; }
}
