/* ===========================
   NAV + STICKY + FOOTER (global)
   =========================== */

/* --- Sticky CTA (global) --- */
:root{
  --sticky-h:52px; /* altura del CTA inferior */
}

.sticky{
  position:fixed; left:0; right:0; bottom:0;
  background:rgba(255,255,255,.44);
  backdrop-filter:blur(10px);
  border-top:1px solid var(--line);
  padding:8px 12px calc(8px + env(safe-area-inset-bottom));
  min-height:var(--sticky-h);
  display:flex; gap:10px; justify-content:center; align-items:center;
  z-index:50;
}

.sticky .btn{
  padding:10px 14px;
  font-size:15px;
  border-radius:12px;
}

.sticky .cta-text-desktop{ display:none; }
.sticky .cta-text-mobile{ display:inline; }
@media (min-width:700px){
  .sticky .cta-text-desktop{ display:inline; }
  .sticky .cta-text-mobile{ display:none; }
}

/* Ajuste de espacio inferior para que el footer no quede tapado */
footer{
  padding-bottom: calc(var(--sticky-h) + env(safe-area-inset-bottom) + 6px) !important;
}
main{
  padding-bottom: 0 !important;
}

/* --- Footer --- */
.site-footer{
  text-align:left;
  padding:8px 0 calc(var(--sticky-h) + env(safe-area-inset-bottom) + 8px);
  color:#6e6e73;
  border-top:1px solid var(--line);
}
.site-footer .footer-card{ padding:16px; }

.site-footer .footer-grid{
  display:grid;
  gap:16px;
  grid-template-columns: 1fr;      /* móvil */
  align-items:stretch;
}
@media (min-width:700px){
  .site-footer .footer-grid{ grid-template-columns: 1.2fr 1fr; }
}
@media (min-width:960px){
  .site-footer .footer-grid{ grid-template-columns: 2fr 1fr 1fr 1fr; }
}

.site-footer .footer-brand{
  display:flex; flex-direction:column;
  justify-content:center; align-items:center;
  text-align:center; min-height:100%; padding:8px 6px;
}
.site-footer .footer-logo{
  width:56px; height:56px; margin:-2px auto 8px;
  background-color: currentColor;
  -webkit-mask: url('/assets/img/xtudiolab-footer.webp') center / contain no-repeat;
          mask: url('/assets/img/xtudiolab-footer.webp') center / contain no-repeat;
}
.site-footer .footer-brand .brand{
  font-weight:400; letter-spacing:-.02em; font-size:18px; margin:0 0 6px;
}
.site-footer .footer-brand .line{ display:block; margin:2px 0; }

.site-footer .footer-col h4{
  margin:0 0 8px; font-size:14px; letter-spacing:.08em;
  text-transform:uppercase; color:#111827;
}
.site-footer .footer-col ul{ list-style:none; padding:0; margin:0; }
.site-footer .footer-col li + li{ margin-top:6px; }
.site-footer .footer-col a{
  color:inherit; text-decoration:none; padding:4px 0; border-radius:8px;
}
.site-footer .footer-col a:hover{
  color:var(--copper); background:rgba(0,0,0,.02);
}

/* --- NAV (header pegajoso) --- */
.nav{
  position:sticky; top:0; z-index:60;
  background: rgba(255,255,255,.52);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
  transition: background .25s ease;
}
.nav.scrolled{ background: rgba(255,255,255,.70) !important; }

.nav .wrap{
  max-width:var(--container-max);
  margin:0 auto;
  padding:10px 20px;
  display:flex; align-items:baseline; justify-content:space-between;
}

.nav .brand{
  display:inline-block;
  font-weight:800;
  letter-spacing:-0.02em;
  font-size:18px; line-height:1;
  padding:12px 10px;
  border-radius:10px;
}
.nav img{ display:none !important; } /* marca solo texto */

.nav ul{ list-style:none; display:flex; gap:16px; margin:0; padding:0; align-items:baseline; }
.nav a{ padding:8px 10px; border-radius:10px; }
.nav a.btn-nav{
  border:1px solid var(--copper-border);
  background:linear-gradient(180deg,rgba(var(--copper-rgb),.18),rgba(var(--copper-rgb),.10));
}

.nav-toggle{ display:none; }

/* Desktop: refinado de menú y CTA a la derecha */
@media (min-width:821px){
  .nav .wrap{ padding-top: 1px; padding-bottom: 1px; } /* nav más bajo */
  .nav .brand,
  .nav .main-menu > li > a,
  .cta-nav{
    padding-top: 5px !important;
    padding-bottom: 5px !important;
    line-height:1;
  }

  .nav .main-menu{ gap: 40px; display:flex; align-items:baseline; }
  .nav .main-menu > li > a{
    padding: 14px 0; font-size: 16px; font-weight: 500; transition: color .2s ease;
  }
  .nav .main-menu > li > a:hover{ color: var(--copper); }

  .nav .wrap a.cta-nav{
    padding: 12px 22px; border-radius:999px; white-space:nowrap;
  }
}

/* CTA nav */
.cta-nav{
  display:inline-flex; align-items:center; gap:8px;
  padding:10px 14px; border-radius:999px;
  border:1px solid rgba(var(--copper-rgb),.22);
  background:linear-gradient(180deg,rgba(255,255,255,.80),rgba(255,255,255,.60));
  font-weight:800; letter-spacing:.2px; line-height:1;
  transition:background .15s ease,border-color .15s ease,transform .12s ease,box-shadow .12s ease;
}
.cta-nav:hover{
  background:linear-gradient(180deg,rgba(var(--copper-rgb),.28),rgba(var(--copper-rgb),.16));
  border-color:rgba(var(--copper-rgb),.35);
  transform:translateY(-1px);
  box-shadow:0 8px 22px rgba(0,0,0,.08);
}
.nav.scrolled .cta-nav{
  background:linear-gradient(180deg,rgba(255,255,255,.86),rgba(255,255,255,.70));
}

.nav .push-right{ margin-left:auto; }

/* MÓVIL */
@media (max-width:820px){
  .nav .brand{ margin-right:auto; }

  .nav-toggle{
    display:inline-flex; align-items:center; justify-content:center;
    width:36px; height:36px;
    border:1px solid var(--line); border-radius:10px;
    background:rgba(255,255,255,.9); backdrop-filter:blur(8px);
    -webkit-appearance:none; appearance:none;
    cursor:pointer; position:relative; z-index:90; font-size:0; transition:all .2s ease;
  }
  .nav-toggle::before{
    content:""; width:18px; height:2px; background:#333; border-radius:2px;
    box-shadow:0 -6px 0 #333, 0 6px 0 #333;
    transition:transform .25s ease, box-shadow .2s ease, background .2s ease;
  }
  .nav.open .nav-toggle::before{ box-shadow:none; transform:rotate(45deg); }
  .nav.open .nav-toggle::after{
    content:""; position:absolute; width:18px; height:2px; background:#333; border-radius:2px; transform:rotate(-45deg);
  }

  .nav .main-menu{
    display:none; opacity:0; transform:translateY(-10px); pointer-events:none;
  }
  .nav.open .main-menu{
    display:flex;
    position:fixed; left:12px; right:12px; top:56px;
    flex-direction:column; gap:6px; padding:10px;
    background:var(--surface);
    backdrop-filter:blur(12px) saturate(140%);
    border:1px solid var(--line); border-radius:14px;
    z-index:2000; box-shadow:0 12px 24px rgba(0,0,0,.08);
    pointer-events:auto;
    animation:glassMenu .25s ease forwards;
  }
  @keyframes glassMenu{
    0%{opacity:0; transform:translateY(-10px);}
    100%{opacity:1; transform:translateY(0);}
  }

  /* El dropdown en móvil se “abre” en flujo */
  .nav .has-drop .drop{
    position:static; border:none; box-shadow:none; padding:0; background:transparent;
  }

  /* Centrado vertical perfecto del brand */
  .nav .wrap{
    display:flex; align-items:center !important;
    padding-top: 4px !important; padding-bottom: 4px !important;
  }
  .nav .brand{ display:flex; align-items:center; line-height:1; padding-top:0 !important; padding-bottom:0 !important; }
}

/* DROPDOWN (.trigger + .drop) */
.nav .has-drop{ position:relative; }
.nav .has-drop .trigger{
  display:inline-block; cursor:pointer; padding:12px 10px; border-radius:10px;
  transition:color .2s ease, background .2s ease;
}
.nav .has-drop .trigger:hover{ color:var(--copper); }

/* Marcado visual cuando está abierto (teclado/móvil) */
.nav .has-drop .trigger[aria-expanded="true"]{ color: var(--copper); }

/* Panel flotante (desktop) */
.nav .has-drop .drop{
  position:absolute; left:0; top: calc(100% + 2px);
  min-width:240px;
  background:var(--surface);
  backdrop-filter:blur(12px) saturate(140%);
  border:1px solid var(--line); border-radius:14px;
  padding:8px; box-shadow:var(--shadow);
  display:none; flex-direction:column; z-index:999;
  transition: opacity .15s ease, transform .15s ease;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
}
.nav .has-drop:hover .drop{
  display:flex; opacity:1; transform: translateY(0); pointer-events:auto;
}
.nav .has-drop .drop a{
  display:block; padding:10px 12px; border-radius:8px; transition:background .2s ease, color .2s ease;
}
.nav .has-drop .drop a:hover{
  background:rgba(var(--copper-rgb),.08); color:var(--copper);
}

/* Cuando está abierto por clase, que sea clicable e igual de visible que en :hover */
.nav .has-drop.is-open .drop{
  display:flex;
  opacity:1;
  transform: translateY(0);
  pointer-events:auto;
}

/* Zona invisible para mantener hover estable */
.nav .has-drop::after{
  content:""; position:absolute; left:0; right:0; top:100%; height:12px;
}

/* --- Offset de anclas según altura de nav --- */
:root{ --nav-offset: 56px; }
@media (min-width:821px){ :root{ --nav-offset: 48px; } }
[id]{ scroll-margin-top: calc(var(--nav-offset) + 8px); }

/* Scroll suave */
html{ scroll-behavior: smooth; }

/* --- iOS VisualViewport fix y artefactos con blur/scroll --- */
html.ios-vv .sticky{ bottom: var(--ios-vv-bottom, 0px) !important; }
html.ios-vv .nav{ top: var(--ios-vv-top, 0px) !important; }

.nav, .sticky{
  transform: translateZ(0);
  will-change: transform;
}

.sticky.is-hidden{
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
}

@media (max-width: 820px){
  /* mostrar el dropdown en móvil cuando el trigger está abierto */
  .nav .has-drop.is-open .drop,
  .nav .has-drop .trigger[aria-expanded="true"] + .drop{
    display: grid;
  }
}

/* === Footer móvil: centrar contenido y enlaces === */
@media (max-width: 700px){
  .site-footer{
    text-align: center !important;
  }
  .site-footer .footer-grid{
    justify-items: center;   /* centra cada “columna” */
    gap: 50px;
  }
  .site-footer .footer-brand,
  .site-footer .footer-col{
    text-align: center;      /* títulos y textos centrados */
  }
  .site-footer .footer-col ul{
    text-align: center;      /* centra los enlaces */
  }
  .site-footer .footer-col a{
    display: inline-block;   /* ancho justo y centrado */
    padding: 6px 8px;
  }
}

/* ===== Dropdown principal (Servicios) ===== */
.has-drop { position: relative; }
.has-drop .drop {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;            /* cerrado por defecto */
  margin-top: 0;            /* sin salto que cree hueco */
  padding-top: 8px;         /* pequeño colchón interno */
}
.has-drop.is-open .drop { display: block; }

/* Puente invisible para que no se cierre al bajar el puntero */
.has-drop .drop::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -10px; height: 10px;
}

/* ===== Submenú anidado: “Informes y certificados” ===== */
.drop .has-subdrop { position: relative; }
.drop .has-subdrop .group-label { display: block; }

/* Estado base cerrado; el JS lo abre con .sub-open */
.drop .has-subdrop > .subdrop {
  display: none;
  margin-top: 6px;
  padding-left: 12px;       /* jerarquía visual */
  border-left: 1px solid var(--line);
}

/* Abrir solo por JS (no por :hover) */
.has-drop .drop .has-subdrop:hover > .subdrop,
.has-drop .drop .has-subdrop:focus-within > .subdrop {
  display: none !important;
}
.drop .has-subdrop.sub-open > .subdrop {
  display: block !important;
}

/* Items del submenú “hijos” */
.drop .subdrop a {
  display: block;
  font-size: .95em;
  padding: 4px 0;
}
