:root {
  /* Paleta: plástico rosado translúcido, plástico blanco, luz de caja de luz rosada */
  --luz: #fdf0f6;
  --luz-borde: #f3cfe0;
  --rosa: #e0398a;
  --rosa-hondo: #9c1f5c;
  --tinta: #3a1428;
  --plastico: #fffbfd;
  --interior: #1a0712;
  --foco-a: rgba(255, 20, 147, 0.6);    /* rosado fuerte */
  --foco-b: rgba(255, 182, 213, 0.6);   /* rosado pastel */
  --sombra: 0 10px 30px rgba(90, 20, 55, 0.18);

  --celda: 84px;
  --radio-plastico: 14px;
  --t-vista: 700ms;

  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  color: var(--tinta);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, var(--luz) 0%, var(--luz) 45%, var(--luz-borde) 100%);
  transition: background-color var(--t-vista) ease;
}

body[data-vista="A"], body[data-vista="B"] { background: var(--interior); }

#escena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- Lente: viñeta redonda al mirar por un ocular ---------- */
.lente {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-vista) ease;
  background:
    radial-gradient(circle at 50% 50%, transparent 0, transparent 41vmin, var(--foco, rgba(224, 57, 138, 0.35)) 43.5vmin, var(--interior) 47vmin);
}
body[data-vista="A"] .lente,
body[data-vista="B"] .lente { opacity: 1; }
body[data-vista="A"] .lente { --foco: var(--foco-a); }
body[data-vista="B"] .lente { --foco: var(--foco-b); }

/* ---------- Cabecera ---------- */
.cabecera {
  position: fixed;
  top: 28px;
  left: 32px;
  max-width: min(46ch, 42vw);
  transition: opacity var(--t-vista) ease;
}
.cabecera h1 {
  margin: 0;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 96;
  color: var(--rosa-hondo);
}
.cabecera p {
  margin: 12px 0 0;
  font-size: 1rem;
  line-height: 1.45;
  max-width: 34ch;
}
body:not([data-vista="general"]) .cabecera { opacity: 0; pointer-events: none; }

/* ---------- Selector de vista ---------- */
.vistas {
  position: fixed;
  top: 28px;
  right: 32px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--plastico);
  border-radius: 999px;
  box-shadow: var(--sombra);
}
.vistas button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tinta);
  cursor: pointer;
}
.vistas button:hover { background: var(--luz); }
.vistas button[aria-pressed="true"] { background: var(--rosa); color: #fff; }

/* ---------- Tarjetero (réplica de la tira que se desliza) ---------- */
.tarjetero {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
}

.riel {
  position: relative;
  width: calc(var(--celda) * 5);
  height: 86px;
  overflow: hidden;
  border-radius: var(--radio-plastico);
  background: var(--plastico);
  box-shadow: var(--sombra);
}

.tira {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  display: flex;
  transform: translateX(calc((var(--n, 1) - 0.5) * var(--celda) * -1));
  transition: transform 420ms cubic-bezier(0.3, 0.7, 0.2, 1);
}

.par {
  flex: 0 0 var(--celda);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 300ms ease;
}
.par[aria-current="true"] { opacity: 1; }
.par:hover { opacity: 0.85; }
.par img {
  width: 33px;
  height: 44px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--luz);
  display: block;
}

/* La carcasa blanca con su ventana fija en el centro */
.marco {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: calc(var(--celda) - 6px);
  transform: translateX(-50%);
  border: 3px solid var(--rosa);
  border-radius: 10px;
  pointer-events: none;
}

.flecha {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--plastico);
  color: var(--rosa-hondo);
  font: inherit;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--sombra);
}
.flecha:hover { background: var(--luz); }
.flecha:disabled { opacity: 0.35; cursor: default; }

/* Oculto a la vista; se mantiene para lectores de pantalla (anuncia el par actual) */
.estado {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Aviso ---------- */
.aviso {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(46ch, calc(100% - 32px));
  padding: 18px 22px;
  background: var(--plastico);
  border-radius: var(--radio-plastico);
  box-shadow: var(--sombra);
  line-height: 1.45;
}
.aviso code { font-size: 0.9em; background: var(--luz); padding: 1px 5px; border-radius: 4px; }
.aviso.breve { top: auto; bottom: 170px; transform: translateX(-50%); }

/* ---------- Foco visible ---------- */
button:focus-visible {
  outline: 3px solid var(--rosa);
  outline-offset: 3px;
}
body:not([data-vista="general"]) button:focus-visible { outline-color: #ff9fcb; }

/* ---------- Móvil ---------- */
/* ---------- Ficha literaria ---------- */
.ficha {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--plastico);
  color: var(--tinta);
  box-shadow: 0 24px 60px rgba(90, 20, 55, 0.35);
  overflow: hidden;
}
.ficha[open] { display: flex; flex-direction: column; }
.ficha:focus, .ficha:focus-visible { outline: none; }
.ficha::backdrop { background: rgba(58, 20, 40, 0.45); backdrop-filter: blur(4px); }
.ficha-texto {
  overflow-y: auto;
  padding: 44px clamp(22px, 6vw, 64px) 56px;
  font-size: 1.02rem;
  line-height: 1.65;
}
.cerrar-ficha {
  position: absolute;
  top: 14px;
  right: 26px; /* deja libre el carril de la barra de scroll */
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--luz);
  color: var(--rosa-hondo);
  font: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.cerrar-ficha:hover { background: var(--luz-borde); }
/* Barra de scroll rosada, suave y sin flechas.
   Chrome/Safari/Edge usan ::-webkit-scrollbar (dejan de usarlo si existe scrollbar-color),
   así que scrollbar-color va solo para Firefox. */
.ficha-texto::-webkit-scrollbar { width: 10px; }
.ficha-texto::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.ficha-texto::-webkit-scrollbar-track { background: transparent; margin: 18px 0; }
.ficha-texto::-webkit-scrollbar-thumb { background: #f1c4d8; border-radius: 999px; border: 3px solid var(--plastico); }
.ficha-texto::-webkit-scrollbar-thumb:hover { background: #e6a3c1; }
@supports (-moz-appearance: none) {
  .ficha-texto { scrollbar-width: thin; scrollbar-color: #f1c4d8 transparent; }
}
.ficha h2 {
  margin: 0 0 4px;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--rosa-hondo);
}
.ficha-autora { margin: 0 0 8px; font-size: 1.1rem; font-weight: 600; }
.ficha section { margin-top: 36px; }
.ficha h3 {
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--luz-borde);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--rosa-hondo);
}
.ficha h4 { margin: 22px 0 6px; font-size: 1.05rem; font-weight: 800; color: var(--rosa); }
.ficha p { margin: 0 0 14px; text-wrap: pretty; }
.ficha ul, .ficha ol { margin: 0 0 14px; padding-left: 1.3em; }
.ficha li { margin-bottom: 4px; }
.ficha figure { margin: 18px 0 0; }
.ficha img { display: block; width: 100%; height: auto; border-radius: 12px; }
.ficha time { font-weight: 800; color: var(--rosa); margin-right: 4px; }
.ficha a { color: var(--rosa-hondo); overflow-wrap: anywhere; }
.referencias { font-size: 0.92rem; }

@media (max-width: 720px) {
  :root { --celda: 64px; }
  .cabecera { top: 16px; left: 16px; right: 16px; max-width: none; }
  .cabecera p { margin-top: 10px; font-size: 0.9rem; line-height: 1.4; }
  .vistas { top: auto; bottom: 122px; right: 50%; transform: translateX(50%); }
  .vistas button { padding: 9px 12px; font-size: 0.85rem; white-space: nowrap; }
  .tarjetero { bottom: 20px; width: calc(100% - 32px); grid-template-columns: auto 1fr auto; }
  .riel { width: 100%; height: 72px; }
  .par img { width: 26px; height: 35px; }
  .flecha { width: 42px; height: 42px; }
  .aviso.breve { bottom: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-vista: 0ms; }
  .tira, .par { transition: none; }
}
