/* =========================================================================
   layout.css — header sticky, navegación, footer, global-page-header, CTA
   ========================================================================= */

/* -------- Skip link (a11y) -------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--ink-900);
  color: #fff;
  padding: 0.75rem 1.25rem;
  z-index: 1000;
  text-decoration: none;
  font-weight: 500;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
  color: #fff;
  outline: 3px solid var(--brand);
}

/* -------- Focus visible global -------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* -------- Header sticky -------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, padding 0.2s ease;
}

.site-header.is-scrolled {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding-block: 0.75rem;
}

.site-header__brand img {
  width: 13rem;
  max-width: 100%;
}

.site-header__seals { display: flex; align-items: center; gap: 0.5rem; margin-left: 0.35rem; margin-right: auto; }
.site-header__seals img { width: 2.6rem; height: 2.6rem; object-fit: contain; display: block; }
.site-header__seals a { display: block; line-height: 0; }
@media (max-width: 900px) { .site-header__seals { display: none; } }

/* -------- Nav -------- */
.site-nav__toggle {
  background: none;
  border: 0;
  padding: 0.5rem;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.site-nav__toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--ink-700);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-nav__list {
  display: none;
  flex-direction: column;
  gap: 0;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem 1rem;
  box-shadow: var(--shadow-md);
}

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

.site-nav__list a {
  display: block;
  padding: 0.75rem 0.5rem;
  color: var(--ink-700);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.site-nav__list li:last-child a {
  border-bottom: 0;
}

.site-nav__list a:hover,
.site-nav__list a[aria-current] {
  color: var(--brand);
}

/* CTA de contacto en la nav (antes style inline) */
.site-nav__list a.site-nav__cta,
.site-nav__list a.site-nav__cta:hover {
  color: #fff;
  text-transform: none;
}

/* -------- Dropdown Insumos (2.4) -------- */
.site-nav__item--sub {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.site-nav__item--sub > a {
  flex: 1;
}

.site-nav__subtoggle {
  background: none;
  border: 0;
  padding: 0.6rem 0.75rem;
  display: inline-flex;
  align-items: center;
  color: var(--ink-700);
  cursor: pointer;
}

.site-nav__subtoggle ion-icon {
  font-size: 1.05rem;
  transition: transform 0.2s ease;
}

.site-nav__item--sub.is-sub-open .site-nav__subtoggle ion-icon {
  transform: rotate(180deg);
}

.site-nav__sub {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Móvil: submenú colapsable dentro del panel */
@media (max-width: 991.98px) {
  .site-nav__sub {
    display: none;
    border-left: 2px solid var(--indigo-100, #e0e7ff);
    margin: 0 0 0.5rem 0.5rem;
  }
  .site-nav__item--sub.is-sub-open .site-nav__sub {
    display: block;
  }
  .site-nav__sub a {
    font-size: 0.8rem;
    text-transform: none;
    padding: 0.55rem 0.9rem;
    border-bottom: 0;
  }
  .site-nav__sub-all a {
    font-weight: 700;
    color: var(--brand);
  }
}

/* Desktop: dropdown flotante por hover / focus / click */
@media (min-width: 992px) {
  .site-nav__subtoggle {
    padding: 0.5rem 0.15rem 0.5rem 0;
    margin-left: -0.55rem;
  }
  .site-nav__sub {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 268px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 12px 30px rgba(30, 27, 75, 0.14));
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 50;
  }
  .site-nav__item--sub:hover .site-nav__sub,
  .site-nav__item--sub:focus-within .site-nav__sub,
  .site-nav__item--sub.is-sub-open .site-nav__sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .site-nav__sub a {
    text-transform: none;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border-bottom: 0;
  }
  .site-nav__sub a:hover {
    background: var(--indigo-50, #eef2ff);
    color: var(--brand);
  }
  .site-nav__sub-all {
    border-top: 1px solid var(--border);
    margin-top: 0.35rem;
    padding-top: 0.35rem;
  }
  .site-nav__sub-all a {
    font-weight: 700;
    color: var(--brand);
  }
}

@media (min-width: 992px) {
  .site-nav__toggle {
    display: none;
  }

  .site-nav__list {
    display: flex;
    flex-direction: row;
    position: static;
    padding: 0;
    border: 0;
    box-shadow: none;
    gap: 0.25rem;
  }

  .site-nav__list a {
    padding: 0.5rem 0.9rem;
    border-bottom: 0;
  }
}

/* -------- Global page header (subpáginas) -------- */
.global-page-header {
  background: linear-gradient(135deg, var(--indigo-950) 0%, var(--indigo-800) 55%, var(--indigo-700) 100%);
  color: #fff;
  text-align: center;
  padding: 4rem 0 1.5rem;
}

.global-page-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .global-page-header {
    padding: 5rem 0 2rem;
  }
  .global-page-header h1 {
    font-size: 2.625rem;
  }
}

/* Trazabilidad: foto del software de fondo (scoped, solo esta página) */
.global-page-header--photo {
  position: relative;
  background-image:
    linear-gradient(135deg, rgba(30, 27, 75, 0.95) 0%, rgba(49, 46, 129, 0.9) 45%, rgba(67, 56, 202, 0.74) 100%),
    url("../img/trazabilidad-header-software.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
@media (min-width: 768px) {
  .global-page-header--photo {
    padding: 6rem 0 3rem;
  }
}

/* Contacto: foto de asesoría de fondo (scoped, solo esta página) */
.global-page-header--contact {
  position: relative;
  background-image:
    linear-gradient(135deg, rgba(30, 27, 75, 0.94) 0%, rgba(49, 46, 129, 0.88) 48%, rgba(67, 56, 202, 0.72) 100%),
    url("../img/contacto-asesoria.png");
  background-size: cover;
  background-position: center 35%;
  background-repeat: no-repeat;
}
@media (min-width: 768px) {
  .global-page-header--contact {
    padding: 6rem 0 3rem;
  }
}

/* Empresa: foto de planta de fondo (scoped, solo esta página) */
.global-page-header--empresa {
  position: relative;
  background-image:
    linear-gradient(135deg, rgba(30, 27, 75, 0.94) 0%, rgba(49, 46, 129, 0.88) 48%, rgba(67, 56, 202, 0.72) 100%),
    url("../img/planta-empaque-matachana.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
@media (min-width: 768px) {
  .global-page-header--empresa {
    padding: 6rem 0 3rem;
  }
}

.breadcrumb {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  font-size: 1rem;
  padding: 0.5rem 0;
  margin: 0;
  flex-wrap: wrap;
  list-style: none;
}

.breadcrumb li {
  list-style: none;
}

.breadcrumb a,
.breadcrumb li {
  color: #fff;
}

.breadcrumb a:hover {
  opacity: 0.85;
}

.breadcrumb__sep {
  opacity: 0.7;
}

/* -------- CTA fijo inferior en móvil (2.6) -------- */
.mobile-cta {
  display: none;
}

@media (max-width: 759.98px) {
  .mobile-cta {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }
  .mobile-cta.is-visible {
    transform: translateY(0);
    visibility: visible;
  }
  .mobile-cta__btn {
    display: block;
    width: 100%;
    text-align: center;
  }
  /* que el CTA no tape el final del footer */
  body.has-mobile-cta .ftr {
    padding-bottom: 5.5rem;
  }
}

/* -------- Call to action -------- */
.cta {
  background: linear-gradient(135deg, var(--indigo-950) 0%, var(--indigo-800) 60%, var(--indigo-700) 100%);
  color: #fff;
  text-align: center;
  padding: 5.5rem 0;
}

.cta h2 {
  color: #fff;
  margin-bottom: 0.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

.cta p {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  margin-bottom: 1.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.95rem 1.9rem;
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn ion-icon {
  font-size: 1.15em;
}

.btn--cta {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

.btn--cta:hover {
  background: var(--brand);
  color: #fff;
}

.btn--primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 8px 20px rgba(67, 56, 202, 0.25);
}

.btn--primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
  box-shadow: 0 12px 26px rgba(49, 46, 129, 0.32);
}

/* Botón secundario: contorno índigo sobre claro */
.btn--ghost {
  background: transparent;
  color: var(--brand-700);
  border-color: var(--indigo-200);
}

.btn--ghost:hover {
  background: var(--indigo-50);
  border-color: var(--brand);
  color: var(--brand-700);
}

/* Botón claro sobre superficies índigo oscuras */
.btn--on-dark {
  background: #fff;
  color: var(--brand-700);
  border-color: #fff;
}

.btn--on-dark:hover {
  background: var(--indigo-100);
  border-color: var(--indigo-100);
  color: var(--brand-700);
}

.btn--outline-light {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.btn--outline-light:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
  color: #fff;
}

.btn--dark {
  background: var(--dark-cta);
  color: #fff;
  border-color: var(--dark-cta);
}

/* -------- Footer rico compartido (.ftr) — movido desde home-v2.css -------- */
.ftr { background: var(--indigo-950); color: #c9cdec; padding: 3.5rem 0 1.6rem; font-size: 0.92rem; }
.ftr a { color: #c9cdec; }
.ftr a:hover { color: #fff; }
.ftr__grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 2.2rem; margin-bottom: 2.4rem; }
.ftr__brand img { height: 46px; width: auto; margin-bottom: 0.9rem; }
.ftr__brand p { color: #9aa0d8; font-size: 0.9rem; max-width: 34ch; margin: 0 0 1.1rem; }
.ftr__seals { display: flex; gap: 0.7rem; }
.ftr__seals img { height: 46px; width: auto; background: #fff; padding: 5px; border-radius: 8px; }
.ftr h4 { color: #fff; font-family: var(--mono, "IBM Plex Mono", ui-monospace, Menlo, monospace); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; margin: 0 0 0.9rem; font-weight: 600; }
.ftr ul { list-style: none; padding: 0; margin: 0; }
.ftr li { margin-bottom: 0.55rem; }
.ftr__bottom { border-top: 1px solid #2c3168; padding-top: 1.3rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: #8c92c4; }
.ftr__bottom a { color: #8c92c4; }
.ftr__social { display: flex; gap: 0.6rem; }
.ftr__social a { width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; }
@media (max-width: 992px) {
  .ftr__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .ftr__grid { grid-template-columns: 1fr; }
}

/* -------- Footer legacy -------- */
.site-footer {
  background: var(--bg);
  padding: 1.5rem 0;
  color: var(--ink-500);
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

.site-footer__copy {
  font-size: 0.8rem;
  margin: 0;
}

.site-footer__copy a {
  color: var(--brand);
}

.site-footer__social {
  display: flex;
  gap: 1rem;
}

.site-footer__social a {
  color: var(--brand);
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
}

@media (min-width: 768px) {
  .site-footer__inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* -------- Reveal on scroll (sustituto de WOW.js) -------- */
html.js .reveal,
html.js .reveal--left,
html.js .reveal--right,
html.js .reveal--down {
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.reveal {
  transform: translateY(24px);
}

.reveal--left {
  transform: translateX(-30px);
}

.reveal--right {
  transform: translateX(30px);
}

.reveal--down {
  transform: translateY(-24px);
}

html.js .reveal.is-visible,
html.js .reveal--left.is-visible,
html.js .reveal--right.is-visible,
html.js .reveal--down.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger escalonado para grids de tarjetas (feature + service) */
.feature-grid > .reveal:nth-child(1),
.service-grid > .reveal:nth-child(1) {
  --reveal-delay: 0ms;
}
.feature-grid > .reveal:nth-child(2),
.service-grid > .reveal:nth-child(2) {
  --reveal-delay: 120ms;
}
.feature-grid > .reveal:nth-child(3),
.service-grid > .reveal:nth-child(3) {
  --reveal-delay: 240ms;
}
.feature-grid > .reveal:nth-child(4),
.service-grid > .reveal:nth-child(4) {
  --reveal-delay: 360ms;
}
.feature-grid > .reveal:nth-child(5),
.service-grid > .reveal:nth-child(5) {
  --reveal-delay: 480ms;
}
.feature-grid > .reveal:nth-child(6),
.service-grid > .reveal:nth-child(6) {
  --reveal-delay: 600ms;
}

.about-feature > .reveal:nth-child(1) {
  --reveal-delay: 0ms;
}
.about-feature > .reveal:nth-child(2) {
  --reveal-delay: 150ms;
}
.about-feature > .reveal:nth-child(3) {
  --reveal-delay: 300ms;
}

.contact-details__grid > .reveal:nth-child(1) {
  --reveal-delay: 0ms;
}
.contact-details__grid > .reveal:nth-child(2) {
  --reveal-delay: 150ms;
}
.contact-details__grid > .reveal:nth-child(3) {
  --reveal-delay: 300ms;
}

.stats-grid > .reveal:nth-child(1) {
  --reveal-delay: 0ms;
}
.stats-grid > .reveal:nth-child(2) {
  --reveal-delay: 120ms;
}
.stats-grid > .reveal:nth-child(3) {
  --reveal-delay: 240ms;
}
.stats-grid > .reveal:nth-child(4) {
  --reveal-delay: 360ms;
}
.stats-grid > .reveal:nth-child(5) {
  --reveal-delay: 480ms;
}
.stats-grid > .reveal:nth-child(6) {
  --reveal-delay: 600ms;
}

.results-grid > .reveal:nth-child(1) {
  --reveal-delay: 0ms;
}
.results-grid > .reveal:nth-child(2) {
  --reveal-delay: 150ms;
}

@media (prefers-reduced-motion: reduce) {
  html.js .reveal,
  html.js .reveal--left,
  html.js .reveal--right,
  html.js .reveal--down {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
