/*
 * Frontend styles for the WP Videos block, shortcode and widget.
 *
 * The tokens reuse the gobbo theme variables (--primary-main, --texto-default,
 * --background-default) so the listing adapts to the light/dark theme, and
 * fall back to neutral values in any other theme.
 */

.wp-videos-widget,
.wpv-block,
.wpv-player,
.wpv-modal {
    --wpv-accent: var(--primary-main, #0073aa);
    --wpv-text: var(--texto-default, #343a40);
    --wpv-bg: var(--background-default, #ffffff);
    --wpv-paper: var(--background-paper, #f8f9fa);
    --wpv-muted: #6c757d;
    --wpv-border: #e3e3e3;
    --wpv-radius: 8px;
    --wpv-gap: 1rem;

    color: var(--wpv-text);
}

@supports (color: color-mix(in srgb, currentColor 20%, transparent)) {
    .wp-videos-widget,
    .wpv-block,
    .wpv-player,
    .wpv-modal {
        --wpv-muted: color-mix(in srgb, var(--wpv-text) 62%, transparent);
        --wpv-border: color-mix(in srgb, var(--wpv-text) 16%, transparent);
    }
}

/* Block heading */
.wpv-block__title {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
}

.wpv-block__more {
    margin: 1rem 0 0;
}

.wpv-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--wpv-accent);
    border-radius: 4px;
    color: var(--wpv-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}

.wpv-button:hover,
.wpv-button:focus-visible {
    background: var(--wpv-accent);
    color: #fff;
}

.wpv-button:focus-visible {
    outline: 2px solid var(--wpv-accent);
    outline-offset: 2px;
}

/* Grid of videos */
.wpv-grid {
    display: grid;
    gap: var(--wpv-gap);
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 992px) {
    .wpv-grid {
        grid-template-columns: repeat(var(--wpv-columns, 4), minmax(0, 1fr));
    }
}

/* Shorts rail */
.wpv-shorts {
    margin-top: 1.5rem;
}

.wpv-shorts__title {
    margin: 0 0 0.6rem;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wpv-rail {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.wpv-rail .wpv-card {
    flex: 0 0 auto;
    width: 150px;
    scroll-snap-align: start;
}

/* Card */
.wpv-card {
    margin: 0;
    background: transparent;
}

.wpv-card__media {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: var(--wpv-radius);
    background: var(--wpv-paper);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    cursor: pointer;
}

.wpv-card--short .wpv-card__media {
    aspect-ratio: 9 / 16;
    border-radius: 10px;
}

.wpv-card__thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.wpv-card__media:hover .wpv-card__thumb {
    transform: scale(1.04);
}

.wpv-card__media:focus-visible {
    outline: 2px solid var(--wpv-accent);
    outline-offset: 2px;
}

.wpv-card__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85) inset;
}

.wpv-card__play::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 8px 0 8px 13px;
    border-color: transparent transparent transparent #fff;
}

.wpv-card--short .wpv-card__play {
    width: 34px;
    height: 34px;
}

.wpv-card__body {
    padding-top: 0.4rem;
}

.wpv-card__title {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.35;
    font-weight: 600;
}

.wpv-card__title a {
    color: inherit;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wpv-card__title a:hover {
    color: var(--wpv-accent);
    text-decoration: underline;
}

.wpv-card__meta {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    color: var(--wpv-muted);
}

/* Pagination */
.wpv-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
}

.wpv-pagination__btn,
.wpv-pagination__dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--wpv-border);
    border-radius: 4px;
    background: var(--wpv-bg);
    color: var(--wpv-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.wpv-pagination__btn:hover,
.wpv-pagination__btn:focus-visible {
    background: var(--wpv-paper);
    border-color: var(--wpv-accent);
    outline: none;
}

.wpv-pagination__btn--active {
    background: var(--wpv-accent);
    color: #fff;
    border-color: var(--wpv-accent);
}

.wpv-pagination__btn--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wpv-pagination__dots {
    border: 0;
    background: transparent;
    color: var(--wpv-muted);
    cursor: default;
}

/* Player layout: list on the left, viewer on the right */
.wpv-player__panel {
    display: flex;
    flex-direction: column;
    max-height: 34rem;
    border: 1px solid var(--wpv-border);
    border-radius: var(--wpv-radius);
    background: var(--wpv-bg);
    overflow: hidden;
}

.wpv-player__tabs {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--wpv-border);
}

.wpv-player__tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--wpv-text);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.wpv-player__tab:hover {
    border-color: var(--wpv-border);
}

.wpv-player__tab.is-active {
    background: var(--wpv-accent);
    color: #fff;
}

.wpv-player__list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    scrollbar-width: thin;
}

.wpv-player__item {
    border-bottom: 1px solid var(--wpv-border);
}

.wpv-player__item:last-child {
    border-bottom: 0;
}

.wpv-player__item-btn {
    display: flex;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.wpv-player__item-btn:hover {
    background: var(--wpv-paper);
}

.wpv-player__item-btn:focus-visible {
    outline: 2px solid var(--wpv-accent);
    outline-offset: -2px;
}

.wpv-player__item.is-active .wpv-player__item-btn {
    background: var(--wpv-paper);
    border-left-color: var(--wpv-accent);
}

.wpv-player__item.is-hidden {
    display: none;
}

.wpv-player__item-thumb {
    flex: 0 0 104px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    overflow: hidden;
    background: var(--wpv-paper);
}

.wpv-player__item-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpv-player__item-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.wpv-player__item-title {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wpv-player__item-meta {
    font-size: 0.76rem;
    color: var(--wpv-muted);
}

.wpv-player__stage {
    position: sticky;
    top: 1rem;
}

.wpv-player__media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--wpv-radius);
    overflow: hidden;
}

.wpv-player__stage--short .wpv-player__media {
    width: min(360px, 80%);
    margin: 0 auto;
    aspect-ratio: 9 / 16;
}

.wpv-player__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.wpv-player__frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.wpv-player__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background-color: #000;
    background-size: cover;
    background-position: center;
    cursor: pointer;
}

.wpv-player__poster:focus-visible {
    outline: 2px solid var(--wpv-accent);
    outline-offset: 2px;
}

.wpv-player__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9) inset;
    transition: transform 0.15s;
}

.wpv-player__poster:hover .wpv-player__play {
    transform: translate(-50%, -50%) scale(1.06);
}

.wpv-player__play::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 14px 0 14px 22px;
    border-color: transparent transparent transparent #fff;
}

.wpv-player__title {
    margin: 0.8rem 0 0.2rem;
    font-size: 1.1rem;
}

.wpv-player__meta {
    margin: 0 0 0.6rem;
    font-size: 0.85rem;
    color: var(--wpv-muted);
}

.wpv-player__links {
    margin: 0;
}

/* Player modal */
.wpv-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.wpv-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    border: 0;
}

.wpv-modal__dialog {
    position: relative;
    width: min(960px, 100%);
    max-height: 92vh;
    overflow: auto;
    padding: 1rem;
    border-radius: 10px;
    background: #fff;
    color: #1d2327;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.wpv-modal__close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.wpv-modal__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.wpv-modal__frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
}

.wpv-modal__frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.wpv-modal--short .wpv-modal__frame {
    width: min(340px, 80vw);
    aspect-ratio: 9 / 16;
    margin: 0 auto;
}

.wpv-modal__title {
    margin: 0.85rem 0 0.25rem;
    font-size: 1.05rem;
}

.wpv-modal__link {
    font-size: 0.9rem;
    color: var(--wpv-accent);
}
