/* ═══════════════════════════════════════════════════════════════════════════
   layout.css — Chainsaw Legends Layout Shell
   Icon-rail sidebar · Topbar · Main content · Mobile drawer · Overlay
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --cl-rail-width: 60px;
    --cl-sidebar-width: 260px;
    --cl-topbar-height: 56px;
    --cl-sidebar-transition: 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}


/* ─── APP SHELL ─────────────────────────────────────────────────────────── */

.cl-app {
    min-height: 100vh;
    background: var(--cl-bg, #FAFAF8);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR — Icon rail (60px) → expands to 260px on hover.
   Fixed position. Overlays content when expanded, content doesn't shift.
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--cl-rail-width);
    background: var(--cl-charcoal, #2A2A2A);
    color: var(--cl-white, #FFFFFF);
    z-index: 40;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transition: width var(--cl-sidebar-transition);
}

/* Desktop hover expand */
@media (min-width: 768px) {
    .cl-sidebar:hover {
        width: var(--cl-sidebar-width);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
}

/* ─── Brand ─── */
.cl-sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
    padding: 0 10px;
    height: var(--cl-topbar-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.cl-sidebar-brand-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.cl-sidebar-brand-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cl-sidebar-brand-text {
    font-family: var(--cl-font-heading, 'Roboto Condensed', sans-serif);
    font-weight: 700;
    font-size: var(--cl-text-lg, 1.125rem);
    letter-spacing: -0.02em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--cl-sidebar-transition);
}

.cl-sidebar:hover .cl-sidebar-brand-text {
    opacity: 1;
}

.cl-sidebar-brand-text span {
    color: var(--cl-stihl-orange, #F37A1F);
}

/* ─── Footer / User ─── */
.cl-sidebar-footer {
    margin-top: auto;
    padding: var(--cl-space-3, 12px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.cl-sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
    padding: var(--cl-space-2, 8px);
    border-radius: var(--cl-radius, 6px);
    cursor: pointer;
    transition: background 180ms ease;
    color: inherit;
    text-decoration: none;
}

    .cl-sidebar-user:hover {
        background: rgba(255, 255, 255, 0.08);
    }

.cl-sidebar-user-info {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--cl-sidebar-transition);
}

.cl-sidebar:hover .cl-sidebar-user-info {
    opacity: 1;
}

.cl-sidebar-user-name {
    font-weight: 600;
    font-size: var(--cl-text-sm, 0.875rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

.cl-sidebar-user-rank {
    font-size: var(--cl-text-xs, 0.75rem);
    opacity: 0.6;
}

.cl-sidebar-user-chevron {
    opacity: 0;
    flex-shrink: 0;
    transition: opacity var(--cl-sidebar-transition);
}

.cl-sidebar:hover .cl-sidebar-user-chevron {
    opacity: 0.4;
}


/* ═══════════════════════════════════════════════════════════════════════════
   NAV LINKS — Icons always visible. Labels fade in on sidebar hover.
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--cl-space-2, 8px) 0;
}

.cl-nav-section {
    padding: var(--cl-space-1, 4px) var(--cl-space-2, 8px);
}

.cl-nav-section-label {
    font-size: var(--cl-text-xs, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: var(--cl-space-3, 12px) var(--cl-space-2, 8px) var(--cl-space-1, 4px);
    color: rgba(255, 255, 255, 0.35);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--cl-sidebar-transition);
}

.cl-sidebar:hover .cl-nav-section-label {
    opacity: 1;
}

.cl-nav-link {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
    padding: var(--cl-space-2, 8px);
    border-radius: var(--cl-radius, 6px);
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: var(--cl-text-sm, 0.875rem);
    font-weight: 500;
    white-space: nowrap;
    transition: background 180ms ease, color 180ms ease;
}

    .cl-nav-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--cl-white, #FFFFFF);
    }

    .cl-nav-link.active {
        background: rgba(243, 122, 31, 0.15);
        color: var(--cl-stihl-orange, #F37A1F);
    }

.cl-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.cl-nav-link-text {
    opacity: 0;
    transition: opacity var(--cl-sidebar-transition);
}

.cl-sidebar:hover .cl-nav-link-text {
    opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR — Fixed at top, offset by rail width. Never shifts.
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-topbar {
    position: fixed;
    top: 0;
    left: var(--cl-rail-width);
    right: 0;
    height: var(--cl-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--cl-space-5, 20px);
    background: var(--cl-white, #FFFFFF);
    border-bottom: var(--cl-border, 1px solid #E8E5E0);
    z-index: 30;
}

.cl-topbar-left {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
}

.cl-topbar-right {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
}

.cl-topbar-title {
    font-family: var(--cl-font-heading, 'Roboto Condensed', sans-serif);
    font-size: var(--cl-text-lg, 1.125rem);
    font-weight: 600;
    margin: 0;
    color: var(--cl-charcoal, #2A2A2A);
}

.cl-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--cl-charcoal, #2A2A2A);
    cursor: pointer;
    padding: var(--cl-space-1, 4px);
    border-radius: var(--cl-radius, 6px);
    transition: background 180ms ease;
}

    .cl-hamburger:hover {
        background: var(--cl-concrete, #E8E5E0);
    }


/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT — Offset by rail + topbar. Standard padding.
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-main {
    margin-left: var(--cl-rail-width);
    padding-top: var(--cl-topbar-height);
    padding-left: var(--cl-space-6, 24px);
    padding-right: var(--cl-space-6, 24px);
    padding-bottom: var(--cl-space-12, 48px);
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
}

.cl-main:focus {
    outline: none;
}

.cl-nav-action {
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.cl-invite-dialog-copy p {
    margin: 0 0 var(--cl-space-2);
}

.cl-invite-dialog-copy {
    margin-bottom: var(--cl-space-4);
}

.cl-invite-error {
    margin-top: var(--cl-space-1);
    color: var(--cl-danger);
    font-size: var(--cl-text-sm);
}

.cl-invite-success {
    display: flex;
    align-items: flex-start;
    gap: var(--cl-space-3);
}

.cl-invite-success-mark {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    color: var(--cl-white);
    font-weight: 800;
    background: var(--cl-success);
    border-radius: 50%;
}

.cl-invite-success p {
    margin: var(--cl-space-1) 0 0;
    color: var(--cl-steel);
    font-size: var(--cl-text-sm);
}


/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE NAVIGATION DRAWER
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 54;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.cl-mobile-nav-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    width: min(320px, 88vw);
    padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
    color: var(--cl-white, #FFFFFF);
    background: var(--cl-charcoal, #2A2A2A);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.28);
    animation: cl-mobile-nav-in 280ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes cl-mobile-nav-in {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.cl-mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--cl-topbar-height);
    padding: 0 var(--cl-space-3, 12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cl-mobile-nav-brand {
    display: flex;
    align-items: center;
    gap: var(--cl-space-2, 8px);
    color: var(--cl-white, #FFFFFF);
    text-decoration: none;
    font-family: var(--cl-font-heading, 'Roboto Condensed', sans-serif);
    font-size: var(--cl-text-lg, 1.125rem);
    font-weight: 700;
}

.cl-mobile-nav-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.cl-mobile-nav-brand > span > span {
    color: var(--cl-stihl-orange, #F37A1F);
}

.cl-mobile-nav-close {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    background: none;
    border: 0;
    border-radius: var(--cl-radius, 6px);
}

.cl-mobile-nav-close:hover {
    color: var(--cl-white, #FFFFFF);
    background: rgba(255, 255, 255, 0.08);
}

.cl-mobile-nav-drawer .cl-nav {
    padding: var(--cl-space-3, 12px) var(--cl-space-1, 4px);
}

.cl-mobile-nav-drawer .cl-nav-section-label,
.cl-mobile-nav-drawer .cl-nav-link-text {
    opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 50;
    cursor: pointer;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}


/* ═══════════════════════════════════════════════════════════════════════════
   RIGHT DRAWER
   ═══════════════════════════════════════════════════════════════════════════ */

.cl-drawer-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 90vw);
    background: var(--cl-white, #FFFFFF);
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.10), -2px 0 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.cl-drawer-right-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--cl-space-5, 20px) var(--cl-space-5, 20px) var(--cl-space-4, 16px);
    border-bottom: var(--cl-border, 1px solid #E8E5E0);
    flex-shrink: 0;
}

.cl-drawer-right-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--cl-space-5, 20px);
}

.cl-drawer-right-footer {
    padding: var(--cl-space-4, 16px) var(--cl-space-5, 20px);
    border-top: var(--cl-border, 1px solid #E8E5E0);
    flex-shrink: 0;
    background: var(--cl-bg, #FAFAF8);
}

.cl-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: var(--cl-space-1, 4px);
}

.cl-drawer-nav-link {
    display: flex;
    align-items: center;
    gap: var(--cl-space-3, 12px);
    padding: var(--cl-space-3, 12px);
    border-radius: var(--cl-radius, 6px);
    color: var(--cl-charcoal, #2A2A2A);
    text-decoration: none;
    font-size: var(--cl-text-sm, 0.875rem);
    font-weight: 500;
    transition: background 180ms ease, color 180ms ease;
}

    .cl-drawer-nav-link:hover {
        background: var(--cl-concrete, #E8E5E0);
        color: var(--cl-stihl-orange, #F37A1F);
    }

    .cl-drawer-nav-link svg {
        flex-shrink: 0;
        opacity: 0.65;
        transition: opacity 180ms ease;
    }

    .cl-drawer-nav-link:hover svg {
        opacity: 1;
    }


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (< 768px)
   Desktop rail is hidden. The interactive hamburger opens the mobile drawer.
   Content goes full-width.
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767.98px) {
    .cl-sidebar {
        display: none;
    }

    .cl-topbar {
        left: 0;
    }

    .cl-hamburger {
        display: flex;
    }

    .cl-main {
        margin-left: 0;
        padding: var(--cl-space-4, 16px);
        padding-top: calc(var(--cl-topbar-height) + var(--cl-space-4, 16px));
        padding-bottom: var(--cl-space-8, 32px);
    }

    .cl-hide-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .cl-hide-desktop {
        display: none !important;
    }
}
