/* =========================================================
   Dr. Diego Torres — Cardiólogo · Puerto Vallarta
   Editorial clínico premium — CSS vanilla, sin frameworks
   ========================================================= */

:root {
  --navy: #233b5a;
  --navy-dark: #16283c;
  --navy-soft: rgba(35, 59, 90, 0.86);
  --cream: #fbfcfd;
  --cream-alt: #e8e9eb;
  --white: #ffffff;
  --coral: #668977;
  --coral-dark: #4f6b5d;
  --ink: #1b2a30;
  --ink-soft: #4d5c62;
  --line: rgba(35, 59, 90, 0.12);
  --shadow: 0 30px 60px -30px rgba(22, 40, 60, 0.35);
  --radius: 18px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--navy);
  line-height: 1.12;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2.6rem, 5.2vw, 4.6rem); }
h2 { font-size: clamp(2rem, 3.6vw, 3.1rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.6rem); }
p { margin: 0 0 1em; color: var(--ink-soft); }
.lede { font-size: clamp(1.05rem, 1.4vw, 1.25rem); color: var(--ink-soft); max-width: 46ch; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
}
.section {
  padding: clamp(4rem, 8vw, 7rem) 0;
}
.section--tight { padding: clamp(2.5rem, 5vw, 4rem) 0; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 1em;
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--coral);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  padding: 0.95em 1.8em;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  border: 1.5px solid transparent;
  transition: transform 0.35s var(--ease), background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn--coral { background: var(--coral); color: var(--white); box-shadow: 0 16px 30px -14px rgba(102, 137, 119, 0.55); }
.btn--coral:hover { background: var(--coral-dark); }
.btn--outline { border-color: rgba(251, 252, 253, 0.55); color: var(--white); }
.btn--outline:hover { background: rgba(251, 252, 253, 0.12); }
.btn--navy { background: var(--navy); color: var(--cream); }
.btn--navy:hover { background: var(--navy-dark); }
.btn--ghost { border-color: var(--line); color: var(--navy); }
.btn--ghost:hover { background: var(--cream-alt); }
.btn--block { width: 100%; }

/* =========================== NAV =========================== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  padding: 1.35rem 0;
  transition: background 0.4s var(--ease), padding 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.site-header.is-scrolled {
  background: rgba(251, 252, 253, 0.92);
  backdrop-filter: blur(10px);
  padding: 0.8rem 0;
  box-shadow: 0 10px 30px -20px rgba(22, 40, 60, 0.4);
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { height: 40px; width: auto; transition: filter 0.4s ease; }
.site-header:not(.is-scrolled) .brand img.logo-dark { display: none; }
.site-header.is-scrolled .brand img.logo-light { display: none; }

.nav-links { display: flex; align-items: center; gap: 2.1rem; }
.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--cream);
  position: relative;
  padding: 0.2rem 0;
}
.site-header.is-scrolled .nav-links a { color: var(--navy); }
.nav-links a::after {
  content: "";
  position: absolute; left: 0; bottom: -3px;
  width: 0; height: 1.5px;
  background: currentColor;
  transition: width 0.3s var(--ease);
}
.nav-links a:hover::after, .nav-links a.is-active::after { width: 100%; }
.nav-cta { display: flex; align-items: center; gap: 0.9rem; }
.nav-phone {
  display: none;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--cream);
}
.site-header.is-scrolled .nav-phone { color: var(--navy); }

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
  z-index: 210;
}
.menu-toggle span {
  width: 24px; height: 2px;
  background: var(--cream);
  transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
}
.site-header.is-scrolled .menu-toggle span,
.mobile-nav.is-open ~ .site-header .menu-toggle span { background: var(--navy); }

.mobile-nav {
  position: fixed; inset: 0;
  background: var(--navy);
  z-index: 199;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  transform: translateY(-100%);
  transition: transform 0.5s var(--ease);
}
.mobile-nav.is-open { transform: translateY(0); }
.mobile-nav a { font-family: var(--serif); font-size: 1.8rem; color: var(--cream); }
.mobile-nav .btn { margin-top: 1rem; }

@media (max-width: 900px) {
  .nav-links, .nav-phone { display: none; }
  .menu-toggle { display: flex; }
}

/* =========================== HERO =========================== */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  color: var(--cream);
  overflow: hidden;
}
.hero__media {
  position: absolute; inset: 0;
  z-index: 0;
}
.hero__media img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 20%;
  transform: scale(1.06);
  will-change: transform;
}
.hero__scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(22, 40, 60,0.55) 0%, rgba(22, 40, 60,0.35) 35%, rgba(22, 40, 60,0.88) 100%),
    linear-gradient(90deg, rgba(22, 40, 60,0.75) 0%, rgba(22, 40, 60,0.15) 60%);
}
.hero__content {
  position: relative; z-index: 2;
  padding: 8rem 0 4.5rem;
  width: 100%;
}
.hero__content h1 { color: var(--white); max-width: 15ch; }
.hero__content .lede { color: rgba(251, 252, 253,0.88); }
.hero__actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.hero__trust {
  margin-top: 3rem;
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.8rem;
  font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(251, 252, 253,0.7);
  border-top: 1px solid rgba(251, 252, 253,0.2);
  padding-top: 1.4rem;
}

/* Page (non-hero) header banner for interior pages */
.page-banner {
  position: relative;
  padding: 10.5rem 0 4.5rem;
  color: var(--cream);
  background: var(--navy);
  overflow: hidden;
}
.page-banner__media { position: absolute; inset: 0; }
.page-banner__media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.34; }
.page-banner__media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(22, 40, 60,0.5), rgba(22, 40, 60,0.96));
}
.page-banner__content { position: relative; z-index: 2; }
.page-banner h1 { color: var(--white); max-width: 20ch; }
.breadcrumb { font-size: 0.85rem; color: rgba(251, 252, 253,0.6); margin-bottom: 1rem; }
.breadcrumb a:hover { color: var(--coral); }

/* =========================== ECG DIVIDER =========================== */
.ecg-divider {
  position: relative;
  height: 90px;
  overflow: hidden;
  background: var(--cream);
}
.ecg-divider svg { width: 100%; height: 100%; display: block; }
.ecg-divider path {
  fill: none;
  stroke: var(--coral);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1600;
  stroke-dashoffset: 1600;
  transition: stroke-dashoffset 2.2s var(--ease);
}
.ecg-divider.is-visible path { stroke-dashoffset: 0; }
.ecg-divider--dark { background: var(--navy); }
.ecg-divider--dark path { stroke: var(--coral); }

/* =========================== TRUST BAR =========================== */
.trust-bar {
  background: var(--navy-dark);
  color: rgba(251, 252, 253,0.85);
  padding: 1.1rem 0;
}
.trust-bar .container {
  display: flex; flex-wrap: wrap; gap: 0.6rem 2.2rem;
  justify-content: center;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.trust-bar strong { color: var(--cream); font-weight: 600; }

/* =========================== SERVICES GRID =========================== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}
.service-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2.2rem 1.8rem;
  border: 1px solid var(--line);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s ease;
  display: flex; flex-direction: column; gap: 0.9rem;
}
.service-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: transparent; }
.service-card__icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--cream-alt);
  color: var(--coral);
}
.service-card__icon svg { width: 26px; height: 26px; }
.service-card h3 { margin-bottom: 0.2em; }
.service-card p { font-size: 0.95rem; margin-bottom: 0.4em; }
.service-card a { font-size: 0.88rem; font-weight: 600; color: var(--coral); }
.service-card a:hover { text-decoration: underline; }

/* Detailed service block (servicios.html) */
.service-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(3rem, 6vw, 5rem) 0;
  border-bottom: 1px solid var(--line);
}
.service-detail:last-of-type { border-bottom: none; }
.service-detail__media { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.service-detail__media img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4/3; }
.service-detail.reverse .service-detail__media { order: 2; }
.service-detail ul { margin: 1.2rem 0; display: flex; flex-direction: column; gap: 0.6rem; }
.service-detail li { display: flex; gap: 0.7rem; align-items: flex-start; font-size: 0.96rem; color: var(--ink-soft); }
.service-detail li svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 3px; color: var(--coral); }

@media (max-width: 800px) {
  .service-detail { grid-template-columns: 1fr; }
  .service-detail.reverse .service-detail__media { order: 0; }
}

/* =========================== ABOUT =========================== */
.about-split {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}
.about-split__media { position: relative; }
.about-split__media img { border-radius: var(--radius); box-shadow: var(--shadow); aspect-ratio: 1/1; object-fit: cover; }
.about-split__badge {
  position: absolute;
  bottom: -1.2rem; right: -1.2rem;
  background: var(--coral);
  color: var(--white);
  padding: 1rem 1.3rem;
  border-radius: 14px;
  font-family: var(--serif);
  font-size: 0.95rem;
  box-shadow: 0 20px 30px -14px rgba(102, 137, 119,0.5);
  max-width: 190px;
}
.credentials-list { margin: 1.6rem 0; display: flex; flex-direction: column; gap: 0.7rem; }
.credentials-list li {
  font-size: 0.92rem;
  color: var(--ink-soft);
  padding-left: 1.4rem;
  position: relative;
}
.credentials-list li::before {
  content: "";
  position: absolute; left: 0; top: 0.55em;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--coral);
}
@media (max-width: 800px) { .about-split { grid-template-columns: 1fr; } .about-split__badge { position: static; margin-top: 1rem; max-width: none; } }

/* =========================== CTA BANNER =========================== */
.cta-banner {
  background: var(--coral);
  color: var(--white);
  padding: clamp(3rem, 6vw, 4.5rem) 0;
  position: relative;
  overflow: hidden;
}
.cta-banner .container { position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2rem; }
.cta-banner h2 { color: var(--white); margin-bottom: 0.3em; max-width: 18ch; }
.cta-banner .lede { color: rgba(255,255,255,0.85); }
.cta-banner__actions { display: flex; flex-wrap: wrap; gap: 1rem; }
.cta-banner .btn--coral { background: var(--navy); box-shadow: none; }
.cta-banner .btn--coral:hover { background: var(--navy-dark); }

/* =========================== CONTACT =========================== */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
}
.contact-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: clamp(1.8rem, 3vw, 2.6rem);
  border: 1px solid var(--line);
}
.contact-method {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}
.contact-method:last-child { border-bottom: none; }
.contact-method__icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--cream-alt); color: var(--coral);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.contact-method__icon svg { width: 22px; height: 22px; }
.contact-method strong { display: block; color: var(--navy); font-size: 1.02rem; }
.contact-method span { font-size: 0.88rem; color: var(--ink-soft); }
@media (max-width: 800px) { .contact-grid { grid-template-columns: 1fr; } }

.map-frame-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  line-height: 0;
}
.map-frame-wrap iframe {
  width: 100%;
  height: 380px;
  border: 0;
  display: block;
}
.map-address {
  margin-top: 1.2rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.map-address strong { color: var(--navy); }

/* =========================== FOOTER =========================== */
.site-footer {
  background: var(--navy-dark);
  color: rgba(251, 252, 253,0.75);
  padding: clamp(3rem, 6vw, 4.5rem) 0 2rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid rgba(251, 252, 253,0.14);
}
.footer-grid img { height: 40px; margin-bottom: 1rem; }
.footer-grid h4 { color: var(--cream); font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1rem; }
.footer-grid ul { display: flex; flex-direction: column; gap: 0.65rem; }
.footer-grid a:hover { color: var(--coral); }
.footer-bottom {
  padding-top: 1.6rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  font-size: 0.8rem;
  color: rgba(251, 252, 253,0.5);
}
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; } }

/* =========================== STICKY MOBILE CTA =========================== */
.mobile-cta {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 190;
  display: none;
  background: var(--navy);
  box-shadow: 0 -10px 30px -10px rgba(0,0,0,0.3);
}
.mobile-cta .row { display: flex; }
.mobile-cta a {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0.95rem 0.5rem;
  font-weight: 600; font-size: 0.92rem;
  color: var(--cream);
}
.mobile-cta a.whatsapp { background: var(--coral); color: var(--white); }
.mobile-cta svg { width: 18px; height: 18px; }
@media (max-width: 900px) {
  .mobile-cta { display: block; }
  body { padding-bottom: 58px; }
}

/* =========================== REVEAL (defensive) =========================== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }
/* Defensive: split-text or JS-conflict safety net — never allow permanent invisibility */
.reveal[data-split] { opacity: 1; transform: none; }
noscript .reveal, .reveal { }

/* Stagger helper */
.reveal-group .reveal:nth-child(1) { transition-delay: 0.05s; }
.reveal-group .reveal:nth-child(2) { transition-delay: 0.15s; }
.reveal-group .reveal:nth-child(3) { transition-delay: 0.25s; }
.reveal-group .reveal:nth-child(4) { transition-delay: 0.35s; }
.reveal-group .reveal:nth-child(5) { transition-delay: 0.45s; }

/* Utility */
.text-center { text-align: center; margin-left: auto; margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mt-0 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Skip link (a11y) */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--coral); color: var(--white);
  padding: 0.8rem 1.2rem; z-index: 999; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
