/*
 * Insider Shorts - carrusel de shorts.
 * Medidas: docs/referencia-a24.md. Los valores configurables llegan como custom properties.
 */

.insider-shorts {
    --is-visible: var(--is-visible-desktop, 3);
    --is-gap-size: var(--is-gap, 16px);
    --is-track-padding: 8px;
    --is-accent-color: var(--is-accent, #604c8d);
    --is-opacity: var(--is-controls-opacity, 1);

    position: relative;
    margin: 0 0 1.5em;
    color: #272727;
}

.insider-shorts,
.insider-shorts *,
.insider-shorts *::before,
.insider-shorts *::after {
    box-sizing: border-box;
}

@media (max-width: 800px) {
    .insider-shorts {
        --is-visible: var(--is-visible-tablet, 2);
    }
}

@media (max-width: 520px) {
    .insider-shorts {
        --is-visible: var(--is-visible-mobile, 1.25);
        --is-track-padding: 0px;
    }
}

/* Resets defensivos frente a estilos del tema. */
.insider-shorts button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    font: inherit;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    min-width: 0;
    min-height: 0;
    height: auto;
    width: auto;
    color: inherit;
}

.insider-shorts .insider-shorts__open,
.insider-shorts .insider-shorts__open:hover,
.insider-shorts .insider-shorts__open:focus,
.insider-shorts .insider-shorts__open:active {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.insider-shorts .insider-shorts__arrow:hover,
.insider-shorts .insider-shorts__arrow:focus,
.insider-shorts .insider-shorts__arrow:active {
    border: 0;
    background: var(--is-accent-color);
    color: #fff;
}

.insider-shorts__carousel {
    position: relative;
}

.insider-shorts__viewport {
    overflow: hidden;
    background: transparent;
}

.insider-shorts__track {
    position: relative;
    display: flex;
    gap: var(--is-gap-size);
    margin: 0;
    padding: 8px var(--is-track-padding);
    list-style: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--is-track-padding);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.insider-shorts__track::-webkit-scrollbar {
    display: none;
}

/* Card */
.insider-shorts__card {
    position: relative;
    flex: 0 0 calc((100% - var(--is-gap-size) * (var(--is-visible) - 1)) / var(--is-visible));
    margin: 0;
    padding: 0;
    list-style: none;
    aspect-ratio: 9 / 16;
    overflow: hidden;
    background: #0b0d12;
    border: 1px solid #e5e7eb;
    border-radius: var(--is-radius, 0px);
    scroll-snap-align: start;
    container-type: inline-size;
}

.insider-shorts__card::before,
.insider-shorts__card::after,
.insider-shorts__card::marker {
    content: none;
}

.insider-shorts__thumb,
.insider-shorts .insider-shorts__thumb {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    object-fit: cover;
    object-position: center;
}

.insider-shorts__preview {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
    background: #000;
}

.insider-shorts__shade {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    height: 46%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.78));
    pointer-events: none;
}

/*
 * Tamano del titulo (setting `title_size`). Escala con el ancho de la card (cqi).
 * En una card de 206px: chico ~12px, mediano ~14px, grande ~21px (a24: 22px en 220px).
 * `--is-title-bottom` deja el titulo apoyado sobre la pill de duracion.
 */
.insider-shorts--title-small {
    --is-title-size: clamp(11px, 6cqi, 16px);
    --is-title-bottom: 40px;
}

.insider-shorts--title-medium {
    --is-title-size: clamp(12px, 7cqi, 19px);
    --is-title-bottom: 42px;
}

.insider-shorts--title-large {
    --is-title-size: clamp(14px, 10cqi, 26px);
    --is-title-bottom: 48px;
}

.insider-shorts__title {
    position: absolute;
    right: 16px;
    bottom: var(--is-title-bottom, 42px);
    left: 16px;
    z-index: 3;
    display: -webkit-box;
    overflow: hidden;
    color: #fff;
    /* Misma tipografia que los titulos de posts del tema (SmartMag: Lato 700, interlineado 1.28). */
    font-family: var(--title-font, inherit);
    font-weight: 700;
    font-size: var(--is-title-size, clamp(13px, 8cqi, 22px));
    line-height: 1.28;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    overflow-wrap: break-word;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.insider-shorts__card.is-previewing .insider-shorts__title {
    opacity: 0;
}

/* Pill de duracion: compacta y alineada abajo a la derecha (a24 la centra y es mas grande). */
.insider-shorts__pill {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(10, 14, 20, 0.55);
    color: #fff;
    pointer-events: none;
    white-space: nowrap;
}

.insider-shorts__pill--icon {
    gap: 0;
    padding: 5px 7px;
}

.insider-shorts__pill-icon {
    width: 0;
    height: 0;
    border-top: 4.5px solid transparent;
    border-bottom: 4.5px solid transparent;
    border-left: 7px solid #fff;
    opacity: 0.95;
}

.insider-shorts__pill-text {
    font-family: var(--title-font, inherit);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.2px;
}

/* Toda la card es clickeable; el boton cubre la card y contiene el play central. */
.insider-shorts .insider-shorts__open {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #fff;
    cursor: pointer;
}

.insider-shorts .insider-shorts__open:focus-visible {
    outline: 3px solid var(--is-accent-color);
    outline-offset: -3px;
}

.insider-shorts__play {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
    transition: opacity 0.2s ease;
}

.insider-shorts__card.is-previewing .insider-shorts__play {
    opacity: 0;
}

/* Flechas */
.insider-shorts__nav {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: none;
    transform: translateY(-50%);
}

.insider-shorts.has-arrows .insider-shorts__nav {
    display: block;
}

.insider-shorts__nav--prev {
    left: -20px;
}

.insider-shorts__nav--next {
    right: -20px;
}

.insider-shorts .insider-shorts__arrow {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--is-accent-color);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    opacity: var(--is-opacity);
    cursor: pointer;
}

.insider-shorts .insider-shorts__arrow:disabled {
    opacity: calc(var(--is-opacity) * 0.35);
    cursor: default;
}

.insider-shorts .insider-shorts__arrow:focus-visible {
    outline: 2px solid #272727;
    outline-offset: 2px;
}

@media (max-width: 520px) {
    .insider-shorts.has-arrows .insider-shorts__nav {
        display: none;
    }

    .insider-shorts.has-arrows.has-arrows-mobile .insider-shorts__nav {
        display: block;
    }

    .insider-shorts__nav--prev {
        left: 8px;
    }

    .insider-shorts__nav--next {
        right: 8px;
    }
}

/* Dots */
.insider-shorts__dots {
    display: none;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.insider-shorts.has-dots .insider-shorts__dots {
    display: flex;
}

.insider-shorts .insider-shorts__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    opacity: calc(var(--is-opacity) * 0.9);
    cursor: pointer;
}

.insider-shorts .insider-shorts__dot.is-active {
    background: var(--is-accent-color);
    opacity: var(--is-opacity);
}

.insider-shorts .insider-shorts__dot:focus-visible {
    outline: 2px solid #272727;
    outline-offset: 2px;
}

/* Si todas las cards entran, no hay navegacion. */
.insider-shorts.is-static .insider-shorts__nav,
.insider-shorts.is-static .insider-shorts__dots {
    display: none;
}

/* Modal (una sola instancia, agregada al body por JS) */
html.insider-shorts-lock,
html.insider-shorts-lock body {
    overflow: hidden;
}

.insider-shorts-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.85);
}

.insider-shorts-modal[hidden] {
    display: none;
}

.insider-shorts-modal,
.insider-shorts-modal * {
    box-sizing: border-box;
}

.insider-shorts-modal__player {
    position: relative;
    width: min(540px, calc(100vw - 32px), calc((100vh - 32px) * 9 / 16));
    max-height: calc(100vh - 32px);
    aspect-ratio: 9 / 16;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.insider-shorts-modal__player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.insider-shorts-modal button {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #111a;
    box-shadow: none;
    color: #fff;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.insider-shorts-modal button:disabled {
    opacity: 0.35;
    cursor: default;
}

.insider-shorts-modal button[hidden] {
    display: none;
}

.insider-shorts-modal button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.insider-shorts-modal__close {
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 48px;
    height: 48px;
}

.insider-shorts-modal__share {
    top: 72px;
    right: 16px;
    z-index: 3;
    width: 48px;
    height: 48px;
}

.insider-shorts-modal__nav {
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translateY(-50%);
}

.insider-shorts-modal__nav--prev {
    left: 12px;
}

.insider-shorts-modal__nav--next {
    right: 12px;
}

.insider-shorts-modal__toast {
    position: absolute;
    bottom: 24px;
    left: 50%;
    z-index: 4;
    padding: 8px 16px;
    border-radius: 999px;
    background: #fff;
    color: #111;
    font-size: 14px;
    transform: translateX(-50%);
    pointer-events: none;
}

.insider-shorts-modal__toast[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .insider-shorts__title,
    .insider-shorts__play {
        transition: none;
    }
}
