/* SAFIR · Pantalla de una obra (WEB-INF/vistas/catalogo/detalle.jsp).
   Se carga DESPUÉS de encabezadoinicio.css, que aporta variables, .btn, el encabezado y el pie. */
:root {
  --od-shadow: 0 12px 34px -18px rgba(37,40,102,.35);
  --od-ok: #1E6B3A; --od-ok-bg: #DDF3E4;
  --od-err: #B3261E; --od-err-bg: #FDECEA;
  --od-curso: #1E6B3A; --od-curso-bg: #DDF3E4;
  --od-flop: #8A4B0F; --od-flop-bg: #FBE6CF;
  --od-fin: var(--indigo); --od-fin-bg: var(--lav-soft);
}
:root[data-theme="dark"] {
  --od-shadow: 0 12px 34px -18px rgba(0,0,0,.7);
  --od-ok: #8fd8a8; --od-ok-bg: #173a24;
  --od-err: #f1a39d; --od-err-bg: #3a1b1b;
  --od-curso: #8fd8a8; --od-curso-bg: #173a24;
  --od-flop: #f3c08a; --od-flop-bg: #3d2a14;
  --od-fin: #D6D4FF; --od-fin-bg: #2C3060;
}

.od-main { display: block; }
.od-main section { padding: 0; }
.od-main h1, .od-main h2 { max-width: none; }
.od-main p { margin: 0; }
.od-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ================= BLOQUE 1: portadas ================= */
/* Fila simple, sin fondo desenfocado ni animación 3D. */
.od-ruleta { position: relative; background: transparent; padding: 1.2rem 0 .6rem !important; }
.od-ruleta-escena { --tapa: clamp(112px, 12vw, 150px); position: relative; width: 100%; }
.od-ruleta-pista {
  list-style: none; margin: 0; display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x proximity;
  /* El relleno lateral permite que cualquier portada, incluso la primera o la última, quede en el centro */
  padding: 1.4rem calc(50% - var(--tapa) / 2) .7rem;
  scrollbar-width: none; -ms-overflow-style: none;
}
.od-ruleta-pista::-webkit-scrollbar { display: none; }
.od-ruleta-item { position: relative; flex: none; width: var(--tapa); scroll-snap-align: center; }
.od-tapa {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 12px; overflow: hidden; text-decoration: none; color: #fff;
  background: linear-gradient(160deg, var(--indigo), var(--lav));
  box-shadow: 0 8px 18px -10px rgba(37,40,102,.55); opacity: .88; transition: opacity .15s;
}
.od-tapa:hover, .od-tapa:focus-visible { opacity: 1; }
.od-tapa img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.od-tapa-letra { font: 400 3.4rem/1 var(--serif); opacity: .9; }
.od-tapa-titulo {
  position: absolute; left: .6rem; right: .6rem; bottom: .7rem;
  font: 500 .85rem/1.25 var(--serif); text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* La portada elegida: borde dorado y la etiqueta "Esta obra" encima */
.od-ruleta-item.seleccionada .od-tapa { opacity: 1; box-shadow: 0 0 0 3px var(--gold), 0 10px 22px -10px rgba(37,40,102,.6); }
.od-ruleta-item.seleccionada::after {
  content: "Esta obra"; position: absolute; top: -.85rem; left: 50%; transform: translateX(-50%);
  padding: .15rem .65rem; border-radius: 999px; background: var(--gold); color: #3b2a05;
  font: 600 .72rem/1.4 var(--sans); letter-spacing: .03em; white-space: nowrap; pointer-events: none;
}

.od-ruleta-btn {
  position: absolute; top: calc(50% - .35rem); z-index: 5; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--indigo);
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 14px -8px rgba(37,40,102,.5);
}
.od-ruleta-btn:hover { background: var(--bg); }
.od-ruleta-btn svg { width: 20px; height: 20px; }
.od-ruleta-btn.anterior { left: clamp(.6rem, 2vw, 1.5rem); }
.od-ruleta-btn.siguiente { right: clamp(.6rem, 2vw, 1.5rem); }
.od-ruleta-btn[hidden] { display: none; }
:root[data-theme="dark"] .od-ruleta-btn { color: var(--title); }

/* ================= Cuerpo: pestañas DETALLES (2, 3, 5) y APOYO (4, 6) ================= */
.od-cuerpo { width: calc(100% - 2 * clamp(.6rem, 2vw, 1.5rem)); margin: 1.8rem auto 3.5rem; display: grid; gap: 1.4rem; transition: opacity .15s; }
.od-cuerpo.cargando { opacity: .5; pointer-events: none; }
/* Dos secciones con pestañas (DETALLES / APOYO); solo se ve una a la vez.
     DETALLES (.od-columnas), en dos columnas:
       izquierda: bloque 2 (ficha) y debajo, con su separación, el bloque 5 (comentarios)
       derecha:   bloque 3 (descripción / capítulos), que llega hasta donde termina el bloque 5
     APOYO (.od-seccion-apoyo): bloque 4 (anima al autor) y, debajo, el bloque 6 (donadores)
   El bloque 3 se adapta a la altura de la izquierda (el contenido largo se desplaza dentro). */
.od-secciones { display: flex; justify-content: center; gap: .6rem; border-bottom: 1px solid var(--line); }
.od-secciones button {
  font: 500 1rem/1.2 var(--sans); letter-spacing: 0; cursor: pointer;
  padding: .75rem 1.3rem; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.od-secciones button:hover { color: var(--title); }
.od-secciones button[aria-selected="true"] { color: var(--title); border-bottom-color: var(--title); }
.od-secciones button:focus-visible { outline: 2px solid var(--lav); outline-offset: -2px; border-radius: 8px; }
.od-seccion[hidden] { display: none; }
.od-seccion-apoyo { display: grid; gap: 1.4rem; width: 100%; max-width: 46rem; margin: 0 auto; }
.od-seccion-apoyo[hidden] { display: none; }

/* DETALLES centrado: las dos columnas quedan en el centro de la página con un ancho máximo.
   El bloque 3 (descripción / capítulos) ya NO se estira a la altura de la izquierda: mide lo que mida su contenido. */
.od-columnas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.4rem; align-items: start;
  width: 100%; max-width: 74rem; margin-inline: auto;
  grid-template-areas: "ficha pest" "com pest"; grid-template-rows: auto 1fr; }
.od-ficha { grid-area: ficha; align-self: start; }
.od-comentarios { grid-area: com; align-self: start; }
.od-pestanas { grid-area: pest; align-self: start; }
/* La descripción se ve completa; solo la lista de capítulos (que puede ser muy larga) se desplaza dentro del bloque */
.od-pestanas .od-panel { max-height: none; overflow: visible; }
.od-pestanas #panelCaps { max-height: 34rem; overflow-y: auto; }
.od-apoyo { align-self: start; }
.od-donadores { align-self: start; }
.od-donadores h2 { font-family: var(--serif); font-weight: 400; font-size: 1.3rem; color: var(--title); }
.od-donadores .od-vacio { margin-top: .6rem; }

/* ---------- BLOQUE 6: donadores ---------- */
/* Cada tarjeta: foto redonda con su nivel encima, imagen del regalo y cantidad (x2) abajo a la izquierda, y @usuario debajo */
/* Las tarjetas se acomodan en filas (3 por fila en la columna) y, si hay muchas, la lista se desplaza hacia abajo */
.od-don-fila { list-style: none; margin: .9rem 0 0; padding: .9rem .4rem .6rem; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1.5rem 1rem; max-height: 23rem; overflow-y: auto; scrollbar-width: thin; }
.od-don { flex: none; width: 92px; display: grid; justify-items: center; gap: .55rem; }
.od-don-perfil { position: relative; display: block; width: 92px; height: 92px; text-decoration: none; }
.od-don-foto {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: var(--soft); color: var(--title); font: 600 1.6rem var(--sans); box-shadow: 0 0 0 2px var(--line);
}
.od-don-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.od-don-nivel {
  position: absolute; top: -.65rem; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: .1rem .6rem; border-radius: 6px; background: var(--title); color: var(--surface);
  font: 700 .72rem/1.4 var(--sans); letter-spacing: .04em; white-space: nowrap;
}
.od-don-regalo, .od-don-cant {
  position: absolute; bottom: -.35rem; z-index: 2; display: grid; place-items: center; height: 32px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; box-shadow: 0 4px 10px -6px rgba(37,40,102,.5);
}
.od-don-regalo { left: -.35rem; width: 32px; }
.od-don-regalo img { width: 24px; height: 24px; object-fit: contain; }
.od-don-cant { left: calc(32px - .1rem); min-width: 36px; padding: 0 .4rem; font: 700 .85rem var(--sans); color: var(--title); }
.od-don-usuario {
  display: block; width: 100%; padding: .3rem .4rem; border-radius: 8px; text-align: center; text-decoration: none;
  background: var(--soft); color: var(--title); font: 600 .78rem/1.3 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.od-don-usuario:hover, .od-don-usuario:focus-visible { background: var(--surface); box-shadow: 0 0 0 1.5px var(--lav); }
/* Botón "+" (apoyar): va después de la última tarjeta */
.od-don-mas { flex: none; }
.od-don-plus {
  display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%; text-decoration: none;
  background: var(--soft); border: 2px dashed var(--lav); color: var(--lav); font: 400 2.4rem/1 var(--sans);
  transition: background .15s, transform .15s;
}
.od-don-plus:hover, .od-don-plus:focus-visible { background: var(--surface); transform: scale(1.05); }
.od-bloque { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem !important; box-shadow: var(--od-shadow); min-width: 0; }

.od-aviso { padding: .75rem 1rem; border-radius: 12px; font-size: .95rem; font-weight: 500; }
.od-aviso.ok { background: var(--od-ok-bg); color: var(--od-ok); }
.od-aviso.error { background: var(--od-err-bg); color: var(--od-err); }
.od-vacio { color: var(--muted); font-size: .95rem; }

/* ---------- BLOQUE 2: características (minimalista) ---------- */
.od-ficha { position: relative; overflow: hidden; padding: 2rem 1.9rem 1.8rem !important; }
.od-ficha h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15; letter-spacing: -.01em; color: var(--title); overflow-wrap: anywhere; }

/* Autor: foto pequeña con su nivel, @usuario y Seguir en una sola línea */
.od-autor { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .8rem; margin-top: 1.1rem; padding: 0; }
.od-autor-perfil { display: grid; justify-items: center; flex: none; }
.od-autor-perfil .lv-badge { position: relative; z-index: 1; margin: 0 0 -.55rem; }
.od-autor-foto {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; text-decoration: none;
  background: var(--soft); color: var(--title); font: 600 1.1rem var(--sans);
  box-shadow: 0 0 0 1.5px var(--line);
}
.od-autor-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.od-autor-usuario { font: 500 .98rem var(--sans); color: var(--title); text-decoration: none; overflow-wrap: anywhere; }
.od-autor-usuario:hover, .od-autor-usuario:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.od-seguir {
  display: inline-block; flex: none; padding: .3rem .9rem; border-radius: 999px; cursor: pointer; text-decoration: none;
  font: 500 .82rem var(--sans); background: transparent; color: var(--title); border: 1px solid var(--title);
  transition: background .15s, color .15s;
}
.od-seguir:hover { background: var(--title); color: var(--surface); }
.od-seguir.es-siguiendo { color: var(--muted); border-color: var(--line); }
.od-seguir.es-siguiendo:hover { background: var(--soft); color: var(--title); }
.od-seguir[disabled] { opacity: .55; cursor: default; }
.od-seguir[disabled]:hover { background: transparent; color: var(--title); }

/* Etiquetas: texto simple, sin cápsulas */
.od-etiquetas { list-style: none; margin: 1.2rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.od-etiquetas a { text-decoration: none; color: var(--muted); font-size: .88rem; transition: color .15s; }
.od-etiquetas a:hover, .od-etiquetas a:focus-visible { color: var(--title); text-decoration: underline; text-underline-offset: 3px; }

/* Datos: una fila fluida de icono + valor, sin líneas ni recuadros */
.od-datos { display: flex; flex-wrap: wrap; gap: .8rem 1.5rem; margin: 1.5rem 0 0; padding: 1.2rem 0 0; border-top: 1px solid var(--line); }
.od-dato { padding: 0; min-width: 0; }
.od-dato dd { margin: 0; display: flex; align-items: center; gap: .45rem; color: var(--text); font-size: .94rem; font-weight: 400; min-width: 0; overflow-wrap: anywhere; }
.od-dato dd > svg { flex: none; width: 17px; height: 17px; color: var(--muted); }
.od-dato.categoria dd { color: var(--title); font-weight: 500; }
.od-estado { display: inline-flex; align-items: center; gap: .4rem; padding: 0; border-radius: 0; font-size: .94rem; font-weight: 400; background: none; color: var(--muted); }
.od-estado svg { width: 12px; height: 12px; flex: none; }
.od-estado.en_curso { color: var(--od-curso); }
.od-estado.flop { color: var(--od-flop); }
.od-estado.completa { color: var(--od-fin); }

/* Estadísticas: tres cifras discretas, sin separadores verticales */
.od-stats { list-style: none; margin: 1.3rem 0 0; padding: 1.2rem 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.od-stats li { display: grid; justify-items: start; gap: .1rem; text-align: left; padding: 0; }
.od-stats svg { width: 17px; height: 17px; color: var(--muted); margin-bottom: .3rem; }
.od-stats b { font-size: 1.3rem; font-weight: 500; color: var(--title); font-variant-numeric: tabular-nums; line-height: 1.2; }
.od-stats span { font-size: .78rem; color: var(--muted); }

.od-acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line); align-items: center; }
.od-acciones form { margin: 0; }
.od-guardada { display: inline-flex; align-items: center; gap: .4rem; padding: .7rem 1rem; border-radius: 999px; background: var(--od-ok-bg); color: var(--od-ok); font-weight: 500; font-size: .92rem; }
.od-guardada svg { width: 16px; height: 16px; }

/* ---------- BLOQUE 4: anima al autor ---------- */
.od-apoyo h2 { font-family: var(--serif); font-weight: 400; font-size: 1.45rem; color: var(--title); text-align: center; }
.od-apoyo .od-vacio { margin-top: .8rem !important; }
.od-apoyo .od-vacio a { color: var(--link); }
/* Frase + imagen que reacciona (imagen/reaccion-regalos/N.png, PNG transparente) */
.od-anima { display: grid; justify-items: center; gap: .5rem; margin: .9rem 0 .4rem; }
.od-anima[hidden] { display: none; }
.od-anima-frase {
  max-width: 100%; padding: .45rem 1rem; border-radius: 14px; text-align: center;
  background: var(--soft); border: 1px solid var(--line); color: var(--title); font: 500 .98rem/1.3 var(--sans);
}
.od-anima-img { display: block; width: auto; max-width: 100%; height: clamp(150px, 20vw, 210px); object-fit: contain; }
.od-anima-img[hidden] { display: none; }
.od-apoyo-saldo { font-size: .88rem; color: var(--muted); }
.od-regalo-form { display: grid; gap: .7rem; margin-top: .8rem; }
.od-regalo-form label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 500; color: var(--title); }
.od-comentar input { width: 100%; }
.od-regalo-form input { font: inherit; color: var(--text); background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: .6rem .8rem; }
.od-regalo-form input:focus { outline: none; border-color: var(--lav); box-shadow: 0 0 0 3px rgba(119,117,214,.28); }
.od-regalo-form .btn { justify-self: start; }

/* ---------- BLOQUE 3: pestañas ---------- */
.od-tabs { display: flex; gap: .3rem; padding: .3rem; border-radius: 999px; background: var(--soft); margin-bottom: 1.2rem; }
.od-tabs button {
  flex: 1; font: 500 .98rem var(--sans); cursor: pointer; padding: .6rem 1rem; border-radius: 999px;
  border: 0; background: transparent; color: var(--muted); transition: background .15s, color .15s;
}
.od-tabs button[aria-selected="true"] { background: var(--surface); color: var(--title); box-shadow: 0 4px 12px -6px rgba(37,40,102,.35); }
.od-tab-n { display: inline-block; min-width: 1.6em; margin-left: .3rem; padding: 0 .4rem; border-radius: 999px; background: var(--lav); color: #fff; font-size: .78rem; }
.od-panel { max-height: 28rem; overflow-y: auto; }
.od-panel[hidden] { display: none; }
.od-panel:focus-visible { outline-offset: 4px; }
.od-descripcion { font-family: var(--serif); font-size: 1.05rem; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; color: var(--text); }

.od-capitulos { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.od-capitulos a {
  display: flex; align-items: center; gap: .85rem; padding: .7rem .85rem; border-radius: 14px;
  text-decoration: none; border: 1px solid var(--line); background: var(--bg); transition: border-color .15s, background .15s;
}
.od-capitulos a:hover { border-color: var(--lav); background: var(--soft); }
.od-cap-num { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); color: var(--title); font-weight: 600; font-size: .9rem; }
.od-cap-texto { display: grid; min-width: 0; flex: 1; }
.od-cap-texto b { font-weight: 500; color: var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.od-cap-texto small { font-size: .8rem; color: var(--muted); }
.od-cap-candado { flex: none; color: #9a6b0c; display: grid; place-items: center; }
:root[data-theme="dark"] .od-cap-candado { color: var(--gold); }
.od-cap-candado svg { width: 18px; height: 18px; }

/* ---------- BLOQUE 5: comentarios ---------- */
.od-com-cab { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.od-com-cab h2 { font-family: var(--serif); font-weight: 400; font-size: 1.45rem; color: var(--title); }
.od-com-pausa { font: 500 .88rem var(--sans); cursor: pointer; padding: .4rem .9rem; border-radius: 999px; border: 1.5px solid var(--outline); background: transparent; color: var(--link); }
.od-com-pausa:hover { background: var(--soft); }
.od-com-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
/* Sin JavaScript: todos los comentarios con desplazamiento */
.od-com-lista:not(.rotando) { max-height: 26rem; overflow-y: auto; }
.od-com {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: .8rem; align-items: start;
  padding: .9rem 1rem; border-radius: 16px; background: var(--bg); border: 1px solid var(--line);
}
.od-com-avatar { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: linear-gradient(160deg, var(--indigo), var(--lav)); color: #fff; font-weight: 600; }
.od-com-avatar img { width: 100%; height: 100%; object-fit: cover; }
.od-com-meta { display: flex; flex-wrap: wrap; gap: .1rem .35rem; font-size: .85rem; color: var(--muted); }
.od-com-meta b { color: var(--title); font-weight: 600; }
.od-com-texto { margin-top: .25rem !important; overflow-wrap: anywhere; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* Rotación: entra por abajo, sale por arriba */
.od-com-lista.rotando .od-com { animation: od-com-entra .6s cubic-bezier(.2,.75,.25,1) both; }
.od-com-lista.rotando .od-com.saliendo { animation: od-com-sale .5s ease-in both; }
@keyframes od-com-entra { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes od-com-sale { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-14px); } }

/* ================= Pantallas pequeñas ================= */
@media (max-width: 1000px) {
  /* ficha | descripción y, debajo, comentarios a todo el ancho */
  .od-columnas { grid-template-areas: "ficha pest" "com com"; grid-template-rows: auto; }
}
@media (max-width: 900px) {
  .od-columnas { grid-template-columns: 1fr; grid-template-areas: none; }
  .od-ficha, .od-pestanas, .od-comentarios { grid-area: auto; }
  .od-ficha { order: 1; } .od-pestanas { order: 2; } .od-comentarios { order: 3; }
  .od-pestanas #panelCaps { max-height: none; }
}
@media (max-width: 600px) {
  .od-ruleta-escena { --tapa: 100px; }
  .od-ruleta-pista { gap: .7rem; }
  .od-ruleta-btn { display: none !important; }
  .od-cuerpo { width: calc(100% - 1.6rem); margin-top: 1.2rem; }
  .od-bloque { padding: 1.1rem !important; border-radius: 16px; }
  .od-secciones button { flex: 1; padding: .6rem .4rem; }
  .od-stats b { font-size: 1.15rem; }
  .od-acciones .btn, .od-acciones form { flex: 1 1 auto; }
  .od-acciones form .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .od-com-lista.rotando .od-com, .od-tapa, .od-cuerpo { transition: none !important; animation: none !important; }
}

/* La etiqueta de nivel (.lv-badge) vive en assets/css/persona.css */
/* Obra propia: el autor la ve como un visitante (controles visibles, sin uso) */
.od-seguir.od-vista[disabled] { opacity: 1; cursor: default; filter: none; }
.od-vista .rg-galeria .rg-item .rg-tarjeta:disabled { opacity: 1; filter: none; cursor: default; }