/* ==========================================================================
   HEMMI · Sistema de diseño hospitalario
   Hospital de Especialidades Médicas Materno Infantil Dr. Paulino Reyes
   CSS puro — complementa a Tailwind. Sin frameworks ni dependencias.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Marca — azul HEMMI extraído del logotipo institucional */
  --hm-900: #061F42;
  --hm-800: #0A2E5C;
  --hm-700: #0E3D78;
  --hm-600: #124C94;
  --hm-500: #1A5FB4;
  --hm-400: #3D82D6;
  --hm-300: #74A8E6;
  --hm-200: #B4D0F4;
  --hm-100: #DCE9FB;
  --hm-50:  #F0F6FE;

  /* Acento vital — turquesa clínico */
  --hm-teal-700: #06706E;
  --hm-teal-600: #0A8C89;
  --hm-teal-500: #12A8A4;
  --hm-teal-100: #D6F3F2;
  --hm-teal-50:  #EDFAFA;

  /* Emergencia — rojo del logotipo */
  --hm-red-700: #A80B22;
  --hm-red-600: #C4102A;
  --hm-red-500: #E11D3A;
  --hm-red-100: #FCE1E5;
  --hm-red-50:  #FEF2F4;

  /* Neutros cálidos */
  --hm-ink:     #0C1626;
  --hm-body:    #40506B;
  /* Se oscureció desde #6B7C97: sobre el lienzo daba 3,94:1, por debajo del
     mínimo legible. Con este valor pasa de 4,5:1 sobre blanco y sobre lienzo
     sin cambiar el carácter del gris. */
  --hm-muted:   #5F7089;
  --hm-line:    #E2E9F2;
  --hm-line-2:  #EFF4F9;
  --hm-surface: #FFFFFF;
  --hm-canvas:  #F6F9FC;
  --hm-canvas-2:#EDF3F9;

  /* Radios */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-2xl: 40px;

  /* Sombras — suaves, con tinte azul, nunca grises puros */
  --sh-xs: 0 1px 2px rgba(10, 46, 92, .06);
  --sh-sm: 0 2px 8px rgba(10, 46, 92, .06), 0 1px 2px rgba(10, 46, 92, .04);
  --sh-md: 0 8px 26px -8px rgba(10, 46, 92, .16), 0 2px 8px rgba(10, 46, 92, .05);
  --sh-lg: 0 22px 50px -14px rgba(10, 46, 92, .22), 0 6px 16px rgba(10, 46, 92, .06);
  --sh-xl: 0 40px 80px -24px rgba(10, 46, 92, .30), 0 10px 24px rgba(10, 46, 92, .08);
  --sh-brand: 0 14px 34px -10px rgba(18, 76, 148, .45);
  --sh-red:   0 14px 34px -10px rgba(196, 16, 42, .42);

  /* Movimiento */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur: .45s;

  /* Tipografía */
  --fuente-ui:        'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fuente-editorial: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;

  /* Layout */
  --header-h: 78px;
  --bar-h: 40px;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--hm-surface);
  color: var(--hm-body);
  font-family: var(--fuente-ui);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'ss01';
  /* `clip` recorta el desbordamiento horizontal SIN crear un contenedor de
     desplazamiento, de modo que la cabecera `position: sticky` sigue funcionando.
     `hidden` queda como respaldo para navegadores sin soporte de `clip`. */
  overflow-x: hidden;
  overflow-x: clip;
}

h1, h2, h3, h4, h5, .hm-display {
  font-family: var(--fuente-ui);
  color: var(--hm-ink);
  letter-spacing: -0.022em;
  line-height: 1.14;
  font-weight: 700;
  text-wrap: balance;
}

p { text-wrap: pretty; }

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--hm-200); color: var(--hm-900); }

/* Foco visible y consistente en todo el sitio (WCAG 2.4.7) */
:focus-visible {
  outline: 3px solid var(--hm-400);
  outline-offset: 3px;
  border-radius: 6px;
}
.hm-focus-red:focus-visible { outline-color: var(--hm-red-500); }

/* Barra de desplazamiento */
@supports (scrollbar-color: auto) {
  html { scrollbar-color: var(--hm-200) transparent; scrollbar-width: thin; }
}
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--hm-canvas); }
::-webkit-scrollbar-thumb {
  background: var(--hm-200); border-radius: 99px; border: 3px solid var(--hm-canvas);
}
::-webkit-scrollbar-thumb:hover { background: var(--hm-300); }

/* Salto al contenido */
.hm-skip {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  transform: translateY(-160%);
  background: var(--hm-700); color: #fff;
  padding: .7rem 1.15rem; border-radius: var(--r-sm);
  font-weight: 600; font-size: .9rem; box-shadow: var(--sh-lg);
  transition: transform .25s var(--ease);
}
.hm-skip:focus { transform: translateY(0); }

/* --------------------------------------------------------------------------
   3. Tipografía fluida
   -------------------------------------------------------------------------- */
/* Los titulares grandes van en serif editorial: dan voz propia al hospital
   y separan claramente el discurso institucional de la interfaz. */
.hm-h1, .hm-h2, .hm-serif {
  font-family: var(--fuente-editorial);
  font-weight: 500;
  font-optical-sizing: auto;
}
.hm-h1      { font-size: clamp(2.4rem, 1.4rem + 3.7vw, 4.4rem);  line-height: 1.02; letter-spacing: -.028em; }
.hm-h2      { font-size: clamp(1.95rem, 1.3rem + 2.4vw, 3.15rem); line-height: 1.08; letter-spacing: -.022em; }
.hm-h3      { font-size: clamp(1.35rem, 1.1rem + .95vw, 1.95rem); line-height: 1.18; letter-spacing: -.022em; }

/* Cursiva del serif para matices dentro de un titular */
.hm-italic { font-style: italic; font-weight: 400; }

/* Cifra grande de acento editorial (números de sección, pasos) */
.hm-numeral {
  font-family: var(--fuente-editorial);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -.02em;
  color: var(--hm-300);
}
.hm-h4      { font-size: clamp(1.1rem, 1rem + .45vw, 1.35rem);    line-height: 1.28; letter-spacing: -.015em; }
.hm-lead    { font-size: clamp(1.03rem, .97rem + .32vw, 1.22rem); line-height: 1.68; color: var(--hm-body); }
.hm-small   { font-size: .8125rem; line-height: 1.55; }

.hm-eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: .74rem; font-weight: 700; letter-spacing: .17em; text-transform: uppercase;
  color: var(--hm-500);
}
.hm-eyebrow::before {
  content: ''; width: 26px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--hm-500), var(--hm-teal-500));
}
.hm-eyebrow--light { color: var(--hm-200); }
.hm-eyebrow--light::before { background: linear-gradient(90deg, var(--hm-300), var(--hm-teal-500)); }
.hm-eyebrow--center { justify-content: center; }

.hm-link {
  color: var(--hm-600); font-weight: 600;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1.5px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size .35s var(--ease), color .2s;
}
.hm-link:hover { background-size: 100% 1.5px; color: var(--hm-700); }

/* --------------------------------------------------------------------------
   4. Botones
   -------------------------------------------------------------------------- */
.hm-btn {
  --btn-bg: var(--hm-600);
  --btn-fg: #fff;
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .82rem 1.5rem;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-family: var(--fuente-ui);
  font-weight: 650; font-size: .945rem; letter-spacing: -.008em;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  transition: transform .28s var(--ease), box-shadow .28s var(--ease),
              background-color .22s ease, color .22s ease, border-color .22s ease;
}
.hm-btn::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(120deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%);
  opacity: 0; transition: opacity .3s ease;
}
.hm-btn:hover { transform: translateY(-2px); }
.hm-btn:hover::after { opacity: 1; }
.hm-btn:active { transform: translateY(0); }

.hm-btn--primary   { background: var(--hm-600); box-shadow: var(--sh-brand); }
.hm-btn--primary:hover { background: var(--hm-700); }

.hm-btn--emergency { background: var(--hm-red-600); box-shadow: var(--sh-red); }
.hm-btn--emergency:hover { background: var(--hm-red-700); }

.hm-btn--teal { background: var(--hm-teal-600); box-shadow: 0 14px 34px -10px rgba(10,140,137,.45); }
.hm-btn--teal:hover { background: var(--hm-teal-700); }

.hm-btn--ghost {
  background: transparent; color: var(--hm-700); border-color: var(--hm-line);
  box-shadow: var(--sh-xs);
}
.hm-btn--ghost:hover { background: var(--hm-50); border-color: var(--hm-200); color: var(--hm-800); }

.hm-btn--white { background: #fff; color: var(--hm-800); box-shadow: var(--sh-md); }
.hm-btn--white:hover { background: var(--hm-50); }

.hm-btn--outline-light {
  background: rgba(255,255,255,.08); color: #fff;
  border-color: rgba(255,255,255,.34); backdrop-filter: blur(10px);
}
.hm-btn--outline-light:hover { background: rgba(255,255,255,.17); border-color: rgba(255,255,255,.6); }

.hm-btn--sm { padding: .58rem 1.1rem; font-size: .865rem; }
.hm-btn--lg { padding: 1.02rem 1.9rem; font-size: 1.02rem; }
.hm-btn--block { width: 100%; }

/* Flecha que avanza al pasar el cursor */
.hm-btn .hm-arrow { transition: transform .32s var(--ease); }
.hm-btn:hover .hm-arrow { transform: translateX(4px); }

/* --------------------------------------------------------------------------
   5. Superficies
   -------------------------------------------------------------------------- */
.hm-card {
  position: relative;
  /* Una tarjeta es celda de rejilla en casi todas las pantallas, y una celda
     no encoge por debajo del mínimo de su contenido salvo que se le diga. */
  min-width: 0;
  background: var(--hm-surface);
  border: 1px solid var(--hm-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .3s ease;
}
.hm-card--hover:hover {
  transform: translateY(-5px);
  box-shadow: var(--sh-lg);
  border-color: var(--hm-200);
}

.hm-panel {
  background: var(--hm-canvas);
  border: 1px solid var(--hm-line-2);
  border-radius: var(--r-lg);
}

.hm-glass {
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

/* Variante para cuando el cristal cae sobre una zona clara de la fotografía:
   un nueve por ciento de blanco no separa nada del hormigón del edificio y lo
   de dentro deja de leerse. Va aquí y no como clase suelta en la vista porque
   `hm-glass` fija `background` y esta hoja se carga después de la de Tailwind:
   cualquier `bg-…` encima se pierde en la cascada. */
.hm-glass--asentado {
  background: rgba(6, 31, 66, .82);
  border-color: rgba(255, 255, 255, .24);
}

.hm-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .34rem .78rem; border-radius: 999px;
  background: var(--hm-50); color: var(--hm-700);
  border: 1px solid var(--hm-100);
  font-size: .775rem; font-weight: 650; letter-spacing: .005em;
  white-space: nowrap;
}
.hm-chip--teal  { background: var(--hm-teal-50);  color: var(--hm-teal-700); border-color: var(--hm-teal-100); }
.hm-chip--red   { background: var(--hm-red-50);   color: var(--hm-red-700);  border-color: var(--hm-red-100); }

/* Un horario como «Lunes a viernes · 7:00 a 19:00» no cabe de una pieza en
   una tarjeta de 320 px: por debajo de ahí la etiqueta puede partirse. */
@media (max-width: 400px) {
  .hm-chip { white-space: normal; }
}
.hm-chip--solid { background: var(--hm-600); color: #fff; border-color: transparent; }
.hm-chip--light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }

/* Icono en cuadro redondeado */
.hm-ico {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: var(--r-sm);
  background: var(--hm-50); color: var(--hm-600);
  border: 1px solid var(--hm-100);
  transition: background-color .3s ease, color .3s ease, transform .4s var(--ease);
}
.hm-ico--teal { background: var(--hm-teal-50); color: var(--hm-teal-600); border-color: var(--hm-teal-100); }
.hm-ico--red  { background: var(--hm-red-50);  color: var(--hm-red-600);  border-color: var(--hm-red-100); }
.hm-ico--solid{ background: var(--hm-600); color: #fff; border-color: transparent; box-shadow: var(--sh-brand); }
.hm-ico--lg   { width: 62px; height: 62px; border-radius: var(--r-md); }
.hm-ico--sm   { width: 40px; height: 40px; border-radius: 10px; }

.hm-card--hover:hover .hm-ico { background: var(--hm-600); color: #fff; border-color: transparent; }
.hm-card--hover:hover .hm-ico--red { background: var(--hm-red-600); }
.hm-card--hover:hover .hm-ico--teal { background: var(--hm-teal-600); }

/* --------------------------------------------------------------------------
   6. Fondos decorativos
   -------------------------------------------------------------------------- */
/*
 * Azul institucional. Una sola fuente de luz, arriba a la izquierda, y un
 * oscurecido hacia abajo que da peso a la superficie. Antes había además un
 * resplandor verde en la esquina derecha: ese cruce de dos halos de colores
 * distintos es el acabado de las plantillas genéricas, no el de una marca.
 */
.hm-bg-deep {
  background:
    radial-gradient(1200px 700px at 12% -18%, rgba(26,95,180,.40), transparent 58%),
    linear-gradient(180deg, transparent 55%, rgba(4,17,38,.55) 100%),
    linear-gradient(168deg, #072347 0%, #0A2E5C 55%, #0B355F 100%);
}
.hm-bg-soft {
  background:
    radial-gradient(760px 380px at 12% 0%, rgba(26,95,180,.07), transparent 62%),
    radial-gradient(640px 340px at 92% 12%, rgba(18,168,164,.08), transparent 60%),
    var(--hm-canvas);
}
.hm-bg-tint { background: var(--hm-canvas); }

/*
 * Grano fino sobre los fondos oscuros.
 *
 * Sustituye a la retícula de cuadros que había antes. Un degradado plano se
 * lee como pantalla; el grano lo acerca a una superficie impresa, que es de
 * donde viene la identidad del hospital. No dibuja ninguna forma reconocible:
 * a tamaño real solo se percibe como textura.
 *
 * El ruido se genera con un filtro SVG incrustado, así que no hay petición de
 * red ni archivo que mantener.
 */
/*
 * Una sola octava y frecuencia alta: eso da grano fino y parejo. Con varias
 * octavas aparecen componentes de baja frecuencia y el fondo se llena de
 * nubes, que es peor que no poner nada. Tampoco se enmascara: el grano no
 * tiene forma, y recortarlo en óvalo sí crearía una mancha.
 */
.hm-textura {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='1' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23g)' opacity='.6'/%3E%3C/svg%3E");
  /* soft-light modula el color en lugar de sumarle gris: el azul mantiene su
     profundidad y solo se percibe la textura. Con opacidad a secas el fondo
     se aclara y pierde el cuerpo del azul institucional. */
  mix-blend-mode: soft-light;
}
/* Sobre fondo claro el grano tiene que ser aún más leve. */
.hm-textura--claro { opacity: .3; }


/* Curva superior/inferior */
.hm-wave { display: block; width: 100%; height: auto; }

/* Difuminado lateral para carruseles */
.hm-fade-x {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

/* --------------------------------------------------------------------------
   7. Cabecera
   -------------------------------------------------------------------------- */
.hm-topbar {
  background: linear-gradient(90deg, var(--hm-900), var(--hm-700) 55%, var(--hm-teal-700));
  color: #fff;
  font-size: .8rem;
}
.hm-topbar a { transition: color .2s ease, opacity .2s ease; }
.hm-topbar a:hover { color: #fff; opacity: 1; }

.hm-header {
  position: sticky; top: 0; z-index: 90;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid transparent;
  transition: box-shadow .35s var(--ease), border-color .35s ease, background-color .35s ease;
}
.hm-header.is-stuck {
  background: rgba(255,255,255,.95);
  border-bottom-color: var(--hm-line);
  box-shadow: 0 10px 30px -18px rgba(10,46,92,.35);
}

.hm-navlink {
  position: relative;
  padding: .55rem .05rem;
  font-size: .93rem; font-weight: 600; color: var(--hm-body);
  transition: color .22s ease;
}
.hm-navlink::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--hm-500), var(--hm-teal-500));
  transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.hm-navlink:hover { color: var(--hm-700); }
.hm-navlink:hover::after { transform: scaleX(1); }
.hm-navlink.is-active { color: var(--hm-700); font-weight: 700; }
.hm-navlink.is-active::after { transform: scaleX(1); }

/* Menú móvil */
.hm-drawer {
  position: fixed; inset: 0; z-index: 120;
  visibility: hidden; pointer-events: none;
}
.hm-drawer.is-open { visibility: visible; pointer-events: auto; }
.hm-drawer__veil {
  position: absolute; inset: 0;
  background: rgba(6,31,66,.55); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .35s var(--ease);
}
.hm-drawer.is-open .hm-drawer__veil { opacity: 1; }
.hm-drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(400px, 88vw);
  background: #fff; box-shadow: var(--sh-xl);
  transform: translateX(102%);
  transition: transform .48s var(--ease);
  display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain;
}
.hm-drawer.is-open .hm-drawer__panel { transform: translateX(0); }
.hm-drawer__link {
  display: flex; align-items: center; justify-content: space-between;
  padding: .95rem .25rem; border-bottom: 1px solid var(--hm-line-2);
  font-family: var(--fuente-ui); font-weight: 650; font-size: 1.03rem;
  color: var(--hm-ink); transition: color .2s ease, padding-left .28s var(--ease);
}
.hm-drawer__link:hover { color: var(--hm-600); padding-left: .6rem; }
.hm-drawer__link.is-active { color: var(--hm-600); }

body.hm-locked { overflow: hidden; }

/* --------------------------------------------------------------------------
   8. Animaciones de entrada
   -------------------------------------------------------------------------- */
/*
 * El punto de partida invisible va bajo `.js`, que fija un guion en línea en
 * la cabecera. Sin JavaScript no hay nada que revele estos elementos, así que
 * ocultarlos incondicionalmente dejaba la página en blanco.
 */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .8s var(--ease-out), transform .8s var(--ease-out);
  transition-delay: var(--d, 0ms);
  will-change: opacity, transform;
}
.js [data-reveal="left"]  { transform: translateX(-30px); }
.js [data-reveal="right"] { transform: translateX(30px); }
.js [data-reveal="zoom"]  { transform: scale(.955); }
.js [data-reveal="fade"]  { transform: none; }
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* El desplazamiento lateral es de 30 px y el margen de la página vale 16 px
   hasta 640, 24 hasta 1024 y 40 desde ahí: solo en escritorio hay sitio. Por
   debajo, el bloque asomaba fuera del viewport y la página entera se podía
   arrastrar de lado. Ahí todos entran desde abajo, que además es el gesto que
   corresponde a una pantalla que se recorre con el pulgar. */
@media (max-width: 1023px) {
  .js [data-reveal="left"],
  .js [data-reveal="right"] { transform: translateY(26px); }
}

@keyframes hm-float   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-13px); } }
@keyframes hm-pulse   { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.55); } }
@keyframes hm-spin    { to { transform: rotate(360deg); } }
@keyframes hm-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes hm-beat    { 0%,100% { transform: scale(1); } 14% { transform: scale(1.16); } 28% { transform: scale(1); } 42% { transform: scale(1.1); } }

.hm-float { animation: hm-float 7s ease-in-out infinite; }
.hm-beat  { animation: hm-beat 2.4s ease-in-out infinite; }

.hm-live-dot { position: relative; display: inline-flex; width: 8px; height: 8px; }
.hm-live-dot::before {
  content: ''; position: absolute; inset: 0; border-radius: 999px;
  background: currentColor; animation: hm-pulse 2s ease-in-out infinite;
}
.hm-live-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 999px; background: currentColor;
}

/* Línea de electrocardiograma */
/* Marquesina */
.hm-marquee { display: flex; width: max-content; animation: hm-marquee 42s linear infinite; }
.hm-marquee:hover { animation-play-state: paused; }

/* --------------------------------------------------------------------------
   9. Componentes del directorio médico
   -------------------------------------------------------------------------- */
.hm-doc {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--hm-line);
  border-radius: var(--r-lg);
  transition: transform .42s var(--ease), box-shadow .42s var(--ease), border-color .3s;
  display: flex; flex-direction: column;
}
.hm-doc:hover { transform: translateY(-6px); box-shadow: var(--sh-lg); border-color: var(--hm-200); }

.hm-doc__media {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  background: linear-gradient(168deg, var(--hm-canvas-2), var(--hm-50));
}
.hm-doc__media img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 12%;
  transition: transform .8s var(--ease), filter .5s ease;
}
.hm-doc:hover .hm-doc__media img { transform: scale(1.055); }
.hm-doc__media::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(6,31,66,.62) 0%, rgba(6,31,66,.10) 34%, transparent 62%);
  opacity: .9; transition: opacity .4s ease;
}
.hm-doc:hover .hm-doc__media::after { opacity: 1; }

.hm-doc__tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  max-width: calc(100% - 24px);
  background: rgba(255,255,255,.93); color: var(--hm-700);
  backdrop-filter: blur(8px);
  padding: .3rem .7rem; border-radius: 999px;
  font-size: .715rem; font-weight: 700; letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hm-doc__body { padding: 1.05rem 1.15rem 1.25rem; display: flex; flex-direction: column; flex: 1; }
.hm-doc__name {
  font-family: var(--fuente-ui); font-weight: 700;
  font-size: 1.02rem; line-height: 1.28; color: var(--hm-ink);
  letter-spacing: -.018em;
}
.hm-doc__meta {
  display: flex; flex-wrap: wrap; gap: .38rem;
  margin-top: .7rem; padding-top: .7rem;
  border-top: 1px dashed var(--hm-line);
}
.hm-doc__pill {
  display: inline-flex; align-items: center; gap: .28rem;
  font-size: .715rem; font-weight: 650; color: var(--hm-muted);
  background: var(--hm-canvas); border: 1px solid var(--hm-line-2);
  padding: .2rem .5rem; border-radius: 7px;
}

/*
 * En el directorio, el teléfono del especialista es un enlace «tel:»: en una
 * pantalla táctil hay que poder acertarlo con el pulgar. Las otras píldoras
 * son solo informativas y se quedan compactas.
 */
@media (pointer: coarse) {
  a.hm-doc__pill {
    min-height: 40px;
    padding-inline: .75rem;
    font-size: .78rem;
  }
}

/* Vista en lista */
.hm-doclist .hm-doc { flex-direction: row; align-items: stretch; }
.hm-doclist .hm-doc__media { width: 132px; flex: none; aspect-ratio: auto; }
.hm-doclist .hm-doc__media::after { background: linear-gradient(to right, transparent 40%, rgba(6,31,66,.10)); }
.hm-doclist .hm-doc__tag { display: none; }
.hm-doclist .hm-doc__body { padding: 1.1rem 1.3rem; }
@media (max-width: 520px) {
  .hm-doclist .hm-doc__media { width: 98px; }
}

/* Estado del filtro */
.hm-filter {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .48rem .95rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--hm-line);
  color: var(--hm-body); font-size: .845rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: all .25s var(--ease);
}
.hm-filter:hover { border-color: var(--hm-300); color: var(--hm-700); background: var(--hm-50); }
.hm-filter.is-active {
  background: var(--hm-600); border-color: var(--hm-600); color: #fff;
  box-shadow: 0 8px 18px -8px rgba(18,76,148,.6);
}
.hm-filter__count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 .3rem; border-radius: 999px;
  background: var(--hm-canvas-2); color: var(--hm-muted);
  font-size: .68rem; font-weight: 700;
}
.hm-filter.is-active .hm-filter__count { background: rgba(255,255,255,.22); color: #fff; }

/* Campo de búsqueda */
.hm-field {
  min-width: 0;
  width: 100%; padding: .88rem 1.1rem .88rem 3rem;
  border: 1px solid var(--hm-line); border-radius: 999px;
  background: #fff; color: var(--hm-ink);
  font-size: .96rem; font-family: inherit;
  box-shadow: var(--sh-xs);
  transition: border-color .25s, box-shadow .25s;
}
.hm-field::placeholder { color: var(--hm-muted); }
.hm-field:focus {
  outline: none; border-color: var(--hm-400);
  box-shadow: 0 0 0 4px var(--hm-100);
}

.hm-input {
  /* El ancho preferido de fábrica de un campo —unos veinte caracteres— no lo
     quita `width: 100%`, y en una celda de rejilla eso fija un mínimo que la
     ensancha por debajo de 360 px. */
  width: 100%; min-width: 0; padding: .82rem 1rem;
  border: 1px solid var(--hm-line); border-radius: var(--r-sm);
  background: #fff; color: var(--hm-ink); font-size: .95rem; font-family: inherit;
  transition: border-color .25s, box-shadow .25s;
}
.hm-input::placeholder { color: var(--hm-muted); }
.hm-input:focus { outline: none; border-color: var(--hm-400); box-shadow: 0 0 0 4px var(--hm-100); }
.hm-label {
  display: block; margin-bottom: .4rem;
  font-size: .82rem; font-weight: 650; color: var(--hm-ink); letter-spacing: .005em;
}

/* Esqueleto de carga */
.hm-skeleton {
  background: linear-gradient(100deg, var(--hm-canvas) 30%, var(--hm-canvas-2) 50%, var(--hm-canvas) 70%);
  background-size: 220% 100%;
  animation: hm-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes hm-shimmer { from { background-position: 200% 0; } to { background-position: -20% 0; } }

/* --------------------------------------------------------------------------
   10. Acordeón
   -------------------------------------------------------------------------- */
.hm-acc { border-bottom: 1px solid var(--hm-line); }
.hm-acc__btn {
  width: 100%; display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem;
  padding: 1.35rem .25rem; background: none; border: 0; cursor: pointer; text-align: left;
  font-family: var(--fuente-ui); font-weight: 650; font-size: 1.03rem;
  color: var(--hm-ink); line-height: 1.42;
  transition: color .22s ease;
}
.hm-acc__btn:hover { color: var(--hm-600); }
.hm-acc__sign {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; margin-top: 1px; border-radius: 50%;
  background: var(--hm-50); color: var(--hm-600); border: 1px solid var(--hm-100);
  transition: transform .42s var(--ease), background-color .3s, color .3s;
}
.hm-acc__btn[aria-expanded="true"] .hm-acc__sign {
  transform: rotate(180deg); background: var(--hm-600); color: #fff; border-color: transparent;
}
.hm-acc__panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .48s var(--ease);
}
/* El estado vive en el contenedor y no en el botón: el botón está dentro
   del <h3> del encabezado, así que nunca es hermano del panel. */
.hm-acc.is-abierto > .hm-acc__panel { grid-template-rows: 1fr; }
.hm-acc__inner { overflow: hidden; }
.hm-acc__inner > div { padding: 0 3rem 1.5rem .25rem; color: var(--hm-body); }
.hm-acc__inner p { margin: 0 0 .85rem; }
.hm-acc__inner p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   11. Pestañas (mapa del hospital)
   -------------------------------------------------------------------------- */
.hm-tab {
  padding: .62rem 1.05rem; border-radius: 999px;
  font-size: .875rem; font-weight: 650; color: var(--hm-body);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: all .26s var(--ease); white-space: nowrap;
}
.hm-tab:hover { background: #fff; color: var(--hm-700); border-color: var(--hm-line); }
.hm-tab[aria-selected="true"] {
  background: #fff; color: var(--hm-700); border-color: var(--hm-200);
  box-shadow: var(--sh-sm); font-weight: 700;
}
.hm-tabpanel[hidden] { display: none; }

/* En estrecho la píldora no cabe —dos rótulos largos y `nowrap`—, así que se
   reparte el ancho entre las dos pestañas y el texto puede caer en dos
   líneas. Con dos opciones no hace falta desplazamiento lateral. */
@media (max-width: 640px) {
  .hm-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .hm-tabs .hm-tab {
    white-space: normal;
    padding: .5rem .55rem;
    font-size: .8125rem;
    line-height: 1.28;
  }
}

/* La especialidad de la ficha puede ser una sola palabra más ancha que la
   tarjeta —«Otorrinolaringólogo»— y no hay dónde partirla sin ayuda. */
.hm-doc__esp { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }

/* Nivel del edificio */
.hm-floor {
  display: flex; align-items: center; gap: 1rem;
  padding: .95rem 1.15rem; border-radius: var(--r-sm);
  background: #fff; border: 1px solid var(--hm-line-2);
  transition: all .3s var(--ease);
}
.hm-floor:hover { border-color: var(--hm-200); box-shadow: var(--sh-sm); transform: translateX(4px); }
.hm-floor__num {
  flex: none; display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(140deg, var(--hm-600), var(--hm-500));
  color: #fff; font-family: var(--fuente-ui); font-weight: 800; font-size: .96rem;
  box-shadow: 0 8px 16px -8px rgba(18,76,148,.7);
}

/* --------------------------------------------------------------------------
   12. Estadísticas y cifras
   -------------------------------------------------------------------------- */
.hm-stat__num {
  font-family: var(--fuente-ui); font-weight: 800;
  font-size: clamp(2.15rem, 1.6rem + 2.1vw, 3.35rem);
  line-height: 1; letter-spacing: -.045em;
  background: linear-gradient(135deg, #fff 15%, var(--hm-200) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}
.hm-stat__num--dark {
  background: linear-gradient(135deg, var(--hm-700), var(--hm-teal-600));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* --------------------------------------------------------------------------
   13. Acciones flotantes
   -------------------------------------------------------------------------- */
.hm-fab-stack {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: .65rem;
}
.hm-fab {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  color: #fff; border: 0; cursor: pointer;
  box-shadow: var(--sh-lg);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), background-color .25s;
}
.hm-fab:hover { transform: translateY(-3px) scale(1.05); }
/* Verde de WhatsApp algo más oscuro: con el anterior, el glifo blanco se
   quedaba en 2,57:1 y el mínimo para un icono es 3:1. */
.hm-fab--wa  { background: #1EA34F; }
.hm-fab--wa:hover { background: #1DA24E; }
.hm-fab--tel { background: var(--hm-red-600); }
.hm-fab--tel:hover { background: var(--hm-red-700); }
.hm-fab--top {
  background: #fff; color: var(--hm-700); border: 1px solid var(--hm-line);
  width: 44px; height: 44px;
  opacity: 0; transform: translateY(12px); pointer-events: none;
}
.hm-fab--top.is-on { opacity: 1; transform: none; pointer-events: auto; }

/* Etiqueta emergente */
.hm-fab__tip {
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(6px);
  background: var(--hm-900); color: #fff;
  padding: .34rem .68rem; border-radius: 7px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: all .28s var(--ease);
}
.hm-fab:hover .hm-fab__tip { opacity: 1; transform: translateY(-50%) translateX(0); }

/* --------------------------------------------------------------------------
   14. Contenido enriquecido (noticias)
   -------------------------------------------------------------------------- */
.hm-prose { color: var(--hm-body); font-size: 1.055rem; line-height: 1.78; }
.hm-prose > p { margin: 0 0 1.35rem; }
.hm-prose > p:first-of-type { font-size: 1.16rem; line-height: 1.7; color: var(--hm-ink); font-weight: 450; }
.hm-prose h2, .hm-prose h3 { margin: 2.4rem 0 .9rem; }
.hm-prose h2 { font-size: 1.6rem; }
.hm-prose h3 { font-size: 1.28rem; }
.hm-prose strong { color: var(--hm-ink); font-weight: 650; }
.hm-prose a { color: var(--hm-600); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
/* Tailwind quita los marcadores de lista en su reinicio; en texto redactado
   hacen falta, si no una lista se lee como párrafos sueltos y mal sangrados. */
.hm-prose ul, .hm-prose ol { margin: 0 0 1.35rem; padding-left: 1.4rem; }
.hm-prose ul { list-style: disc; }
.hm-prose ol { list-style: decimal; }
.hm-prose li { margin-bottom: .5rem; padding-left: .2rem; }
.hm-prose li::marker { color: var(--hm-300); }
.hm-prose blockquote {
  margin: 1.8rem 0; padding: 1.15rem 1.5rem;
  border-left: 3px solid var(--hm-500); background: var(--hm-50);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 1.08rem; color: var(--hm-800); font-style: italic;
}
.hm-prose img { border-radius: var(--r-md); margin: 1.8rem 0; }

/* --------------------------------------------------------------------------
   15. Otros
   -------------------------------------------------------------------------- */
.hm-noscroll::-webkit-scrollbar { display: none; }
.hm-noscroll { -ms-overflow-style: none; scrollbar-width: none; }

.hm-divider {
  height: 1px; border: 0;
  background: linear-gradient(90deg, transparent, var(--hm-line) 18%, var(--hm-line) 82%, transparent);
}

.hm-ratio-16-9 { aspect-ratio: 16 / 9; }
.hm-ratio-4-3  { aspect-ratio: 4 / 3; }
.hm-ratio-1-1  { aspect-ratio: 1 / 1; }

.hm-img-cover { width: 100%; height: 100%; object-fit: cover; }

/*
 * Para material gráfico —afiches de campañas, jornadas— donde recortar se
 * lleva por delante el titular. La imagen entra entera y el marco conserva su
 * altura.
 */
/* Horas libres en la tarjeta del especialista: se pulsan para ir a ese día. */
.ct-hora {
  display: inline-flex; align-items: center;
  padding: .3rem .55rem;
  border: 1px solid var(--hm-line);
  border-radius: 8px;
  background: #fff;
  font-size: .78rem; font-weight: 650;
  color: var(--hm-700);
  transition: all .16s var(--ease);
}
.ct-hora:hover { border-color: var(--hm-300); background: var(--hm-50); }
.ct-hora--mas { color: var(--hm-muted); font-weight: 600; }

@media (pointer: coarse) {
  .ct-hora { min-height: 36px; padding-inline: .7rem; }
}

.hm-img-entera {
  width: 100%; height: 100%;
  object-fit: contain;
  background: var(--hm-canvas);
}

.hm-zoom-wrap { overflow: hidden; }
.hm-zoom-wrap img { transition: transform .9s var(--ease); }
.hm-zoom-wrap:hover img { transform: scale(1.06); }

/* Estado vacío */
.hm-empty {
  display: grid; place-items: center; gap: .9rem;
  padding: 4rem 1.5rem; text-align: center;
  border: 1px dashed var(--hm-line); border-radius: var(--r-lg);
  background: var(--hm-canvas);
}

/* --------------------------------------------------------------------------
   16. Accesibilidad e impresión
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .js [data-reveal] { opacity: 1 !important; transform: none !important; }
}

@media (prefers-contrast: more) {
  :root { --hm-line: #9FB3CC; --hm-body: #22334E; --hm-muted: #43587A; }
  .hm-card, .hm-doc { border-width: 1.5px; }
}

@media print {
  .hm-header, .hm-topbar, .hm-fab-stack, .hm-drawer, footer, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .hm-doc { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}

/* ═══════════════════════════════════════ BUSCADOR DE LA PORTADA ══ */
/* z-index explícito: sin él las sugerencias quedan por debajo de lo que viene
   después en el documento, porque los elementos con `data-reveal` llevan
   transform y se pintan en la misma capa que los posicionados. */
.bp { position: relative; z-index: 30; max-width: 34rem; }

.bp__campo {
  display: flex; align-items: center; gap: .75rem;
  padding: .2rem .2rem .2rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 12px 34px -12px rgba(3, 18, 42, .55);
}
.bp__campo svg { flex: none; color: var(--hm-muted); }

.bp__campo input {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  padding: .82rem 0;
  font: inherit; font-size: .95rem; color: var(--hm-ink);
}
.bp__campo input::placeholder { color: var(--hm-muted); }
.bp__campo input:focus { outline: none; }
.bp__campo:focus-within { box-shadow: 0 0 0 3px rgba(255,255,255,.35), 0 12px 34px -12px rgba(3,18,42,.55); }

.bp__ir {
  flex: none;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .68rem 1.15rem;
  border-radius: 999px;
  background: var(--hm-600); color: #fff;
  font-size: .875rem; font-weight: 700;
  transition: background .16s ease;
}
.bp__ir:hover { background: var(--hm-700); }

/*
 * En pantallas estrechas el botón cede su palabra al campo: con ella, el
 * marcador se cortaba a media palabra. La palabra sigue ahí para los lectores
 * de pantalla, que son quienes le dan nombre al botón.
 */
@media (max-width: 430px) {
  .bp__ir { padding: .68rem .85rem; }
  .bp__ir > span {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* Lista de sugerencias */
.bp__lista, .bp__vacio {
  position: absolute; z-index: 1; top: calc(100% + .5rem); left: 0; right: 0;
  max-height: 24rem; overflow-y: auto;
  border: 1px solid var(--hm-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 54px -18px rgba(3, 18, 42, .45);
  padding: .35rem;
}
.bp__vacio { padding: 1.1rem 1.25rem; font-size: .875rem; color: var(--hm-muted); }

/* Rótulo de cada bloque de resultados */
.bp__grupo {
  margin: .5rem 0 .2rem; padding: 0 .75rem;
  font-size: .655rem; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--hm-muted);
}
.bp__grupo:first-child { margin-top: .25rem; }

.bp__i {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .75rem;
  border-radius: 11px;
  color: var(--hm-body);
  transition: background .12s ease;
}
.bp__i:hover, .bp__i.is-marcado { background: var(--hm-canvas); }
.bp__i mark { background: none; color: var(--hm-teal-700); font-weight: 700; }

.bp__ico {
  flex: none; display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--hm-50);
  color: var(--hm-500);
}
.bp__ico svg { width: 15px; height: 15px; }

.bp__tx { min-width: 0; flex: 1; }
.bp__t  { display: block; font-size: .875rem; font-weight: 600; color: var(--hm-ink);
          line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp__s  { display: block; font-size: .755rem; color: var(--hm-muted); line-height: 1.35;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* La fecha real del primer turno libre dice más que una etiqueta genérica */
.bp__fecha {
  flex: none; text-align: right; line-height: 1.25;
  font-size: .66rem; color: var(--hm-muted);
}
.bp__fecha b { display: block; font-size: .765rem; font-weight: 700; color: var(--hm-teal-700); }

.bp__pie {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .3rem; padding: .6rem .75rem .45rem;
  border-top: 1px solid var(--hm-line-2);
  font-size: .78rem; font-weight: 600; color: var(--hm-600);
}
.bp__pie svg { width: 14px; height: 14px; }
.bp__pie:hover { color: var(--hm-700); }
@media (max-width: 480px) {
  .bp__ir span { display: none; }
  .bp__ir { padding: .68rem .8rem; }
}

/* Contador de los filtros: estaba en 10,9 px, ilegible en un móvil. */
.hm-filter__count { font-size: .72rem; min-width: 21px; height: 21px; }

/* En pantalla táctil los enlaces de listas —pie, barra superior, menús— ganan
   altura para que quepa el dedo, sin tocar el aspecto en escritorio. */
@media (pointer: coarse) {
  .hm-topbar a,
  footer ul a,
  footer li > a { padding-block: .3rem; }
}
