/* ==========================================================================
   Spotify-like Left Rail Layout (rk-*) - MOBILE ENHANCED
   ========================================================================== */

:root {
    --rk-sidebar-w: 260px;
    --rk-sidebar-w-compact: 76px;
    --rk-player-height: 90px;
    --rk-logo-h: 84px;
    /* desktop sidebar logo */
    --rk-logo-h-mobile: 72px;
    /* mobile sidebar logo */

    /* ✅ Updated: Smaller logo vs header on mobile */
    --rk-header-h-mobile: 64px;
    /* total mobile header height */
    --rk-mobile-header-logo-h:28px;
    /* smaller logo image height */

    --rk-z-sidebar: 97;
    --rk-z-scrim: 98;
    --rk-z-player: 100;
    --rk-z-mobile-header: 99;

    --rk-sidebar-w-mobile: min(88vw, 320px);
}

/* ---- Shell - MOBILE FIRST ---- */
.rk-shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    background: var(--the-bg, #121212);
    padding-bottom: var(--rk-player-height);
}

/* Desktop shell */
@media (min-width: 1025px) {
    .rk-shell {
        grid-template-columns: var(--rk-sidebar-w) 1fr;
        padding-bottom: var(--rk-player-height);
    }
}

/* ---- Sidebar - MOBILE OFFCANVAS ---- */
.rk-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: var(--rk-sidebar-w-mobile);
    max-height: calc(100dvh - var(--rk-player-height));
    background: var(--the-sidebarBg, #0f0f0f);
    color: var(--the-inkOnSidebar, #e9eef4);
    border-right: 1px solid var(--the-line, #222222);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: var(--rk-z-sidebar);
    transform: translateX(-100%);
    transition: transform .3s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.rk-sidebar.is-open {
    transform: translateX(0);
}

/* Desktop sidebar */
@media (min-width: 1025px) {
    .rk-sidebar {
        position: sticky;
        transform: translateX(0);
        width: var(--rk-sidebar-w);
        max-height: calc(100vh - var(--rk-player-height));
        box-shadow: none;
    }
}

/* ---- Mobile Header ---- */
.rk-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--rk-header-h-mobile);
    background: var(--the-sidebarBg, #0f0f0f);
    border-bottom: 1px solid var(--the-line, #222222);
    padding: 0 1rem;
    z-index: var(--rk-z-mobile-header);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.rk-mobile-header .rk-mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--the-inkOnSidebar, #e9eef4);
    font-weight: 700;
}

/* ✅ Smaller mobile header logo */
.rk-mobile-header .rk-mobile-brand img {
    height: var(--rk-mobile-header-logo-h);
    width: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

/* Mobile menu button */
.rk-mobile-header .rk-mobile-menu-btn {
    background: none;
    border: none;
    color: var(--the-inkOnSidebar, #e9eef4);
    font-size: 1.4rem;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.rk-mobile-header .rk-mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Hide mobile header on desktop */
@media (min-width: 1025px) {
    .rk-mobile-header {
        display: none;
    }
}

/* ---- Mobile Scrim ---- */
.rk-mobile-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: calc(var(--rk-z-sidebar) - 1);
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rk-sidebar.is-open~.rk-content .rk-mobile-scrim {
    display: block;
    opacity: 1;
}

/* Hide scrim on desktop */
@media (min-width: 1025px) {
    .rk-mobile-scrim {
        display: none !important;
    }
}

/* ---- Brand (logo/title) ---- */
.rk-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 16px;
    text-decoration: none;
    color: var(--the-inkOnSidebar, #e9eef4);
    font-weight: 800;
    border-radius: 10px;
    transition: background .15s ease, color .15s ease;
}

.rk-brand:hover {
    background: color-mix(in srgb, var(--the-inkOnSidebar, #e9eef4) 8%, transparent);
}

.rk-brand img {
    height: var(--rk-logo-h);
    width: auto;
    object-fit: contain;
    display: block;
    max-height: none !important;
}

.rk-brand-title {
    font-size: 1.1rem;
    letter-spacing: .3px;
}

.rk-brand.hide-title .rk-brand-title {
    display: none !important;
}

.rk-brand.hide-title {
    justify-content: center;
}

/* Mobile brand adjustments */
@media (max-width: 1020px) {
    .rk-brand img {
        height: var(--rk-logo-h-mobile);
    }

    .rk-brand {
        padding: 8px 8px 12px;
    }
}

/* ---- Nav rail ---- */
.rk-navrail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
    flex: 1;
}

.rk-navlink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--the-inkOnSidebar, #dfe6ee);
    text-decoration: none;
    font-weight: 600;
    font-size: .96rem;
    line-height: 1;
    transition: background .15s ease, color .15s ease, transform .12s ease;
}

.rk-navlink i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}

.rk-navlink:hover {
    color: #fff;
    background: color-mix(in srgb, var(--the-inkOnSidebar, #e9eef4) 14%, transparent);
    transform: translateY(-1px);
}

/* Mobile navlink adjustments */
@media (max-width: 480px) {
    .rk-navlink {
        padding: 13px 14px;
    }

    .rk-navlink i {
        width: 20px;
        font-size: 1.1rem;
    }
}

/* ---- Active state ---- */
.rk-navlink.active {
    background: var(--the-brand, #1ed760);
    color: #fff !important;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.rk-navlink.active i {
    color: #fff !important;
}

/* ---- Footer ---- */
.rk-sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 6px;
    padding-bottom: 25px;
}

.rk-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--the-inkOnSidebar, #c7d1db);
    text-decoration: none;
    font-size: .9rem;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background .15s ease, color .15s ease;
}

.rk-mini:hover {
    color: #fff;
    background: color-mix(in srgb, var(--the-inkOnSidebar, #e9eef4) 10%, transparent);
}

/* ---- Content - MOBILE PADDING ---- */
.rk-content {
    background: var(--the-bg, #121212);
    color: var(--the-ink, #e6e9ef);
    padding-bottom: var(--rk-player-height);
    padding-top: 0;
}

/* Mobile content padding */
@media (max-width: 1020px) {
    .rk-content {
        padding-top: var(--rk-header-h-mobile);
    }
}

/* ---- Player ---- */
.rk-player-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--rk-player-height);
    background: var(--the-bg, #121212);
    border-top: 1px solid var(--the-line, #2a2a2a);
    z-index: var(--rk-z-player);
}

/* Mobile player adjustments */
@media (max-width: 768px) {
    .rk-player-area {
        height: var(--rk-player-h-mobile, 80px);
    }

    .rk-shell {
        padding-bottom: var(--rk-player-h-mobile, 80px);
    }

    .rk-sidebar {
        bottom: var(--rk-player-h-mobile, 80px);
        max-height: calc(100dvh - var(--rk-player-h-mobile, 80px));
    }
}

/* ---- Compact Mode ---- */
.rk-sidebar.is-compact {
    width: var(--rk-sidebar-w-compact);
}

.rk-sidebar.is-compact .rk-brand-title,
.rk-sidebar.is-compact .rk-navlink span,
.rk-sidebar.is-compact .rk-mini span {
    display: none;
}

.rk-sidebar.is-compact .rk-navlink,
.rk-sidebar.is-compact .rk-mini {
    justify-content: center;
}

.rk-sidebar.is-compact .rk-brand img {
    height: 56px !important;
}

/* ---- Scrollbar ---- */
.rk-sidebar::-webkit-scrollbar {
    width: 8px;
}

.rk-sidebar::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--the-inkOnSidebar, #e9eef4) 18%, transparent);
    border-radius: 6px;
}

.rk-sidebar::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--the-inkOnSidebar, #e9eef4) 30%, transparent);
}

/* ---- Focus ---- */
.rk-sidebar a:focus-visible,
.rk-content a:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--the-brand, #1ed760) 80%, white 20%);
    outline-offset: 2px;
}

/* ---- Safe Area Insets ---- */
@supports(padding: max(0px)) {
    .rk-mobile-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: env(safe-area-inset-top);
        height: calc(var(--rk-header-h-mobile) + env(safe-area-inset-top));
    }

    .rk-content {
        padding-top: calc(var(--rk-header-h-mobile) + env(safe-area-inset-top));
    }

    .rk-sidebar {
        padding-top: calc(18px + env(safe-area-inset-top));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        height: calc(100dvh + env(safe-area-inset-top));
    }

    .rk-player-area {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--rk-player-height) + env(safe-area-inset-bottom));
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {

    .rk-sidebar,
    .rk-navlink,
    .rk-brand,
    .rk-mobile-scrim {
        transition: none !important;
    }
}

/* ---- Body lock ---- */
.rk-body-locked {
    overflow: hidden;
}

/* ---- Mobile performance ---- */
@media (max-width: 768px) {
    .rk-sidebar {
        will-change: transform;
    }

    .rk-mobile-scrim {
        will-change: opacity;
    }
}