/**
 * QMF Science Lab Header — QuizzMan Tools v2.0
 * Unified QMF-styled header with tier auth integration.
 * Design tokens from ui.quizzman.com/qmf
 */

/* ── QMF Header Design Tokens ──────────────────────────────── */
:root {
    --qmf-header-h: 60px;
    --qmf-header-bg: rgba(255, 255, 255, 0.92);
    --qmf-header-border: #e2e8f0;
    --qmf-header-blur: blur(20px) saturate(1.8);
    --qmf-header-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
    --qmf-header-text: #1e293b;
    --qmf-header-muted: #64748b;
    --qmf-header-btn-bg: rgba(255, 255, 255, 0.7);
    --qmf-header-btn-border: rgba(0, 0, 0, 0.1);
    --qmf-header-btn-hover-bg: rgba(139, 105, 20, 0.08);
    --qmf-header-btn-hover-color: #8b6914;
    --qmf-header-brand-gradient: linear-gradient(135deg, #8b6914, #5c4a9e);
}

[data-theme="dark"],
body.dark-mode {
    --qmf-header-bg: rgba(15, 23, 42, 0.95);
    --qmf-header-border: #1e293b;
    --qmf-header-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
    --qmf-header-text: #e2e8f0;
    --qmf-header-muted: #94a3b8;
    --qmf-header-btn-bg: rgba(255, 255, 255, 0.06);
    --qmf-header-btn-border: rgba(255, 255, 255, 0.1);
    --qmf-header-btn-hover-bg: rgba(212, 168, 67, 0.12);
    --qmf-header-btn-hover-color: #d4a843;
    --qmf-header-brand-gradient: linear-gradient(135deg, #d4a843, #9b8ce0);
}

/* ── Lab Header ─────────────────────────────────────────────── */
.lab-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1001;
    height: var(--qmf-header-h);
    background: var(--qmf-header-bg);
    backdrop-filter: var(--qmf-header-blur);
    -webkit-backdrop-filter: var(--qmf-header-blur);
    border-bottom: 1px solid var(--qmf-header-border);
    box-shadow: var(--qmf-header-shadow);
    transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    padding: 0;
    display: block;
}

/* Inner flex row */
.lab-header__inner {
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
}

/* ── Brand (left) ───────────────────────────────────────────── */
.lab-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--qmf-header-text);
    transition: opacity 0.2s;
}

.lab-header__brand:hover {
    opacity: 0.85;
}

.lab-header__logo {
    height: 36px;
    width: auto;
    border-radius: 8px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lab-header__brand:hover .lab-header__logo {
    transform: scale(1.06);
}

.lab-header__titles {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.lab-header__name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--qmf-header-text);
}

.lab-header__sub {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--qmf-header-muted);
    opacity: 0.75;
}

/* ── Center (QuizzMan link / QM group) ─────────────────────── */
.lab-header__center,
.lab-header__qm-group {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--qmf-header-text);
}

.lab-header__qm-group picture {
    display: flex;
    align-items: center;
}

.lab-header__qm-logo {
    height: 26px;
    width: auto;
    opacity: 0.85;
    transition: opacity 0.25s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lab-header__qm-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

.lab-header__qm-texts {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    line-height: 1.15;
}

.lab-header__qm-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: var(--qmf-header-brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lab-header__qm-sub {
    display: none;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qmf-header-muted);
    opacity: 0.55;
    transition: opacity 0.25s;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
}

.lab-header__qm-group:hover .lab-header__qm-sub {
    opacity: 0.85;
}

/* ── Actions (right) ────────────────────────────────────────── */
.lab-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lab-header__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--qmf-header-btn-border);
    background: var(--qmf-header-btn-bg);
    color: var(--qmf-header-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    font-family: inherit;
    padding: 0;
    line-height: 1;
}

.lab-header__btn:hover {
    background: var(--qmf-header-btn-hover-bg);
    color: var(--qmf-header-btn-hover-color);
    border-color: var(--qmf-header-btn-hover-color);
    transform: translateY(-1px);
}

.lab-header__btn:active {
    transform: translateY(0);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .lab-header__brand { display: none; }
    .lab-header__center { display: none; }
    /* Keep qm-group absolutely centered on mobile */
    .lab-header__qm-group {
        display: flex;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        gap: 10px;
    }
    /* Logo: larger, full opacity, subtle glow on mobile */
    .lab-header__qm-logo {
        height: 32px;
        opacity: 1;
        filter: drop-shadow(0 1px 4px rgba(139, 105, 20, 0.18));
        transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                    filter 0.3s ease;
    }
    .lab-header__qm-group:active .lab-header__qm-logo {
        transform: scale(0.92);
    }
    /* Show QM texts: "QuizzMan" on top, "Science Lab" below */
    .lab-header__qm-texts {
        display: flex;
        flex-direction: column;
        line-height: 1.15;
        gap: 1px;
    }
    .lab-header__qm-name {
        font-size: 0.95rem;
        font-weight: 800;
        letter-spacing: -0.01em;
    }
    .lab-header__qm-sub {
        display: block;
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        opacity: 0.6;
        transition: opacity 0.25s;
    }
    .lab-header__qm-group:hover .lab-header__qm-sub {
        opacity: 0.85;
    }
    /* Force actions to the right */
    .lab-header__actions { gap: 6px; margin-left: auto; }
    /* Hide docs/tools btn + theme btn on mobile — keep lang + auth */
    .lab-header__actions > a.lab-header__btn { display: none; }
    .lab-header__actions > #theme-btn { display: none; }
}

/* Dark mode mobile logo glow */
@media (max-width: 768px) {
    [data-theme="dark"] .lab-header__qm-logo,
    body.dark-mode .lab-header__qm-logo {
        filter: drop-shadow(0 1px 6px rgba(212, 168, 67, 0.25));
    }
}

@media (max-width: 480px) {
    .lab-header__inner { padding: 0 10px; }
    .lab-header__qm-group { gap: 7px; }
    .lab-header__qm-logo { height: 26px; }
    .lab-header__qm-name { font-size: 0.82rem; font-weight: 800; }
    .lab-header__qm-sub { font-size: 0.52rem; }
    .lab-header__actions { gap: 4px; }
    .page-title.compact { padding: 0.6rem 0; margin-bottom: 1rem; }
    .page-title.compact h1 { font-size: 1.1rem; gap: 0.35rem; }
    .page-title h1 { font-size: 1.2rem; }
}
