/**
 * YT Player for Fluent Community — Custom Player Styles
 * Full-overlay facade: thumbnails + custom controls on top of hidden iframe
 */

/* ============================================
   GOOGLE FONT
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    --ytpfc-radius: 12px;
    --ytpfc-accent: #e53935;
    --ytpfc-ctrl-bg: rgba(10, 10, 10, 0.88);
    --ytpfc-ctrl-h: 44px;
    --ytpfc-icon-size: 20px;
    --ytpfc-font: 'Inter', system-ui, -apple-system, sans-serif;
    --ytpfc-transition: 0.22s cubic-bezier(.4, 0, .2, 1);
}

/* ============================================
   PLAYER SHELL
   ============================================ */
.ytpfc-player {
    margin: 1.5em auto;
    font-family: var(--ytpfc-font);
    user-select: none;
    -webkit-user-select: none;
}

/* 16:9 stage */
.ytpfc-stage {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: var(--ytpfc-radius);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
}

/* ============================================
   THUMBNAIL LAYER (z=1)
   ============================================ */
.ytpfc-thumb {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.ytpfc-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease, filter 0.3s ease;
}

.ytpfc-thumb-blur {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.06);
    transition: background var(--ytpfc-transition);
}

/* Dim thumbnail on hover to suggest clickability */
.ytpfc-player:hover .ytpfc-thumb-blur {
    background: rgba(0, 0, 0, 0.14);
}

/* Hide thumbnail once played */
.ytpfc-player.is-started .ytpfc-thumb {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* ============================================
   IFRAME LAYER (z=2)
   Hidden behind shield — only YouTube audio/video engine
   ============================================ */
.ytpfc-iframe-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.ytpfc-player.is-started .ytpfc-iframe-wrap {
    opacity: 1;
}

.ytpfc-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ============ FULL SHIELD ============
   Transparent 100% overlay on top of the iframe.
   Blocks ALL native YouTube UI elements:
   title, channel name, logo, suggested videos,
   share icon, embed icon, watch-later icon.
   pointer-events: none so clicks fall through
   only to our custom UI layer above it.
   ===================================== */
.ytpfc-shield {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: transparent;
    pointer-events: none;
    /* let our UI layer handle clicks */
}

/* ============================================
   CUSTOM UI LAYER (z=10)
   Sits above iframe+shield
   ============================================ */
.ytpfc-ui {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    cursor: pointer;
}

/* Default cursor on controls area so buttons feel normal */
.ytpfc-ui .ytpfc-controls {
    cursor: default;
}

/* ============================================
   BIG CENTRE PLAY BUTTON
   ============================================ */
.ytpfc-big-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 80px;
    height: 80px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--ytpfc-transition), opacity var(--ytpfc-transition);
    opacity: 1;
}

.ytpfc-big-play svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5));
    transition: transform var(--ytpfc-transition);
}

.ytpfc-big-play:hover svg {
    transform: scale(1.1);
}

.ytpfc-big-play:focus-visible {
    outline: 3px solid #fff;
    border-radius: 50%;
    outline-offset: 4px;
}

/* Hide big play while video is playing (not paused) */
.ytpfc-player.is-playing .ytpfc-big-play {
    opacity: 0;
    pointer-events: none;
}

/* Show on pause (not during buffering) */
.ytpfc-player.is-paused .ytpfc-big-play {
    opacity: 1;
    pointer-events: auto;
}

/* Hide during pre-start on hover to reduce clutter 
   (only if user hasn't started yet we keep it always visible) */
.ytpfc-player.is-started.is-paused .ytpfc-big-play {
    opacity: 0.92;
}

/* ============================================
   CONTROLS BAR (bottom)
   ============================================ */
.ytpfc-controls {
    position: relative;
    z-index: 12;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, transparent 100%);
    padding: 32px 0 0;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--ytpfc-transition), transform var(--ytpfc-transition);
    pointer-events: none;
}

/* Show controls on hover OR when paused/ended */
.ytpfc-player:hover .ytpfc-controls,
.ytpfc-player.is-paused .ytpfc-controls,
.ytpfc-player.is-ended .ytpfc-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Also show when not yet started */
.ytpfc-player:not(.is-started) .ytpfc-controls {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   PROGRESS / SEEK BAR
   ============================================ */
.ytpfc-progress-wrap {
    padding: 6px 12px 2px;
    cursor: pointer;
    position: relative;
}

.ytpfc-progress-track {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    overflow: visible;
    transition: height var(--ytpfc-transition);
}

.ytpfc-progress-wrap:hover .ytpfc-progress-track {
    height: 6px;
}

.ytpfc-progress-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s linear;
}

.ytpfc-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--ytpfc-accent);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.ytpfc-progress-knob {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    left: 0%;
    transition: transform var(--ytpfc-transition), left 0.1s linear;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.ytpfc-progress-wrap:hover .ytpfc-progress-knob {
    transform: translate(-50%, -50%) scale(1);
}

/* ============================================
   BOTTOM BAR
   ============================================ */
.ytpfc-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px 8px;
    gap: 4px;
}

.ytpfc-bar-left,
.ytpfc-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Generic icon button */
.ytpfc-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ytpfc-transition), transform var(--ytpfc-transition);
    line-height: 1;
}

.ytpfc-btn svg {
    width: var(--ytpfc-icon-size);
    height: var(--ytpfc-icon-size);
    flex-shrink: 0;
    display: block;
}

.ytpfc-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ytpfc-btn:active {
    transform: scale(0.92);
}

.ytpfc-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* Play/Pause button icons — show only the right one */
.ytpfc-playpause .ic-pause,
.ytpfc-playpause .ic-replay {
    display: none;
}

.ytpfc-player.is-playing .ytpfc-playpause .ic-play {
    display: none;
}

.ytpfc-player.is-playing .ytpfc-playpause .ic-pause {
    display: block;
}

.ytpfc-player.is-ended .ytpfc-playpause .ic-play {
    display: none;
}

.ytpfc-player.is-ended .ytpfc-playpause .ic-replay {
    display: block;
}

/* ============================================
   VOLUME
   ============================================ */
.ytpfc-vol-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ytpfc-mute .ic-mute {
    display: none;
}

.ytpfc-player.is-muted .ytpfc-mute .ic-vol {
    display: none;
}

.ytpfc-player.is-muted .ytpfc-mute .ic-mute {
    display: block;
}

.ytpfc-vol-slider-wrap {
    width: 0;
    overflow: hidden;
    transition: width var(--ytpfc-transition);
}

.ytpfc-vol-group:hover .ytpfc-vol-slider-wrap,
.ytpfc-vol-slider-wrap:focus-within {
    width: 72px;
}

.ytpfc-vol-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 68px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    cursor: pointer;
    accent-color: var(--ytpfc-accent);
}

.ytpfc-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ============================================
   TIME DISPLAY
   ============================================ */
.ytpfc-time {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 4px;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.ytpfc-sep {
    opacity: 0.6;
}

/* ============================================
   SPEED MENU
   ============================================ */
.ytpfc-speed-wrap {
    position: relative;
}

.ytpfc-speed-btn {
    font-size: 12px;
    font-weight: 600;
    gap: 2px;
    min-width: 38px;
    color: #fff;
}

.ytpfc-speed-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: rgba(16, 16, 16, 0.96);
    border-radius: 8px;
    overflow: hidden;
    min-width: 90px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    backdrop-filter: blur(8px);
}

.ytpfc-speed-wrap.open .ytpfc-speed-menu {
    display: flex;
}

.ytpfc-speed-menu button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 9px 16px;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--ytpfc-font);
}

.ytpfc-speed-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.ytpfc-speed-menu button.active {
    color: var(--ytpfc-accent);
    font-weight: 600;
}

/* ============================================
   FULLSCREEN BUTTON
   ============================================ */
.ytpfc-fs .ic-fs-exit {
    display: none;
}

.ytpfc-player.is-fullscreen .ytpfc-fs .ic-fs-enter {
    display: none;
}

.ytpfc-player.is-fullscreen .ytpfc-fs .ic-fs-exit {
    display: block;
}

/* Fullscreen adjustments */
.ytpfc-player.is-fullscreen .ytpfc-stage {
    border-radius: 0;
    padding-bottom: 0;
    height: 100vh;
}

/* ============================================
   END SCREEN (full solid overlay — no suggestions)
   ============================================ */
.ytpfc-endscreen {
    position: absolute;
    inset: 0;
    z-index: 13;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.ytpfc-player.is-ended .ytpfc-endscreen {
    display: flex;
}

.ytpfc-replay-btn {
    background: var(--ytpfc-accent);
    border: none;
    border-radius: 40px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--ytpfc-font);
    transition: background var(--ytpfc-transition), transform var(--ytpfc-transition), box-shadow var(--ytpfc-transition);
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.4);
}

.ytpfc-replay-btn svg {
    width: 22px;
    height: 22px;
}

.ytpfc-replay-btn:hover {
    background: #c62828;
    transform: scale(1.05);
    box-shadow: 0 6px 22px rgba(229, 57, 53, 0.5);
}

.ytpfc-replay-btn:active {
    transform: scale(0.98);
}

/* ============================================
   ERROR STATE
   ============================================ */
.ytpfc-error {
    color: #ef9a9a;
    background: #3e2723;
    border: 1px solid #5d4037;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    text-align: center;
    margin: 1em 0;
    font-family: var(--ytpfc-font);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .ytpfc-time {
        font-size: 11px;
    }

    .ytpfc-btn svg {
        width: 18px;
        height: 18px;
    }

    .ytpfc-bar {
        padding: 2px 6px 6px;
    }

    .ytpfc-big-play,
    .ytpfc-big-play svg {
        width: 60px;
        height: 60px;
    }

    .ytpfc-replay-btn {
        font-size: 14px;
        padding: 11px 22px;
    }

    .ytpfc-vol-group:hover .ytpfc-vol-slider-wrap {
        width: 52px;
    }

    .ytpfc-player {
        margin: 1em auto;
    }
}

@media (max-width: 400px) {

    .ytpfc-vol-slider-wrap,
    .ytpfc-vol-group:hover .ytpfc-vol-slider-wrap {
        width: 0;
    }
}

/* ============================================
   FLUENT COMMUNITY OVERRIDES
   ============================================ */
.fcom_post_body .ytpfc-player,
.fcom_lesson_body .ytpfc-player,
.fcom-content .ytpfc-player,
[class*="lesson"] .ytpfc-player,
.fcom_feed .ytpfc-player {
    max-width: 100% !important;
}

/* ============================================
   DARK/LIGHT MODE — error box only
   ============================================ */
@media (prefers-color-scheme: light) {
    .ytpfc-error {
        color: #c62828;
        background: #fff3f3;
        border-color: #ffcdd2;
    }
}