/* Recompensated global header + authenticated workspace shell.
 * Mirrors the flatter, token-led visual system used by the Guided Reward Story
 * homepage and the rebuilt Daily Bonus experience.
 */

:root {
    --workspace-rail-width: 17rem;
}

/* ==========================================================================
 * Header
 * ========================================================================== */

.site-header {
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-base);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.site-header::after {
    display: none;
}

.site-header__row {
    min-height: 4.5rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.site-header__brand {
    gap: 0.65rem;
}

.site-header__logo-icon {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.site-header__brand:hover .site-header__logo-icon {
    transform: none;
    border-color: var(--accent-border);
    box-shadow: none;
}

.site-header__wordmark {
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 850;
    letter-spacing: -0.025em;
}

.site-header__brand:hover .site-header__wordmark {
    color: var(--text-primary);
}

.site-header__nav-link {
    min-height: 2.4rem;
    padding: 0.55rem 0.72rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted) !important;
    font-size: 0.82rem;
    font-weight: 700;
}

.site-header__nav-link:hover {
    border-color: var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary) !important;
}

.site-header__nav-link.is-active,
.site-header__nav-link--earn:hover {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary) !important;
    box-shadow: none;
    transform: none;
}

.site-header__nav-link--earn::after {
    display: none;
}

.site-header__nav-link--earn:hover::after {
    animation: none;
}

.header-actions {
    gap: 0.4rem;
}

.notif-bell,
.header-lang-btn,
.header-wallet,
.account-trigger,
.language-trigger--compact,
.mobile-profile-trigger {
    border-color: var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    box-shadow: none;
}

.notif-bell,
.header-lang-btn {
    color: var(--text-muted);
}

.notif-bell:hover,
.notif-bell:focus-visible,
.header-lang-btn:hover,
.header-lang-btn:focus-visible,
.language-trigger--compact:hover,
.language-trigger--compact:focus-visible,
.mobile-profile-trigger:hover,
.mobile-profile-trigger:focus-visible,
.mobile-profile-trigger.is-open,
.account-trigger:hover,
.account-trigger:focus-visible,
.account-trigger.is-open {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    box-shadow: none;
    outline: none;
    transform: none;
}

.notif-bell:focus-visible,
.header-lang-btn:focus-visible,
.language-trigger--compact:focus-visible,
.mobile-profile-trigger:focus-visible,
.account-trigger:focus-visible,
.header-auth-link:focus-visible,
.header-auth-cta:focus-visible,
.app-sidebar__profile:focus-visible,
.app-sidebar__label:focus-visible,
.app-sidebar__item:focus-visible,
.app-sidebar__support-link:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

.header-wallet {
    min-height: 2.5rem;
    overflow: hidden;
}

.header-wallet__balance {
    gap: 0.48rem;
    padding: 0.3rem 0.7rem 0.3rem 0.42rem;
}

.header-wallet__coin {
    width: 1.7rem;
    height: 1.7rem;
    border-radius: var(--radius-sm);
    background: var(--money-dim);
    color: var(--money);
    box-shadow: none;
}

.header-wallet__amount {
    gap: 0.12rem;
}

.header-wallet__amount small {
    color: var(--text-faint);
    font-size: 0.55rem;
    font-weight: 750;
    letter-spacing: 0.12em;
}

.header-wallet__amount strong {
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 800;
}

.header-wallet__cashout {
    padding: 0 0.8rem;
    border-left: 1px solid var(--accent-border);
    background: var(--accent);
    color: var(--bg-base);
    text-shadow: none;
    animation: none;
    transition: background 160ms ease, color 160ms ease;
}

.header-wallet__cashout::after {
    display: none;
    animation: none;
}

.header-wallet__cashout:hover,
.header-wallet__cashout:focus-visible {
    background: var(--accent-hover);
    color: var(--bg-base);
    filter: none;
    box-shadow: none;
    outline: none;
}

.header-wallet__cashout:hover i {
    animation: none;
}

.account-trigger {
    padding: 0.28rem 0.55rem 0.28rem 0.32rem;
}

.account-trigger__avatar {
    width: 1.85rem;
    height: 1.85rem;
    border-color: var(--border-strong);
    border-radius: calc(var(--radius-sm) - 0.08rem);
    box-shadow: none;
}

.account-trigger__name {
    color: var(--text-primary);
    font-size: 0.76rem;
}

.account-trigger__caret {
    color: var(--text-faint);
}

.account-trigger.is-open .account-trigger__caret {
    color: var(--accent);
}

.header-auth-link,
.header-auth-cta {
    min-height: 2.5rem;
    padding: 0.62rem 0.95rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;
}

.header-auth-link {
    border: 1px solid transparent;
    color: var(--text-muted) !important;
}

.header-auth-link:hover {
    border-color: var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary) !important;
}

.header-auth-cta {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--bg-base) !important;
    box-shadow: none;
}

.header-auth-cta:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: var(--bg-base) !important;
}

.notif-dropdown,
.account-dropdown {
    border-color: var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-card-end);
    box-shadow: var(--shadow-lg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.notif-dropdown__header {
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.notif-dropdown__mark-read {
    color: var(--accent);
}

.notif-dropdown__empty {
    color: var(--text-muted);
}

/* ==========================================================================
 * Desktop workspace rail
 * ========================================================================== */

.app-shell {
    grid-template-columns: var(--workspace-rail-width) minmax(0, 1fr);
}

.app-sidebar {
    height: calc(100vh - 8rem);
    min-height: 0;
    max-height: calc(100vh - 8rem);
    padding: 1rem 0.85rem 1.1rem;
    overflow-x: hidden;
    overflow-y: auto;
    border-right-color: var(--border-subtle);
    background: var(--bg-base);
    scrollbar-color: transparent transparent;
    scrollbar-width: thin;
    overscroll-behavior: contain;
}

.app-sidebar::-webkit-scrollbar {
    width: 0.38rem;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: transparent;
}

.app-sidebar:hover {
    scrollbar-color: var(--border-strong) transparent;
}

.app-sidebar:hover::-webkit-scrollbar-thumb {
    background: var(--border-strong);
}

.app-sidebar::before {
    background: var(--bg-base);
    border-right-color: var(--border-subtle);
}

.app-sidebar__panel + .app-sidebar__panel {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top-color: var(--border-subtle);
}

.app-sidebar__profile {
    gap: 0.65rem;
    margin: 0;
    padding: 0.62rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    transition: border-color 160ms ease, background 160ms ease;
}

.app-sidebar__profile:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    transform: none;
}

.app-sidebar__avatar {
    width: 2.4rem;
    height: 2.4rem;
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.app-sidebar__profile-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.app-sidebar__name {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar__meta {
    overflow: hidden;
    margin-top: 0.16rem;
    color: var(--text-faint);
    font-size: 0.65rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar__profile-arrow {
    flex: 0 0 auto;
    color: var(--text-faint);
    font-size: 0.62rem;
}

.app-sidebar__profile:hover .app-sidebar__profile-arrow {
    color: var(--accent);
}

.cashout-goal {
    margin-top: 0.65rem;
    padding: 0.72rem;
    border-color: var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.cashout-goal__head {
    color: var(--text-faint);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.cashout-goal__head i,
.cashout-goal__head strong {
    color: var(--accent);
}

.cashout-goal__bar {
    height: 0.32rem;
    margin-top: 0.55rem;
    background: var(--bg-card);
}

.cashout-goal__bar span {
    background: var(--accent);
    box-shadow: 0 0 0.7rem var(--glow-accent);
}

.cashout-goal__meta {
    margin-top: 0.55rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.45;
}

.cashout-goal__meta strong {
    color: var(--text-primary);
}

.cashout-goal__cta {
    display: flex;
    justify-content: flex-start;
    min-height: 2.15rem;
    margin-top: 0.62rem;
    padding: 0.48rem 0.58rem;
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    transition: border-color 160ms ease, background 160ms ease;
}

.cashout-goal__cta:hover,
.cashout-goal__cta:focus-visible {
    border-color: var(--accent);
    background: var(--bg-surface-hover);
    color: var(--accent);
    outline: none;
}

.app-sidebar__section + .app-sidebar__section {
    margin-top: 0.72rem;
}

.app-sidebar__label {
    margin-bottom: 0.35rem;
    padding: 0.28rem 0.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    font-size: 0.62rem;
    font-weight: 850;
    letter-spacing: 0.15em;
}

.app-sidebar__label:hover {
    border-color: var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-body);
}

.app-sidebar__label-caret {
    color: var(--accent);
    opacity: 1;
}

.app-sidebar__nav {
    gap: 0.2rem;
}

.app-sidebar__item {
    gap: 0.62rem;
    min-height: 3.15rem;
    padding: 0.5rem 0.58rem;
    border-color: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.app-sidebar__item:hover {
    border-color: var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    transform: none;
}

.app-sidebar__item.is-active {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary);
    box-shadow: none;
}

.app-sidebar__item.is-active::before {
    display: none;
}

.app-sidebar__item-icon {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.82rem;
}

.app-sidebar__item:hover .app-sidebar__item-icon {
    border-color: var(--border-strong);
    color: var(--text-body);
}

.app-sidebar__item.is-active .app-sidebar__item-icon {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--accent);
}

.app-sidebar__item-text strong {
    color: inherit;
    font-size: 0.8rem;
    font-weight: 800;
}

.app-sidebar__item-text span {
    margin-top: 0.16rem;
    color: var(--text-faint);
    font-size: 0.64rem;
    line-height: 1.25;
}

.app-sidebar__support {
    padding-top: 0.85rem;
    border-top-color: var(--border-subtle);
}

.app-sidebar__support-link {
    display: flex;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 750;
}

.app-sidebar__support-link:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.app-sidebar__support-link i {
    color: var(--accent);
}

/* ==========================================================================
 * Desktop workspace collapse + edge preview
 * ========================================================================== */

.workspace-rail-toggle,
.workspace-rail-hover-zone {
    display: none;
}

@media (min-width: 1024px) {
    .app-shell {
        transition: grid-template-columns 320ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .app-sidebar {
        grid-column: 1;
        grid-row: 1;
        z-index: 30;
        width: var(--workspace-rail-width);
        box-sizing: border-box;
        transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0s, box-shadow 220ms ease;
    }

    .workspace-rail-toggle {
        position: sticky;
        top: 50vh;
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        justify-self: end;
        z-index: 46;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.75rem;
        height: 3.2rem;
        padding: 0;
        border: 1px solid var(--border-strong);
        border-left: 0;
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        background: var(--bg-card-end);
        color: var(--text-muted);
        box-shadow: var(--shadow-md);
        cursor: pointer;
        transform: translate(100%, -50%);
        transition: width 220ms ease, border-color 220ms ease, background 220ms ease, color 220ms ease, box-shadow 220ms ease;
    }

    .app-content {
        grid-column: 2;
        grid-row: 1;
    }

    .workspace-rail-toggle:hover,
    .workspace-rail-toggle:focus-visible {
        border-color: var(--accent-border);
        background: var(--bg-card-end);
        color: var(--accent);
        box-shadow: var(--shadow-md);
        outline: none;
    }

    .workspace-rail-toggle:hover {
        width: 2rem;
    }

    .workspace-rail-toggle i {
        font-size: 0.78rem;
        transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .workspace-rail-toggle:hover i {
        transform: translateX(-0.12rem);
    }

    .app-shell.is-workspace-collapsed .workspace-rail-toggle:hover i {
        transform: translateX(0.12rem);
    }

    .workspace-rail-toggle:focus-visible {
        box-shadow: var(--focus-ring);
    }

    .workspace-rail-toggle__label {
        position: absolute;
        top: 50%;
        left: calc(100% + 0.5rem);
        padding: 0.42rem 0.58rem;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-sm);
        background: var(--bg-card-end);
        color: var(--text-body);
        box-shadow: var(--shadow-md);
        font-size: 0.68rem;
        font-weight: 750;
        line-height: 1.2;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transform: translate(0.25rem, -50%);
        transition: opacity 140ms ease, transform 140ms ease;
    }

    .workspace-rail-toggle:hover .workspace-rail-toggle__label,
    .workspace-rail-toggle:focus-visible .workspace-rail-toggle__label {
        opacity: 1;
        transform: translate(0, -50%);
    }

    .workspace-rail-hover-zone {
        position: fixed;
        top: 8rem;
        bottom: 0;
        left: 0;
        z-index: 28;
        width: 1.15rem;
    }

    .app-shell.is-workspace-collapsed {
        grid-template-columns: 0 minmax(0, 1fr);
    }

    .app-shell.is-workspace-collapsed .workspace-rail-hover-zone {
        display: block;
    }

    .app-shell.is-workspace-collapsed .app-sidebar {
        visibility: hidden;
        pointer-events: none;
        transform: translateX(calc(-100% - 1px));
        transition-delay: 0s, 320ms, 0s;
    }

    .app-shell.is-workspace-collapsed.is-workspace-peeking,
    .app-shell.is-workspace-collapsed:has(.workspace-rail-hover-zone:hover) {
        grid-template-columns: var(--workspace-rail-width) minmax(0, 1fr);
    }

    .app-shell.is-workspace-collapsed.is-workspace-peeking .app-sidebar,
    .app-shell.is-workspace-collapsed:has(.workspace-rail-hover-zone:hover) .app-sidebar {
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
        transition-delay: 0s;
    }

    body.workspace-rail-collapsed .site-header--app-shell .site-header__brand-zone {
        flex-basis: auto;
    }
}

/* ==========================================================================
 * Responsive shell controls
 * ========================================================================== */

.app-mobile-nav {
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-base);
}

.app-mobile-nav__track {
    gap: 0.38rem;
    padding: 0.7rem 1rem;
}

.app-mobile-nav__item {
    min-height: 2.35rem;
    padding: 0.48rem 0.65rem;
    border-color: var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.72rem;
}

.app-mobile-nav__item.is-active {
    border-color: var(--accent-border);
    background: var(--accent-dim);
    color: var(--text-primary);
}

@media (min-width: 1024px) {
    .site-header--app-shell .site-header__inner {
        max-width: none;
    }

    .site-header--app-shell .site-header__row {
        column-gap: 0;
    }

    .site-header--app-shell .site-header__row > :not([hidden]) ~ :not([hidden]) {
        margin-left: 0;
    }

    .site-header--app-shell .site-header__brand-zone {
        flex: 0 0 calc(var(--workspace-rail-width) - 0.5rem);
    }

    .site-header--app-shell .site-header__row > nav {
        justify-content: flex-start;
        padding-left: 1.15rem;
    }

    .site-header--app-shell .header-actions {
        margin-left: auto;
    }
}

@media (max-width: 1023px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 767px) {
    .site-header__row {
        min-height: 4rem;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .site-header__brand {
        margin-left: 0;
        padding: 0;
    }

    .site-header__logo-icon {
        width: 2.35rem;
        height: 2.35rem;
    }

    .language-trigger--compact,
    .mobile-profile-trigger {
        min-height: 2.65rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-header__brand,
    .site-header__logo-icon,
    .site-header__wordmark,
    .app-sidebar__profile,
    .app-sidebar__item,
    .cashout-goal__cta,
    .app-shell,
    .workspace-rail-toggle,
    .workspace-rail-toggle__label {
        transition: none;
    }
}
