/**
 * This file is part of Moodle - http://moodle.org/
 *
 * Moodle is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Moodle is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Styles for the modern video player activity.
 *
 * @package    mod_modernvideoplayer
 * @copyright  2026 Adebare Showemimo <adebareshowemimo@gmail.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

.modernvideoplayer {
    max-width: 1100px;
    margin: 0 auto;
}

.modernvideoplayer__shell {
    background: linear-gradient(180deg, #f8fbff 0%, #eef4f8 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1.5rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.modernvideoplayer__topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(14px);
    position: relative;
}

.modernvideoplayer__close {
    flex: 0 0 auto;
    opacity: 0.72;
    margin-left: auto;
}

.modernvideoplayer__close:hover,
.modernvideoplayer__close:focus {
    opacity: 1;
}

.modernvideoplayer__title {
    margin: 0;
    /* stylelint-disable-next-line csstree/validator */
    font-size: clamp(1rem, 0.7rem + 1vw, 1.4rem);
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    max-width: calc(100% - 3rem);
}

.modernvideoplayer__title--left {
    margin-right: auto;
    text-align: left;
}

.modernvideoplayer__title--center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.modernvideoplayer__title--right {
    margin-left: auto;
    text-align: right;
    padding-right: 2.5rem;
}

.modernvideoplayer__content {
    padding: 1.25rem;
}

.modernvideoplayer__stage {
    background: #07111c;
    border-radius: 1.25rem;
    overflow: hidden;
    /* stylelint-disable-next-line csstree/validator */
    min-height: min(70vh, 42rem);
}

.modernvideoplayer__video {
    display: block;
    width: 100%;
    background: #000;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.modernvideoplayer-status {
    display: block;
}

.modernvideoplayer-status__item {
    display: grid;
    gap: 0.85rem;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 1rem;
    box-shadow: none;
}

.modernvideoplayer-status__headline {
    color: #eaf1ff;
    /* stylelint-disable-next-line csstree/validator */
    font-size: clamp(0.95rem, 0.82rem + 0.4vw, 1.1rem);
    font-weight: 600;
    line-height: 1;
}

.modernvideoplayer-status__meta {
    color: #c7d4ea;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
}

.modernvideoplayer-status__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #4ade80;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
}

.modernvideoplayer-status__badge svg {
    flex-shrink: 0;
}

.modernvideoplayer-status__track {
    height: 0.4rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    touch-action: none;
}

.modernvideoplayer-status__track:hover,
.modernvideoplayer--scrubbing .modernvideoplayer-status__track {
    height: 0.6rem;
}

.modernvideoplayer-status__fill {
    border-radius: 999px;
}

.modernvideoplayer-status__fill--verified {
    background: linear-gradient(90deg, #0b5ed7 0%, #2563eb 100%);
    z-index: 2;
}

.modernvideoplayer-status__fill--buffered {
    background: linear-gradient(90deg, rgba(14, 116, 144, 0.16) 0%, rgba(6, 182, 212, 0.3) 100%);
    z-index: 1;
}

.modernvideoplayer-status__thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 0.9rem;
    height: 0.9rem;
    transform: translate(-50%, -50%);
    border: 2px solid #3b82f6;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.24);
    z-index: 3;
    pointer-events: none;
}

.modernvideoplayer-controls {
    z-index: 3;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

[data-region="resume-overlay"],
[data-region="next-activity-overlay"] {
    z-index: 10;
}

.modernvideoplayer-controls__surface {
    border-radius: 1.15rem;
    background: rgba(8, 15, 27, 0.72);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
    padding: 0.95rem 1rem 0.85rem;
}

.modernvideoplayer--playing .modernvideoplayer-controls {
    opacity: 0;
    transform: translateY(0.75rem);
    pointer-events: none;
}

.modernvideoplayer--playing.modernvideoplayer--controls-visible .modernvideoplayer-controls,
.modernvideoplayer--playing [data-region="player-stage"]:hover .modernvideoplayer-controls,
.modernvideoplayer--playing [data-region="player-stage"]:focus-within .modernvideoplayer-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.modernvideoplayer-controls__bar {
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.modernvideoplayer-controls__button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: #eaf1ff;
    font-weight: 600;
}

.modernvideoplayer-controls__button:hover,
.modernvideoplayer-controls__button:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.modernvideoplayer-controls__button--primary {
    background: rgba(37, 99, 235, 0.92);
    border-color: rgba(96, 165, 250, 0.3);
}

.modernvideoplayer-controls__button--primary:hover,
.modernvideoplayer-controls__button--primary:focus {
    background: rgba(59, 130, 246, 1);
}

.modernvideoplayer-controls__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.modernvideoplayer-controls__icon svg {
    display: block;
}

.modernvideoplayer-controls__text {
    font-size: 0.82rem;
}

.modernvideoplayer-controls--icononly .modernvideoplayer-controls__text {
    display: none;
}

.modernvideoplayer-controls--icononly .modernvideoplayer-controls__button {
    min-width: 2.25rem;
    /* stylelint-disable declaration-no-important -- override Bootstrap utility classes. */
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
    /* stylelint-enable declaration-no-important */
}

/* The focus-mode rules below intentionally use !important to override Boost theme defaults
   on a per-instance basis without modifying core CSS. The long selectors target deeply-nested
   Boost markup. Stylelint disabled for this targeted block only. */
/* stylelint-disable declaration-no-important, max-line-length */

/* Neutralise the extra left offset Boost adds to #page when drawers are present. */
.modernvideoplayer-focus-mode #page.drawers {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Always hidden in focus mode regardless of instance settings. */
.modernvideoplayer-focus-mode #page-wrapper #page-footer,
.modernvideoplayer-focus-mode #page-wrapper .activity-header,
.modernvideoplayer-focus-mode #page-wrapper #region-main-settings-menu {
    display: none !important;
}

/* Hide primary navigation bar only when the instance setting is off. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-primarynav #page-wrapper .primary-navigation {
    display: none !important;
}

/* Hide secondary navigation (course tabs) and page header only when the instance setting is off.
   NOTE: Do NOT include #topofscroll here — it is the parent wrapper that contains #page-content
   and #region-main (the video). Hiding it would hide the video as well. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-secondarynav #page-wrapper .secondary-navigation,
.modernvideoplayer-focus-mode.modernvideoplayer-hide-secondarynav #page-wrapper .tertiary-navigation,
.modernvideoplayer-focus-mode.modernvideoplayer-hide-secondarynav #page-wrapper #page-header,
.modernvideoplayer-focus-mode.modernvideoplayer-hide-secondarynav #page-wrapper [data-region="header-actions-container"] {
    display: none !important;
}

/* Hide left (course index) drawer and its toggle only when the instance setting is off. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-courseindex #page-wrapper [data-region="drawer"][data-side="left"],
.modernvideoplayer-focus-mode.modernvideoplayer-hide-courseindex #page-wrapper #theme_boost-drawers-courseindex,
.modernvideoplayer-focus-mode.modernvideoplayer-hide-courseindex #page-wrapper [data-region="drawer-toggle"][data-action="toggle-drawer"][data-side="left"] {
    display: none !important;
}

/* Hide right (blocks) drawer and its toggle only when the instance setting is off. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-rightblocks #page-wrapper [data-region="right-hand-drawer"],
.modernvideoplayer-focus-mode.modernvideoplayer-hide-rightblocks #page-wrapper #theme_boost-drawers-blocks,
.modernvideoplayer-focus-mode.modernvideoplayer-hide-rightblocks #page-wrapper [data-region="drawer-toggle"][data-action="toggle-drawer"][data-side="right"] {
    display: none !important;
}

/* Hide the drawer-toggles container only when both drawers are turned off. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-courseindex.modernvideoplayer-hide-rightblocks #page-wrapper .drawer-toggles {
    display: none !important;
}

/* When the primary navbar is hidden Boost's navbar-offset padding on #page must be adjusted.
   - If the secondary nav (page header / tabs) is still visible, keep a small breathing-room
     gap so the header is not flush with the top of the viewport (mirrors the visual space
     the navbar would have provided on a normal page like forum/view.php).
   - If both are hidden there is nothing to show at the top, so remove all padding for a
     fully clean, distraction-free presentation. */
.modernvideoplayer-focus-mode.modernvideoplayer-hide-primarynav.modernvideoplayer-show-secondarynav #page-wrapper #page {
    padding-top: 1rem !important;
}
.modernvideoplayer-focus-mode.modernvideoplayer-hide-primarynav.modernvideoplayer-hide-secondarynav #page-wrapper #page {
    padding-top: 0 !important;
}
/* stylelint-enable declaration-no-important, max-line-length */

.modernvideoplayer-focus-mode #region-main {
    padding-top: 1rem;
}

.modernvideoplayer-focus-mode #region-main-box,
.modernvideoplayer-focus-mode #region-main {
    background: transparent;
}

.modernvideoplayer-focus-mode .activity-description,
.modernvideoplayer-focus-mode .generalbox {
    margin-bottom: 0;
}

/* Tablet and below. */
@media (max-width: 767.98px) {
    .modernvideoplayer__topbar {
        padding-right: 1rem;
    }

    .modernvideoplayer__title {
        max-width: calc(100% - 3.25rem);
    }

    .modernvideoplayer__content {
        padding: 0.75rem;
    }

    .modernvideoplayer__title--center {
        position: static;
        transform: none;
        margin-right: auto;
        text-align: left;
    }

    .modernvideoplayer__title--right {
        margin-right: 0;
        padding-right: 0;
        text-align: left;
    }

    .modernvideoplayer__stage {
        min-height: 0;
    }

    /* stylelint-disable declaration-no-important -- override Bootstrap utilities (p-3/p-md-4, gap-3, gap-2). */
    .modernvideoplayer-controls {
        padding: 0.5rem !important;
    }

    .modernvideoplayer-controls__surface {
        padding: 0.6rem 0.7rem;
        border-radius: 0.85rem;
    }

    /* Keep controls bar as a wrapping row, not column-stacked. */
    .modernvideoplayer-controls__bar {
        gap: 0.5rem !important;
    }

    .modernvideoplayer-controls__bar > div {
        gap: 0.35rem !important;
        flex-wrap: wrap;
    }

    .modernvideoplayer-controls__button {
        min-height: 2rem;
        padding-left: 0.6rem !important;
        padding-right: 0.6rem !important;
    }
    /* stylelint-enable declaration-no-important */

    .modernvideoplayer-transcript {
        max-height: 14rem;
    }

    .modernvideoplayer-transcript__body {
        max-height: 11rem;
    }

    .modernvideoplayer-chapters {
        max-height: 14rem;
    }

    .modernvideoplayer-chapters__body {
        max-height: 11rem;
    }
}

/* Phones only. */
@media (max-width: 575.98px) {
    /* stylelint-disable declaration-no-important -- override Bootstrap utilities and inline styles on resume overlay. */
    .modernvideoplayer-controls__text {
        display: none !important;
    }

    /* Take controls OUT of the absolute overlay so the 16:9 video keeps its full frame.
       Controls flow below the video as a normal block; the inner stage grows to contain both. */
    .modernvideoplayer-controls {
        position: static !important;
        padding: 0.5rem 0 0 !important;
    }

    /* Disable auto-hide while controls are below the video — opacity:0 made sense only
       when overlaid on the video. */
    .modernvideoplayer--playing .modernvideoplayer-controls {
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
    }

    .modernvideoplayer-controls__surface {
        padding: 0.5rem 0.6rem;
        border-radius: 0.75rem;
    }

    .modernvideoplayer-status__item {
        gap: 0.4rem;
    }

    .modernvideoplayer-status__headline {
        font-size: 0.85rem;
    }

    .modernvideoplayer-controls__bar {
        margin-top: 0.5rem !important;
        padding-top: 0.5rem;
        flex-wrap: nowrap !important;
        gap: 0.35rem !important;
    }

    .modernvideoplayer-controls__button {
        min-width: 2rem;
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
    }

    .modernvideoplayer-controls__bar > div {
        gap: 0.25rem !important;
        flex-wrap: nowrap !important;
    }

    [data-region="resume-overlay"],
    [data-region="next-activity-overlay"] {
        aspect-ratio: 16 / 9;
        height: auto !important;
        overflow-y: auto;
        padding: 0.5rem !important;
        align-items: flex-start !important;
    }

    [data-region="resume-overlay"] > div,
    [data-region="next-activity-overlay"] > div {
        max-width: 100% !important;
        padding: 0.85rem !important;
    }

    [data-region="resume-heading"],
    [data-region="resume-subtitle"],
    [data-region="resume-overlay"] .text-uppercase,
    [data-region="next-activity-overlay"] .text-uppercase {
        display: none !important;
    }

    [data-region="resume-overlay"] .btn,
    [data-region="next-activity-overlay"] .btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.85rem;
    }

    [data-region="next-activity-overlay"] {
        align-items: center !important;
    }

    [data-region="next-activity-overlay"] > div {
        display: flex;
        flex-direction: column;
        max-height: calc(100% - 1rem);
        overflow-y: auto;
    }

    [data-region="next-activity-name"] {
        font-size: 1rem;
        line-height: 1.2;
        margin-bottom: 0.35rem !important;
    }

    [data-region="next-activity-overlay"] p {
        margin-bottom: 0.65rem !important;
        font-size: 0.82rem;
        line-height: 1.25;
    }

    [data-region="next-activity-actions"] {
        flex-shrink: 0;
    }

    [data-region="next-activity-overlay"] [data-action="next-activity-go"] {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: 2.25rem;
        visibility: visible !important;
        opacity: 1 !important;
    }
    /* stylelint-enable declaration-no-important */

    .modernvideoplayer-speedmenu__list {
        min-width: 8rem;
    }

    .modernvideoplayer-shortcuts-help {
        padding: 0.5rem;
    }

    .modernvideoplayer-shortcuts-help__dialog {
        max-height: 85vh;
    }
}

/* Landscape phones — keep video from exceeding viewport. */
@media (max-width: 932px) and (orientation: landscape) and (max-height: 500px) {
    .modernvideoplayer__video {
        max-height: 100vh;
        width: auto;
        margin: 0 auto;
    }

    .modernvideoplayer__stage {
        display: flex;
        align-items: center;
        justify-content: center;
        max-height: 100vh;
    }
}

.content.activityiconcontainer.icon-size-6.modicon_modernvideoplayer {
    margin-right: 10px;
}
/* ---------- Captions & transcript ---------- */
.modernvideoplayer-controls__button--active {
    background: rgba(59, 130, 246, 0.18);
    color: #1d4ed8;
}
.modernvideoplayer-transcript {
    max-height: 18rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modernvideoplayer-transcript__body {
    overflow-y: auto;
    max-height: 15rem;
}
.modernvideoplayer-transcript__cue {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}
.modernvideoplayer-transcript__cue:last-child {
    border-bottom: 0;
}
.modernvideoplayer-transcript__button {
    text-decoration: none;
    color: inherit;
    border-radius: 0.5rem;
    transition: background-color 120ms ease;
}
.modernvideoplayer-transcript__button:hover,
.modernvideoplayer-transcript__button:focus-visible {
    background: rgba(59, 130, 246, 0.08);
    text-decoration: none;
}
.modernvideoplayer-transcript__cue--active .modernvideoplayer-transcript__button {
    background: rgba(59, 130, 246, 0.18);
    color: #1d4ed8;
    font-weight: 600;
}
.modernvideoplayer-transcript__time {
    font-variant-numeric: tabular-nums;
    font-size: 0.85em;
}
.modernvideoplayer-transcript__text {
    white-space: pre-wrap;
}

/* Chapter markers. */
.modernvideoplayer-chapters__pins {
    pointer-events: none;
}

.modernvideoplayer-chapters__pin {
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    padding: 0;
    margin: 0;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.95);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    z-index: 3;
    transition: transform 120ms ease, background-color 120ms ease;
}

.modernvideoplayer-chapters__pin:hover,
.modernvideoplayer-chapters__pin:focus {
    background: rgba(59, 130, 246, 1);
    transform: translate(-50%, -50%) scale(1.25);
    outline: none;
}

.modernvideoplayer-chapters__pin--active {
    background: rgba(245, 158, 11, 1);
    border-color: #fff;
}

.modernvideoplayer-chapters {
    max-height: 320px;
    overflow: hidden;
}

.modernvideoplayer-chapters__body {
    max-height: 260px;
    overflow-y: auto;
}

.modernvideoplayer-chapters__cue {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.modernvideoplayer-chapters__cue:last-child {
    border-bottom: 0;
}

.modernvideoplayer-chapters__button {
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: .5rem;
}

.modernvideoplayer-chapters__button:hover,
.modernvideoplayer-chapters__button:focus {
    background: rgba(37, 99, 235, 0.08);
    text-decoration: none;
}

.modernvideoplayer-chapters__cue--active .modernvideoplayer-chapters__button {
    background: rgba(37, 99, 235, 0.15);
    font-weight: 600;
}

.modernvideoplayer-chapters__time {
    font-variant-numeric: tabular-nums;
    font-size: .85em;
}

.modernvideoplayer-chapters__text {
    white-space: pre-wrap;
}


/* Playback speed menu. */
.modernvideoplayer-speedmenu {
    position: relative;
}

.modernvideoplayer-speedmenu__list {
    position: absolute;
    bottom: calc(100% + .25rem);
    right: 0;
    min-width: 140px;
    z-index: 20;
    display: block;
    padding: .25rem 0;
}

.modernvideoplayer-speedmenu__list.d-none {
    display: none;
}

.modernvideoplayer-speedmenu__item {
    width: 100%;
    text-align: left;
    padding: .35rem .9rem;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.modernvideoplayer-speedmenu__item:hover,
.modernvideoplayer-speedmenu__item:focus {
    background: rgba(37, 99, 235, 0.1);
    outline: none;
}

.modernvideoplayer-speedmenu__item--active {
    font-weight: 600;
    background: rgba(37, 99, 235, 0.12);
}

/* Keyboard shortcuts help modal. */
.modernvideoplayer-shortcuts-help {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    padding: 1rem;
}

.modernvideoplayer-shortcuts-help.d-none {
    display: none;
}

.modernvideoplayer-shortcuts-help__dialog {
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
}

.modernvideoplayer-shortcuts-help__list dt {
    margin-bottom: .5rem;
}

.modernvideoplayer-shortcuts-help__list dd {
    margin-bottom: .5rem;
}

.modernvideoplayer-shortcuts-help kbd {
    font-size: .85em;
    padding: .15em .4em;
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    border-radius: .25rem;
    font-family: var(--bs-font-monospace, monospace);
}
