/* ── Tokens ────────────────────────────────────────── */
:root {
  --primary:       #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-light: #3B82F6;
  --accent:        #60A5FA;
  --pale:          #EFF6FF;
  --pale2:         #DBEAFE;
  --white:         #FFFFFF;
  --ink:           #0E1726;
  --ink-2:         #334155;
  --muted:         #64748B;
  --muted-2:       #94A3B8;
  --line:          #E7EBF1;
  --surface:       #F7F9FC;
  --surface-2:     #EEF3FB;
  --green:         #16A34A;

  --radius:        14px;
  --radius-lg:     22px;
  --radius-xl:     34px;

  --shadow-sm:     0 2px 10px rgba(15,23,42,.05);
  --shadow:        0 14px 40px -18px rgba(15,23,42,.22);
  --shadow-lg:     0 40px 80px -32px rgba(15,23,42,.34);
  --shadow-blue:   0 18px 40px -16px rgba(37,99,235,.45);

  --ease:          .4s cubic-bezier(.22,1,.36,1);
  --ease-fn:       cubic-bezier(.22,1,.36,1);
  --gutter:        clamp(20px, 5vw, 48px);
}

/* ── Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  position: relative;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  letter-spacing: -.01em;
  color: var(--ink-2);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Foto de fondo fija + película negra */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
}
body::before {
  background: center/cover no-repeat;
  background-image: url('../img/hub-bg-hospital.jpg');
  background-image: image-set(url('../img/hub-bg-hospital.webp') type('image/webp'), url('../img/hub-bg-hospital.jpg') type('image/jpeg'));
  will-change: transform;
}
body::after {
  z-index: -1;
  background: linear-gradient(180deg, rgba(6,10,18,.74), rgba(6,10,18,.84));
}

img { display: block; max-width: 100%; height: auto; }
a   { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  line-height: 1.14;
  letter-spacing: -.015em;
  color: var(--ink);
  font-weight: 600;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ── Header ────────────────────────────────────────── */
.hub-header {
  padding: 20px 0;
}
.hub-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 10px;
  padding-inline: clamp(14px, 3vw, 22px);
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 100px;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.hub-logo img { height: 34px; width: auto; }
.hub-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}
.hub-back:hover { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.22); }
.hub-back i { font-size: 12px; }

/* ── Hero ──────────────────────────────────────────── */
.hub-hero {
  padding: clamp(28px, 6vw, 56px) 0 clamp(20px, 5vw, 40px);
  text-align: center;
}
.hub-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary-light);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  padding: 8px 16px;
  border-radius: 100px;
  margin-bottom: 18px;
}
.hub-title {
  font-size: clamp(27px, 5vw, 46px);
  max-width: 780px;
  margin-inline: auto;
  color: var(--white);
  letter-spacing: -.005em;
}
.hub-title span { color: var(--accent); }
.hub-lead {
  max-width: 720px;
  margin: 24px auto 0;
  color: rgba(255,255,255,.88);
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 500;
  line-height: 1.6;
  text-wrap: balance;
}

/* Chips de especialidades */
.hub-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 780px;
  margin: 26px auto 0;
}
.hub-tag {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  padding: 9px 18px;
  border-radius: 100px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background var(--ease), border-color var(--ease);
}
.hub-tag:hover {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.32);
}

/* ── Cards: bento asimétrico ───────────────────────── */
.hub-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 8px 0 clamp(48px, 8vw, 90px);
}

/* Escritorio: Servicios grande a la izquierda, el resto apilado a la derecha */
@media (min-width: 840px) {
  .hub-cards {
    grid-template-columns: 1.12fr 1fr;
    grid-auto-rows: 1fr;
    gap: 22px;
  }
  .hub-card--feature { grid-row: 1 / span 2; }

  .hub-card--feature .hub-card-no {
    font-size: clamp(180px, 22vw, 300px);
    top: auto;
    bottom: -32px;
    right: -6px;
  }
}

.hub-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(26px, 4vw, 40px);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
}

.hub-card--feature {
  background: linear-gradient(150deg, var(--primary-light), var(--primary-dark));
  border-color: transparent;
  box-shadow: var(--shadow-blue), var(--shadow-lg);
}

.hub-card:hover,
.hub-card:focus-within {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.hub-card--feature:hover,
.hub-card--feature:focus-within {
  box-shadow: var(--shadow-blue), var(--shadow-lg);
}

/* Número grande como marca de agua */
.hub-card-no {
  position: absolute;
  z-index: -1;
  top: clamp(-6px, 0.5vw, 4px);
  right: clamp(10px, 2.5vw, 26px);
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(90px, 13vw, 168px);
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--primary);
  opacity: .09;
  pointer-events: none;
}
.hub-card--feature .hub-card-no { color: #fff; opacity: .16; }

/* Ícono de marca de agua: solo en responsivo */
.hub-card-watermark { display: none; }

.hub-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.hub-card-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--primary);
}
.hub-card h2 {
  font-size: clamp(22px, 3vw, 30px);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: .5em;
}
.hub-card-ico {
  font-size: 1em;
  line-height: 1;
  color: var(--primary);
}
.hub-card p { color: var(--muted); font-size: 15px; }

.hub-card--feature .hub-card-kicker { color: rgba(255,255,255,.85); }
.hub-card--feature h2 { color: #fff; font-size: clamp(28px, 4vw, 44px); }
.hub-card--feature .hub-card-ico { color: #fff; }
.hub-card--feature p  { color: rgba(255,255,255,.88); font-size: clamp(15px, 1.5vw, 17px); }

/* Botón + globo "Da clic aquí" */
.hub-card-action {
  align-self: flex-start;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.hub-card-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
  background: var(--primary);
  border-radius: 100px;
  box-shadow: var(--shadow-blue);
  white-space: nowrap;
}
.hub-card-hint::after {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-right: -6px;
  background: var(--primary);
  border-radius: 0 0 0 3px;
  transform: translateY(-50%) rotate(45deg);
}
.hub-card--feature .hub-card-hint {
  color: var(--primary-dark);
  background: #fff;
  box-shadow: 0 12px 26px -12px rgba(3,10,28,.5);
}
.hub-card--feature .hub-card-hint::after { background: #fff; }

.hub-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
  background: var(--primary);
  padding: 12px 26px;
  border-radius: 100px;
  box-shadow: var(--shadow-blue);
  transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.hub-card:hover .hub-card-cta {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.hub-card-cta i {
  font-size: 12px;
  transition: transform var(--ease);
}
.hub-card:hover .hub-card-cta i,
.hub-card:focus-within .hub-card-cta i {
  animation: none;
  transform: translateX(6px);
}

.hub-card--feature .hub-card-cta {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 16px 30px -14px rgba(3,10,28,.5);
}
.hub-card--feature:hover .hub-card-cta {
  background: var(--pale);
  transform: translateY(-2px);
}

/* Botón secundario (contorno) */
.hub-card-cta--alt {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  border: 1.5px solid var(--pale2);
}
.hub-card:hover .hub-card-cta--alt,
.hub-card:focus-within .hub-card-cta--alt {
  background: var(--pale);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* ── Ayuda / WhatsApp ─────────────────────────────── */
.hub-help {
  text-align: center;
  padding: 0 0 clamp(48px, 8vw, 90px);
}
.hub-help p { color: rgba(255,255,255,.78); margin-bottom: 16px; font-size: 15px; }
.hub-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  background: var(--green);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  border-radius: 100px;
  box-shadow: 0 16px 32px -14px rgba(22,163,74,.5);
  transition: transform var(--ease), box-shadow var(--ease);
}
.hub-whatsapp:hover { transform: translateY(-2px); }

/* ── Footer ───────────────────────────────────────── */
.hub-footer {
  border-top: 1px solid rgba(255,255,255,.16);
  padding: 22px 0;
}
.hub-footer .container {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.hub-footer p { font-size: 13px; color: rgba(255,255,255,.55); }

/* ── Animaciones ──────────────────────────────────── */

/* Reveal al entrar en pantalla (lo activa el JS con .js) */
.js .reveal { opacity: 0; }
.js .reveal.in   { animation: hubReveal .8s var(--ease-fn) var(--d, 0s) both; }
.js .reveal.done { opacity: 1; animation: none; }
@keyframes hubReveal {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hub-cards .reveal:nth-child(1) { --d: .04s; }
.hub-cards .reveal:nth-child(2) { --d: .12s; }
.hub-cards .reveal:nth-child(3) { --d: .20s; }

/* Brillo de la card destacada */
.hub-card--feature::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 34%, rgba(255,255,255,.20) 50%, transparent 66%);
  transform: translateX(-130%);
}

/* Feedback de toque en móvil */
.hub-card, .hub-card-cta, .hub-back, .hub-whatsapp, .hub-logo {
  -webkit-tap-highlight-color: transparent;
}
.hub-card-cta:active {
  transform: scale(.96);
  transition-duration: .12s;
}
.hub-back:active, .hub-whatsapp:active { transform: scale(.96); }

@media (prefers-reduced-motion: no-preference) {
  body::before               { animation: hubKen 30s ease-in-out infinite alternate; }
  .hub-card--feature::after  { animation: hubSheen 6.5s ease-in-out 1.4s infinite; }
  .hub-whatsapp              { animation: hubPulse 2.8s ease-in-out infinite; }

  /* El globo entra con fade-in y luego flota (delay = entrada + duración) */
  .hub-card-hint {
    animation: hubHintIn .9s ease .6s both,
               hubHintFloat 3.4s ease-in-out 1.5s infinite;
  }
  .hub-cards .hub-card:nth-child(2) .hub-card-hint { animation-delay: .95s, 1.85s; }
  .hub-cards .hub-card:nth-child(3) .hub-card-hint { animation-delay: 1.3s, 2.2s; }
}
@keyframes hubHintIn {
  from { opacity: 0; transform: translateY(8px) scale(.92); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
@keyframes hubHintFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes hubKen {
  from { transform: scale(1.02); }
  to   { transform: scale(1.12); }
}
@keyframes hubSheen {
  0%       { transform: translateX(-130%); }
  55%,100% { transform: translateX(130%); }
}
@keyframes hubPulse {
  0%   { box-shadow: 0 16px 32px -14px rgba(22,163,74,.5), 0 0 0 0 rgba(22,163,74,.45); }
  70%  { box-shadow: 0 16px 32px -14px rgba(22,163,74,.5), 0 0 0 16px rgba(22,163,74,0); }
  100% { box-shadow: 0 16px 32px -14px rgba(22,163,74,.5), 0 0 0 0 rgba(22,163,74,0); }
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1 !important; }
  body::before,
  .hub-card--feature::after,
  .hub-whatsapp,
  .reveal.in { animation: none !important; }
}

/* ── Cards apiladas por scroll — solo móvil (≤839px) ── */
/* hub.js añade .is-stacked y actualiza --s / --b según el scroll */
@media (max-width: 839px) {
  .hub-card-no { display: none; }
  .hub-card-watermark {
    display: block;
    position: absolute;
    z-index: -1;
    top: clamp(2px, 2.5vw, 18px);
    right: clamp(4px, 3vw, 22px);
    font-size: clamp(84px, 25vw, 132px);
    line-height: 1;
    color: var(--primary);
    opacity: .1;
    pointer-events: none;
  }
  .hub-card--feature .hub-card-watermark { color: #fff; opacity: .18; }

  .hub-cards.is-stacked {
    display: block;
    padding-top: 4px;
  }

  .hub-cards.is-stacked .hub-card {
    position: sticky;
    /* cada card se fija más abajo → asoma el borde de las de atrás */
    top: calc(var(--stack-top, 80px) + var(--i, 0) * 14px);
    margin: 0 0 22px;

    transform-origin: center top;
    transform: scale(var(--s, 1));
    filter: brightness(var(--b, 1));
    transition: none;
    will-change: transform, filter;
    backface-visibility: hidden;
  }

  .hub-cards.is-stacked .hub-card:last-child {
    margin-bottom: clamp(24px, 6vw, 40px);
  }
}
