/* ============================================
   Header V2 — Korsordsvar Redesign
   Target: < 4KB gzipped
   No Bootstrap dependency
   ============================================ */

:root {
    --hv2-orange: #D97706;
    --hv2-orange-hover: #B45309;
    --hv2-orange-light: #FEF3C7;
    --hv2-dark: #1C1917;
    --hv2-grey-700: #44403C;
    --hv2-grey-500: #78716C;
    --hv2-grey-300: #D6D3D1;
    --hv2-grey-200: #E7E5E4;
    --hv2-grey-100: #F5F5F4;
    --hv2-grey-50: #FAFAF9;
    --hv2-white: #FFFFFF;
    --hv2-red: #EF4444;
}

/* ===== BASE HEADER ===== */
.header-v2 {
    background: var(--hv2-white);
    border-bottom: 1px solid var(--hv2-grey-200);
    z-index: 100;
    width: 100%;
}

.header-v2__inner {
    max-width: 1200px;
    margin: 0 auto;
}

.header-v2__row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    min-height: 56px;
}

/* ===== LOGO ===== */
.header-v2__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.header-v2__logo img {
    height: 36px;
    width: auto;
}

/* ===== ANONYMOUS ACTIONS ===== */
.header-v2__actions-anon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-v2__btn {
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    line-height: 1;
}

.header-v2__btn--outline {
    color: var(--hv2-orange);
    border: 2px solid var(--hv2-orange);
    background: none;
}

.header-v2__btn--outline:hover {
    background: var(--hv2-orange-light);
    color: var(--hv2-orange);
    text-decoration: none;
}

.header-v2__btn--solid {
    color: var(--hv2-white);
    background: var(--hv2-dark);
    border: 2px solid var(--hv2-dark);
}

.header-v2__btn--solid:hover {
    background: #292524;
    color: var(--hv2-white);
    text-decoration: none;
}

/* Focus states for accessibility */
.header-v2__btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--hv2-orange-light);
}

/* ===== LOGGED-IN USER AREA ===== */
.header-v2__actions-logged {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-v2__streak {
    font-size: 18px;
    font-weight: 700;
    color: var(--hv2-orange);
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

/* ===== AVATAR ===== */
.header-v2__avatar-wrap {
    position: relative;
}

.header-v2__avatar-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: 2px solid var(--hv2-grey-300);
    padding: 0;
    cursor: pointer;
    background: var(--hv2-orange-light);
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: visible;
    -webkit-appearance: none;
    appearance: none;
}

.header-v2__avatar-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--hv2-orange-light);
}

/* Clean avatar circle — no level badge */
.header-v2__avatar-circle {
    width: 34px;
    height: 34px;
    background: var(--hv2-orange-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--hv2-orange);
    overflow: hidden;
}

.header-v2__avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ===== PROFILE DROPDOWN ===== */
.header-v2__profile-drop {
    display: none;
    position: absolute;
    top: 48px;
    right: 0;
    width: 240px;
    background: var(--hv2-white);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
    border: 1px solid var(--hv2-grey-200);
    z-index: 200;
    overflow: hidden;
    animation: hv2DropIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.header-v2__profile-drop.is-open {
    display: block;
}

@keyframes hv2DropIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.header-v2__prof-header {
    padding: 16px;
    background: var(--hv2-grey-50);
    border-bottom: 1px solid var(--hv2-grey-200);
    text-align: center;
}

.header-v2__prof-avatar-big {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin: 0 auto 8px;
    overflow: hidden;
}

.header-v2__prof-avatar-big img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.header-v2__prof-avatar-initial {
    width: 100%;
    height: 100%;
    background: var(--hv2-orange-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--hv2-orange);
}

/* Profile menu items: SVG icons */
.header-v2__prof-item svg {
    width: 18px;
    height: 18px;
    color: var(--hv2-grey-500);
    flex-shrink: 0;
}

.header-v2__prof-item--logout svg {
    color: var(--hv2-red);
}

.header-v2__prof-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--hv2-dark);
}

.header-v2__prof-level {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--hv2-orange);
    font-weight: 600;
    background: var(--hv2-orange-light);
    padding: 3px 10px;
    border-radius: 10px;
    margin-top: 4px;
}

.header-v2__prof-bar {
    width: 100%;
    height: 6px;
    background: var(--hv2-grey-200);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.header-v2__prof-bar-fill {
    height: 100%;
    background: var(--hv2-orange);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.header-v2__prof-bar-text {
    font-size: 13px;
    color: var(--hv2-grey-500);
    margin-top: 4px;
}

.header-v2__prof-divider {
    height: 1px;
    background: var(--hv2-grey-200);
}

.header-v2__prof-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--hv2-grey-700);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
    min-height: 48px;
    transition: background 0.1s;
}

.header-v2__prof-item:hover {
    background: var(--hv2-grey-50);
    text-decoration: none;
    color: var(--hv2-grey-700);
}

.header-v2__prof-item--logout {
    color: var(--hv2-red);
}

.header-v2__prof-item--logout:hover {
    color: var(--hv2-red);
}

/* ===== TABS ===== */
.header-v2__tabs {
    display: flex;
    padding: 0 8px;
    border-top: 1px solid var(--hv2-grey-200);
}

.header-v2__tab {
    flex: 1;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 600;
    color: var(--hv2-grey-500);
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    transition: color 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.header-v2__tab:hover {
    color: var(--hv2-grey-700);
    text-decoration: none;
}

.header-v2__tab.is-active {
    color: var(--hv2-dark);
}

.header-v2__tab.is-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--hv2-orange);
    border-radius: 2px;
}

.header-v2__tab:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--hv2-orange-light);
}

.header-v2__tab-badge {
    min-width: 20px;
    height: 20px;
    background: var(--hv2-orange);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Spel badge green when all done (3/3) */
.header-v2__tab-badge--done {
    background: #15803D;
}

/* ===== DESKTOP SEARCH IN HEADER ===== */
.header-v2__search {
    display: none;
    max-width: 340px;
    min-width: 200px;
    margin: 0 16px;
}

/* ===== DESKTOP TABS INLINE ===== */
.header-v2__tabs-desktop {
    display: none;
}

/* ===== SCROLL BEHAVIOR ===== */
.header-v2--smart {
    position: sticky;
    top: 0;
    transition: transform 0.3s ease;
}

.header-v2--smart.is-hidden {
    transform: translateY(-100%);
}

/* Static header (anonymous mobile) — no position sticky */
.header-v2--static {
    position: relative;
}

/* ===== RESPONSIVE: DESKTOP (≥1024px) ===== */
@media (min-width: 1024px) {
    .header-v2 {
        position: sticky;
        top: 0;
    }

    /* Override mobile-only smart scroll on desktop */
    .header-v2--static {
        position: sticky;
        top: 0;
    }

    .header-v2__row1 {
        padding: 8px 24px;
    }

    /* Show desktop search */
    .header-v2__search {
        display: flex;
    }

    /* Hide mobile tabs, show desktop tabs */
    .header-v2__tabs--mobile {
        display: none;
    }

    .header-v2__tabs-desktop {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-left: auto;
        margin-right: 16px;
    }

    .header-v2__tabs-desktop .header-v2__tab {
        flex: none;
        padding: 0 12px;
        min-height: 44px;
    }

    .header-v2__tabs-desktop .header-v2__tab.is-active::after {
        left: 8px;
        right: 8px;
    }
}
