/* =====================================================================
   04 · COMPONENTES — header, botones, tarjetas, formulario, footer
   ===================================================================== */

/* ---------------------------------------------------------------------
   4.1 HEADER flotante (píldora centrada)
   La opacidad del fondo cambia con el scroll: ver js/sections/header.js
   --------------------------------------------------------------------- */
.header {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 100;
  width: min(760px, calc(100% - 24px));
  transform: translateX(-50%);
}

.header__bar {
  --header-bg: 0.55; /* JS lo anima de 0.55 a 0.94 */
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-h);
  padding: 0 10px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  background: rgba(255, 255, 255, var(--header-bg));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  overflow: hidden;
}

.header__logo img {
  width: 64px;
  height: auto;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 22px);
  margin-left: auto;
  font-size: var(--fs-small);
}

.nav a:not(.btn) {
  position: relative;
  color: var(--c-slate);
}

.nav a:not(.btn)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: var(--c-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-out);
}

.nav a:not(.btn):hover::after,
.nav a[aria-current="true"]::after {
  transform: scaleX(1);
}

.lang {
  display: flex;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--c-slate);
}

.lang a[aria-current="page"] {
  color: var(--c-primary);
  font-weight: 700;
}

/* Barra de progreso de lectura (sincronizada con el scroll) */
.header__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--grad-brand);
  transform: scaleX(0);
  transform-origin: left;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  margin-left: auto;
  border-radius: 10px;
  color: var(--c-primary);
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 20px;
  height: 2px;
  margin: auto;
  background: currentColor;
  transition: transform 0.3s var(--ease-out);
}

.menu-toggle span {
  position: relative;
}

.menu-toggle span::before,
.menu-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }

@media (max-width: 900px) {
  .menu-toggle {
    display: block;
  }

  .header__bar {
    overflow: visible;
  }

  .nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--shadow-soft);
    font-size: 17px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.3s, transform 0.3s var(--ease-out), visibility 0.3s;
  }

  .nav a:not(.btn) {
    padding: 12px 14px;
  }

  .nav .btn {
    margin: 8px 6px 4px;
  }

  .lang {
    justify-content: center;
    padding: 10px;
  }

  .header.is-open .nav {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .header.is-open .menu-toggle span { background: transparent; }
  .header.is-open .menu-toggle span::before { transform: translateY(6px) rotate(45deg); }
  .header.is-open .menu-toggle span::after { transform: translateY(-6px) rotate(-45deg); }
}

/* ---------------------------------------------------------------------
   4.2 BOTONES
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--grad-brand);
  background-size: 160% 100%;
  background-position: 0 0;
  color: #fff;
  font-size: var(--fs-small);
  font-weight: 700;
  white-space: nowrap;
  transition: background-position 0.5s var(--ease-out), transform 0.3s var(--ease-out);
}

.btn:hover {
  background-position: 100% 0;
}

.btn--lg {
  min-height: 52px;
  padding: 0 30px;
  font-size: 17px;
  font-weight: 500;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fff;
  color: var(--c-primary);
  transition: transform 0.3s var(--ease-out);
}

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

/* ---------------------------------------------------------------------
   4.3 TARJETA DE CASO
   --------------------------------------------------------------------- */
.case-card {
  display: block;
  color: #fff;
}

.case-card__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1.25;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.15);
}

.case-card--wide .case-card__media {
  aspect-ratio: 3;
}

.case-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  transform-origin: center;
}

.case-card__word {
  position: absolute;
  left: 4%;
  bottom: 14%;
  z-index: 1;
  color: #fff;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
}

.case-card .btn {
  position: absolute;
  right: 3%;
  bottom: 6%;
  z-index: 1;
  min-height: 36px;
  padding: 0 18px;
  font-size: 13px;
}

.case-card__title {
  margin-top: 16px;
}

.case-card__meta {
  margin-top: 6px;
  font-size: clamp(15px, 1.4vw, 19px);
  opacity: 0.92;
}

/* ---------------------------------------------------------------------
   4.4 FORMULARIO
   --------------------------------------------------------------------- */
.form-card {
  padding: clamp(24px, 3vw, 36px);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.field + .field {
  margin-top: 22px;
}

.field label {
  display: block;
  color: var(--c-primary);
  font-size: 15px;
  font-weight: 500;
}

.field input {
  width: 100%;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--c-line);
  background: transparent;
  outline: 0;
  transition: border-color 0.3s;
}

.field input:focus {
  border-color: var(--c-primary);
}

.field input::placeholder {
  color: rgba(59, 67, 80, 0.55);
}

.form-card .btn {
  margin-top: 28px;
}

.form-note {
  margin-top: 16px;
  font-size: 13px;
}

/* ---------------------------------------------------------------------
   4.5 FOOTER
   --------------------------------------------------------------------- */
.footer {
  padding-block: clamp(56px, 6vw, 80px) 40px;
  background: var(--c-slate);
  color: #fff;
}

.footer__grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  align-items: center;
  gap: 48px;
}

.footer__logo img {
  width: clamp(180px, 20vw, 270px);
}

.footer__addresses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 40px;
  font-size: 14px;
  line-height: 1.45;
}

.footer__addresses strong {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-helvetica);
  font-weight: 700;
  font-size: 1rem;
}

.footer__tail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 36px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer__social {
  display: flex;
  gap: 12px;
}

.footer__social a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  transition: transform 0.3s var(--ease-out);
}

.footer__social a:hover {
  transform: translateY(-3px);
}

@media (max-width: 900px) {
  .footer__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .footer__addresses {
    grid-template-columns: 1fr;
  }

  .footer__tail {
    justify-content: space-between;
  }
}

/* ---------------------------------------------------------------------
   4.6 BOTÓN "VOLVER AL INICIO" (abajo a la derecha)
   Aparece al salir del hero: js/sections/header.js → initToTop
   --------------------------------------------------------------------- */
.to-top {
  position: fixed;
  right: clamp(16px, 2.5vw, 32px);
  bottom: clamp(16px, 2.5vw, 32px);
  z-index: 90;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--grad-brand);
  background-size: 160% 100%;
  color: #fff;
  box-shadow: 0 12px 30px -8px rgba(48, 35, 174, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.35s, visibility 0.35s, transform 0.35s var(--ease-out), background-position 0.5s var(--ease-out);
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.to-top:hover {
  background-position: 100% 0;
  transform: translateY(-3px);
}

/* "Ver caso" sin enlace por ahora (se activará cuando existan las páginas de caso) */
.btn--static {
  cursor: default;
  pointer-events: none;
}

/* Íconos de redes del footer (assets/img/brand/*.svg) */
.footer__social img {
  width: 24px;
  height: 24px;
}

/* Móvil: el botón "volver al inicio" sube para no tapar los íconos del footer */
@media (max-width: 640px) {
  .to-top {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
}
