/* Visor de galería compartido (detalle de ruta, panel edición) */
.sw-gl-lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.25rem 1rem 1rem;
    box-sizing: border-box;
}

.sw-gl-lightbox[hidden] {
    display: none !important;
}

.sw-gl-lightbox__fondo {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
    cursor: pointer;
}

.sw-gl-lightbox__barra {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.75), transparent);
}

.sw-gl-lightbox__contador {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f8fafc;
    min-width: 3.5rem;
}

.sw-gl-lightbox__zoom {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sw-gl-lightbox__btn-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: var(--sw-radio-md);
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--sw-trans-rapida), color var(--sw-trans-rapida);
    font-family: inherit;
}

.sw-gl-lightbox__btn-icono:hover {
    background: rgba(255, 255, 255, 0.22);
}

.sw-gl-lightbox__btn-icono:focus-visible {
    outline: 2px solid var(--sw-primario-claro, #93c5fd);
    outline-offset: 2px;
}

.sw-gl-lightbox__cerrar {
    margin-left: auto;
}

.sw-gl-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #f8fafc;
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--sw-trans-rapida);
    font-family: inherit;
}

.sw-gl-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.26);
}

.sw-gl-lightbox__nav:focus-visible {
    outline: 2px solid var(--sw-primario-claro, #93c5fd);
    outline-offset: 2px;
}

.sw-gl-lightbox__nav:disabled {
    opacity: 0.28;
    cursor: default;
    pointer-events: none;
}

.sw-gl-lightbox__nav--ant {
    left: 0.75rem;
}

.sw-gl-lightbox__nav--sig {
    right: 0.75rem;
}

.sw-gl-lightbox__viewport {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    gap: 0.5rem;
}

/* Pie de pertenencia: «Nombre de la ruta/parada (contexto)» justo debajo del medio. */
.sw-gl-lightbox__origen {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.4rem;
    max-width: min(40rem, 100%);
    padding: 0 0.75rem;
    box-sizing: border-box;
    text-align: center;
}

.sw-gl-lightbox__origen[hidden] {
    display: none;
}

.sw-gl-lightbox__origen-nombre {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.96);
    line-height: 1.35;
}

.sw-gl-lightbox__origen-meta {
    font-size: 0.8125rem;
    font-weight: 400;
    color: rgba(248, 250, 252, 0.72);
    line-height: 1.35;
}

.sw-gl-lightbox__leyenda {
    flex-shrink: 0;
    max-width: min(40rem, 100%);
    padding: 0 0.75rem 0.25rem;
    box-sizing: border-box;
    text-align: center;
}

.sw-gl-lightbox__leyenda-titulo {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.96);
    line-height: 1.35;
}

.sw-gl-lightbox__leyenda-desc {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 400;
    color: rgba(248, 250, 252, 0.82);
    line-height: 1.45;
    max-height: 5.5rem;
    overflow-y: auto;
}

.sw-gl-lightbox__stage {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.sw-gl-lightbox__stage:active {
    cursor: grabbing;
}

.sw-gl-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    user-select: none;
}

.sw-gl-lightbox__video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
    background: var(--sw-pie-fondo, #1e293b);
}

/* Hueco donde el visor inyecta el reproductor ÚNICO (.sw-repro-audio--visor). Solo ancla y
   centra: la tarjeta, sus colores y su alto los pone el bloque compartido de más abajo. */
.sw-gl-lightbox__audiobox {
    width: min(30rem, 90vw);
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.sw-gl-lightbox__audiobox[hidden] {
    display: none !important;
}

/* Sin imagen no hay escenario que repartir: al colapsarlo, el viewport centra como un único
   bloque el origen, la leyenda y el reproductor. */
.sw-gl-lightbox--audio-sin-imagen .sw-gl-lightbox__stage {
    display: none;
}

/* Fila del audio: con imagen no es una caja (`contents`) y no altera nada; sin imagen se vuelve
   la fila que flanquea al reproductor con las flechas. */
.sw-gl-lightbox__audiofila {
    display: contents;
}

/* Sin escenario, las flechas dejan de flotar y se colocan a los lados del reproductor. */
.sw-gl-lightbox--audio-sin-imagen .sw-gl-lightbox__nav {
    position: static;
    transform: none;
    flex: 0 0 auto;
}

.sw-gl-lightbox--audio-sin-imagen .sw-gl-lightbox__audiofila {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0 0.5rem;
}

.sw-gl-lightbox--audio-sin-imagen .sw-gl-lightbox__audiobox {
    width: min(30rem, 100%);
    flex: 0 1 auto;
    min-width: 0;
}

/* ── Reproductor de audio ÚNICO ──────────────────────────────────────────────────────────────
   Lo pinta window.swAudioItem.html() (public/js/web/audio-altavoz.js) y es el MISMO marcado y el
   MISMO CSS en el detalle de ruta, el detalle de parada, los paneles rápidos del inicio, las
   fichas de vinculados y el visor: si hace falta otro aspecto es un modificador de este bloque,
   nunca una copia. Vive en esta hoja porque es la única que cargan las tres páginas con
   reproductor (detalle-ruta.phtml, detalle-parada.phtml e index.phtml) y, al cargarse la última,
   no tiene que pelearse por especificidad con las hojas de superficie.

   Disposición: una fila para el título, la descripción plegada justo debajo (la despliega la «i»)
   y una fila de controles con el número de orden y su semicírculo de marca, el play, la barra con
   el tiempo. A la derecha, la «i» a la altura del título y los vinculados debajo. */
.sw-repro-audio {
    box-sizing: border-box;
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--sw-blanco);
    border: 1px solid var(--sw-borde);
    border-radius: var(--sw-radio-md);
}

.sw-repro-audio__contenido {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sw-repro-audio__titulo {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.5rem;
    color: var(--sw-texto);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Bandera del idioma grabado (P5), delante del título; los audios universales no la llevan. */
.sw-repro-audio__idioma {
    display: inline-flex;
    vertical-align: -2px;
    margin-right: 0.375rem;
    line-height: 1;
}

.sw-repro-audio__idioma img,
.sw-repro-audio__idioma .fi {
    width: 18px;
    height: 13.5px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--sw-texto, #111) 15%, transparent);
}

.sw-repro-audio__desc {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--sw-texto-secundario);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 6rem;
    overflow-y: auto;
}

.sw-repro-audio__desc[hidden] {
    display: none !important;
}

.sw-repro-audio__fila {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

/* Número de orden con un semicírculo en el color primario que lo separa del resto de la fila. */
.sw-repro-audio__orden {
    position: relative;
    flex: 0 0 auto;
    padding-right: 0.65rem;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--sw-texto-secundario);
}

.sw-repro-audio__orden::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0.4rem;
    height: 1.5rem;
    border-radius: 0 999px 999px 0;
    background: var(--sw-primario);
}

/* Reutiliza el círculo de marca de .sw-audio-altavoz: aquí solo el tamaño y sin halo latiendo. */
.sw-repro-audio__play {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.875rem;
    animation: none;
}

/* Foto vinculada al audio, a la izquierda del play: abre esa foto en el visor con el audio. */
.sw-repro-audio__foto {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: var(--sw-radio-sm);
    overflow: hidden;
    background: var(--sw-fondo);
    cursor: zoom-in;
}

.sw-repro-audio__foto img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sw-repro-audio__foto:focus-visible {
    outline: 2px solid var(--sw-primario);
    outline-offset: 2px;
}

.sw-repro-audio__control {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sw-repro-audio__barra {
    flex: 1 1 auto;
    min-width: 0;
    height: 0.9rem;   /* diana cómoda; la línea pintada es más fina */
    margin: 0;
    accent-color: var(--sw-primario);
    cursor: pointer;
}

.sw-repro-audio__tiempo {
    flex: 0 0 auto;
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    color: var(--sw-texto-secundario);
}

.sw-repro-audio__acciones {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.sw-repro-audio__acciones:empty {
    display: none;
}

.sw-repro-audio__vinc {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
    color: var(--sw-primario);
}

.sw-repro-audio__info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid var(--sw-borde);
    border-radius: 50%;
    background: transparent;
    color: var(--sw-texto-secundario);
    font-size: 0.6875rem;
    line-height: 1;
    cursor: pointer;
}

.sw-repro-audio__info[aria-expanded="true"] {
    background: var(--sw-primario-claro);
    border-color: var(--sw-primario);
    color: var(--sw-primario);
}

.sw-repro-audio__info:focus-visible {
    outline: 2px solid var(--sw-primario);
    outline-offset: 2px;
}

/* Las fichas de vinculados conservan su variante compacta. */
.sw-repro-audio--compacto {
    padding: 0.5rem 0.625rem;
}

.sw-repro-audio--compacto .sw-repro-audio__play {
    width: 2rem;
    height: 2rem;
    font-size: 0.8125rem;
}

.sw-repro-audio--compacto .sw-repro-audio__tiempo {
    font-size: 0.625rem;
}

.sw-repro-audio--compacto {
    background: var(--sw-fondo);
    border-radius: var(--sw-radio-sm);
}

/* Visor: el fondo es negro, así que la tarjeta clara se repinta en oscuro. */
.sw-repro-audio--visor {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.sw-repro-audio--visor .sw-repro-audio__titulo {
    color: #f8fafc;
}

.sw-repro-audio--visor .sw-repro-audio__desc,
.sw-repro-audio--visor .sw-repro-audio__tiempo,
.sw-repro-audio--visor .sw-repro-audio__orden {
    color: rgba(248, 250, 252, 0.85);
}

.sw-repro-audio--visor .sw-repro-audio__vinc {
    color: var(--sw-primario-claro);
}

.sw-repro-audio--visor .sw-repro-audio__info {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(248, 250, 252, 0.85);
}

/* El navegador vetó el arranque automático (solo pasa en el visor): se resalta el play. */
.sw-audio-altavoz.is-pendiente {
    animation: sw-audio-latido 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .sw-audio-altavoz.is-pendiente {
        animation: none;
        box-shadow: 0 0 0 0.3rem var(--sw-primario-claro);
    }
}

@keyframes sw-audio-latido {
    0%, 100% { box-shadow: 0 0 0 0.35rem var(--sw-primario-claro), var(--sw-sombra-sm); }
    50% { box-shadow: 0 0 0 0.6rem var(--sw-primario-claro), var(--sw-sombra-sm); }
}

/* Altavoz de reproducción directa en los listados de medios (audio-altavoz.js). A diferencia
   del triángulo decorativo que sustituye, es un botón real: recibe puntero y foco. */
.sw-audio-altavoz {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--sw-primario);
    color: var(--sw-texto-invertido, #fff);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--sw-trans-rapida), transform var(--sw-trans-rapida);
}

.sw-audio-altavoz:hover {
    background: var(--sw-primario-oscuro, var(--sw-primario));
    transform: scale(1.08);
}

.sw-audio-altavoz:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Sonando: anillo de marca para distinguirlo de los demás altavoces de la rejilla. */
.sw-audio-altavoz[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--sw-primario-claro, rgba(255, 255, 255, 0.4));
}

/* Diana táctil mínima sin agrandar el círculo pintado. */
@media (pointer: coarse) {
    .sw-audio-altavoz {
        width: 44px;
        height: 44px;
        border: 8px solid transparent;
        background-clip: padding-box;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sw-audio-altavoz {
        transition: none;
    }

    .sw-audio-altavoz:hover {
        transform: none;
    }
}

/* Tira de archivos vinculados del item abierto */
.sw-gl-lightbox__strip {
    flex-shrink: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    padding: 0.35rem 0.5rem 0;
}

.sw-gl-lightbox__strip[hidden] {
    display: none !important;
}

.sw-gl-lightbox__strip-titulo {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(248, 250, 252, 0.85);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.sw-gl-lightbox__strip-lista {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(56rem, 92vw);
    overflow-x: auto;
    padding: 0.15rem 0.15rem 0.35rem;
    scrollbar-width: thin;
}

.sw-gl-lightbox__strip-item {
    position: relative;
    flex: 0 0 auto;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--sw-radio-md, 0.5rem);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    cursor: pointer;
    transition: border-color var(--sw-trans-rapida), transform var(--sw-trans-rapida);
    font-family: inherit;
}

.sw-gl-lightbox__strip-item:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.45);
}

.sw-gl-lightbox__strip-item.is-activa {
    border-color: var(--sw-primario-claro, #93c5fd);
}

.sw-gl-lightbox__strip-item:focus-visible {
    outline: 2px solid var(--sw-primario-claro, #93c5fd);
    outline-offset: 2px;
}

.sw-gl-lightbox__strip-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sw-gl-lightbox__strip-ico {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sw-gl-lightbox__strip-item--video .sw-gl-lightbox__strip-ico {
    background: rgba(15, 23, 42, 0.55);
}

.sw-gl-lightbox__strip-item--audio .sw-gl-lightbox__strip-ico {
    background: rgba(37, 99, 235, 0.35);
}

@supports (padding: env(safe-area-inset-top)) {
    .sw-gl-lightbox__barra {
        padding-top: max(0.75rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .sw-gl-lightbox {
        padding-top: max(3.25rem, calc(env(safe-area-inset-top) + 2.5rem));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

@media (max-width: 991.98px) {
    .sw-gl-lightbox__leyenda-desc {
        font-size: 0.875rem;
    }
}

@media (max-width: 575.98px) {
    .sw-gl-lightbox__audiobox {
        width: min(30rem, calc(100vw - 2rem));
    }

    .sw-gl-lightbox__strip-lista {
        max-width: calc(100vw - 1.5rem);
    }

    .sw-gl-lightbox__strip-titulo {
        font-size: 0.8125rem;
    }
}

@media (pointer: coarse) {
    .sw-gl-lightbox__btn-icono {
        width: 44px;
        height: 44px;
    }

    .sw-repro-audio__barra {
        min-height: 44px;
    }

    .sw-repro-audio__foto {
        width: 44px;
        height: 44px;
    }
}

/* Miniatura / hero abre visor */
.sw-gl-disparador {
    cursor: zoom-in;
}

.sw-gl-disparador:focus-visible {
    outline: 2px solid var(--sw-primario);
    outline-offset: 2px;
}

/* C1: crédito de la foto («Foto de» + avatar + nombre) bajo el medio del visor y como insignia en las miniaturas. */
.sw-gl-lightbox__credito { flex-shrink: 0; display: flex; justify-content: center; padding: 0.25rem 0.75rem 0; }
.sw-gl-lightbox__credito[hidden] { display: none; }
.sw-gl-credito { display: inline-flex; align-items: center; gap: 0.4rem; max-width: 100%; font-size: 0.8125rem; line-height: 1.2; color: inherit; }
.sw-gl-credito__avatar { flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover; }
.sw-gl-credito__avatar--inicial { display: inline-grid; place-items: center; background: var(--sw-primario-claro, #e7efff); color: var(--sw-primario, #1463ff); font-size: 0.7rem; font-weight: 700; }
.sw-gl-credito__texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-gl-credito__de { opacity: 0.8; }
.sw-gl-credito__nombre { font-weight: 600; }
.sw-gl-credito--compacto { position: absolute; left: 0.35rem; bottom: 0.35rem; z-index: 2; max-width: calc(100% - 0.7rem); padding: 0.15rem 0.5rem 0.15rem 0.2rem; border-radius: 999px; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 0.7rem; pointer-events: none; }
.sw-gl-credito--compacto .sw-gl-credito__avatar { width: 1.1rem; height: 1.1rem; }
