:root {
  --papel: #f3ecdd;
  --papel-2: #ebe1cc;
  --tinta: #2b2118;
  --tinta-suave: #5d4e3f;
  --granate: #7b2d2d;
  --oro: #a8864a;
  --linea: #cdbf9f;
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, "Times New Roman", serif;
  --texto: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --ancho: 46rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--papel);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(168,134,74,.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(123,45,45,.05), transparent 45%);
  color: var(--tinta);
  font-family: var(--texto);
  font-size: 1.125rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--granate); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--tinta); }

#progreso {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--granate); z-index: 60;
}

.cabecera {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 3rem);
  background: rgba(243,236,221,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--linea);
}
.marca { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; color: var(--tinta); text-decoration: none; white-space: nowrap; }
.marca span { color: var(--granate); }
.menu { display: flex; gap: 1.3rem; flex-wrap: wrap; justify-content: flex-end; }
.menu a {
  font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--tinta-suave); text-decoration: none; padding: .2rem 0;
  border-bottom: 1px solid transparent;
}
.menu a:hover, .menu a.activo { color: var(--granate); border-bottom-color: var(--granate); }

.portada {
  min-height: 92vh;
  display: grid; grid-template-columns: 1.1fr .9fr; align-items: center;
  gap: clamp(1.5rem, 5vw, 5rem);
  padding: clamp(2rem, 6vw, 6rem) clamp(1.2rem, 6vw, 7rem);
  max-width: 82rem; margin: 0 auto;
}
.sobretitulo { font-size: .8rem; letter-spacing: .3em; text-transform: uppercase; color: var(--oro); margin: 0 0 1.2rem; }
.portada h1 {
  font-family: var(--serif); font-weight: 600; line-height: 1;
  font-size: clamp(3rem, 8vw, 6.5rem); margin: 0 0 1.5rem;
}
.portada h1 em { color: var(--granate); font-style: italic; font-weight: 500; }
.portada .entradilla { font-size: 1.25rem; max-width: 34rem; color: var(--tinta-suave); }
.portada .firma { font-family: var(--serif); font-style: italic; font-size: 1.3rem; margin-top: 1.6rem; }
.boton {
  display: inline-block; margin-top: 1.8rem; padding: .85rem 1.8rem;
  background: var(--granate); color: var(--papel); text-decoration: none;
  font-size: .8rem; letter-spacing: .18em; text-transform: uppercase;
  transition: background .25s, transform .25s;
}
.boton:hover { background: var(--tinta); color: var(--papel); transform: translateY(-2px); }
.retrato-portada { position: relative; justify-self: center; max-width: 24rem; }
.retrato-portada img {
  width: 100%; filter: sepia(.35) contrast(1.05);
  border: .7rem solid #fbf7ee; box-shadow: 0 25px 50px -20px rgba(43,33,24,.55);
  transform: rotate(2deg);
}
.retrato-portada::after {
  content: "Manuel y Carmen · El Retiro, Madrid";
  display: block; text-align: center; margin-top: 1.1rem;
  font-family: var(--serif); font-style: italic; color: var(--tinta-suave); font-size: 1.05rem;
}

.seccion { padding: clamp(3.5rem, 8vw, 7rem) clamp(1.2rem, 5vw, 4rem); }
.seccion.alt { background: var(--papel-2); border-block: 1px solid var(--linea); }
.encabezado { text-align: center; max-width: 40rem; margin: 0 auto 3.5rem; }
.encabezado .num { font-family: var(--serif); color: var(--oro); font-size: 1.1rem; letter-spacing: .3em; text-transform: uppercase; }
.encabezado h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.1; margin: .4rem 0 1rem; }
.encabezado p { color: var(--tinta-suave); margin: 0; }
.encabezado::after { content: ""; display: block; width: 4rem; height: 1px; background: var(--oro); margin: 1.8rem auto 0; }

/* ÁRBOL */
.arbol { max-width: 74rem; margin: 0 auto; }
.nivel-etiqueta {
  text-align: center; font-size: .72rem; letter-spacing: .3em; text-transform: uppercase;
  color: var(--oro); margin: 2.4rem 0 1rem;
}
.nivel { display: grid; gap: 1.2rem; }
.nivel.n2 { grid-template-columns: repeat(2, 1fr); }
.nivel.n4 { grid-template-columns: repeat(4, 1fr); }
.nivel.n1 { grid-template-columns: minmax(0, 28rem); justify-content: center; }
.pareja {
  display: flex; flex-direction: column; gap: .5rem; position: relative;
}
.pareja + .pareja::before { content: none; }
.persona {
  display: block; background: #fbf7ee; border: 1px solid var(--linea);
  padding: .9rem 1.1rem; text-decoration: none; color: var(--tinta);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
a.persona:hover { transform: translateY(-3px); box-shadow: 0 12px 24px -14px rgba(43,33,24,.5); border-color: var(--granate); }
.persona b { display: block; font-family: var(--serif); font-size: 1.2rem; line-height: 1.2; }
.persona small { display: block; color: var(--tinta-suave); font-size: .85rem; line-height: 1.4; margin-top: .2rem; }
.persona.principal { border-color: var(--granate); border-width: 2px; }
.union { text-align: center; color: var(--granate); font-family: var(--serif); font-size: 1.3rem; line-height: 1; }
.conector { height: 2.2rem; width: 1px; background: var(--oro); margin: .4rem auto 0; }
.hermanos { margin-top: 1rem; font-size: .92rem; color: var(--tinta-suave); text-align: center; max-width: 52rem; margin-inline: auto; }
.hermanos strong { color: var(--tinta); font-weight: 600; }
.rama { text-align: center; font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--granate); margin-bottom: .6rem; }

/* CRONOLOGÍA */
.cronologia { max-width: 62rem; margin: 0 auto; position: relative; padding: 0; list-style: none; }
.cronologia::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--oro); transform: translateX(-50%); }
.hito { position: relative; width: 50%; padding: 0 2.6rem 2.2rem 0; text-align: right; }
.hito:nth-child(even) { margin-left: 50%; padding: 0 0 2.2rem 2.6rem; text-align: left; }
.hito::after {
  content: ""; position: absolute; top: .55rem; right: -.4rem; width: .8rem; height: .8rem;
  background: var(--papel); border: 2px solid var(--granate); border-radius: 50%;
}
.hito:nth-child(even)::after { right: auto; left: -.4rem; }
.hito .año { font-family: var(--serif); font-size: 2rem; font-weight: 700; color: var(--granate); line-height: 1.1; }
.hito p { margin: .2rem 0 0; font-size: 1rem; line-height: 1.55; color: var(--tinta-suave); }
.hito.oscuro .año { color: var(--tinta); }

/* CAPÍTULOS */
.capitulo { max-width: var(--ancho); margin: 0 auto; }
.capitulo h3 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  line-height: 1.15; margin: 3.4rem 0 1rem; color: var(--tinta);
}
.capitulo h3:first-child { margin-top: 0; }
.capitulo h3 small { display: block; font-size: .8rem; letter-spacing: .25em; text-transform: uppercase; color: var(--oro); font-family: var(--texto); font-weight: 400; margin-bottom: .35rem; }
.capitulo p { margin: 0 0 1.15rem; hyphens: auto; }
.capitulo > p:first-of-type::first-letter { }
.entrada p:first-child::first-letter {
  font-family: var(--serif); font-size: 4.6rem; float: left; line-height: .8;
  padding: .35rem .6rem 0 0; color: var(--granate); font-weight: 600;
}
blockquote {
  margin: 1.8rem 0; padding: .4rem 0 .4rem 1.6rem;
  border-left: 3px solid var(--oro);
  font-family: var(--serif); font-size: 1.28rem; line-height: 1.55; font-style: italic; color: var(--tinta-suave);
}
blockquote p { margin: 0 0 .8rem; }
blockquote cite { display: block; font-style: normal; font-family: var(--texto); font-size: .85rem; letter-spacing: .06em; color: var(--oro); }

figure.foto { margin: 0; }
figure.foto img {
  border: .45rem solid #fbf7ee; box-shadow: 0 14px 28px -14px rgba(43,33,24,.55);
  filter: sepia(.22) contrast(1.03); cursor: zoom-in; transition: filter .3s, transform .3s;
  background: #fbf7ee;
}
figure.foto img:hover { filter: sepia(0); transform: rotate(-.6deg); }
figure.foto figcaption {
  font-family: var(--serif); font-style: italic; font-size: .98rem; line-height: 1.35;
  color: var(--tinta-suave); text-align: center; margin-top: .6rem; padding-inline: .3rem;
}
figure.foto.der { float: right; width: min(15rem, 42%); margin: .3rem -4.5rem 1rem 1.8rem; }
figure.foto.izq { float: left; width: min(15rem, 42%); margin: .3rem 1.8rem 1rem -4.5rem; }
figure.foto.ancha { float: none; width: min(26rem, 100%); margin: 2rem auto; }
.capitulo::after, .capitulo .limpia { content: ""; display: block; clear: both; }
.sin-float { clear: both; }

.pares { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.6rem; margin: 2rem 0; clear: both; align-items: start; }
.pares figure.foto { margin: 0; width: auto; float: none; }

.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; margin: 2rem 0; clear: both; align-items: start; }
.trio figure.foto { margin: 0; width: auto; float: none; }
.trio figure.foto figcaption { font-size: .88rem; }
@media (max-width: 760px) { .trio { grid-template-columns: 1fr; } }

.notas { max-width: var(--ancho); margin: 3rem auto 0; padding-top: 1.4rem; border-top: 1px solid var(--linea); font-size: .92rem; color: var(--tinta-suave); }
.notas ol { padding-left: 1.3rem; margin: 0; }
sup a { text-decoration: none; font-weight: 700; }

.pie { text-align: center; padding: 4rem 1.2rem 5rem; color: var(--tinta-suave); font-family: var(--serif); font-size: 1.1rem; border-top: 1px solid var(--linea); }
.pie p { margin: .3rem 0; }
.pie .escudo { font-size: 2.2rem; color: var(--granate); }
.pie small { font-family: var(--texto); font-size: .8rem; letter-spacing: .08em; }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s ease, transform .8s ease; }
.reveal.visible { opacity: 1; transform: none; }

#visor {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(30,22,15,.92); align-items: center; justify-content: center; flex-direction: column; padding: 2rem; cursor: zoom-out;
}
#visor.abierto { display: flex; }
#visor img { max-height: 82vh; max-width: 92vw; box-shadow: 0 0 60px rgba(0,0,0,.6); border: .5rem solid #fbf7ee; }
#visor p { color: #f3ecdd; font-family: var(--serif); font-style: italic; margin-top: 1rem; text-align: center; }

@media (max-width: 62rem) {
  figure.foto.der, figure.foto.izq { margin-inline: 1.4rem 0; }
  figure.foto.izq { margin-inline: 0 1.4rem; }
  figure.foto.der { margin-left: 1.4rem; margin-right: 0; }
  .nivel.n4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 48rem) {
  .menu { display: none; }
  .portada { grid-template-columns: 1fr; min-height: auto; }
  .retrato-portada { order: -1; max-width: 16rem; }
  .nivel.n2, .nivel.n4 { grid-template-columns: 1fr; }
  .cronologia::before { left: .5rem; }
  .hito, .hito:nth-child(even) { width: 100%; margin-left: 0; padding: 0 0 1.8rem 2.2rem; text-align: left; }
  .hito::after, .hito:nth-child(even)::after { left: .1rem; right: auto; }
  figure.foto.der, figure.foto.izq { float: none; width: min(16rem, 100%); margin: 1.5rem auto; }
  .pares { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
@media print {
  .cabecera, #progreso, #visor { display: none; }
  body { background: #fff; }
}

/* ÁRBOL APAISADO (estilo lámina) */
.tablero-marco { max-width: 1200px; margin: 0 auto; position: relative; background: #fff; box-shadow: 0 24px 50px -24px rgba(43,33,24,.5); border: 1px solid var(--linea); overflow: hidden; }
.tablero { position: absolute; top: 0; left: 0; width: 1200px; height: 850px; transform-origin: top left; background: #fff; }
.tablero .conectores { position: absolute; inset: 0; width: 1200px; height: 850px; }
.tablero-titulo { position: absolute; top: 18px; left: 0; width: 1200px; text-align: center; }
.guion { font-family: "Pinyon Script", "Cormorant Garamond", cursive; font-size: 3rem; line-height: 1.1; color: var(--tinta); display: block; }
.tablero-titulo small, .boda small { display: block; font-size: .72rem; letter-spacing: .28em; text-transform: uppercase; color: var(--oro); }
.arbolito { position: absolute; left: 520px; top: 96px; width: 160px; height: 180px; }
.fig { position: absolute; width: var(--fw, 130px); left: calc(var(--x) * 1px - var(--fw, 130px) / 2); top: calc(var(--y) * 1px - var(--h) / 2); text-align: center; text-decoration: none; color: var(--tinta); line-height: 1.2; }
.ovalo { display: block; width: var(--w); height: var(--h); margin: 0 auto; border-radius: 50%; overflow: hidden; background: #e8ede9; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #7f9487; transition: box-shadow .25s, transform .25s; }
.ovalo img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.05); }
.ovalo.sin-foto { display: flex; align-items: center; justify-content: center; }
.ovalo.sin-foto::before { content: none; }
a.fig:hover .ovalo { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--granate); transform: scale(1.04); }
a.fig:hover { color: var(--granate); }
.rotulo { display: block; margin-top: 12px; }
.rotulo b { display: block; font-family: var(--serif); font-size: 1.02rem; font-weight: 600; line-height: 1.15; }
.rotulo small { display: block; font-family: var(--serif); font-style: italic; font-size: .85rem; color: var(--tinta-suave); margin-top: 2px; }
.fig.centro .rotulo b { font-size: 1.12rem; }
.fig.autor .ovalo { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--granate); }
.boda { position: absolute; left: 0; width: 1200px; top: 560px; text-align: center; }
.boda .guion { font-size: 1.7rem; }
.boda small { letter-spacing: .12em; }
.arbol-movil { display: none; }
.nivel.n5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 760px) {
  .tablero-marco { display: none; }
  .arbol-movil { display: block; }
  .nivel.n5 { grid-template-columns: 1fr; }
}

.fig.hijo .rotulo small { white-space: nowrap; }

.ovalo { position: relative; }
.ovalo.giro90 img { position: absolute; width: var(--h); height: var(--w); left: calc((var(--w) - var(--h)) / 2); top: calc((var(--h) - var(--w)) / 2); transform: rotate(90deg); }

.lamina-web { max-width: 1200px; margin: 0 auto; }
.lamina-web[hidden] { display: none; }
.lamina-web img { width: 100%; height: auto; background: #fff; border: 1px solid var(--linea); box-shadow: 0 24px 50px -24px rgba(43,33,24,.5); }
.lamina-web figcaption { text-align: center; font-family: var(--serif); font-style: italic; color: var(--tinta-suave); margin-top: .8rem; }
.lamina-web .solo-movil { display: none; }
.con-lamina .arbol-movil { display: none !important; }
@media (max-width: 760px) {
  .lamina-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-inline: -1rem; padding-bottom: .4rem; }
  .lamina-web img { width: 880px; max-width: none; }
  .lamina-web .solo-ordenador { display: none; }
  .lamina-web .solo-movil { display: inline; }
}
