:root {
  --fondo: #14110f;
  --superficie: #1e1a17;
  --superficie-2: #29231f;
  --borde: #3a322c;
  --texto: #f1e9df;
  --texto-2: #b7aa9b;
  --acento: #d9452b;
  --acento-2: #f0b13a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radio: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 15px/1.45 var(--sans); }
button, input, select { font: inherit; color: inherit; }

/* Cabecera */
.cab { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--fondo) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--borde); padding: 12px 16px 8px; }
.cab-fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; max-width: 1600px; margin: 0 auto; }
.cab-fila + .cab-fila { margin-top: 10px; }
.marca { font: 600 clamp(19px, 2.4vw, 26px)/1.1 var(--serif); margin: 0; flex: 1; letter-spacing: .01em;
  display: flex; align-items: center; gap: 10px; }
.marca-pico { width: 30px; height: 30px;
  flex: none; }
.cab-acciones { display: flex; gap: 8px; }
.btn { background: var(--superficie-2); border: 1px solid var(--borde); border-radius: 999px; padding: 7px 14px;
  cursor: pointer; white-space: nowrap; transition: background .15s; }
.btn:hover { background: var(--borde); }
.btn-acento { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn-acento:hover { background: #c23a22; }

.filtros input[type=search] { flex: 1 1 260px; min-width: 0; }
.filtros input[type=search], .filtros select { background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 8px; padding: 8px 12px; }
.filtros select { flex: 0 1 200px; min-width: 0; }
.interruptor { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--texto-2); white-space: nowrap; }
.interruptor input { accent-color: var(--acento); width: 16px; height: 16px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; max-width: 1600px; margin: 10px auto 0; }
.cab .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { background: transparent; border: 1px solid var(--borde); color: var(--texto-2); border-radius: 999px;
  padding: 4px 11px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--texto); border-color: var(--texto-2); }
.chip[aria-pressed=true] { background: var(--texto); color: var(--fondo); border-color: var(--texto); }
.chip small { opacity: .6; margin-left: 4px; }
.chip-elem { border-style: dashed; }
#ficha-elems:empty { display: none; }

/* Filete solo para banderas cuyo contorno se funde con el fondo (tema oscuro: contorno negro) */
img[data-o] { outline: 1px solid rgba(255, 255, 255, .28); outline-offset: 0; }
:root[data-tema=claro] img[data-o] { outline: none; }
:root[data-tema=claro] img[data-c] { outline: 1px solid rgba(0, 0, 0, .22); }

/* Mosaico */
main { max-width: 1600px; margin: 0 auto; padding: 14px 16px 60px; }
.resumen { color: var(--texto-2); margin: 0 0 14px; font-size: 14px; }
.resumen b { color: var(--texto); font-weight: 600; }
.mosaico { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tarjeta { background: var(--superficie); border: 1px solid transparent; border-radius: var(--radio); padding: 0;
  cursor: pointer; text-align: left; overflow: hidden; display: flex; flex-direction: column;
  transition: transform .18s ease, border-color .18s, background .18s; }
.tarjeta:hover, .tarjeta:focus-visible { transform: translateY(-3px); border-color: var(--borde); background: var(--superficie-2); outline: none; }
.tarjeta-img { aspect-ratio: 3 / 2; display: grid; place-items: center; padding: 16px; }
.tarjeta-img img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 4px 14px #0007;
  opacity: 0; transition: opacity .35s; }
.tarjeta-img img.ok { opacity: 1; }
.tarjeta-txt { padding: 0 12px 12px; display: grid; gap: 2px; }
.tarjeta-titulo { font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.tarjeta-trad { color: var(--texto-2); font-size: 11.5px; font-style: italic; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta-trad:empty, .trad:empty { display: none; }
.trad { color: var(--texto-2); font-size: 13px; font-style: italic; margin: 2px 0 6px; }
.tarjeta-sub { color: var(--texto-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marcas { display: flex; gap: 6px; margin-top: 4px; }
.marca-doc { font-size: 11.5px; color: var(--acento-2); }
.marca-ver { font-size: 11.5px; color: var(--texto-2); }
.marca-pend { font-size: 11.5px; color: var(--texto-2); font-style: italic; }
.interruptor small { opacity: .6; }
.vacio { text-align: center; color: var(--texto-2); padding: 60px 0; }
#centinela { height: 1px; }

/* Ficha */
.ficha { width: min(1180px, 96vw); max-height: 94vh; border: 1px solid var(--borde); border-radius: 14px;
  background: var(--superficie); color: var(--texto); padding: 0; overflow: hidden; }
.ficha::backdrop { background: #000c; backdrop-filter: blur(3px); }
.ficha-cuerpo { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); max-height: 94vh; }
/* las flechas viven en los márgenes laterales del visor, nunca encima de la bandera */
.ficha-visor { margin: 0; background: #0d0b0a; display: grid; place-items: center; padding: 28px 64px; min-height: 340px; position: relative; min-width: 0; }
.ficha-visor img { max-width: 100%; max-height: 74vh; object-fit: contain; box-shadow: 0 10px 40px #000a; }
.ficha-visor figcaption { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: var(--texto-2); font-size: 12.5px; }
.ficha-datos { padding: 26px 24px; overflow-y: auto; }
.ficha-lugar { margin: 0; color: var(--acento-2); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.ficha-datos h2 { font: 600 26px/1.15 var(--serif); margin: 6px 0 4px; }
.ficha-anyos { margin: 0 0 10px; color: var(--texto-2); }
.ficha-datos h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-2); margin: 20px 0 8px; }
.tiras { display: flex; gap: 8px; flex-wrap: wrap; }
.tira { flex: none; box-sizing: border-box; width: 84px; height: 60px; padding: 4px; border-radius: 6px; border: 2px solid transparent;
  background: var(--superficie-2); cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tira img { display: block; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.tira[aria-current=true] { border-color: var(--acento); }
.tira span { font-size: 10px; color: var(--texto-2); }
.doc-si, .doc-no { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }
.doc-si { background: #f0b13a1f; color: var(--acento-2); }
.doc-no { background: var(--superficie-2); color: var(--texto-2); }
.cerrar { position: absolute; top: 10px; right: 12px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: #0008; font-size: 22px; cursor: pointer; }
.nav { position: absolute; top: 50%; translate: 0 -50%; width: 40px; height: 64px; border: 0; background: #0006;
  font-size: 30px; cursor: pointer; border-radius: 8px; }
.nav-ant { left: 8px; } .nav-sig { right: 8px; }
.nav:hover, .cerrar:hover { background: #000b; }

/* Exposición */
.expo { position: fixed; inset: 0; z-index: 20; background: #0b0908; display: grid; place-items: center; cursor: none; }
.expo img { position: absolute; max-width: 82vw; max-height: 66vh; object-fit: contain; box-shadow: 0 18px 60px #000;
  opacity: 0; transition: opacity 1.4s ease, transform 7s linear; transform: scale(.97); }
.expo img.ver { opacity: 1; transform: scale(1.02); }
.expo-pie { position: absolute; bottom: 6vh; left: 0; right: 0; text-align: center; padding: 0 16px; }
.expo-pie p { margin: 0; color: var(--texto-2); letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.expo-pie h2 { margin: 6px 0; font: 600 clamp(22px, 3.4vw, 40px)/1.15 var(--serif); }
#expo-ideo, #expo-trad { text-transform: none; letter-spacing: 0; font-size: 15px; }
#expo-salir { position: absolute; top: 16px; right: 16px; opacity: .35; cursor: pointer; }
.expo:hover #expo-salir { opacity: 1; }

.aviso { position: fixed; bottom: 18px; left: 50%; translate: -50% 0; background: var(--superficie-2); border: 1px solid var(--borde);
  padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100vw - 32px); }

@media (max-width: 760px) {
  .mosaico { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .ficha { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .ficha-cuerpo { grid-template-columns: 1fr; max-height: 100dvh; overflow-y: auto; }
  .ficha-visor { min-height: 0; padding: 48px 50px 28px; }
  .ficha-visor img { max-height: 46vh; }
  .nav { width: 36px; height: 56px; font-size: 26px; }
  .nav-ant { left: 7px; } .nav-sig { right: 7px; }
  .ficha-datos { overflow: visible; padding: 18px 16px 40px; }
  .filtros select { flex: 1 1 140px; }
  .cab-acciones .btn { padding: 6px 11px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.marca-sigla { letter-spacing: .08em; }
.marca-nombre { font: 400 .62em/1.1 var(--sans); color: var(--texto-2); letter-spacing: .02em; }
@media (max-width: 420px) { .marca-nombre { display: none; } }

/* Vista «Ideologías» */
.vista-ideo { position: relative; padding-bottom: 30px; }
.ideo-pest { display: flex; gap: 6px; margin-bottom: 10px; }
.ideo-intro { color: var(--texto-2); font-size: 14px; margin: 0 0 14px; max-width: 70ch; }
.ideo-red { width: 100%; height: auto; max-height: 78vh; display: block; background: var(--superficie); border-radius: var(--radio); }
.ideo-red line { stroke: var(--texto-2); stroke-opacity: .22; stroke-linecap: round; transition: stroke-opacity .15s; }
.ideo-red .nodo { cursor: pointer; outline: none; }
.ideo-red circle { fill: var(--superficie-2); stroke: var(--texto-2); stroke-width: 1.5; transition: fill .15s, opacity .15s; }
.ideo-red text { fill: var(--texto); font-size: 12.5px; paint-order: stroke; stroke: var(--superficie); stroke-width: 3px; pointer-events: none; }
.ideo-red.foco .nodo { opacity: .28; } .ideo-red.foco line { stroke-opacity: .06; }
.ideo-red.foco .nodo.on, .ideo-red.foco .nodo.vecino { opacity: 1; }
.ideo-red .nodo.on circle { fill: var(--acento); stroke: var(--texto); }
.ideo-red .nodo.vecino circle { fill: var(--borde); }
.ideo-red line.on { stroke: var(--acento-2); stroke-opacity: .85; }
.ideo-pista { position: absolute; z-index: 4; pointer-events: none; background: var(--superficie-2); border: 1px solid var(--borde);
  border-radius: 8px; padding: 8px 11px; max-width: 240px; font-size: 13px; display: grid; gap: 2px; box-shadow: 0 6px 20px #0008; }
.ideo-pista small { color: var(--texto-2); }
.ideo-arbol { columns: 300px; column-gap: 28px; }
.ideo-rama { break-inside: avoid; margin-bottom: 22px; }
.ideo-rama h3 { font: 600 17px/1.2 var(--serif); margin: 0 0 6px; color: var(--acento-2); }
.ideo-rama ul { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--borde); }
.ideo-rama > ul { padding-left: 0; border: 0; }
.ideo-rama summary { list-style: none; cursor: pointer; }
.ideo-rama summary::-webkit-details-marker { display: none; }
.ideo-rama summary::before { content: "▾"; color: var(--texto-2); font-size: 11px; margin-right: 2px; }
.ideo-rama details:not([open]) > summary::before { content: "▸"; }
.ideo-hoja { background: none; border: 0; padding: 3px 4px; cursor: pointer; text-align: left; border-radius: 6px; }
.ideo-hoja:hover:not(:disabled) { background: var(--superficie-2); }
.ideo-hoja:disabled { color: var(--texto-2); cursor: default; }
.ideo-hoja small { color: var(--texto-2); margin-left: 6px; font-size: 12px; }
.ideo-otras { display: flex; flex-wrap: wrap; gap: 0 6px; }
.ideo-leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--texto-2); margin-bottom: 12px; }
.ideo-leyenda i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; box-shadow: inset 0 0 0 1px #fff3; }
.ideo-colores { display: grid; gap: 4px; }
.ideo-fila { display: grid; grid-template-columns: minmax(110px, 200px) 44px 1fr; align-items: center; gap: 10px;
  background: none; border: 0; padding: 4px 6px; border-radius: 8px; cursor: pointer; text-align: left; }
.ideo-fila:hover { background: var(--superficie); }
.ideo-fila small { color: var(--texto-2); font-size: 12px; text-align: right; }
.ideo-nom { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ideo-barra { display: flex; gap: 2px; height: 18px; }
.ideo-barra i { min-width: 2px; box-shadow: inset 0 0 0 1px #fff2; }
.ideo-barra i[data-c=negro], .ideo-leyenda i[style*="#0a0a0a"] { box-shadow: inset 0 0 0 1px #ffffff70; }
.ideo-barra i:first-child { border-radius: 4px 0 0 4px; } .ideo-barra i:last-child { border-radius: 0 4px 4px 0; }
@media (max-width: 760px) {
  .ideo-fila { grid-template-columns: 1fr 40px; } .ideo-barra { grid-column: 1 / -1; }
  .ideo-red text { font-size: 15px; }
}
