/* FHP Video Card — matches the Sostenibilità keypoint grid (radius, brand blue, General Sans). */

.fhp-video-card {
    --fhp-video-blue: #002d72;
    --fhp-video-radius: var(--rounded-default, 1.25rem);
    height: 100%;
}

/* Oxygen's Shortcode element wraps the output in a div; let it fill the grid cell. */
.oxy-shortcode:has(> .fhp-video-card) {
    height: 100%;
}

.fhp-video-card__trigger {
    position: relative;
    display: block;
    height: 100%;
    min-height: 16rem;
    overflow: hidden;
    border-radius: var(--fhp-video-radius);
    background: var(--fhp-video-blue);
    color: var(--fhp-video-blue);
    text-decoration: none;
}

.fhp-video-card__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.fhp-video-card__label {
    position: absolute;
    left: 1.25rem;
    bottom: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: max-content;
    max-width: calc(100% - 2.5rem);
    padding: 0.5rem 1.25rem 0.5rem 0.5rem;
    border-radius: 999px;
    background: #fff;
    transition: background-color 0.2s ease;
}

.fhp-video-card__play {
    flex: none;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--fhp-video-blue);
    color: #fff;
}

.fhp-video-card__text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.fhp-video-card__title {
    font-size: 1.125rem;
    font-weight: 500;
}

.fhp-video-card__meta {
    font-size: 0.875rem;
    opacity: 0.75;
}

.fhp-video-card__trigger:hover .fhp-video-card__poster,
.fhp-video-card__trigger:focus-visible .fhp-video-card__poster {
    transform: scale(1.03);
}

.fhp-video-card__trigger:hover .fhp-video-card__label,
.fhp-video-card__trigger:focus-visible .fhp-video-card__label {
    background: #dfe6f1;
}

.fhp-video-card__trigger:focus-visible {
    outline: 3px solid var(--fhp-video-blue);
    outline-offset: 3px;
}

.fhp-video-card__trigger:active .fhp-video-card__label {
    background: #cbd6e8;
}

.fhp-video-card--empty {
    display: grid;
    place-items: center;
    height: 100%;
    min-height: 16rem;
    padding: 2rem;
    border: 2px dashed rgba(0, 45, 114, 0.4);
    border-radius: var(--rounded-default, 1.25rem);
    color: #002d72;
    text-align: center;
}

/* Modal player */

.fhp-video-dialog {
    /* Fit 16:9 inside the viewport, leaving room above for the close button. */
    width: min(90rem, calc(100vw - 2rem), calc((100vh - 8rem) * 16 / 9));
    width: min(90rem, calc(100vw - 2rem), calc((100dvh - 8rem) * 16 / 9));
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.fhp-video-dialog::backdrop {
    background: rgba(0, 20, 50, 0.85);
}

.fhp-video-dialog__inner {
    position: relative;
}

.fhp-video-dialog__player {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 0.75rem;
    background: #000;
}

.fhp-video-dialog__player .plyr,
.fhp-video-dialog__video {
    display: block;
    width: 100%;
    height: 100%;
}

/* Spinner while Plyr loads on the first click. */
.fhp-video-dialog__inner.is-loading .fhp-video-dialog__player::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3rem;
    height: 3rem;
    margin: -1.5rem 0 0 -1.5rem;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fhp-video-spin 0.8s linear infinite;
}

@keyframes fhp-video-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Plyr theme: FHP palette (site variables with fallbacks) and the site font. */
.fhp-video-dialog {
    --plyr-color-main: var(--primary, #002d72);
    --plyr-font-family: inherit;
    /* Stronger than Plyr's default so white controls stay readable over the video's white slides. */
    --plyr-video-controls-background: linear-gradient(rgba(0, 27, 69, 0), rgba(0, 27, 69, 0.65) 35%, rgba(0, 27, 69, 0.92));
    --plyr-video-control-color: #fff;
    --plyr-video-control-color-hover: #fff;
    --plyr-video-control-background-hover: var(--primary, #002d72);
    --plyr-control-radius: 999px;
    --plyr-range-fill-background: var(--primary-light, #ccd5e3);
    --plyr-range-thumb-background: #fff;
    --plyr-video-range-track-background: rgba(255, 255, 255, 0.25);
    --plyr-video-progress-buffered-background: rgba(204, 213, 227, 0.4);
    --plyr-focus-visible-color: var(--primary-light, #ccd5e3);
    --plyr-menu-background: #fff;
    --plyr-menu-color: var(--primary-dark, #001b45);
    --plyr-menu-radius: 0.75rem;
    --plyr-control-toggle-checked-background: var(--primary, #002d72);
    --plyr-badge-background: var(--primary, #002d72);
    --plyr-badge-text-color: #fff;
    --plyr-tooltip-background: #fff;
    --plyr-tooltip-color: var(--primary-dark, #001b45);
    --plyr-tooltip-radius: 0.5rem;
}

/* Large centre Play button: white on the blue poster. */
.fhp-video-dialog .plyr__control--overlaid {
    padding: 1.5rem;
    background: #fff;
    color: var(--primary, #002d72);
}

.fhp-video-dialog .plyr__control--overlaid svg {
    width: 1.5rem;
    height: 1.5rem;
}

.fhp-video-dialog .plyr__control--overlaid:hover,
.fhp-video-dialog .plyr__control--overlaid:focus-visible {
    background: var(--primary-light, #ccd5e3);
    color: var(--primary-dark, #001b45);
}

.fhp-video-dialog .plyr__poster {
    background-size: cover;
}

/* Small screens: leave the width to the progress bar (volume stays on the mute button). */
@media (max-width: 600px) {
    .fhp-video-dialog .plyr__volume input[type="range"],
    .fhp-video-dialog .plyr__controls [data-plyr="pip"] {
        display: none;
    }
}

.fhp-video-dialog__close {
    position: absolute;
    top: -3.25rem;
    right: 0;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #002d72;
    cursor: pointer;
}

.fhp-video-dialog__close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

html:has(.fhp-video-dialog[open]) {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .fhp-video-card__poster,
    .fhp-video-card__label {
        transition: none;
    }

    .fhp-video-dialog__inner.is-loading .fhp-video-dialog__player::after {
        animation-duration: 2.4s;
    }
}
