/* Viaje de Toya al fin del mundo — carta náutica en pergamino */
:root {
  color-scheme: light;
  --pergamino: #e4cf9f;
  --pergamino-claro: #f0e2bf;
  --pergamino-hondo: #cdb27a;
  --tinta: #2a1a0e;
  --tinta-suave: #5b4330;
  --mar: #34586a;
  --sangre: #8b2316;
  --sangre-hondo: #63170d;
  --laton: #9a6f22;
  --hielo: #eef0e6;

  --display: "Pirata One", "IM Fell English", Georgia, serif;
  --texto: "IM Fell English", Georgia, "Times New Roman", serif;

  --paso-1: .5rem; --paso-2: .75rem; --paso-3: 1rem; --paso-4: 1.5rem; --paso-5: 2.25rem; --paso-6: 3.5rem;
  --barra: 3.25rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--barra) + .5rem); }
body {
  margin: 0;
  background: var(--pergamino);
  color: var(--tinta);
  font: 1.125rem/1.6 var(--texto);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: oldstyle-nums;
}
/* Textura de papel y bordes quemados, sobre toda la página */
body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60;
}
body::before { filter: url(#papel); opacity: .32; background: #fff; mix-blend-mode: multiply; }
body::after { background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(92, 54, 18, .28) 88%, rgba(60, 30, 8, .5) 100%); }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--sangre); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--sangre-hondo); }
:focus-visible { outline: 2px dashed var(--sangre); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.05; margin: 0; letter-spacing: .01em; }
em { font-style: italic; }

/* ---------- Barra superior ---------- */
.barra {
  position: fixed; inset: 0 0 auto 0; height: var(--barra); z-index: 50;
  display: flex; align-items: center; gap: var(--paso-3); padding: 0 var(--paso-3);
  background: rgba(42, 26, 14, .94); color: var(--pergamino-claro);
  border-bottom: 1px solid #000;
}
.barra-nombre { font-family: var(--display); font-size: 1.35rem; color: inherit; text-decoration: none; margin-right: auto; white-space: nowrap; }
.barra-nav { display: flex; gap: var(--paso-3); }
.barra-nav a { color: var(--pergamino-claro); text-decoration: none; font-style: italic; padding: .6rem .2rem; }
.barra-nav a:hover { text-decoration: underline; color: #fff; }
.musica {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 2.5rem; padding: 0 .9rem;
  font: italic 1rem var(--texto); color: var(--tinta); background: var(--pergamino-claro);
  border: 1px solid var(--laton); border-radius: 2rem; cursor: pointer;
}
.musica svg { width: 1rem; height: 1rem; }
.musica[aria-pressed="true"] { background: var(--sangre); color: var(--pergamino-claro); border-color: var(--sangre-hondo); }
.barra :focus-visible { outline-color: var(--pergamino-claro); }

/* ---------- Portada ---------- */
.portada {
  min-height: 100svh; padding: calc(var(--barra) + var(--paso-5)) var(--paso-3) var(--paso-5);
  display: grid; gap: var(--paso-5); align-content: center;
  grid-template-columns: minmax(0, 1fr);
  max-width: 78rem; margin: 0 auto; position: relative;
}
.portada-fecha { font-style: italic; color: var(--tinta-suave); margin: 0 0 var(--paso-2); font-size: 1.15rem; }
.portada h1 {
  font-size: clamp(3.6rem, 13vw, 8.8rem); line-height: .86; color: var(--tinta);
  text-shadow: 0 1px 0 rgba(255, 245, 220, .5);
}
.portada h1 span { display: block; font-size: .52em; line-height: 1.1; margin-top: .25em; color: var(--sangre); }
.portada-bajada { font-size: clamp(1.2rem, 2.4vw, 1.45rem); max-width: 34ch; margin: var(--paso-4) 0 var(--paso-5); }
.portada-acciones { display: flex; align-items: center; gap: var(--paso-4); flex-wrap: wrap; }
.portada-ayuda { max-width: 30ch; margin: 0; font-style: italic; color: var(--tinta-suave); font-size: 1rem; }

/* Sello de lacre */
.sello {
  --t: 7.25rem;
  width: var(--t); height: var(--t); flex: none; display: grid; place-items: center; text-decoration: none;
  color: #f6dccf; font: 1.7rem var(--display); letter-spacing: .02em;
  background:
    radial-gradient(circle at 38% 32%, rgba(255, 170, 150, .55), transparent 42%),
    radial-gradient(circle, var(--sangre) 58%, var(--sangre-hondo) 62%, var(--sangre) 66%, var(--sangre-hondo) 100%);
  border-radius: 46% 54% 50% 50% / 52% 48% 54% 46%;
  box-shadow: 0 3px 0 var(--sangre-hondo), 0 8px 18px rgba(60, 20, 5, .35), inset 0 0 0 7px rgba(0, 0, 0, .12);
  transform: rotate(-8deg); transition: transform .2s ease;
}
.sello span { border: 1.5px dashed rgba(246, 220, 207, .55); border-radius: 50%; width: 76%; height: 76%; display: grid; place-items: center; }
.sello:hover { color: #fff; transform: rotate(-3deg) scale(1.04); }
.sello:active { transform: rotate(-3deg) scale(.97); }

.lamina { margin: 0; position: relative; justify-self: center; max-width: 34rem; transform: rotate(1.5deg); }
.lamina img {
  width: 100%; aspect-ratio: 3 / 2; object-fit: cover;
  border: 10px solid var(--pergamino-claro); outline: 1px solid var(--tinta-suave);
  box-shadow: 0 14px 30px rgba(60, 35, 10, .35);
  filter: sepia(.25) saturate(1.05) contrast(1.02);
}
.lamina figcaption { font-style: italic; text-align: center; margin-top: var(--paso-2); color: var(--tinta-suave); }

.gramola { display: flex; align-items: center; gap: var(--paso-3); max-width: 30rem; }
.gramola-marco { flex: none; width: 200px; height: 200px; border: 6px solid var(--tinta); background: var(--tinta); box-shadow: 0 0 0 1px var(--laton); }
.gramola-marco iframe, #yt { width: 100%; height: 100%; display: block; border: 0; }
.gramola p { margin: 0; font-size: 1rem; font-style: italic; color: var(--tinta-suave); }

@media (min-width: 60rem) {
  .portada { grid-template-columns: 1.15fr .85fr; grid-template-areas: "texto lamina" "texto gramola"; column-gap: var(--paso-6); }
  .portada-texto { grid-area: texto; align-self: center; }
  .lamina { grid-area: lamina; align-self: end; }
  .gramola { grid-area: gramola; align-self: start; justify-self: center; }
}

/* ---------- La carta: mapa + bitácora ---------- */
.carta { display: grid; grid-template-columns: minmax(0, 1fr); border-top: 2px solid var(--tinta); }
.carta-mapa {
  position: sticky; top: var(--barra); z-index: 10; height: 42svh;
  background: var(--pergamino); border-bottom: 2px solid var(--tinta);
}
.mapa-marco { position: relative; height: 100%; padding: .4rem; }
#mapa { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; border: 1.5px solid var(--tinta); outline: 4px double var(--tinta-suave); outline-offset: -8px; background: rgba(240, 226, 191, .35); }
#mapa.arrastrando { cursor: grabbing; }
.mapa-controles { position: absolute; right: .9rem; top: .9rem; display: flex; gap: .3rem; }
.mapa-controles button {
  min-width: 2.5rem; min-height: 2.5rem; padding: 0 .6rem; cursor: pointer;
  font: 1.2rem var(--texto); color: var(--tinta); background: var(--pergamino-claro);
  border: 1px solid var(--tinta-suave); border-radius: 3px;
}
.mapa-controles button:hover { background: #fff7e2; }
#z-isla { font-size: .95rem; font-style: italic; }
.mapa-resumen {
  position: absolute; left: .9rem; bottom: .9rem; margin: 0; max-width: calc(100% - 1.8rem);
  background: rgba(240, 226, 191, .92); border: 1px solid var(--tinta-suave); padding: .25rem .6rem;
  font-size: .95rem; font-style: italic;
}

/* Elementos del mapa */
.m-mar-linea { stroke: var(--mar); fill: none; }
.m-tierra { fill: #eddcb4; stroke: var(--tinta); stroke-width: 1.1; stroke-linejoin: round; }
.m-costa { fill: none; stroke: var(--mar); stroke-linejoin: round; }
.m-glaciar { fill: var(--hielo); stroke: #7d8f95; stroke-width: .6; stroke-dasharray: 1.5 1.5; }
.m-rio { fill: none; stroke: var(--mar); stroke-width: .6; opacity: .7; }
.m-reticula { stroke: var(--tinta-suave); stroke-width: .4; opacity: .35; fill: none; }
.m-rumbo { stroke: var(--laton); stroke-width: .5; opacity: .4; }
.m-etiqueta-mar { font: italic 15px var(--texto); fill: var(--mar); letter-spacing: .3em; opacity: .85; }
.m-etiqueta-hielo { font: italic 11px var(--texto); fill: #56676c; letter-spacing: .15em; }
.m-grado { font: 9px var(--texto); fill: var(--tinta-suave); }
.m-ruta { fill: none; stroke: var(--sangre); stroke-width: 2.6; stroke-dasharray: 7 5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.m-ruta-sombra { fill: none; stroke: rgba(255, 245, 220, .8); stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.m-tramo.activo .m-ruta { stroke-width: 3.6; stroke-dasharray: none; }
.m-alt { fill: var(--pergamino-claro); stroke: var(--tinta-suave); stroke-width: 1.2; opacity: .8; cursor: pointer; vector-effect: non-scaling-stroke; }
.m-alt:hover, .m-alt:focus-visible { opacity: 1; stroke: var(--sangre); }
.m-camp { cursor: pointer; }
.m-camp circle { fill: var(--sangre); stroke: var(--pergamino-claro); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.m-camp text { fill: #fff3df; font: 700 12px var(--texto); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.m-camp.activo circle { fill: var(--tinta); }
.m-lugar { fill: var(--tinta); }
.m-lugar-etiqueta { font: italic 13px var(--texto); fill: var(--tinta); paint-order: stroke; stroke: rgba(240, 226, 191, .95); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.m-lugares { opacity: .45; transition: opacity .3s; }
.m-lugares.activo { opacity: 1; }
.m-lugares:not(.activo) .m-lugar-etiqueta { display: none; }
.m-ancla { color: var(--tinta); }
.m-titulo { font-family: var(--display); fill: var(--tinta); }
.m-serpiente { fill: none; stroke: var(--mar); stroke-width: 1.4; stroke-linecap: round; }

/* ---------- Bitácora ---------- */
.bitacora { padding: var(--paso-5) var(--paso-3) var(--paso-6); }
.bitacora-intro { max-width: 40rem; margin-bottom: var(--paso-5); }
.bitacora-intro h2 { font-size: clamp(2.4rem, 6vw, 3.4rem); }
.bitacora-intro p { margin: var(--paso-2) 0 0; }
.dias { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--paso-6); }

.dia { position: relative; min-width: 0; scroll-margin-top: calc(var(--barra) + 44svh); }
.dia-cabeza { display: grid; grid-template-columns: auto 1fr; column-gap: var(--paso-3); align-items: baseline; }
.dia-numero { font: 3.3rem/1 var(--display); color: var(--sangre); grid-row: span 2; min-width: 2.2ch; text-align: right; }
.dia-fecha { font-style: italic; color: var(--tinta-suave); }
.dia-titulo { font-size: clamp(1.9rem, 4.5vw, 2.5rem); }
.dia-etapa { grid-column: 2; margin: .1rem 0 0; font-style: italic; }
.dia-tramo {
  margin: var(--paso-3) 0 0; padding: var(--paso-2) var(--paso-3);
  border-left: 3px solid var(--sangre); background: rgba(240, 226, 191, .55);
}
.dia-tramo strong { font-weight: 400; font-family: var(--display); font-size: 1.25rem; letter-spacing: .02em; }
.dia-tramo .largo { display: inline-flex; align-items: center; gap: .3rem; color: var(--sangre); font-style: italic; }
.dia-tramo .largo svg { width: 1.1rem; height: 1.1rem; }
.dia-nota { margin: var(--paso-2) 0 0; font-style: italic; color: var(--sangre-hondo); }

.lugares {
  list-style: none; margin: var(--paso-4) calc(-1 * var(--paso-3)) 0; padding: .25rem var(--paso-3) var(--paso-3);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(13rem, 16rem); gap: var(--paso-3);
  overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: var(--paso-3); scrollbar-color: var(--tinta-suave) transparent;
}
.lugar { scroll-snap-align: start; }
.lugar a { color: inherit; text-decoration: none; display: block; }
.lugar figure { margin: 0; }
.lugar img, .lugar .sin-foto {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--pergamino-hondo);
  border: 6px solid var(--pergamino-claro); outline: 1px solid rgba(91, 67, 48, .55);
  box-shadow: 0 6px 14px rgba(60, 35, 10, .22); filter: sepia(.18);
}
.lugar .sin-foto { display: grid; place-items: center; font: 2.4rem var(--display); color: var(--tinta-suave); filter: none; }
.lugar h4 { margin: var(--paso-2) 0 0; font: 1.25rem/1.15 var(--display); letter-spacing: .01em; font-weight: 400; }
.lugar p { margin: .2rem 0 0; font-size: 1rem; line-height: 1.4; color: var(--tinta-suave); }
.lugar a:hover h4 { color: var(--sangre); text-decoration: underline; text-decoration-thickness: 1px; }

/* Elección de camping */
.eleccion { border: 0; margin: var(--paso-4) 0 0; padding: 0; min-width: 0; }
.eleccion legend { font: 1.5rem var(--display); padding: 0; margin-bottom: var(--paso-2); }
.opciones { display: grid; gap: var(--paso-3); grid-template-columns: minmax(0, 1fr); }
.opcion { position: relative; display: block; cursor: pointer; }
.opcion input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.boleto {
  display: grid; gap: .35rem; height: 100%; padding: var(--paso-3) var(--paso-3) var(--paso-3) 4.2rem;
  background: var(--pergamino-claro); border: 1.5px solid rgba(91, 67, 48, .5); border-radius: 4px;
  position: relative; transition: border-color .15s, box-shadow .15s, opacity .15s; opacity: .78;
}
.opcion:hover .boleto { opacity: 1; border-color: var(--tinta-suave); }
.opcion input:focus-visible + .boleto { outline: 2px dashed var(--sangre); outline-offset: 3px; }
.opcion input:checked + .boleto { opacity: 1; border-color: var(--tinta); box-shadow: 4px 4px 0 var(--tinta); }
.boleto-letra {
  position: absolute; left: .8rem; top: .9rem; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center; font: 1.5rem var(--display);
  border: 1.5px solid var(--tinta-suave); color: var(--tinta-suave); background: transparent;
}
.opcion input:checked + .boleto .boleto-letra {
  background: radial-gradient(circle at 38% 32%, #c4553f, var(--sangre) 55%, var(--sangre-hondo));
  color: #f6dccf; border-color: var(--sangre-hondo); transform: rotate(-10deg);
}
.boleto-nombre { font: 1.35rem/1.1 var(--display); letter-spacing: .01em; }
.boleto-zona { font-style: italic; font-size: 1rem; color: var(--tinta-suave); }
.boleto-datos { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: 1rem; }
.boleto-elegido { display: none; font-style: italic; color: var(--sangre); font-size: .95rem; }
.opcion input:checked + .boleto .boleto-elegido { display: block; }
.servicios { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: .2rem 0 0; padding: 0; }
.servicios li {
  display: inline-flex; align-items: center; gap: .25rem; font-size: .9rem; padding: .1rem .5rem;
  border: 1px solid rgba(91, 67, 48, .45); border-radius: 2rem;
}
.servicios svg { width: .95rem; height: .95rem; }
.servicios .no { text-decoration: line-through; color: rgba(91, 67, 48, .7); border-style: dashed; }
.servicios .extra::after { content: "+€"; font-size: .75rem; color: var(--sangre); }
.servicios .duda { color: rgba(91, 67, 48, .7); border-style: dotted; }

.ficha { margin-top: var(--paso-3); border-top: 1px dashed var(--tinta-suave); padding-top: var(--paso-2); }
.ficha summary { cursor: pointer; font-style: italic; min-height: 2.75rem; display: flex; align-items: center; }
.ficha dl { display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .25rem var(--paso-3); margin: var(--paso-2) 0 0; font-size: 1rem; }
.ficha dt { font-style: italic; color: var(--tinta-suave); }
.ficha dd { margin: 0; overflow-wrap: anywhere; }

@media (min-width: 40rem) {
  .opciones { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 64rem) {
  .carta { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .carta-mapa { height: calc(100svh - var(--barra)); border-bottom: 0; border-right: 2px solid var(--tinta); }
  .mapa-marco { padding: .8rem; }
  .bitacora { padding: var(--paso-6) var(--paso-5); }
  .dia { scroll-margin-top: calc(var(--barra) + 1rem); }
  .opciones { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 90rem) {
  .opciones { grid-template-columns: 1fr 1fr; }
}

/* ---------- Cofre ---------- */
.cofre { border-top: 2px solid var(--tinta); padding: var(--paso-6) var(--paso-3); max-width: 70rem; margin: 0 auto; }
.cofre h2 { font-size: clamp(2.6rem, 7vw, 4rem); }
.cofre-bajada { margin: var(--paso-1) 0 var(--paso-5); font-style: italic; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--paso-4); margin: 0 0 var(--paso-5); }
.cifras div { border-top: 3px double var(--tinta); padding-top: var(--paso-2); }
.cifras dt { font-style: italic; color: var(--tinta-suave); }
.cifras dd { margin: 0; font: 2.6rem/1.05 var(--display); color: var(--sangre); }
.cifras dd small { display: block; font: italic 1rem var(--texto); color: var(--tinta-suave); margin-top: .2rem; }
.cofre-tabla-envoltura { overflow-x: auto; }
.noches { width: 100%; border-collapse: collapse; font-size: 1rem; min-width: 36rem; }
.noches caption { text-align: left; font: 1.5rem var(--display); margin-bottom: var(--paso-2); }
.noches th, .noches td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid rgba(91, 67, 48, .35); vertical-align: top; }
.noches thead th { font-weight: 400; font-style: italic; color: var(--tinta-suave); border-bottom: 1.5px solid var(--tinta); }
.noches td:first-child { font-family: var(--display); font-size: 1.2rem; color: var(--sangre); }
.noches .op { display: inline-block; min-width: 1.6rem; text-align: center; border: 1px solid var(--tinta-suave); border-radius: 50%; margin-right: .4rem; font-size: .85rem; }
.noches td.largo { color: var(--sangre); }
.cofre-acciones { display: flex; flex-wrap: wrap; gap: var(--paso-2); align-items: center; margin-top: var(--paso-5); }
.boton {
  min-height: 2.75rem; padding: 0 1.1rem; cursor: pointer; font: 1.05rem var(--texto);
  background: var(--tinta); color: var(--pergamino-claro); border: 1px solid var(--tinta); border-radius: 3px;
}
.boton:hover { background: var(--sangre-hondo); }
.boton-suave { background: transparent; color: var(--tinta); }
.boton-suave:hover { background: var(--pergamino-claro); }
.aviso { margin: 0; font-style: italic; color: var(--sangre); min-height: 1.6em; }

/* ---------- Pie ---------- */
.pie { border-top: 2px solid var(--tinta); padding: var(--paso-5) var(--paso-3) var(--paso-6); max-width: 70rem; margin: 0 auto; font-size: 1rem; color: var(--tinta-suave); }
.pie p { max-width: 62ch; }
.creditos summary { cursor: pointer; font-style: italic; min-height: 2.75rem; display: flex; align-items: center; color: var(--tinta); }
.creditos ul { columns: 2 18rem; font-size: .9rem; padding-left: 1.1rem; }
.creditos li { break-inside: avoid; margin-bottom: .3rem; }

/* Al cambiar camping: el tramo nuevo se dibuja */
@keyframes dibujar { from { stroke-dashoffset: var(--largo); } to { stroke-dashoffset: 0; } }
.m-tramo.nuevo .m-mascara { animation: dibujar 1.1s ease-out forwards; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 40rem) {
  .mapa-resumen { font-size: .8rem; line-height: 1.3; padding: .2rem .45rem; left: .7rem; bottom: .7rem; }
  .mapa-controles { right: .7rem; top: .7rem; }
  .mapa-controles button { min-width: 2.25rem; min-height: 2.25rem; font-size: 1.05rem; }
  #z-isla { font-size: .85rem; }
  .barra-nav { display: none; }
  .barra-nombre { font-size: 1.15rem; }
  .gramola { flex-direction: column; align-items: flex-start; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
