/* ═══════════════════════════════════════════════════════════════════════════
   MUSEO DELLE VOCI ARTIFICIALI
   Header Component — Refined Museum Navigation
   ═══════════════════════════════════════════════════════════════════════════

   Structure:
   .museo-header
   ├── .museo-header__nav (left)
   │   └── .museo-header__back
   ├── .museo-header__brand (center, absolute)
   │   ├── .museo-header__logo
   │   │   ├── .museo-header__logo-diamond
   │   │   └── .museo-header__logo-text
   │   └── .museo-header__brand-text
   └── .museo-header__right (right)
       ├── .museo-header__lang
       │   └── .museo-header__lang-btn
       └── .museo-header__controls
           ├── .museo-header__audio-btn
           └── .museo-header__account-btn

   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   HEADER CONTAINER
   ═══════════════════════════════════════════ */
.museo-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-header, 100);

    display: flex;
    align-items: center;
    justify-content: space-between;

    height: var(--header-height, 64px);
    padding: 0 2rem;

    /* Glassmorphism background */
    background: linear-gradient(
        180deg,
        rgba(10, 10, 10, 0.96) 0%,
        rgba(8, 8, 8, 0.92) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* GPU acceleration for better scroll performance */
    will-change: transform;
    transform: translateZ(0);

    /* Subtle border with accent glow */
    border-bottom: 1px solid var(--border-color, rgba(201, 162, 39, 0.15));
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.02) inset,
        0 4px 24px rgba(0, 0, 0, 0.4);

    /* Entry animation */
    opacity: 0;
    transform: translateY(-100%);
    animation: headerReveal 0.8s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) 0.2s forwards;
}

@keyframes headerReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════
   LEFT SECTION — Navigation
   ═══════════════════════════════════════════ */
.museo-header__nav {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 120px;
}

.museo-header__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;

    font-family: var(--font-ui, 'DM Sans', sans-serif);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-muted, rgba(245, 245, 245, 0.7));

    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm, 4px);
    border: 1px solid var(--border-color, rgba(201, 162, 39, 0.2));
    background: rgba(201, 162, 39, 0.04);

    transition: all 0.3s ease;
    cursor: pointer;
}

/* Hidden by default ONLY in tour, shown with .visible class */
.museo-header--tour .museo-header__back {
    opacity: 0;
    pointer-events: none;
}

.museo-header__back::before {
    content: '\2190'; /* ← */
    font-size: 0.9rem;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.museo-header__back:hover {
    color: var(--accent, #c9a227);
    background: rgba(201, 162, 39, 0.1);
    border-color: var(--border-hover, rgba(201, 162, 39, 0.4));
}

.museo-header__back:hover::before {
    opacity: 1;
    transform: translateX(-3px);
}

/* ═══════════════════════════════════════════
   CENTER SECTION — Brand (Absolute Positioned)
   ═══════════════════════════════════════════ */
.museo-header__brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    align-items: center;
    gap: 1.25rem;

    text-decoration: none;
    cursor: default;
    pointer-events: none; /* Allow clicks to pass through to elements behind */
}

.museo-header__brand[href] {
    cursor: pointer;
    pointer-events: auto; /* Re-enable clicks when brand is a link */
}

/* Logo container */
.museo-header__logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-right: 1.25rem;
    border-right: 1px solid rgba(201, 162, 39, 0.25);
}

/* Diamond icon */
.museo-header__logo-diamond {
    position: relative;
    width: 14px;
    height: 14px;
    background: transparent;
    border: 1.5px solid var(--accent, #c9a227);
    transform: rotate(45deg);
    box-shadow: 0 0 8px var(--accent-glow, rgba(201, 162, 39, 0.3));
    transition: all 0.4s ease;
}

.museo-header__logo-diamond::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: var(--accent, #c9a227);
    transform: translate(-50%, -50%);
    transition: all 0.4s ease;
}

.museo-header__brand:hover .museo-header__logo-diamond {
    border-color: var(--accent-light, #e8d48a);
    box-shadow: 0 0 16px var(--accent-glow, rgba(201, 162, 39, 0.5));
}

/* M.V.S. text */
.museo-header__logo-text {
    font-family: var(--font-body, 'Cormorant Garamond', serif);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    color: var(--accent, #c9a227);
    transition: color 0.4s ease;
}

.museo-header__brand:hover .museo-header__logo-text {
    color: var(--accent-light, #e8d48a);
}

/* Brand text */
.museo-header__brand-text {
    font-family: var(--font-body, 'Cormorant Garamond', serif);
    font-size: 1.05rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.1em;
    color: var(--text-muted, rgba(245, 245, 245, 0.75));
    transition: color 0.4s ease;
}

.museo-header__brand:hover .museo-header__brand-text {
    color: var(--text-primary, #f5f5f5);
}

/* ═══════════════════════════════════════════
   RIGHT SECTION — Language + Controls
   ═══════════════════════════════════════════ */
.museo-header__right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    min-width: 120px;
    justify-content: flex-end;
}

/* ─── Language Switcher ─── */
.museo-header__lang {
    display: flex;
    align-items: center;
    gap: 0.25rem;

    padding: 4px;
    background: rgba(201, 162, 39, 0.06);
    border: 1px solid rgba(201, 162, 39, 0.15);
    border-radius: 6px;

    transition: all 0.3s ease;
}

.museo-header__lang:hover {
    background: rgba(201, 162, 39, 0.1);
    border-color: rgba(201, 162, 39, 0.25);
}

.museo-header__lang-btn {
    font-family: var(--font-ui, 'DM Sans', sans-serif);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;

    color: var(--text-dim, rgba(245, 245, 245, 0.5));
    background: transparent;
    border: none;
    border-radius: 4px;

    padding: 0.4rem 0.7rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;

    transition: all 0.3s ease;
}

.museo-header__lang-btn:hover:not(.active) {
    color: var(--text-muted, rgba(245, 245, 245, 0.8));
    background: rgba(255, 255, 255, 0.05);
}

.museo-header__lang-btn.active {
    color: var(--nero-profondo, #0a0a0a);
    background: linear-gradient(
        135deg,
        var(--accent, #c9a227) 0%,
        var(--accent-light, #e8d48a) 100%
    );
    font-weight: 600;
    box-shadow: 0 2px 8px var(--accent-glow, rgba(201, 162, 39, 0.3));
    cursor: default;
}

/* ─── Controls Container ─── */
.museo-header__controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ─── Audio Button ─── */
.museo-header__audio-btn {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 38px;
    height: 38px;

    background: transparent;
    border: 1px solid var(--border-color, rgba(201, 162, 39, 0.2));
    border-radius: var(--radius-sm, 4px);

    color: var(--text-muted, rgba(245, 245, 245, 0.7));
    cursor: pointer;

    transition: all 0.3s ease;
}

.museo-header__audio-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.museo-header__audio-btn:hover {
    color: var(--accent, #c9a227);
    border-color: var(--border-hover, rgba(201, 162, 39, 0.4));
    background: rgba(201, 162, 39, 0.08);
}

.museo-header__audio-btn:hover svg {
    transform: scale(1.1);
}

.museo-header__audio-btn.playing {
    color: var(--accent, #c9a227);
    border-color: var(--accent, #c9a227);
    animation: audioPulse 1.5s ease-in-out infinite;
}

@keyframes audioPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow, rgba(201, 162, 39, 0.4)); }
    50% { box-shadow: 0 0 12px 2px var(--accent-glow, rgba(201, 162, 39, 0.3)); }
}

/* ─── Account Button ─── */
.museo-header__account-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;

    padding: 0.5rem 0.85rem;

    background: transparent;
    border: 1px solid var(--border-color, rgba(201, 162, 39, 0.2));
    border-radius: var(--radius-sm, 4px);

    color: var(--text-muted, rgba(245, 245, 245, 0.7));
    font-family: var(--font-ui, 'DM Sans', sans-serif);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;

    cursor: pointer;
    overflow: hidden;

    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.museo-header__account-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-glow, rgba(201, 162, 39, 0.15)) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.museo-header__account-btn:hover {
    border-color: var(--border-hover, rgba(201, 162, 39, 0.4));
    color: var(--accent-light, #e8d48a);
}

.museo-header__account-btn:hover::before {
    opacity: 1;
}

.museo-header__account-btn svg {
    position: relative;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.museo-header__account-btn:hover svg {
    transform: scale(1.1);
}

.museo-header__account-status {
    position: relative;
    font-size: 0.6rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logged-in state */
.museo-header__account-btn.logged-in {
    border-color: var(--accent, #c9a227);
    color: var(--accent, #c9a227);
}

.museo-header__account-btn.logged-in::after {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    background: var(--accent, #c9a227);
    border-radius: 50%;
    animation: accountPulse 2s ease-in-out infinite;
}

@keyframes accountPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .museo-header {
        padding: 0 1.5rem;
    }

    .museo-header__right {
        gap: 0.75rem;
    }

    .museo-header__brand-text {
        font-size: 0.95rem;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile Large
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
    .museo-header__logo {
        display: none;
    }

    .museo-header__brand-text {
        font-size: 0.9rem;
        letter-spacing: 0.08em;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .museo-header {
        height: 58px;
        padding: 0 1rem;
    }

    .museo-header__nav {
        min-width: auto;
    }

    .museo-header__back {
        font-size: 0.65rem;
        padding: 0.4rem 0.75rem;
    }

    .museo-header__brand {
        display: none;
    }

    .museo-header__right {
        min-width: auto;
        gap: 0.5rem;
    }

    .museo-header__lang-btn {
        font-size: 0.65rem;
        padding: 0.35rem 0.6rem;
    }

    .museo-header__audio-btn {
        width: 34px;
        height: 34px;
    }

    .museo-header__audio-btn svg {
        width: 16px;
        height: 16px;
    }

    .museo-header__account-btn {
        padding: 0.4rem 0.65rem;
    }

    .museo-header__account-status {
        display: none;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile Small
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
    .museo-header {
        padding: 0 0.75rem;
    }

    .museo-header__back {
        padding: 0.35rem 0.6rem;
        font-size: 0.6rem;
    }

    .museo-header__back::before {
        margin-right: 0;
    }

    .museo-header__lang {
        padding: 3px;
    }

    .museo-header__lang-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.6rem;
    }
}

/* ═══════════════════════════════════════════
   BOOK CONTROLS — Theme Toggle
   ═══════════════════════════════════════════ */
.museo-header__theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 38px;
    height: 38px;

    background: transparent;
    border: 1px solid var(--border-color, rgba(201, 162, 39, 0.2));
    border-radius: var(--radius-sm, 4px);

    color: var(--text-muted, rgba(245, 245, 245, 0.7));
    cursor: pointer;

    transition: all 0.3s ease;
}

.museo-header__theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.4s ease;
}

.museo-header__theme-toggle:hover {
    color: var(--accent, #c9a227);
    border-color: var(--border-hover, rgba(201, 162, 39, 0.4));
    background: rgba(201, 162, 39, 0.08);
}

.museo-header__theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* ═══════════════════════════════════════════
   BOOK CONTROLS — Font Size
   ═══════════════════════════════════════════ */
.museo-header__font-controls {
    display: flex;
    align-items: center;
    gap: 2px;

    padding: 3px;
    background: rgba(201, 162, 39, 0.06);
    border: 1px solid rgba(201, 162, 39, 0.15);
    border-radius: 6px;
}

.museo-header__font-btn {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    background: transparent;
    border: none;
    border-radius: 4px;

    color: var(--text-dim, rgba(245, 245, 245, 0.5));
    font-family: var(--font-ui, 'DM Sans', sans-serif);
    font-size: 0.75rem;
    font-weight: 600;

    cursor: pointer;
    transition: all 0.3s ease;
}

.museo-header__font-btn:hover {
    color: var(--text-muted, rgba(245, 245, 245, 0.8));
    background: rgba(255, 255, 255, 0.05);
}

.museo-header__font-btn:active {
    transform: scale(0.95);
}

.museo-header__font-btn--decrease {
    font-size: 0.65rem;
}

.museo-header__font-btn--increase {
    font-size: 0.85rem;
}

.museo-header__font-divider {
    width: 1px;
    height: 20px;
    background: rgba(201, 162, 39, 0.2);
    margin: 0 2px;
}

/* ═══════════════════════════════════════════
   DAY MODE — Light Theme for Reading
   ═══════════════════════════════════════════ */
.museo-header--day {
    background: linear-gradient(
        180deg,
        rgba(248, 246, 241, 0.98) 0%,
        rgba(245, 243, 238, 0.95) 100%
    );
    border-bottom-color: rgba(139, 112, 25, 0.15);
}

.museo-header--day .museo-header__back {
    color: rgba(50, 50, 50, 0.8);
    border-color: rgba(139, 112, 25, 0.25);
    background: rgba(139, 112, 25, 0.05);
}

.museo-header--day .museo-header__back:hover {
    color: var(--oro-scuro, #8b7019);
    border-color: rgba(139, 112, 25, 0.4);
    background: rgba(139, 112, 25, 0.1);
}

.museo-header--day .museo-header__brand-text {
    color: rgba(50, 50, 50, 0.7);
}

.museo-header--day .museo-header__logo-text {
    color: var(--oro-scuro, #8b7019);
}

.museo-header--day .museo-header__logo-diamond {
    border-color: var(--oro-scuro, #8b7019);
}

.museo-header--day .museo-header__logo-diamond::before {
    background: var(--oro-scuro, #8b7019);
}

.museo-header--day .museo-header__lang {
    background: rgba(139, 112, 25, 0.06);
    border-color: rgba(139, 112, 25, 0.15);
}

.museo-header--day .museo-header__lang-btn {
    color: rgba(50, 50, 50, 0.5);
}

.museo-header--day .museo-header__lang-btn.active {
    color: #f8f6f1;
}

.museo-header--day .museo-header__theme-toggle,
.museo-header--day .museo-header__account-btn {
    color: rgba(50, 50, 50, 0.6);
    border-color: rgba(139, 112, 25, 0.2);
}

.museo-header--day .museo-header__theme-toggle:hover,
.museo-header--day .museo-header__account-btn:hover {
    color: var(--oro-scuro, #8b7019);
    border-color: rgba(139, 112, 25, 0.4);
    background: rgba(139, 112, 25, 0.08);
}

.museo-header--day .museo-header__font-controls {
    background: rgba(139, 112, 25, 0.06);
    border-color: rgba(139, 112, 25, 0.15);
}

.museo-header--day .museo-header__font-btn {
    color: rgba(50, 50, 50, 0.5);
}

.museo-header--day .museo-header__font-btn:hover {
    color: rgba(50, 50, 50, 0.8);
    background: rgba(139, 112, 25, 0.1);
}

.museo-header--day .museo-header__font-divider {
    background: rgba(139, 112, 25, 0.2);
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Book Controls
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .museo-header__theme-toggle {
        width: 34px;
        height: 34px;
    }

    .museo-header__theme-toggle svg {
        width: 16px;
        height: 16px;
    }

    .museo-header__font-controls {
        padding: 2px;
    }

    .museo-header__font-btn {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }

    .museo-header__font-btn--decrease {
        font-size: 0.55rem;
    }

    .museo-header__font-btn--increase {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .museo-header__font-controls {
        display: none;
    }
}

/* ═══════════════════════════════════════════
   UTILITY — No Animation (Accessibility)
   ═══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .museo-header {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .museo-header__back::before,
    .museo-header__logo-diamond,
    .museo-header__audio-btn svg,
    .museo-header__account-btn svg,
    .museo-header__theme-toggle svg {
        transition: none;
    }
}

/* ═══════════════════════════════════════════
   TOUR SPECIFIC — Manual visibility control
   ═══════════════════════════════════════════ */

/* Override animation for manual control in tour */
.museo-header--tour {
    opacity: 0;
    transform: translateY(-100%);
    animation: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.museo-header--tour.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Back button visibility toggle */
.museo-header__back--hidden {
    opacity: 0;
    pointer-events: none;
}

.museo-header__back.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Home/Atrio button for tour */
.museo-header__home {
    font-family: var(--font-ui, 'DM Sans', sans-serif);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(245, 245, 245, 0.8);
    text-decoration: none;
    background: rgba(201, 162, 39, 0.04);
    border: 1px solid rgba(201, 162, 39, 0.2);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

/* Hide home button when not needed */
.museo-header__home.hidden {
    opacity: 0;
    pointer-events: none;
}

.museo-header__home::before {
    content: '←';
    font-size: 0.85rem;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.museo-header__home:hover {
    color: var(--accent, #c9a227);
    background: rgba(201, 162, 39, 0.1);
    border-color: rgba(201, 162, 39, 0.4);
}

.museo-header__home:hover::before {
    opacity: 1;
    transform: translateX(-3px);
}

/* Audio button toggle states */
.museo-header__audio-btn .audio-icon--off {
    display: none;
}

.museo-header__audio-btn.muted .audio-icon--on {
    display: none;
}

.museo-header__audio-btn.muted .audio-icon--off {
    display: block;
}
