/* ==========================================================================
   FIORE PAKLENICA - Header & Navigation System
   Stable, cross-device implementation
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties for Header System
   ========================================================================== */
:root {
    --header-height: 80px;
    --notification-height: 40px;
    --header-z-index: 1000;
    --notification-z-index: 1001;
    --mobile-nav-z-index: 1002;
    --nav-toggle-z-index: 1003;
}

/* ==========================================================================
   Notification Bar - Fixed at top, independent of header
   ========================================================================== */
.notification-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--notification-z-index);
    min-height: var(--notification-height);
    padding: 8px 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, #2d5a4a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.notification-bar.hidden {
    transform: translateY(-100%);
    pointer-events: none;
}

.notification-bar__content {
    flex: 1;
    text-align: center;
    padding: 0 60px;
}

.notification-bar__text {
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    letter-spacing: 0.03em;
    margin: 0;
}

.notification-bar__close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.notification-bar__close:hover,
.notification-bar__close:focus {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    outline: none;
}

.notification-bar__close:active {
    background: rgba(255, 255, 255, 0.25);
}

.notification-bar__close svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* ==========================================================================
   Header - Positioned below notification bar
   ========================================================================== */
.header {
    position: fixed;
    top: var(--notification-height);
    left: 0;
    right: 0;
    z-index: var(--header-z-index);
    height: var(--header-height);
    display: flex;
    align-items: center;
    /* No transitions until JS ready - prevents jump on page load */
    transition: none;
}

/* Enable transitions only after JS has initialized */
body.js-loaded .header {
    transition:
        top 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s ease,
        box-shadow 0.3s ease;
    will-change: top, background;
}

/* When notification is hidden, header moves to top */
.notification-bar.hidden ~ .header,
body:not(.has-notification) .header {
    top: 0;
}

/* Header background overlay for transparency on hero */
.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0%, transparent 100%);
    pointer-events: none;
    opacity: 1;
    transition: none;
}

body.js-loaded .header::before {
    transition: opacity 0.3s ease;
}

/* Scrolled state - no height change to prevent layout shift */
.header--scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.header--scrolled::before {
    opacity: 0;
}

/* ==========================================================================
   Header Inner Container
   ========================================================================== */
.header__inner {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   Logo
   ========================================================================== */
.header__logo {
    position: relative;
    height: 55px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header__logo img {
    height: 100%;
    width: auto;
    max-width: none;
    transition: none;
}

body.js-loaded .header__logo img {
    transition: opacity 0.3s ease;
}

.header__logo .logo-dark {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.header--scrolled .header__logo .logo-light {
    opacity: 0;
}

.header--scrolled .header__logo .logo-dark {
    opacity: 1;
}

/* ==========================================================================
   Desktop Navigation
   ========================================================================== */
.nav {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.nav__link {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-white);
    position: relative;
    padding: var(--space-xs) 0;
    transition: color 0.2s ease;
}

.nav__link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: currentColor;
    transition: width 0.3s ease;
}

.nav__link:hover::after,
.nav__link.active::after {
    width: 100%;
}

.header--scrolled .nav__link {
    color: var(--color-text);
}

/* ==========================================================================
   Header Actions (Language + CTA)
   ========================================================================== */
.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-switcher__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-white);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.lang-switcher__toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.header--scrolled .lang-switcher__toggle {
    border-color: var(--color-sand);
    color: var(--color-text);
}

.header--scrolled .lang-switcher__toggle:hover {
    background: var(--color-cream);
}

.lang-switcher__toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.lang-switcher.open .lang-switcher__toggle svg {
    transform: rotate(180deg);
}

.lang-switcher__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 140px;
    background: var(--color-white);
    border: 1px solid var(--color-sand);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.lang-switcher.open .lang-switcher__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-switcher__option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.lang-switcher__option:hover {
    background: var(--color-cream);
}

.lang-switcher__option.active {
    background: var(--color-primary);
    color: var(--color-white);
}

/* Language Flags */
.lang-flag,
.lang-switcher__flag {
    overflow: hidden;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.lang-switcher__flag {
    width: 24px;
    height: 17px;
}

.lang-flag {
    width: 22px;
    height: 15px;
    display: inline-block;
    vertical-align: middle;
}

/* Book Now Button */
.btn--header {
    padding: 0.875rem 1.75rem;
    background: var(--color-gold);
    color: var(--color-charcoal);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn--header:hover {
    background: var(--color-gold-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(201, 162, 39, 0.3);
}

.header--scrolled .btn--header {
    background: var(--color-primary);
    color: var(--color-white);
}

.header--scrolled .btn--header:hover {
    background: var(--color-primary-dark);
}

/* ==========================================================================
   Mobile Navigation Toggle
   ========================================================================== */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: var(--nav-toggle-z-index);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nav-toggle__bar {
    width: 24px;
    height: 2px;
    background: var(--color-white);
    transition: all 0.3s ease;
    transform-origin: center;
}

.header--scrolled .nav-toggle__bar {
    background: var(--color-text);
}

/* Hamburger to X animation */
.nav-toggle.active .nav-toggle__bar {
    background: var(--color-white);
}

.nav-toggle.active .nav-toggle__bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active .nav-toggle__bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle.active .nav-toggle__bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* ==========================================================================
   Mobile Controls Container (Language + Hamburger)
   ========================================================================== */
.mobile-controls {
    display: none;
    align-items: center;
    gap: 8px;
}

/* Mobile Language Switcher */
.mobile-lang {
    display: none;
    position: relative;
}

.mobile-lang__toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--color-white);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-lang__toggle:hover,
.mobile-lang__toggle:focus {
    border-color: rgba(255, 255, 255, 0.6);
    outline: none;
}

.mobile-lang__toggle:active {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-lang__toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.mobile-lang.open .mobile-lang__toggle svg {
    transform: rotate(180deg);
}

.header--scrolled .mobile-lang__toggle {
    color: var(--color-text);
    border-color: var(--color-sand);
}

.header--scrolled .mobile-lang__toggle:hover,
.header--scrolled .mobile-lang__toggle:focus {
    border-color: var(--color-text-muted);
}

/* Mobile Language Dropdown */
.mobile-lang__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 130px;
    background: var(--color-white);
    border: 1px solid var(--color-sand);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: calc(var(--nav-toggle-z-index) + 1);
    overflow: hidden;
}

.mobile-lang.open .mobile-lang__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.mobile-lang__option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-lang__option:hover,
.mobile-lang__option:focus {
    background: var(--color-cream);
    outline: none;
}

.mobile-lang__option:active {
    background: var(--color-sand);
}

.mobile-lang__option.active {
    font-weight: 600;
    color: var(--color-primary);
}

.mobile-lang__option .lang-flag {
    width: 20px;
    height: 14px;
}

/* ==========================================================================
   Mobile Navigation Overlay
   Switch to mobile nav at 1024px for better laptop/tablet UX
   ========================================================================== */
@media (max-width: 1024px) {
    .nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        background: var(--color-charcoal);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: var(--space-lg);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: var(--mobile-nav-z-index);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav--open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .nav__link {
        font-size: 5.5vw !important;
        font-weight: 300 !important;
        letter-spacing: 0.15em !important;
        color: var(--color-white) !important;
        padding: 2.5vh 32px !important;
        min-height: 9vh;
        display: flex;
        align-items: center;
        justify-content: center;
        text-transform: uppercase;
    }

    .nav__link::after {
        bottom: 8px;
    }

    .nav-toggle {
        display: flex;
    }

    .mobile-controls {
        display: flex;
    }

    .mobile-lang {
        display: block;
    }

    .header__actions {
        display: none;
    }

    .header__inner {
        gap: var(--space-md);
    }
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --header-height: 70px;
        --header-height-scrolled: 56px;
        --notification-height: 36px;
    }

    .header__logo {
        height: 45px;
    }

    .notification-bar__content {
        padding: 0 50px;
    }

    .notification-bar__text {
        font-size: 0.75rem;
    }

    .notification-bar__close {
        right: 8px;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 64px;
        --header-height-scrolled: 52px;
        --notification-height: 32px;
    }

    .header__logo {
        height: 40px;
    }

    .notification-bar__content {
        padding: 0 44px;
    }

    .notification-bar__text {
        font-size: 0.7rem;
    }

    .mobile-lang__toggle {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .nav-toggle {
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    .nav-toggle__bar {
        width: 22px;
    }
}

@media (max-width: 320px) {
    :root {
        --header-height: 56px;
        --notification-height: 32px;
    }

    .header__logo {
        height: 32px;
    }

    .notification-bar {
        padding: 6px 0;
    }

    .notification-bar__content {
        padding: 0 36px;
    }

    .notification-bar__text {
        font-size: 0.6rem;
        line-height: 1.3;
    }

    .notification-bar__close {
        right: 4px;
    }
}

/* ==========================================================================
   Hero Section Offset (accounts for fixed header + notification)
   ========================================================================== */
.hero {
    padding-top: calc(var(--notification-height) + var(--header-height));
}

body:not(.has-notification) .hero,
.notification-bar.hidden ~ main .hero {
    padding-top: var(--header-height);
}

/* ==========================================================================
   Safe Area Handling (iOS notch, etc.)
   ========================================================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .notification-bar {
        padding-top: env(safe-area-inset-top);
    }

    .header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */
.header,
.notification-bar,
.nav {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .header,
    .notification-bar,
    .nav,
    .lang-switcher__dropdown,
    .mobile-lang__dropdown,
    .nav-toggle__bar {
        transition: none !important;
    }
}
