/* =========================================================
   BASE · reset, tipografía, cabecera, contacto
   ========================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
}
html.is-chapter { overflow: hidden; }

body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color var(--t-theme) ease, color var(--t-theme) ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; height: auto; }
ol, ul { list-style: none; }
em { font-style: normal; font-weight: 600; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 5px; border-radius: 2px; }

.skip {
  position: fixed; left: var(--margin); top: -4rem; z-index: 200;
  background: var(--fg); color: var(--bg); padding: .7rem 1rem; font-size: .85rem;
}
.skip:focus { top: .8rem; }

/* ---------- Cabecera ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--margin);
  pointer-events: none;
  /* blanco + difference: legible sobre papel, sobre el monograma negro y sobre cualquier atmósfera */
  color: #fff; mix-blend-mode: difference;
}
.site-header > * { pointer-events: auto; }

.site-header__mark {
  display: block; width: 34px;
  opacity: clamp(0, calc((var(--p, 0) - .55) * 4), 1);
}
.site-header__mark svg { display: block; width: 100%; height: auto; fill: currentColor; }

.site-header__nav { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 2.2rem); margin-left: auto; }
.site-header__nav a, .lang {
  position: relative;
  font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
}
.site-header__nav a::after, .lang::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease-out);
}
.site-header__nav a:hover::after, .lang:hover::after,
.site-header__nav a:focus-visible::after, .lang:focus-visible::after { transform: scaleX(1); }
.lang { padding: 0; }

/* Selector de idioma ES · EN · BG */
.langs { display: inline-flex; align-items: center; gap: .15rem; }
.langs__b {
  position: relative; padding: .45rem .4rem; min-width: 2rem;
  font: 600 .72rem/1 var(--font); letter-spacing: .16em; text-transform: uppercase;
  opacity: .5; transition: opacity .3s ease;
}
.langs__b:hover, .langs__b:focus-visible, .langs__b[aria-pressed="true"] { opacity: 1; }
.langs__b::after {
  content: ""; position: absolute; left: .4rem; right: .4rem; bottom: .15rem; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease-out);
}
.langs__b[aria-pressed="true"]::after { transform: scaleX(1); }

/* ---------- Contacto ---------- */
.contact {
  padding: 8vh var(--margin) 5vh;
  display: flex; flex-direction: column; align-items: flex-start;
}
.contact__label {
  font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  margin-bottom: 2.4rem;
}
.contact__mail {
  position: relative; display: inline-block;
  font-weight: 300; letter-spacing: -.03em; line-height: 1.05;
  font-size: clamp(1.5rem, 5.6vw, 5.4rem);
  overflow-wrap: anywhere;
}
.contact__mail::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -.08em; height: 2px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .7s var(--ease-out);
}
.contact__mail:hover::after, .contact__mail:focus-visible::after { transform: scaleX(1); }
.contact__line { margin-top: 1.6rem; font-size: .95rem; opacity: .7; }
.contact__link { position: relative; display: inline-block; padding: .6rem 0; margin: -.6rem 0; } /* área táctil mayor, sin cambio visual */
.contact__link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: calc(.6rem - 2px); height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease-out);
}
.contact__link:hover::after, .contact__link:focus-visible::after { transform: scaleX(1); }
/* Firma final: nombre y especialidad a la izquierda, MD pequeño (el SVG original) a la derecha, alineados por la base */
.contact__sign {
  margin-top: clamp(4rem, 11vh, 6.5rem); padding-top: clamp(1.4rem, 3vh, 2rem); width: 100%;
  border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem 2rem;
}
.contact__who {
  margin: 0; display: flex; flex-direction: column; gap: .35rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; line-height: 1.4;
}
.contact__who span:last-child { font-weight: 400; opacity: .7; }
.contact__mark { flex: none; display: block; width: 4.5rem; height: auto; aspect-ratio: 734 / 583; fill: currentColor; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-delay: 0s !important; }
}
