/* Unified Media Stage HUD, Silk Squiggle 60fps Timeline, Custom 2.5px Studio Scroll Rail & Responsive Rules */

/* =======================================================
   1. SHARED STAGE HUD & BORDERLESS SILK PLAYBACK (ALL RESOLUTIONS)
======================================================== */
.media-stage-hud {
    position: absolute;
    inset: 0;
    z-index: 35;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* BOTTOM-LEFT ZONE: Inline 2-Way Album Fade Wheel + Album Title above Track Title */
.hud-album-anchor {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    min-width: 0;
    padding-right: 54px;
    pointer-events: none;
}

.hud-album-wheel {
    height: 48px;
    padding: 0 6px;
    margin-left: -6px;
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
    pointer-events: auto;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
}

.hud-album-wheel > * {
    transform: translate3d(var(--scrub-offset, 0px), 0, 0);
    transition: transform 0.14s var(--ease-out-expo);
}

.hud-album-wheel.is-scrubbing {
    cursor: grabbing;
}

.hud-album-wheel.is-scrubbing > * {
    transition: none;
}

.hud-album-side {
    appearance: none;
    border: 0;
    padding: 0;
    width: 29px;
    height: 29px;
    border-radius: 50%;
    overflow: hidden;
    opacity: 0.58;
    cursor: pointer;
    flex-shrink: 0;
    background: #18181c;
    transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.hud-album-side[hidden] {
    display: none;
}

.hud-album-side:hover,
.hud-album-side:active {
    opacity: 0.95;
    transform: scale(1.08);
}

.hud-album-active {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.58);
    background: #18181c;
    transition: transform 0.18s var(--ease-out-expo), box-shadow 0.18s ease;
}

.hud-album-wheel.is-scrubbing .hud-album-active {
    transform: translate3d(var(--scrub-offset, 0px), 0, 0) scale(1.07);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.72);
}

.hud-album-side img,
.hud-album-active img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.hud-album-name {
    color: #ffffff;
    font-size: 16.5px;
    font-weight: 700;
    letter-spacing: 0.015em;
    line-height: 1.25;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.88);
}

/* BOTTOM-RIGHT EDGE: Continuous Scroll/Swipe Item Wheel + Hairline + Total above Mute/Zoom */
.hud-right {
    position: absolute;
    right: 12px;
    bottom: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    pointer-events: auto;
}

.hud-right.is-hidden {
    display: none;
}

.hud-item-wheel {
    padding: 10px 4px;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
}

.hud-item-wheel.is-scrubbing {
    cursor: grabbing;
}

.hud-item-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform var(--dur-fast) var(--ease-out-expo);
}

.hud-item-wheel.is-scrubbing .hud-item-track {
    transition: none;
    will-change: transform;
}

.hud-item-far {
    position: relative;
    width: 19px;
    height: 24px;
    border-radius: 5px;
    overflow: hidden;
    opacity: 0.28;
    flex-shrink: 0;
    background: #1a1a20;
    pointer-events: none;
}

.hud-item-far[hidden] {
    display: none;
}

.hud-item-side {
    position: relative;
    appearance: none;
    border: 0;
    padding: 0;
    width: 25px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0.62;
    cursor: pointer;
    flex-shrink: 0;
    background: #1a1a20;
    transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.hud-item-side:hover,
.hud-item-side:active {
    opacity: 0.96;
    transform: scale(1.06);
}

.hud-item-active {
    position: relative;
    width: 36px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.62);
    background: #1a1a20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--dur-fast) var(--ease-out-expo), box-shadow var(--dur-fast) ease;
}

.hud-item-wheel.is-scrubbing .hud-item-active {
    transform: scale(1.07);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.78);
}

.hud-item-far img,
.hud-item-side img,
.hud-item-active img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.hud-item-active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    z-index: 1;
}

.hud-item-index {
    position: relative;
    z-index: 2;
    color: #ffffff;
    font-size: 16px;
    font-family: 'Inter', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.92);
}

.hud-item-divider {
    width: 20px;
    height: 1.5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
}

.hud-item-total {
    color: rgba(255, 255, 255, 0.84);
    font-size: 14.5px;
    font-family: 'Inter', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.92);
}

/* Bottom Borderless Scrim & Playback */
.hud-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3.5rem 1rem 0.9rem;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.90) 0%,
        rgba(0, 0, 0, 0.48) 58%,
        transparent 100%
    );
    pointer-events: none;
}

html[data-theme="light"] .hud-bottom {
    background: linear-gradient(
        to top,
        rgba(6, 10, 22, 0.92) 0%,
        rgba(6, 10, 22, 0.56) 60%,
        transparent 100%
    );
}

.hud-album-name {
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.16s ease;
}

.hud-album-name:hover {
    opacity: 0.82;
}

.hud-bottom-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.hud-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    min-width: 0;
}

.hud-rank-crest {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    background: transparent;
    border: 0;
    flex-shrink: 0;
    line-height: 1;
}

.hud-rank-crest[hidden] {
    display: none;
}

.hud-rank-crest[data-rank="legend"] {
    color: #ffd55a;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(255, 213, 90, 0.55);
}

.hud-rank-crest[data-rank="hot"] {
    color: #e9d5ff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(192, 132, 252, 0.62);
}

.hud-rank-crest[data-rank="new"] {
    color: #86efac;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(74, 222, 128, 0.52);
}

.hud-rank-crest svg {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.85));
}

.hud-rank-label {
    font-family: 'Kanit', 'Space Grotesk', sans-serif;
    font-style: italic;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding-right: 3px;
}

.hud-track-title {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
    padding-right: 56px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    min-width: 0;
}

.hud-playback-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    pointer-events: auto;
}

.hud-ctrl-btn {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.94);
    cursor: pointer;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.75));
    transition: color var(--dur-fast) ease, transform var(--dur-fast) ease;
    -webkit-tap-highlight-color: transparent;
}

.hud-ctrl-btn[hidden] {
    display: none;
}

.hud-ctrl-btn:hover {
    color: var(--studio-accent);
}

.hud-ctrl-btn:active {
    transform: scale(0.88);
}

.hud-ctrl-btn.is-active-accent {
    color: var(--studio-accent);
}

.hud-ctrl-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Timeline Slot: Silk Squiggle SVG & Photo Hairline Segments (Compositor-Only) */
.hud-timeline-slot {
    flex: 1 1 0%;
    min-width: 0;
}

.hud-seek-bar {
    position: relative;
    width: 100%;
    height: 28px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.hud-wave-svg {
    width: 100%;
    height: 22px;
    display: block;
    overflow: visible;
}

.hud-wave-svg .wave-rest {
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 1.9;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.hud-wave-svg .wave-played {
    fill: none;
    stroke: var(--studio-accent);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

/* Position uses individual `translate` (zero transition lag); height breathes via `scale` (compositor-only) */
.hud-wave-needle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 3px;
    height: 15px;
    border-radius: 999px;
    background: #ffffff;
    translate: calc(var(--needle-x, 0px) - 50%) -50% 0;
    scale: 1 1;
    box-shadow: 0 0 8px color-mix(in srgb, var(--studio-accent) 70%, rgba(255, 255, 255, 0.6));
    pointer-events: none;
    transition: scale var(--dur-fast) var(--ease-out-expo), box-shadow var(--dur-fast) ease;
}

.hud-wave-needle.is-paused {
    scale: 1 0.73;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.hud-wave-needle.is-scrubbing {
    scale: 1 1.2;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.95);
}

/* Static Photo Segmented Hairline */
.hud-photo-segments {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 3px;
}

.hud-photo-seg {
    flex: 1 1 0%;
    height: 2.5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    transition: background-color 0.18s ease, transform 0.18s var(--ease-out-expo), box-shadow 0.18s ease;
}

.hud-photo-seg.is-past {
    background: var(--studio-accent);
}

.hud-photo-seg.is-active {
    transform: scaleY(1.4);
    background: #ffffff;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}

.hud-photo-track {
    position: relative;
    width: 100%;
    height: 2.5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
}

.hud-photo-fill {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: var(--studio-accent);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform var(--dur-fast) var(--ease-out-expo);
}

/* =======================================================
   2. DESKTOP STUDIO ENHANCEMENTS (40/60 MIRROR, 2.5PX SCROLL RAIL, ULTRAWIDE CEILING)
======================================================== */
.media-studio--video .media-stage-col.is-landscape-stage {
    width: 100%;
    aspect-ratio: auto;
    border-left: 0;
    border-right: 0;
}

/* Custom Ultra-Slim 2.5px Studio Scroll Rail */
.thumb-scroll-rail {
    flex-shrink: 0;
    height: 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    transition: opacity 0.2s ease;
}

.thumb-scroll-rail.is-hidden {
    opacity: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
}

.thumb-scroll-track {
    position: relative;
    width: 100%;
    height: 2.5px;
    border-radius: var(--radius-full);
    background: var(--hairline);
    overflow: hidden;
}

.thumb-scroll-thumb {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 35%;
    border-radius: var(--radius-full);
    background: var(--studio-accent);
    opacity: 0.82;
    will-change: transform;
    transition: opacity 0.15s ease;
}

.thumb-scroll-rail:hover .thumb-scroll-thumb,
.thumb-scroll-rail.is-dragging .thumb-scroll-thumb {
    opacity: 1;
}

/* Tablet Landscape (1024px) & Short Laptop Breathing Room */
@media (min-width: 961px) and (max-width: 1200px) and (min-height: 521px) {
    .media-studio {
        padding: 2vh 2vw 2vh calc(var(--rail-width, 0px) + 2vw);
        gap: 1.75vw;
    }

    .media-menu-col {
        padding: 1rem;
        gap: 0.85rem;
    }
}

/* Ultrawide 21:9 & 4K Ceiling */
@media (min-width: 2200px) {
    .media-studio {
        max-width: 2200px;
        margin-inline: auto;
        padding: 2.5vh 2.5rem 2.5vh calc(var(--rail-width, 0px) + 2.5rem);
        gap: 2rem;
    }
}

/* =======================================================
   3. COMPACT MODE (MOBILE PORTRAIT/LANDSCAPE, SQUARE 1:1 & PORTRAIT TABLET)
======================================================== */
@media (max-width: 960px), (max-aspect-ratio: 6 / 5), (max-height: 520px) {
    .media-studio {
        padding: 0;
        gap: 0;
        height: 100%;
        overflow: hidden;
    }

    .media-menu-col,
    .thumb-scroll-rail {
        display: none;
    }

    .media-studio--video .media-stage-wrapper,
    .media-studio--gallery .media-stage-wrapper {
        flex: 1 1 100%;
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: #070709;
    }

    .media-wrapper-backdrop {
        display: none;
    }

    .media-studio--video .media-stage-col,
    .media-studio--gallery .media-stage-col {
        width: 100%;
        height: 100%;
        max-width: none;
        aspect-ratio: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: #070709;
    }

    /* Keep dark cinema backdrop rich in Compact Mode regardless of Light Theme */
    html[data-theme="light"] .media-stage-backdrop.is-visible {
        filter: blur(22px) brightness(0.42);
        opacity: 1;
    }

    .media-feed {
        touch-action: pan-y;
    }

    .hud-right {
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(max(18px, env(safe-area-inset-bottom)) + 54px);
    }

    .hud-bottom {
        padding: 4rem max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.88) 0%,
            rgba(0, 0, 0, 0.44) 55%,
            transparent 100%
        );
    }

    .hud-bottom-inner {
        gap: 0.48rem;
    }

    .hud-track-title {
        color: rgba(255, 255, 255, 0.78);
        font-size: 0.8125rem;
        font-weight: 500;
        letter-spacing: 0;
        padding-right: 56px;
    }

    .hud-playback-row {
        gap: 0.75rem;
        padding-right: 0;
    }

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

    .hud-ctrl-btn svg {
        width: 24px;
        height: 24px;
    }

    .hud-seek-bar {
        height: 32px;
    }

    .hud-wave-svg {
        height: 26px;
    }

    .hud-wave-svg .wave-rest {
        stroke-width: 2.1;
    }

    .hud-wave-svg .wave-played {
        stroke-width: 2.8;
    }

    .hud-wave-needle {
        width: 3.5px;
        height: 18px;
    }

    .hud-photo-seg {
        height: 3px;
    }

    .hud-photo-track {
        height: 3px;
    }
}

/* Tier 1: Small Phone (<= 380px width) */
@media (max-width: 380px) {
    .hud-album-anchor {
        gap: 8px;
        padding-right: 54px;
    }

    .hud-album-wheel {
        height: 40px;
        padding: 0 4px;
        gap: 7px;
    }

    .hud-album-active {
        width: 36px;
        height: 36px;
    }

    .hud-album-side {
        width: 24px;
        height: 24px;
    }

    .hud-album-name {
        font-size: 14.5px;
    }

    .hud-track-title {
        font-size: 0.75rem;
        padding-right: 54px;
    }

    .hud-playback-row {
        gap: 0.65rem;
        padding-right: 0;
    }

    .hud-ctrl-btn {
        width: 36px;
        height: 36px;
    }
}

/* Tier 3: Short Landscape Phone (H <= 520px & Landscape) */
@media (max-height: 520px) and (orientation: landscape) {
    .hud-album-anchor {
        gap: 8px;
        padding-right: 0;
    }

    .hud-album-wheel {
        height: 30px;
        padding: 0 6px;
        gap: 8px;
    }

    .hud-album-active {
        width: 28px;
        height: 28px;
    }

    .hud-album-side {
        width: 20px;
        height: 20px;
    }

    .hud-album-name {
        font-size: 14.5px;
    }

    .hud-right {
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 48px);
    }

    .hud-item-wheel {
        padding: 4px;
    }

    .hud-item-track {
        gap: 4px;
    }

    .hud-item-far {
        display: none;
    }

    .hud-item-active {
        width: 25px;
        height: 32px;
    }

    .hud-bottom {
        padding: 2rem max(18px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    }

    .hud-bottom-inner {
        max-width: 460px;
        margin-inline: auto;
        gap: 0.35rem;
    }

    .hud-track-title,
    .hud-playback-row {
        padding-right: 0;
    }

    .hud-track-title {
        font-size: 0.75rem;
    }
}

/* Tier 5: Portrait Tablet (iPad 680px..960px Portrait) */
@media (min-width: 680px) and (max-width: 960px) and (orientation: portrait) {
    .hud-album-anchor {
        padding-right: 0;
    }

    .hud-album-wheel {
        height: 48px;
        gap: 12px;
    }

    .hud-album-active {
        width: 44px;
        height: 44px;
    }

    .hud-album-side {
        width: 30px;
        height: 30px;
    }

    .hud-album-name {
        font-size: 17.5px;
    }

    .hud-right {
        right: max(16px, env(safe-area-inset-right));
        bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
    }

    .hud-item-active {
        width: 44px;
        height: 58px;
    }

    .hud-item-side {
        width: 29px;
        height: 37px;
    }

    .hud-item-index {
        font-size: 19px;
    }

    .hud-item-total {
        font-size: 17px;
    }

    .hud-bottom-inner {
        max-width: 580px;
        margin-inline: auto;
    }

    .hud-track-title,
    .hud-playback-row {
        padding-right: 0;
    }

    .hud-track-title {
        font-size: 0.875rem;
    }
}
