/* =========================================================
   Dr. Emiliano Cárdenas — Medicina interna, Xalapa
   Sistema: tinta + azul/menta del logotipo, serif editorial
   para voz, mono para el lenguaje del expediente.
   ========================================================= */

:root {
  --ink:        #0E2233;
  --ink-2:      #1B3A52;
  --ink-soft:   #4A6376;
  --azul:       #528AC8;
  --azul-deep:  #2E5F97;
  --azul-wash:  #EAF1F9;
  --menta:      #7CC7B9;
  --menta-wash: #E7F4F1;
  --papel:      #F3F6F5;
  --white:      #FFFFFF;
  --line:       rgba(14, 34, 51, .13);
  --line-soft:  rgba(14, 34, 51, .07);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --pad-x: clamp(20px, 5vw, 56px);
  --sec-y: clamp(72px, 9vw, 128px);
  --r: 14px;
  --shadow: 0 1px 2px rgba(14,34,51,.04), 0 12px 32px -18px rgba(14,34,51,.28);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, iframe { display: block; max-width: 100%; }
a { color: inherit; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.25rem, 4.6vw, 3.7rem); }
h2 { font-size: clamp(1.95rem, 3.8vw, 3rem); }
h3 { font-size: 1.28rem; line-height: 1.25; }
p  { margin: 0; }

::selection { background: var(--menta); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--azul-deep);
  outline-offset: 3px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: -999px; top: 12px; z-index: 200;
  background: var(--ink); color: var(--white);
  padding: 10px 16px; border-radius: 8px; text-decoration: none;
  font-family: var(--mono); font-size: .8rem;
}
.skip:focus { left: 16px; }

.wrap { width: min(1180px, 100%); margin-inline: auto; padding-inline: var(--pad-x); }

.kicker {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--azul-deep);
  margin-bottom: 18px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: .95rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--azul-deep); }

.btn-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); background: var(--papel); }

.btn-block { width: 100%; justify-content: center; padding-block: 15px; }

.ico { width: 18px; height: 18px; fill: currentColor; }

/* ---------- Navegación ---------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease, background .25s ease;
}
.nav.is-stuck { border-bottom-color: var(--line-soft); }

.nav-inner {
  width: min(1180px, 100%); margin-inline: auto;
  padding: 14px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--serif); font-weight: 500; font-size: 1.06rem; }
.brand-text span {
  font-family: var(--mono); font-size: .66rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
}

.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links > a {
  padding: 9px 14px; border-radius: 999px;
  text-decoration: none; font-size: .95rem; color: var(--ink-soft);
  transition: color .18s ease, background .18s ease;
}
.nav-links > a:hover { color: var(--ink); background: var(--papel); }
.nav-links > a.is-active { color: var(--ink); }
.nav-cta { margin-left: 10px; }
.nav-links > a.nav-cta { color: var(--white); }
.nav-links > a.nav-cta:hover { color: var(--white); background: var(--azul-deep); }

.nav-toggle {
  display: none; width: 44px; height: 44px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--white); cursor: pointer;
}
.nav-toggle-bars { display: block; width: 18px; }
.nav-toggle-bars i {
  display: block; height: 1.5px; background: var(--ink); border-radius: 2px;
  transition: transform .22s ease, opacity .22s ease;
}
.nav-toggle-bars i + i { margin-top: 5px; }
.nav-toggle[aria-expanded="true"] i:first-child { transform: translateY(3.25px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] i:last-child  { transform: translateY(-3.25px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { padding: clamp(52px, 7vw, 92px) 0 clamp(48px, 6vw, 76px); position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -220px -10% auto 40%;
  height: 640px; z-index: -1;
  background:
    radial-gradient(46% 46% at 30% 40%, rgba(124,199,185,.30), transparent 70%),
    radial-gradient(48% 48% at 72% 28%, rgba(82,138,200,.24), transparent 72%);
  filter: blur(12px);
}

.hero-title { margin-bottom: clamp(32px, 4vw, 52px); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: clamp(32px, 5vw, 72px); align-items: start;
}
.hero-copy { padding-top: 4px; }

.mark { position: relative; white-space: nowrap; }
.mark-line {
  position: absolute; left: 0; right: 0; bottom: -.06em;
  width: 100%; height: .22em; overflow: visible;
}
.mark-line path {
  fill: none; stroke: var(--menta); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 320; stroke-dashoffset: 320;
  animation: draw 1s cubic-bezier(.4,0,.2,1) .5s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.lede {
  font-size: clamp(1.05rem, 1.5vw, 1.22rem);
  color: var(--ink-soft);
  max-width: 34em;
  margin-bottom: 32px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }

.hero-note {
  font-family: var(--mono); font-size: .78rem; line-height: 1.7;
  color: var(--ink-soft);
}

/* ---------- Firma: hoja de expediente ---------- */
.chart {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 0;
}
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--papel);
  border-bottom: 1px solid var(--line);
}
.chart-title {
  font-family: var(--mono); font-size: .74rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink);
}
.chart-id {
  font-family: var(--mono); font-size: .7rem;
  letter-spacing: .12em; color: var(--azul-deep);
}
.chart-rows { margin: 0; }
.chart-row {
  display: grid; grid-template-columns: 116px 1fr;
  gap: 16px; padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.chart-row:last-child { border-bottom: 0; }
.chart-row dt {
  font-family: var(--mono); font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); padding-top: 4px;
}
.chart-row dd { margin: 0; font-size: .96rem; line-height: 1.55; }
.chart-row dd em { font-style: italic; color: var(--azul-deep); }

.chart-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  background: var(--menta-wash);
  font-family: var(--mono); font-size: .74rem; line-height: 1.5;
  color: var(--ink-2);
}
.chart-dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--menta); box-shadow: 0 0 0 4px rgba(124,199,185,.3);
}

/* ---------- Cifras ---------- */
.facts {
  list-style: none; margin: clamp(48px, 6vw, 80px) 0 0; padding: 26px 0 0;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px;
}
.facts li { display: flex; flex-direction: column; gap: 4px; }
.facts strong {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(2rem, 3.4vw, 2.8rem); line-height: 1;
  color: var(--ink);
}
.facts span {
  font-family: var(--mono); font-size: .73rem; line-height: 1.5;
  letter-spacing: .04em; color: var(--ink-soft);
}

/* ---------- Secciones ---------- */
.section { padding-block: var(--sec-y); }
.section-paper { background: var(--papel); }

.sec-head { max-width: 640px; margin-bottom: clamp(40px, 5vw, 64px); }
.sec-head-center { margin-inline: auto; text-align: center; }
.sec-lede { color: var(--ink-soft); font-size: 1.06rem; margin-top: 18px; }
.sec-head .btn { margin-top: 28px; }

/* ---------- Servicios ---------- */
.cards {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.card {
  background: var(--white); padding: 30px 26px 34px;
  display: flex; flex-direction: column; gap: 10px;
  transition: background .22s ease;
}
.card:hover { background: var(--azul-wash); }
.card-tag {
  font-family: var(--mono); font-size: .66rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--azul-deep);
}
.card h3 { margin-top: 2px; }
.card p { font-size: .94rem; color: var(--ink-soft); line-height: 1.6; }

/* ---------- Consulta ---------- */
.consulta-grid {
  display: grid; grid-template-columns: .85fr 1.15fr;
  gap: clamp(32px, 5vw, 80px); align-items: start;
}
.consulta-grid .sec-head { margin-bottom: 0; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.step {
  display: grid; grid-template-columns: 108px 1fr; gap: 0 24px;
  padding: 26px 0; border-top: 1px solid var(--line);
}
.step:last-child { border-bottom: 1px solid var(--line); }
.step-time {
  grid-column: 1; grid-row: 1 / span 2;
  font-family: var(--mono); font-size: .76rem; letter-spacing: .06em;
  color: var(--azul-deep); padding-top: 5px;
}
.step h3 { grid-column: 2; margin-bottom: 8px; }
.step p { grid-column: 2; color: var(--ink-soft); font-size: .97rem; }

/* ---------- Sobre mí ---------- */
.section-ink { background: var(--ink); color: rgba(255,255,255,.86); }
.section-ink h2 { color: var(--white); }
.section-ink .kicker { color: var(--menta); }

.sobre-grid {
  display: grid; grid-template-columns: .8fr 1.2fr;
  gap: clamp(36px, 5vw, 80px); align-items: start;
}
.sobre-aside { display: flex; flex-direction: column; gap: 20px; }

.portrait {
  margin: 0; border-radius: var(--r); overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.045);
}
.portrait img {
  width: 100%; height: auto; aspect-ratio: 4 / 5;
  object-fit: cover; object-position: 50% 45%;
}
.portrait figcaption {
  display: flex; flex-direction: column; gap: 4px;
  padding: 15px 18px; border-top: 1px solid rgba(255,255,255,.12);
  font-family: var(--mono); font-size: .74rem; letter-spacing: .04em;
  color: rgba(255,255,255,.9);
}
.portrait figcaption span { color: rgba(255,255,255,.55); font-size: .7rem; }

.chart-dark { background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.14); box-shadow: none; }
.chart-dark .chart-head { background: rgba(255,255,255,.05); border-bottom-color: rgba(255,255,255,.12); }
.chart-dark .chart-title { color: var(--white); }
.chart-dark .chart-id { color: var(--menta); }
.chart-dark .chart-row { border-bottom-color: rgba(255,255,255,.09); }
.chart-dark .chart-row dt { color: rgba(255,255,255,.55); }
.chart-dark .chart-row dd { color: rgba(255,255,255,.9); font-size: .92rem; }

.sobre-copy h2 { margin-bottom: 28px; max-width: 15ch; }
.prose { display: flex; flex-direction: column; gap: 18px; max-width: 56ch; font-size: 1.03rem; }

.quote {
  margin: 36px 0 0; padding: 4px 0 4px 24px;
  border-left: 2px solid var(--menta);
}
.quote p {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(1.2rem, 2vw, 1.5rem); line-height: 1.4; color: var(--white);
  max-width: 30ch;
}

/* ---------- Testimonios ---------- */
.quotes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.qcard {
  margin: 0; padding: 30px 28px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column; gap: 20px;
}
.qcard blockquote {
  margin: 0; font-family: var(--serif); font-weight: 300;
  font-size: 1.16rem; line-height: 1.45; color: var(--ink);
}
.qcard figcaption {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .04em;
  color: var(--ink); display: flex; flex-direction: column; gap: 3px;
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-soft);
}
.qcard figcaption span { color: var(--ink-soft); }

/* ---------- Contacto ---------- */
.contacto-grid {
  display: grid; grid-template-columns: .85fr 1.15fr;
  gap: clamp(32px, 5vw, 72px); align-items: start;
}

.info-list { margin: 0; }
.info-row {
  padding: 18px 0; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 104px 1fr; gap: 18px;
}
.info-row:last-child { border-bottom: 1px solid var(--line); }
.info-row dt {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft); padding-top: 3px;
}
.info-row dd { margin: 0; font-size: .97rem; line-height: 1.6; }
.info-row a { color: var(--azul-deep); text-decoration: none; border-bottom: 1px solid rgba(46,95,151,.3); }
.info-row a:hover { border-bottom-color: var(--azul-deep); }

.form {
  background: var(--papel); border: 1px solid var(--line);
  border-radius: var(--r); padding: clamp(24px, 3vw, 36px);
  display: flex; flex-direction: column; gap: 18px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field label {
  font-family: var(--mono); font-size: .72rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
}
.field .opt { text-transform: none; letter-spacing: 0; }

.field input, .field select, .field textarea {
  font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: var(--white); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; width: 100%;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(82,138,200,.18);
}
.field.has-error input, .field.has-error select { border-color: #C0483C; }

.error { font-family: var(--mono); font-size: .72rem; color: #C0483C; min-height: 0; }
.error:empty { display: none; }

.form-note { font-family: var(--mono); font-size: .72rem; line-height: 1.6; color: var(--ink-soft); }
.form-status {
  font-family: var(--mono); font-size: .8rem; line-height: 1.6;
  color: var(--ink-2); background: var(--menta-wash);
  border-radius: 10px; padding: 14px 16px;
}
.form-status:empty { display: none; }

/* ---------- Mapa ---------- */
.map-block { margin-top: clamp(52px, 6vw, 88px); }
.map-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 24px;
}
.map-head h3 { font-size: 1.5rem; }
.map-sub { color: var(--ink-soft); font-size: .97rem; margin-top: 8px; max-width: 46ch; }

.map-frame {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--papel);
}
.map-frame iframe {
  width: 100%; height: clamp(320px, 42vh, 460px); border: 0;
  filter: saturate(.72) contrast(1.02);
}

/* ---------- Pie ---------- */
.footer { background: var(--ink); color: rgba(255,255,255,.72); padding-top: clamp(52px, 6vw, 80px); }
.footer-grid {
  display: grid; grid-template-columns: 1.1fr .7fr 1.2fr;
  gap: 36px; padding-bottom: 44px;
}
.footer-brand { display: flex; align-items: flex-start; gap: 14px; }
.footer-brand p { font-size: .95rem; line-height: 1.6; color: rgba(255,255,255,.72); }
.footer-brand strong { color: var(--white); font-family: var(--serif); font-weight: 500; font-size: 1.08rem; }

.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-links a { text-decoration: none; font-size: .95rem; color: rgba(255,255,255,.72); }
.footer-links a:hover { color: var(--white); }

.footer-legal { font-family: var(--mono); font-size: .73rem; line-height: 1.75; color: rgba(255,255,255,.5); }
.demo-chip {
  display: inline-block; margin-right: 8px; padding: 3px 10px;
  border: 1px solid rgba(124,199,185,.5); border-radius: 999px;
  color: var(--menta); letter-spacing: .1em; text-transform: uppercase; font-size: .64rem;
}

.footer-base {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-block: 20px; border-top: 1px solid rgba(255,255,255,.12);
  font-family: var(--mono); font-size: .72rem; color: rgba(255,255,255,.45);
}
.footer-base a { text-decoration: none; }
.footer-base a:hover { color: var(--white); }

/* ---------- Animación de entrada ---------- */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .6s cubic-bezier(.2,.6,.2,1), transform .6s cubic-bezier(.2,.6,.2,1);
  transition-delay: var(--d, 0ms);
}

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .nav-links {
    position: absolute; inset: 100% 0 auto; display: none;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--white); border-bottom: 1px solid var(--line);
    padding: 12px var(--pad-x) 20px;
  }
  .nav-links.is-open { display: flex; }
  .nav-links > a { padding: 12px 4px; font-size: 1.05rem; }
  .nav-cta { margin: 8px 0 0; justify-content: center; }
  .nav-toggle { display: inline-flex; }

  .hero-grid,
  .consulta-grid,
  .sobre-grid,
  .contacto-grid { grid-template-columns: 1fr; }

  .consulta-grid .sec-head { margin-bottom: 8px; }
  .sobre-aside { max-width: 420px; }
  .facts { grid-template-columns: repeat(2, 1fr); gap: 28px 24px; }
  .quotes { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  /* Al envolverse en varias líneas, el trazo dibujado deja de funcionar:
     se sustituye por un subrayado que sí sigue el texto. */
  .mark {
    white-space: normal;
    text-decoration: underline;
    text-decoration-color: var(--menta);
    text-decoration-thickness: 3px;
    text-underline-offset: 7px;
  }
  .mark-line { display: none; }
  .cards { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; gap: 6px; }
  .step { grid-template-columns: 1fr; gap: 6px 0; }
  .step-time { grid-row: auto; }
  .step-time, .step h3, .step p { grid-column: 1; }
  .info-row { grid-template-columns: 1fr; gap: 6px; }
  .field-row { grid-template-columns: 1fr; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .map-head { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .mark-line path { animation: none; stroke-dashoffset: 0; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
