* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

button {
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
}

#reel-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: #000;
}

#reel-container {
    position: relative;
    width: 85.9vw;
    max-width: 610px;
    height: 100vh;
    background: #111;
    overflow: hidden;
    touch-action: manipulation;
    backface-visibility: hidden;
}

#reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#reel-doubletap-heart {
    position: absolute;
    left: 0;
    top: 0;
    width: 92px;
    height: 92px;
    pointer-events: none;
    z-index: 16;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    will-change: transform, opacity;
}

#reel-doubletap-heart svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}

#reel-doubletap-heart.is-animating {
    animation: reel-doubletap-heart-pop 0.85s cubic-bezier(0.17, 0.89, 0.32, 1.25) forwards;
}

@keyframes reel-doubletap-heart-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    14% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.06);
    }
}

#reel-actions {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.reel-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #fff;
}

.reel-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.reel-action-icon:hover { background: rgba(0, 0, 0, 0.75); }

.reel-action-count {
    font-size: 12px;
    color: #fff;
    font-weight: 500;
    text-align: center;
    min-width: 30px;
}

.reel-action-btn.liked .reel-action-icon {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.reel-action-btn.liked .reel-action-icon svg {
    fill: #ff4757;
    stroke: #ff4757;
}

/* View count — direct child of #reel-container; absolute corners relative reel column (escapes transformed #reel-actions) */
#btn-views.reel-action-btn {
    position: absolute;
    top: max(20px, calc(env(safe-area-inset-top, 0px) + 12px));
    right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
    left: auto;
    bottom: auto;
    margin: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 999px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    width: max-content;
    max-width: calc(100vw - 40px);
    cursor: default;
    line-height: 1;
}

#btn-views .reel-action-icon {
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent !important;
    border-radius: 0;
}

#btn-views .reel-action-icon:hover {
    background: transparent !important;
}

#btn-views .reel-action-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}

#btn-views .reel-action-count {
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 500;
    color: inherit;
    text-align: center;
    text-shadow: none;
    min-width: 0;
    line-height: 1;
}

#btn-views br,
#btn-views .count-below {
    display: none;
}

#reel-progress {
    position: absolute;
    bottom: 90px; /* flush with top of #reel-bottom-bar (bottom 40px + height 50px) */
    height: 20px;
    left: 0;
    right: 0;
    z-index: 24;
    cursor: pointer;
    background-color: transparent;
    display: flex;
    align-items: center;
}

#reel-progress::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 8px;
    margin-top: -4px;
    background-color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    z-index: 0;
}

#reel-progress-fill {
    position: absolute;
    left: 0;
    top: 50%;
    height: 8px;
    margin-top: -4px;
    width: 0%;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(to right, #ec1c55, #6bcad2);
    background-color: transparent;
}

#reel-progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translateX(-50%);
    margin-top: -8px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

#reel-progress:hover #reel-progress-thumb,
#reel-progress.dragging #reel-progress-thumb {
    opacity: 1;
}

#reel-progress-hitarea {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    z-index: 3;
    cursor: pointer;
}

/* Container for the buttons at the bottom (Recent / Popular) */
#reel-bottom-bar {
    position: absolute;
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    height: 50px;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

#reel-progress {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

.reel-feed-btn {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.reel-feed-btn.active {
    color: #fff;
    border-bottom-color: #fff;
}

@media (max-width: 767px) {
    #reel-bottom-bar {
        bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    }

    #reel-progress {
        bottom: calc(98px + env(safe-area-inset-bottom, 0px));
    }

    #reel-controls-overlay {
        bottom: calc(98px + env(safe-area-inset-bottom, 0px) + 12px);
    }

    /* Scope to #reel-actions so the views capsule (moved out by JS) isn't clobbered */
    #reel-actions .reel-action-icon {
        width: 52px !important;
        height: 52px !important;
    }

    #reel-actions .reel-action-icon svg {
        width: 26px;
        height: 26px;
    }
}

#reel-controls-overlay {
    position: absolute;
    bottom: calc(90px + 5px + 12px); /* above progress row + offsets */
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 22;
}

.reel-ctrl-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
}

#reel-title-overlay {
    clip: rect(1px, 1px, 1px, 1px) !important;
    background: transparent !important;
    border: 0 !important;
    color: transparent !important;
    height: 1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important;
    flex: 0 0 0 !important;
    margin: -1px;
    opacity: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    pointer-events: none !important;
    text-shadow: none !important;
}

#reel-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
    z-index: 30;
}

@keyframes spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

#reel-tooltip {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 20;
}

#reel-tooltip.show { opacity: 1; }

@media (max-width: 680px) {
    #reel-container {
        width: 100vw;
        max-width: 100vw;
    }

    #reel-actions {
        right: 6px;
    }

    .reel-action-icon {
        width: 42px;
        height: 42px;
    }
}

/* =============================================
   MOBILE FIRST — Default styles for phones
   ============================================= */

html, body {
    overflow: hidden;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

#reel-container {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
}

#reel-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 20;
}

.reel-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.reel-action-count {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    text-align: center;
    min-width: 30px;
}

#reel-controls-overlay {
    bottom: calc(90px + 5px + 12px);
    left: 10px;
    right: 62px;
    transition: opacity 0.3s ease;
}

.reel-feed-btn {
    font-size: 13px;
    font-weight: 600;
    gap: 5px;
}

.reel-feed-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =============================================
   TABLET — 480px and up
   ============================================= */
@media (min-width: 480px) {
    #reel-container {
        width: 85.9vw;
        max-width: 420px;
    }

    #reel-actions {
        right: -60px;
        top: 50%;
        transform: translateY(-50%);
    }

    .reel-action-icon {
        width: 48px;
        height: 48px;
    }

    #reel-controls-overlay {
        right: 12px;
    }
}

/* =============================================
   DESKTOP — 768px and up
   All UI (actions, progress, bottom nav) contained in #reel-container — no full-bleed fixed layers.
   ============================================= */
@media (min-width: 768px) {
    #reel-wrapper {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100vw;
        height: 100vh;
        background: #000;
    }

    body.admin-bar #reel-wrapper {
        height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
    }

    #reel-container {
        position: relative;
        width: 420px;
        max-width: 420px;
        height: 100vh;
        background: #1a1e32;
        overflow: hidden;
        flex-shrink: 0;
    }

    body.admin-bar #reel-container {
        height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
    }

    /* Bottom nav: spans column only, anchored to bottom of container */
    #reel-bottom-bar {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 50px;
        z-index: 28;
    }

    /* Progress sits flush atop the 50px bottom bar */
    #reel-progress {
        bottom: 50px;
    }

    #reel-controls-overlay {
        bottom: calc(50px + 5px + 12px);
        left: 14px;
        right: 14px;
    }

    /* Action rail: right edge of the column only, stacked upward above progress */
    #reel-actions {
        position: absolute;
        right: 8px;
        top: max(10px, env(safe-area-inset-top, 0px));
        bottom: calc(50px + 5px + 12px);
        left: auto;
        transform: none;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        gap: 14px;
        z-index: 25;
    }

    #reel-video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }

    .reel-action-icon {
        width: 52px;
        height: 52px;
    }

    .reel-action-icon:hover {
        background: rgba(0, 0, 0, 0.75);
        cursor: pointer;
    }

    .reel-action-count {
        font-size: 12px;
    }

    .reel-ctrl-btn {
        width: 38px;
        height: 38px;
    }

    .reel-feed-btn {
        font-size: 14px;
        gap: 7px;
    }
}

/* WordPress admin bar height in the 768–782px band (fallback if CSS var absent) */
@media (min-width: 768px) and (max-width: 782px) {
    body.admin-bar #reel-wrapper,
    body.admin-bar #reel-container {
        height: calc(100vh - 46px);
    }
}

/* =============================================
   LARGE DESKTOP — 1200px and up
   ============================================= */
@media (min-width: 1200px) {
    #reel-container {
        max-width: 610px;
    }

    #reel-actions {
        right: 10px;
        gap: 20px;
    }

    .reel-action-icon {
        width: 54px;
        height: 54px;
    }
}

/* =============================================
   FULLSCREEN MODE
   ============================================= */
/* Mobile / tablet: reel column fullscreen — fills viewport when container is fullscreened */
#reel-container:fullscreen,
#reel-container:-webkit-full-screen,
#reel-container:-moz-full-screen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
}

#reel-container:fullscreen #reel-actions,
#reel-container:-webkit-full-screen #reel-actions {
    right: 10px;
}

/* Desktop: documentElement fullscreen — hide browser UI only; column stays centered, no stretch */
html:fullscreen #reel-container,
html:-webkit-full-screen #reel-container,
html:-moz-full-screen #reel-container {
    width: auto !important;
    max-width: 480px !important;
    height: 100vh !important;
    margin: 0 auto !important;
}

html:fullscreen body,
html:-webkit-full-screen body,
html:-moz-full-screen body {
    background: #000 !important;
}

/* =============================================
   TOUCH & UX IMPROVEMENTS
   ============================================= */
button,
.reel-action-btn,
.reel-action-icon,
.reel-ctrl-btn,
.reel-feed-btn {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

#reel-wrapper {
    user-select: none;
    -webkit-user-select: none;
}

#reel-video {
    transition: opacity 0.2s ease;
}

#reel-video.loading {
    opacity: 0.5;
}

.reel-action-btn.liked .reel-action-icon {
    animation: heartPop 0.3s ease;
}

@keyframes heartPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#reel-tooltip {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 30;
    white-space: nowrap;
}

#reel-tooltip.show {
    opacity: 1;
}

#reel-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    display: none;
    z-index: 25;
}

#reel-loader.visible {
    display: block;
}

#reel-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: none;
}

#reel-play-icon {
    width: 72px;
    height: 72px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#reel-play-icon.show {
    opacity: 1;
    transform: scale(1);
}

#reel-play-icon.hide {
    opacity: 0;
    transform: scale(0.8);
}

/* Volume slider (DOM injected by assets/js/main.js) — left of #btn-mute, 6px gap, vertically aligned with mute */
#volume-slider-wrap {
    position: absolute;
    top: 50%;
    bottom: auto;
    right: calc(8px + 44px + 6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    padding: 10px 8px;
    /* #reel-actions column is vertically centered; mute is last item — offset to mute icon vertical center */
    transform: translateY(calc(-50% + 153px));
}

#volume-slider-wrap.visible {
    opacity: 1;
    pointer-events: all;
}

#volume-slider {
    -webkit-appearance: slider-vertical;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 4px;
    height: 80px;
    cursor: pointer;
    accent-color: #ffffff;
}

@media (max-width: 680px) {
    #volume-slider-wrap {
        right: calc(6px + 42px + 6px);
        transform: translateY(calc(-50% + 149px));
    }
}

@media (min-width: 768px) {
    /* Match desktop #reel-actions rail: same bottom inset + half mute icon (~52px) */
    #volume-slider-wrap {
        top: auto;
        bottom: calc(50px + 5px + 12px + 52px / 2);
        right: calc(8px + 52px + 6px);
        transform: translateY(50%);
    }
}

@media (min-width: 1200px) {
    #volume-slider-wrap {
        right: calc(10px + 54px + 6px);
        bottom: calc(50px + 5px + 12px + 54px / 2);
    }
}

/* Accessibility */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
