/* Paleta tomada de los colores de seguridad (UNE-EN ISO 7010) */
:root {
  --tinta: #16262b;
  --tinta-2: #4b5b5f;
  --papel: #edf0ea;
  --hoja: #fbfcf9;
  --linea: #c8cfc5;
  --amarillo: #f2b705;
  --azul: #1f5fa6;
  --verde: #007a52;
  --rojo: #b8302a;
  --info: #3e5b66;
  --radio: 6px;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --texto: "Barlow", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--papel); color: var(--tinta); font: 400 17px/1.5 var(--texto); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--azul); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.saltar { position: absolute; left: -999px; top: 0; background: var(--tinta); color: #fff; padding: .5rem 1rem; z-index: 10; }
.saltar:focus { left: 1rem; }

main, .cabecera-in, .pie { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* ---------- Cabecera ---------- */
.cabecera { padding: clamp(28px, 6vw, 64px) 0 28px; }
.origen { margin: 0 0 .6rem; color: var(--tinta-2); font-size: .95rem; }
.origen a { color: inherit; font-weight: 600; }
h1 { font: 700 clamp(2.8rem, 8vw, 5.6rem)/.9 var(--cond); letter-spacing: -.01em; margin: 0 0 1rem; }
.intro { max-width: 60ch; margin: 0 0 1.6rem; font-size: 1.1rem; color: var(--tinta-2); }
.buscador { display: flex; max-width: 680px; border: 2px solid var(--tinta); border-radius: var(--radio); background: var(--hoja); overflow: hidden; }
.buscador input { flex: 1; min-width: 0; border: 0; padding: .8rem 1rem; background: transparent; font-size: 1.05rem; }
.buscador input:focus { outline: none; }
.buscador:focus-within { outline: 3px solid var(--azul); outline-offset: 2px; }
.buscador button { border: 0; background: var(--tinta); color: #fff; padding: 0 1.3rem; font: 600 1.1rem var(--cond); letter-spacing: .02em; }

/* ---------- Señales ---------- */
.senal { --t: 52px; width: var(--t); height: var(--t); flex: none; display: grid; place-items: center; position: relative; color: #fff; }
.senal svg { width: 54%; height: 54%; position: relative; z-index: 1; }
.senal-obligacion { background: var(--azul); border-radius: 50%; }
.senal-salvamento { background: var(--verde); border-radius: 12%; }
.senal-info { background: var(--info); border-radius: 12%; }
.senal-riesgo { color: var(--tinta); }
.senal-riesgo::before, .senal-riesgo::after { content: ""; position: absolute; inset: 0; }
.senal-riesgo::before { background: var(--tinta); clip-path: polygon(50% 3%, 100% 93%, 0 93%); }
.senal-riesgo::after { background: var(--amarillo); clip-path: polygon(50% 15%, 90.5% 86.5%, 9.5% 86.5%); }
.senal-riesgo svg { width: 42%; height: 42%; margin-top: 18%; }
.senal.mini { --t: 20px; display: inline-grid; vertical-align: -4px; margin-right: .4em; }
.senal.mini svg { stroke-width: 2.4; }
.sg { display: inline-block; width: 12px; height: 12px; margin-right: .4em; vertical-align: -1px; }
.sg-riesgo { background: var(--amarillo); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sg-obligacion { background: var(--azul); border-radius: 50%; }
.sg-salvamento { background: var(--verde); }
.sg-info { background: var(--info); }

/* ---------- Tablero de temas ---------- */
.tablero { padding: 8px 0 28px; }
.leyenda { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .88rem; color: var(--tinta-2); margin-bottom: .8rem; }
.temas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tema { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 14px 14px; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--hoja); position: relative; overflow: hidden; transition: border-color .15s, background .15s; }
.tema:hover { border-color: var(--tinta); }
.tema.activo { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.tema.activo .tema-n { color: #c9d3d0; }
.tema-txt { display: grid; gap: 1px; }
.tema-nombre { font: 600 1.25rem/1.1 var(--cond); }
.tema-n { font-size: .85rem; color: var(--tinta-2); }
.tema-avance { position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p); background: var(--verde); }

/* ---------- Pestañas y barra ---------- */
.pestanas { display: flex; gap: 4px; border-bottom: 2px solid var(--tinta); margin-top: 8px; scroll-margin-top: 8px; overflow-x: auto; }
.pestana { border: 0; background: none; padding: .6rem 1rem .5rem; font: 600 1.2rem var(--cond); color: var(--tinta-2); border-radius: var(--radio) var(--radio) 0 0; white-space: nowrap; }
.pestana[aria-current="page"] { background: var(--tinta); color: #fff; }
.pestana:hover:not([aria-current]) { color: var(--tinta); background: #dfe4dc; }

.vista { padding: 20px 0 48px; }
.nota-vista { color: var(--tinta-2); max-width: 70ch; margin: 0 0 1.2rem; }
.barra { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; margin-bottom: 18px; }
.filtro-activo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cuenta { margin: 0 .4rem 0 0; font-size: 1.05rem; }
.cuenta strong { font: 700 1.5rem var(--cond); }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--hoja); border: 1px solid var(--linea); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: .92rem; }
.chip button { border: 0; background: none; width: 26px; height: 26px; border-radius: 50%; font-size: .8rem; }
.chip button:hover { background: var(--papel); }
.controles { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: .95rem; }
.segmentos { display: inline-flex; border: 1px solid var(--tinta); border-radius: var(--radio); overflow: hidden; }
.segmentos button { border: 0; background: var(--hoja); padding: .35rem .8rem; }
.segmentos button + button { border-left: 1px solid var(--tinta); }
.segmentos button[aria-pressed="true"] { background: var(--tinta); color: #fff; }
.sel { display: inline-flex; align-items: center; gap: .5rem; }
.sel select { border: 1px solid var(--tinta); border-radius: var(--radio); background: var(--hoja); padding: .35rem .5rem; }
.chk { display: inline-flex; align-items: center; gap: .4rem; }
.chk input { width: 18px; height: 18px; accent-color: var(--verde); }

/* ---------- Rejilla de vídeos ---------- */
.sub { font: 600 1.45rem var(--cond); margin: 1.6rem 0 .8rem; }
.sub:first-child { margin-top: 0; }
.sub span { color: var(--tinta-2); font-weight: 500; margin-left: .3rem; }
.rejilla { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px 18px; }
.rejilla-short { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tj { position: relative; }
.tj-btn { display: block; width: 100%; border: 0; padding: 0; background: none; text-align: left; }
.tj-img { display: block; position: relative; aspect-ratio: 16 / 9; border-radius: var(--radio); overflow: hidden; background: #d5dbd2; }
.tj-short .tj-img { aspect-ratio: 9 / 16; }
.tj-img img { width: 100%; height: 100%; object-fit: cover; }
.tj-btn:hover .tj-img img { filter: brightness(1.06); }
.tj-btn:hover .tj-titulo { text-decoration: underline; text-underline-offset: 3px; }
.tj-dur { position: absolute; right: 6px; bottom: 6px; background: rgba(22, 38, 43, .88); color: #fff; font-size: .78rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.tj-check { position: absolute; left: 6px; top: 6px; background: var(--verde); color: #fff; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 4px; }
.tj-visto .tj-img img { opacity: .55; }
.tj-txt { display: grid; gap: 3px; padding-top: 8px; }
.tj-titulo { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tj-short .tj-titulo { font-size: .92rem; }
.tj-meta, .tj-tema { font-size: .84rem; color: var(--tinta-2); }
.tj-meta b { color: var(--tinta); font-weight: 600; }
.tj-fav { position: absolute; right: 6px; top: 6px; background: var(--hoja); color: var(--tinta); border-radius: 4px; padding: 0 6px; font-size: .9rem; pointer-events: none; }
.mas { display: block; margin: 22px auto 0; border: 1px solid var(--tinta); background: var(--hoja); padding: .55rem 1.2rem; border-radius: var(--radio); font-weight: 600; }
.mas:hover { background: var(--tinta); color: #fff; }
.vacio { border: 1px dashed var(--linea); border-radius: var(--radio); padding: 2rem; text-align: center; color: var(--tinta-2); }
.vacio p:first-child { color: var(--tinta); font-weight: 600; }

/* ---------- Rutas ---------- */
#rutas { display: grid; gap: 18px; }
.ruta { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 8px 32px; background: var(--hoja); border: 1px solid var(--linea); border-left: 6px solid var(--verde); border-radius: var(--radio); padding: 20px 22px; }
.ruta h3 { font: 600 1.6rem/1.1 var(--cond); margin: 0 0 .4rem; }
.ruta-cab p { margin: 0 0 .6rem; color: var(--tinta-2); }
.ruta-meta { font-size: .88rem; }
.ruta-barra { display: block; height: 6px; background: var(--papel); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.ruta-barra span { display: block; height: 100%; background: var(--verde); }
.ruta-fin { color: var(--verde) !important; font-weight: 600; }
.ruta-pasos { margin: 0; padding: 0; list-style: none; counter-reset: paso; }
.ruta-pasos li { counter-increment: paso; border-top: 1px solid var(--papel); }
.ruta-pasos li:first-child { border-top: 0; }
.ruta-pasos button { width: 100%; display: grid; grid-template-columns: 2rem 1fr auto; align-items: baseline; gap: 10px; border: 0; background: none; text-align: left; padding: 8px 4px; }
.ruta-pasos button::before { content: counter(paso); font: 700 1.15rem var(--cond); color: var(--tinta-2); }
.ruta-pasos .hecho button::before { content: "✓"; color: var(--verde); }
.ruta-pasos .hecho .paso-t { color: var(--tinta-2); }
.ruta-pasos button:hover .paso-t { text-decoration: underline; }
.paso-d { font-size: .85rem; color: var(--tinta-2); }

/* ---------- Mi lista ---------- */
.notas { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.notas li { background: var(--hoja); border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; }
.notas button { border: 0; background: none; padding: 0; font-weight: 600; text-align: left; }
.notas button:hover { text-decoration: underline; }
.notas p { margin: .3rem 0 0; white-space: pre-wrap; color: var(--tinta-2); }
#milista .nota-vista { margin-top: 1.6rem; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; border: 1px solid var(--tinta); background: var(--tinta); color: #fff; border-radius: var(--radio); padding: .5rem 1rem; font-weight: 600; font-size: .95rem; text-decoration: none; }
.btn:hover { background: #24393f; }
.btn[aria-pressed="true"] { background: var(--verde); border-color: var(--verde); }
.btn-sec { background: var(--hoja); color: var(--tinta); }
.btn-sec:hover { background: var(--papel); }

/* ---------- Reproductor ---------- */
dialog { border: 0; padding: 0; width: min(1180px, 96vw); max-height: 94vh; border-radius: 10px; background: var(--hoja); color: var(--tinta); box-shadow: 0 24px 60px rgba(10, 20, 24, .35); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(14, 26, 30, .72); }
.r-cab { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--linea); }
.r-tema { margin: 0; font: 600 1.1rem var(--cond); }
.r-cerrar { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; }
.r-cerrar:hover { background: var(--papel); }
.r-cuerpo { display: grid; grid-template-columns: 1.55fr 1fr; overflow: auto; }
.r-video { background: #000; aspect-ratio: 16 / 9; position: sticky; top: 0; align-self: start; }
.r-video.vertical { aspect-ratio: auto; height: min(80vh, 720px); display: flex; justify-content: center; }
.r-video.vertical iframe { width: auto; aspect-ratio: 9 / 16; height: 100%; }
.r-video iframe { width: 100%; height: 100%; border: 0; display: block; }
.r-info { padding: 18px 22px 24px; }
.r-info h2 { font: 600 1.6rem/1.15 var(--cond); margin: 0 0 .3rem; }
.r-meta { margin: 0 0 .9rem; font-size: .9rem; color: var(--tinta-2); }
.r-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1rem; }
.r-resumen { margin: 0 0 1rem; max-width: 65ch; }
.r-h { font: 600 1.15rem var(--cond); margin: 1.1rem 0 .4rem; }
.capitulos { list-style: none; margin: 0; padding: 0; font-size: .93rem; }
.capitulos button { width: 100%; display: grid; grid-template-columns: 4.2rem 1fr; text-align: left; border: 0; background: none; padding: 4px 2px; border-radius: 4px; }
.capitulos button:hover { background: var(--papel); }
.capitulos span { color: var(--azul); font-variant-numeric: tabular-nums; font-weight: 600; }
.r-nota { display: grid; gap: 4px; margin-top: 1.1rem; font: 600 1.15rem var(--cond); }
.r-nota textarea { font: 400 .95rem/1.45 var(--texto); border: 1px solid var(--linea); border-radius: var(--radio); padding: .6rem; background: #fff; resize: vertical; }
.rel { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rel button { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: start; border: 0; background: none; text-align: left; padding: 0; font-size: .92rem; font-weight: 500; }
.rel img { aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; }
.rel button:hover span { text-decoration: underline; }

/* ---------- Pie ---------- */
.pie { padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--linea); font-size: .9rem; color: var(--tinta-2); }
.pie p { max-width: 80ch; margin: 0 0 .5rem; }
.firma-autor { margin-top: 1rem !important; font-size: .82rem; }

/* ---------- Adaptación ---------- */
@media (max-width: 900px) {
  .r-cuerpo { grid-template-columns: 1fr; }
  .r-video { position: static; }
  .r-video.vertical { height: 62vh; }
  .ruta { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .temas { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tema { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; }
  .senal:not(.mini) { --t: 40px; }
  .tema-nombre { font-size: 1.08rem; }
  .rejilla { grid-template-columns: 1fr 1fr; gap: 16px 12px; }
  .rejilla-short { grid-template-columns: repeat(3, 1fr); }
  .tj-titulo { font-size: .92rem; }
  .tj-tema { display: none; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
