/* ========================================
   HENX3 Video Player - Premium Custom Styles
   Editorial / Tech-Startup Aesthetic
   ======================================== */

/* CSS Custom Properties for Video Player */
:root {
    --video-bg: #09090b;
    --video-controls-bg: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    --video-accent: var(--accent, #3B82F6);
    --video-accent-rgb: var(--accent-rgb, 59, 130, 246);
    --video-text: #fafafa;
    --video-text-dim: rgba(250, 250, 250, 0.7);
    --video-border: rgba(255, 255, 255, 0.1);
    --video-radius: 1rem;
    --video-transition: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   Main Video Container
   ======================================== */

.henx-video {
    position: relative;
    width: 100%;
    aspect-ratio: var(--aspect-ratio, 16/9);
    background: var(--video-bg);
    border-radius: var(--video-radius);
    overflow: hidden;
    isolation: isolate;

    /* Subtle glow effect */
    box-shadow:
        0 0 0 1px var(--video-border),
        0 20px 50px -20px rgba(0, 0, 0, 0.5),
        0 0 100px -50px rgba(var(--video-accent-rgb), 0.2);
}

.henx-video__wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ========================================
   Video Element
   ======================================== */

.henx-video__element {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--video-bg);
}

/* ========================================
   Poster / Thumbnail Overlay
   ======================================== */

.henx-video__poster {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--video-bg);
    transition: opacity 0.5s var(--video-transition), visibility 0.5s;
}

.henx-video__poster-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.7);
    transition: filter 0.4s ease, transform 0.6s var(--video-transition);
}

.henx-video:hover .henx-video__poster-img {
    filter: brightness(0.5);
    transform: scale(1.02);
}

.henx-video.is-playing .henx-video__poster {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ========================================
   Big Play Button (on poster)
   ======================================== */

.henx-video__play-big {
    position: relative;
    z-index: 11;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    outline: none;
}

.henx-video__play-big-ring {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 1px solid rgba(var(--video-accent-rgb), 0.3);
    border-radius: 50%;
    animation: video-pulse 2s ease-in-out infinite;
}

.henx-video__play-big-ring::before {
    content: '';
    position: absolute;
    inset: -20px;
    border: 1px solid rgba(var(--video-accent-rgb), 0.15);
    border-radius: 50%;
    animation: video-pulse 2s ease-in-out infinite 0.3s;
}

@keyframes video-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.5; }
}

.henx-video__play-big-icon {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--video-accent-rgb), 0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--video-accent-rgb), 0.4);
    border-radius: 50%;
    color: var(--video-accent);
    transition: all 0.4s var(--video-transition);
}

.henx-video__play-big-icon svg {
    width: 32px;
    height: 32px;
    margin-left: 4px; /* Visual center for play icon */
    filter: drop-shadow(0 0 10px rgba(var(--video-accent-rgb), 0.5));
}

.henx-video__play-big:hover .henx-video__play-big-icon {
    transform: scale(1.1);
    background: rgba(var(--video-accent-rgb), 0.25);
    border-color: var(--video-accent);
    box-shadow: 0 0 40px rgba(var(--video-accent-rgb), 0.4);
}

.henx-video__play-big:active .henx-video__play-big-icon {
    transform: scale(0.95);
}

.henx-video__play-big-label {
    font-family: var(--font-sans, 'Space Grotesk', system-ui, sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--video-text);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s var(--video-transition);
}

.henx-video:hover .henx-video__play-big-label {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Loading Indicator
   ======================================== */

.henx-video__loader {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.henx-video.is-loading .henx-video__loader {
    opacity: 1;
    visibility: visible;
}

.henx-video__loader-spinner {
    width: 48px;
    height: 48px;
    border: 2px solid var(--video-border);
    border-top-color: var(--video-accent);
    border-radius: 50%;
    animation: video-spin 0.8s linear infinite;
}

@keyframes video-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Custom Controls
   ======================================== */

.henx-video__controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 2rem 1.5rem 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s var(--video-transition);
}

.henx-video:hover .henx-video__controls,
.henx-video.show-controls .henx-video__controls {
    opacity: 1;
    transform: translateY(0);
}

.henx-video__gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: var(--video-controls-bg);
    pointer-events: none;
    z-index: 19;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.henx-video:hover .henx-video__gradient,
.henx-video.show-controls .henx-video__gradient {
    opacity: 1;
}

/* ========================================
   Progress Bar
   ======================================== */

.henx-video__progress {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: height 0.2s ease;
}

.henx-video__progress:hover {
    height: 6px;
}

.henx-video__progress-buffer {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    pointer-events: none;
}

.henx-video__progress-played {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--video-accent);
    border-radius: 2px;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(var(--video-accent-rgb), 0.5);
}

.henx-video__progress-seek {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* Seek thumb - larger hit area */
.henx-video__progress-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: transparent;
    cursor: pointer;
}

.henx-video__progress-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    padding: 0.35rem 0.6rem;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--video-border);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--video-text);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 0.2s;
}

.henx-video__progress:hover .henx-video__progress-tooltip {
    opacity: 1;
}

/* ========================================
   Controls Bar
   ======================================== */

.henx-video__controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.henx-video__controls-left,
.henx-video__controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========================================
   Control Buttons
   ======================================== */

.henx-video__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: var(--video-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.henx-video__btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.henx-video__btn:active {
    transform: scale(0.95);
}

.henx-video__btn svg {
    width: 20px;
    height: 20px;
}

.henx-video__btn--text {
    width: auto;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-sans, 'Space Grotesk', system-ui, sans-serif);
}

/* Icon visibility states */
.henx-video__icon { display: none; }
.henx-video__icon--play { display: block; }

.henx-video.is-playing .henx-video__icon--play { display: none; }
.henx-video.is-playing .henx-video__icon--pause { display: block; }

.henx-video__icon--expand { display: block; }
.henx-video__icon--compress { display: none; }

.henx-video.is-fullscreen .henx-video__icon--expand { display: none; }
.henx-video.is-fullscreen .henx-video__icon--compress { display: block; }

/* Volume icons */
.henx-video__icon--volume-high { display: block; }
.henx-video__icon--volume-low { display: none; }
.henx-video__icon--volume-mute { display: none; }

.henx-video.volume-low .henx-video__icon--volume-high { display: none; }
.henx-video.volume-low .henx-video__icon--volume-low { display: block; }

.henx-video.is-muted .henx-video__icon--volume-high,
.henx-video.is-muted .henx-video__icon--volume-low { display: none; }
.henx-video.is-muted .henx-video__icon--volume-mute { display: block; }

/* ========================================
   Volume Control
   ======================================== */

.henx-video__volume {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.henx-video__volume-slider {
    position: relative;
    width: 0;
    height: 4px;
    overflow: hidden;
    transition: width 0.3s var(--video-transition);
}

.henx-video__volume:hover .henx-video__volume-slider {
    width: 80px;
}

.henx-video__volume-slider input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.henx-video__volume-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    background: var(--video-accent);
    border-radius: 2px;
    pointer-events: none;
    transform-origin: left;
}

/* ========================================
   Time Display
   ======================================== */

.henx-video__time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-sans, 'Space Grotesk', system-ui, sans-serif);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--video-text-dim);
    font-variant-numeric: tabular-nums;
    margin-left: 0.5rem;
}

.henx-video__time-sep {
    opacity: 0.5;
}

/* ========================================
   Playback Speed Menu
   ======================================== */

.henx-video__speed {
    position: relative;
}

.henx-video__speed-menu {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--video-border);
    border-radius: 0.5rem;
    padding: 0.25rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.henx-video__speed-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.henx-video__speed-menu button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--video-text-dim);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.henx-video__speed-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--video-text);
}

.henx-video__speed-menu button.active {
    color: var(--video-accent);
}

/* ========================================
   Variant: Hero Background
   ======================================== */

.henx-video--hero {
    position: absolute;
    inset: 0;
    border-radius: 0;
    box-shadow: none;
}

.henx-video--hero .henx-video__poster,
.henx-video--hero .henx-video__controls,
.henx-video--hero .henx-video__gradient {
    display: none;
}

.henx-hero-video {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.henx-hero-video__element {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.henx-hero-video__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(9, 9, 11, var(--overlay-opacity, 0.6)) 0%,
        rgba(9, 9, 11, calc(var(--overlay-opacity, 0.6) * 0.8)) 50%,
        rgba(9, 9, 11, var(--overlay-opacity, 0.6)) 100%
    );
}

/* ========================================
   Variant: Thumbnail
   ======================================== */

.henx-video--thumbnail {
    aspect-ratio: 16/9;
    border-radius: 0.75rem;
}

.henx-video--thumbnail .henx-video__controls {
    display: none;
}

.henx-video--thumbnail .henx-video__play-big-icon {
    width: 56px;
    height: 56px;
}

.henx-video--thumbnail .henx-video__play-big-icon svg {
    width: 24px;
    height: 24px;
}

.henx-video--thumbnail .henx-video__play-big-ring {
    width: 80px;
    height: 80px;
}

/* ========================================
   Video Thumbnail (Grid Item)
   ======================================== */

.henx-video-thumb {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.henx-video-thumb__preview {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--video-bg);
    box-shadow:
        0 0 0 1px var(--video-border),
        0 10px 30px -10px rgba(0, 0, 0, 0.3);
    transition: all 0.4s var(--video-transition);
}

.henx-video-thumb__preview:hover {
    box-shadow:
        0 0 0 1px rgba(var(--video-accent-rgb), 0.3),
        0 20px 40px -10px rgba(0, 0, 0, 0.4),
        0 0 60px -20px rgba(var(--video-accent-rgb), 0.3);
    transform: translateY(-4px);
}

.henx-video-thumb__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--video-transition);
}

.henx-video-thumb__preview:hover img {
    transform: scale(1.05);
}

.henx-video-thumb__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.henx-video-thumb__preview:hover .henx-video-thumb__overlay {
    opacity: 1;
}

.henx-video-thumb__play {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--video-accent-rgb), 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(var(--video-accent-rgb), 0.5);
    border-radius: 50%;
    color: var(--video-accent);
    cursor: pointer;
    transform: scale(0.8);
    transition: all 0.3s var(--video-transition);
}

.henx-video-thumb__play svg {
    width: 24px;
    height: 24px;
    margin-left: 3px;
}

.henx-video-thumb__preview:hover .henx-video-thumb__play {
    transform: scale(1);
}

.henx-video-thumb__play:hover {
    background: rgba(var(--video-accent-rgb), 0.35);
    border-color: var(--video-accent);
    box-shadow: 0 0 30px rgba(var(--video-accent-rgb), 0.4);
}

.henx-video-thumb__duration {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--video-text);
    font-variant-numeric: tabular-nums;
}

.henx-video-thumb__title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--video-text-dim);
    line-height: 1.4;
    transition: color 0.2s ease;
}

.henx-video-thumb:hover .henx-video-thumb__title {
    color: var(--video-text);
}

/* ========================================
   Video Modal
   ======================================== */

.henx-video-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s var(--video-transition);
}

.henx-video-modal[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.henx-video-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
}

.henx-video-modal__container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s var(--video-transition);
}

.henx-video-modal[aria-hidden="false"] .henx-video-modal__container {
    transform: scale(1) translateY(0);
}

.henx-video-modal__close {
    position: absolute;
    top: -3rem;
    right: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--video-border);
    border-radius: 50%;
    color: var(--video-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.henx-video-modal__close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.henx-video-modal__close svg {
    width: 24px;
    height: 24px;
}

.henx-video-modal__content {
    border-radius: var(--video-radius);
    overflow: hidden;
    box-shadow:
        0 0 0 1px var(--video-border),
        0 50px 100px -20px rgba(0, 0, 0, 0.7);
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    .henx-video__controls {
        padding: 1.5rem 1rem 0.75rem;
    }

    .henx-video__btn {
        width: 36px;
        height: 36px;
    }

    .henx-video__btn svg {
        width: 18px;
        height: 18px;
    }

    .henx-video__time {
        font-size: 0.75rem;
    }

    .henx-video__play-big-icon {
        width: 64px;
        height: 64px;
    }

    .henx-video__play-big-icon svg {
        width: 26px;
        height: 26px;
    }

    .henx-video__play-big-ring {
        width: 100px;
        height: 100px;
    }

    .henx-video__speed,
    [data-pip] {
        display: none;
    }

    .henx-video-modal {
        padding: 1rem;
    }

    .henx-video-modal__close {
        top: -2.5rem;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .henx-video__volume-slider {
        display: none;
    }

    .henx-video__controls-bar {
        gap: 0.25rem;
    }
}

/* ========================================
   Keyboard Focus States
   ======================================== */

.henx-video__btn:focus-visible,
.henx-video__progress-seek:focus-visible,
.henx-video__volume-slider input:focus-visible,
.henx-video-thumb__play:focus-visible,
.henx-video-modal__close:focus-visible {
    outline: 2px solid var(--video-accent);
    outline-offset: 2px;
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .henx-video,
    .henx-video *,
    .henx-video-thumb,
    .henx-video-thumb *,
    .henx-video-modal,
    .henx-video-modal * {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
