/**
 * Header Component Styles
 * Nowy Tydzień Theme
 * 
 * @package NowyTydzien
 * @author Rafał Dziewa
 * @link https://dziewa.pl/
 * @version 2.0.0
 */

/* ============================================
   iOS SCROLL LOCK
   Used by MobileMenuModule + SearchModule — overflow:hidden alone doesn't
   prevent background scroll on iOS Safari; position:fixed is required.
   ============================================ */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* top is set via JS to preserve scroll position */
}

/* ============================================
   SPACING OVERRIDE — ochrona przed A-/A+
   Zmienne --space-* w variables.css są w rem (skalują się z root font-size).
   Nadpisujemy je na stałe px w nagłówku, aby A-/A+ nie zmieniało layoutu.
   ============================================ */
.top-bar,
.site-header,
.mobile-header {
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
}

/* ============================================
   MOBILE HEADER — styl Onet
   Widoczny tylko na ≤768px. Dwa rzędy:
   Rząd 1: logo + ikony akcji
   Rząd 2: zakładki kategorii + ••• (więcej)
   ============================================ */
.mobile-header {
    display: none;
}

.mobile-header__tabs {
    display: none;
}

@media (max-width: 1024px) {
    .mobile-header {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: calc(var(--z-index-header) + 2);
        background: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* --- Row 1: Logo + Icons --- */
    .mobile-header__top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 12px;
        min-height: 48px;
        border-bottom: 1px solid #f0f0f0;
    }

    .mobile-header__logo a {
        display: flex;
        align-items: center;
        text-decoration: none;
    }

    .mobile-header__logo img {
        height: 32px;
        width: auto;
        display: block;
    }

    .mobile-header__site-title {
        font-size: 18px;
        font-weight: 700;
        color: var(--color-primary);
    }

    .mobile-header__actions {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-header__icon {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        padding: 4px 6px 2px;
        border-radius: 8px;
        color: #333;
        text-decoration: none;
        transition: background 0.15s ease, color 0.15s ease;
        gap: 1px;
    }

    .mobile-header__icon:hover,
    .mobile-header__icon:focus-visible {
        background: rgba(225, 27, 34, 0.08);
        color: var(--color-primary);
    }

    .mobile-header__icon svg {
        flex-shrink: 0;
    }

    .mobile-header__icon-label {
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0.3px;
        line-height: 1;
        color: inherit;
        text-transform: uppercase;
    }

    .mobile-header__icon--cart {
        position: relative;
    }

    .mobile-header__cart-count {
        display: none;
        position: absolute;
        top: 2px;
        right: 4px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        font-size: 10px;
        font-weight: 700;
        line-height: 16px;
        text-align: center;
        color: #fff;
        background: var(--color-primary);
        border-radius: 8px;
    }

    .mobile-header__cart-count.has-items {
        display: block;
    }

    /* --- Row 2: Category Tabs --- */
    .mobile-header__tabs {
        display: flex;
        align-items: stretch;
        background: var(--color-primary);
        overflow: visible;
        overflow-x: clip;
        position: fixed;
        top: 49px;
        left: 0;
        right: 0;
        z-index: calc(var(--z-index-header) + 3);
        width: 100%;
        max-width: 100vw;
    }

    .mobile-header__tab {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 4px;
        color: rgba(255, 255, 255, 0.85);
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border: none;
        background: transparent;
        cursor: pointer;
        transition: color 0.15s ease, background 0.15s ease;
        position: relative;
        -webkit-tap-highlight-color: transparent; /* iOS: no blue flash on tap */
    }

    .mobile-header__tab:hover,
    .mobile-header__tab:focus-visible {
        color: #fff;
        background: rgba(255, 255, 255, 0.12);
    }

    /* "Kup Gazetę" — delikatne pulsowanie */
    .mobile-header__tab:nth-child(2) {
        animation: tab-pulse 3s ease-in-out infinite;
    }

    @keyframes tab-pulse {
        0%, 100% { background: transparent; }
        50% { background: rgba(255, 255, 255, 0.18); }
    }

    .mobile-header__tab--active {
        color: #fff;
        background: rgba(0, 0, 0, 0.15);
    }

    .mobile-header__tab--active::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 20%;
        right: 20%;
        height: 3px;
        background: #fff;
        border-radius: 3px 3px 0 0;
    }

    /* Show only first 4 tabs, rest hidden */
    .mobile-header__tabs > a.mobile-header__tab:nth-child(n+5) {
        display: none;
    }

    /* Expanded dropdown panel — overlays body, doesn't push it */
    .mobile-header__tabs-dropdown {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--color-primary);
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
        border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
        padding: 8px 6px 10px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .mobile-header__tabs-dropdown.mobile-header__tabs-dropdown--open {
        display: flex;
        justify-content: flex-end;
    }

    .mobile-header__tabs-dropdown a.mobile-header__tab {
        flex: 0 0 auto;
        padding: 6px 14px;
        font-size: 11px;
        letter-spacing: 0.4px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 20px;
        color: rgba(255, 255, 255, 0.92);
        white-space: nowrap;
    }

    .mobile-header__tabs-dropdown a.mobile-header__tab:hover,
    .mobile-header__tabs-dropdown a.mobile-header__tab:focus-visible {
        background: rgba(255, 255, 255, 0.28);
        color: #fff;
    }

    .mobile-header__tab--more {
        flex: 0 0 46px;
        max-width: 46px;
        padding: 10px 0;
        color: #fff;
        background: rgba(0, 0, 0, 0.18);
        border-left: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 0;
    }

    .mobile-header__tab--more:hover,
    .mobile-header__tab--more:focus-visible {
        color: #fff;
        background: rgba(0, 0, 0, 0.28);
    }

    /* Animated hamburger → X */
    .mobile-header__tab--more svg line {
        transition: transform 0.25s ease, opacity 0.2s ease;
        transform-origin: center;
    }

    .mobile-header__tab--more.is-active svg line:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-header__tab--more.is-active svg line:nth-child(2) {
        opacity: 0;
    }

    .mobile-header__tab--more.is-active svg line:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    /* --- Ukryj stary header na mobile + tablet --- */
    .site-header {
        display: none !important;
    }

    body.admin-bar .mobile-header {
        top: 46px;
    }

    body.admin-bar .mobile-header__tabs {
        top: calc(49px + 46px);
    }
}

/* Top-bar ukryty tylko na mobile (tablet zachowuje) */
@media (max-width: 768px) {
    .top-bar {
        display: none !important;
    }
}

/* Tablet: mobile-header poniżej top-bar */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-header {
        top: var(--topbar-height);
        transition: top var(--transition-base);
    }

    .mobile-header__tabs {
        top: calc(49px + var(--topbar-height));
        transition: top var(--transition-base);
    }

    body.top-bar-hidden .mobile-header {
        top: 0;
    }

    body.top-bar-hidden .mobile-header__tabs {
        top: 49px;
    }

    body.admin-bar .mobile-header {
        top: calc(var(--topbar-height) + 32px);
    }

    body.admin-bar .mobile-header__tabs {
        top: calc(49px + var(--topbar-height) + 32px);
    }

    body.admin-bar.top-bar-hidden .mobile-header {
        top: 32px;
    }

    body.admin-bar.top-bar-hidden .mobile-header__tabs {
        top: calc(49px + 32px);
    }
}

/* Dark mode for mobile header */
@media (max-width: 1024px) {
    body.dark-mode .mobile-header {
        background: var(--bg-primary, #1a1a1a);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    body.dark-mode .mobile-header__top {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    body.dark-mode .mobile-header__site-title {
        color: #fff;
    }
    body.dark-mode .mobile-header__icon {
        color: #ddd;
    }
    body.dark-mode .mobile-header__icon:hover,
    body.dark-mode .mobile-header__icon:focus-visible {
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================
   TOP BAR
   ============================================ */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: calc(var(--z-index-header) + 1);
    transition: transform var(--transition-base);
}

.top-bar.hidden {
    transform: translateY(-100%);
}

.top-bar-inner {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

@media (max-width: 768px) {
    .top-bar-inner {
        padding: 0 var(--space-md);
    }
}

/* Weather Widget */
.top-bar-left {
    display: flex;
    align-items: center;
}

.weather-widget {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
}

.weather-widget svg {
    flex-shrink: 0;
}

.weather-text {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.weather-text strong {
    font-weight: var(--font-weight-semibold);
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
}

/* Social Icons */
.top-bar-right {
    display: flex;
    align-items: center;
}

.social-icons {
    display: flex;
    gap: var(--space-sm);
}

.social-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.social-icons a:hover {
    color: var(--color-primary);
    transform: translateY(-2px);
}

.social-icons a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ============================================
   MAIN HEADER
   ============================================ */
.site-header {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    box-shadow: var(--shadow-md);
    z-index: var(--z-index-header);
    transition: top var(--transition-base), box-shadow var(--transition-base), height var(--transition-base);
}

body.top-bar-hidden .site-header {
    top: 0;
}

.site-header.scrolled {
    box-shadow: var(--shadow-lg);
    height: 56px;
}

.header-inner {
    --header-padding-x: var(--space-xl);
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--header-padding-x);
    height: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: var(--space-lg);
    transition: gap var(--transition-base), padding var(--transition-base), max-width var(--transition-base);
}


.site-header.scrolled .header-inner {
    --header-padding-x: var(--space-md);
    max-width: var(--container-max-width);
    gap: var(--space-md);
    padding: 0 var(--header-padding-x);
}

@media (max-width: 1024px) {
    .header-inner {
        grid-template-columns: auto 1fr auto auto;
        gap: var(--space-md);
        padding: 0 var(--space-md);
        background: var(--bg-header);
    }
}

/* ============================================
   HEADER ACTIONS (Search + Accessibility)
   ============================================ */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

@media (max-width: 1024px) {
    .header-actions {
        gap: var(--space-xs);
    }
}

/* ============================================
   HEADER CART ICON + MINI-CART DROPDOWN
   ============================================ */
.header-cart-wrapper {
    position: relative;
}

.header-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 10px;
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm, 4px);
    transition: opacity var(--transition-base);
    position: relative;
}

.header-cart:hover {
    opacity: 0.85;
    color: #fff;
}

.header-cart svg {
    flex-shrink: 0;
    stroke: #fff;
}

.header-cart-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
    line-height: 1;
}

.header-cart-count {
    position: absolute;
    top: -2px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    color: #fff;
    background: var(--color-border);
    border-radius: 9px;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.header-cart-count.has-items {
    opacity: 1;
    transform: scale(1);
    background: var(--color-primary);
}

/* Dropdown mini-cart */
.header-cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    background: #fff;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 9999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    margin-top: 4px;
}

.header-cart-wrapper:hover .header-cart-dropdown,
.header-cart-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Arrow/triangle */
.header-cart-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);
}

.header-cart-dropdown-inner {
    padding: var(--space-md, 16px);
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: inherit;
}

/* Cart items list */
.header-cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.header-cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.header-cart-item:last-child {
    border-bottom: none;
}

.header-cart-item-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm, 4px);
    overflow: hidden;
    display: block;
    text-decoration: none;
}

.header-cart-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-cart-item-info {
    flex: 1;
    min-width: 0;
}

.header-cart-item-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #333);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    transition: color 0.15s ease;
}

.header-cart-item-name:hover {
    color: var(--color-primary, #e11b22);
}

.header-cart-item-qty {
    display: block;
    font-size: 12px;
    color: var(--text-secondary, #666);
    margin-top: 2px;
}

/* Remove button */
.header-cart-item-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    color: #999;
    text-decoration: none;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}

.header-cart-item-remove:hover {
    color: var(--color-primary, #e11b22);
    background: #fef2f2;
}

/* Total */
.header-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 8px;
    border-top: 2px solid #f0f0f0;
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-primary, #333);
}

/* Buttons */
.header-cart-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.header-cart-btn {
    flex: 1;
    display: inline-block;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius-sm, 4px);
    transition: background 0.2s ease, color 0.2s ease;
}

.header-cart-btn--view {
    background: #f0f0f0;
    color: var(--text-primary, #333);
}

.header-cart-btn--view:hover {
    background: #e0e0e0;
    color: var(--text-primary, #333);
}

.header-cart-btn--checkout {
    background: var(--color-primary, #e11b22);
    color: #fff;
}

.header-cart-btn--checkout:hover {
    background: var(--color-primary-dark, #c01820);
    color: #fff;
}

/* Empty cart */
.header-cart-empty {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary, #666);
    font-size: 13px;
    margin: 0;
}

/* Scrolled header — compact */
.site-header.scrolled .header-cart svg {
    width: 16px;
    height: 16px;
}

.site-header.scrolled .header-cart-label {
    font-size: 9px;
}

/* Mobile — hide dropdown, keep icon */
@media (max-width: 768px) {
    .header-cart-dropdown {
        display: none;
    }
    
    .header-cart-label {
        font-size: 9px;
    }
    
    .header-cart {
        padding: 4px 6px;
    }
}

/* ============================================
   MOBILE MENU TOGGLE
   ============================================ */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 22px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: calc(var(--z-index-header) + 2);
    -webkit-tap-highlight-color: transparent; /* iOS: no blue flash on tap */
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-light);
    border-radius: var(--radius-sm);
    transition: transform var(--transition-base), opacity var(--transition-base);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(9.5px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-9.5px) rotate(-45deg);
}

@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

/* ============================================
   LOGO
   ============================================ */
.site-logo {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 0 var(--space-md) 0 var(--space-md);
    height: 100%;
    flex-shrink: 0;
    min-width: fit-content;
    transition: padding var(--transition-base);
}

.site-logo a {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 40px;
    min-height: 40px;
    width: auto;
    min-width: 120px;
    max-width: 200px;
    object-fit: contain;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .logo-img {
        height: 32px;
        min-height: 32px;
        min-width: 100px;
    }
}

.site-header.scrolled .site-logo {
    padding: 0 var(--space-sm) 0 var(--space-md);
}

.site-header.scrolled .logo-img {
    height: 36px;
    min-height: 36px;
}

/* ============================================
   MAIN NAVIGATION
   ============================================ */
.main-navigation {
    display: flex;
    align-items: center;
}

.main-navigation ul {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-navigation a {
    display: block;
    color: var(--text-light);
    font-weight: var(--font-weight-medium);
    font-size: 14px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), padding var(--transition-fast), font-size var(--transition-fast);
}

.site-header.scrolled .main-navigation a {
    padding: var(--space-xs) var(--space-sm);
    font-size: 13px;
}

.main-navigation a:hover,
.main-navigation a:focus {
    background: rgba(255, 255, 255, 0.1);
}

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
    background: rgba(255, 255, 255, 0.2);
    font-weight: var(--font-weight-semibold);
}

/* Old submenu styles removed — consolidated at end of file (SUBMENU section) */

@media (max-width: 1024px) {
    .nav-menu > li > ul.sub-menu {
        display: none;
    }
}

@media (min-width: 1025px) {
    .main-navigation {
        flex: 1;
    }
    .main-navigation,
    .main-navigation > ul.nav-menu {
        height: 100%;
    }
    .main-navigation ul.nav-menu {
        gap: 0;
        justify-content: center;
        width: 100%;
    }
    /* Exclude submenu from height: 100% */
    .main-navigation ul.sub-menu {
        height: auto !important;
    }
    .main-navigation li {
        height: 100%;
        flex: 1;
        max-width: 180px;
        overflow: visible;
    }
    /* Submenu items should not stretch */
    .main-navigation ul.sub-menu > li {
        height: auto;
        flex: 0 0 auto;
        max-width: none;
    }
    .main-navigation a {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 var(--space-md);
        border-radius: 0;
    }
    .site-header.scrolled .main-navigation a {
        padding: 0 var(--space-sm);
        font-size: 13px;
    }
    /* Keep submenu size after scroll */
    .site-header.scrolled .nav-menu ul.sub-menu > li > a {
        padding: 10px 16px;
        font-size: 12px;
    }
}

@media (max-width: 1024px) {
    .main-navigation {
        position: fixed;
        top: calc(var(--topbar-height) + var(--header-height));
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-header);
        padding: var(--space-xl) var(--space-lg);
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* iOS smooth momentum scroll */
    }
    
    body.top-bar-hidden .main-navigation {
        top: var(--header-height);
    }
    
    .main-navigation.active {
        transform: translateX(0);
    }
    
    .main-navigation ul {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    
    .main-navigation a {
        padding: var(--space-md);
        font-size: 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Nav slide-in: position below new mobile header on small screens */
@media (max-width: 768px) {
    .main-navigation {
        top: 88px !important; /* height of mobile-header (48+40) */
        z-index: calc(var(--z-index-header) + 1);
    }
    body.admin-bar .main-navigation {
        top: 134px !important; /* 88 + 46px admin bar */
    }
}

/* Mobile Top Menu */
.mobile-top-menu {
    display: none;
}

@media (max-width: 1024px) {
    .mobile-top-menu {
        display: block;
        padding-bottom: var(--space-md);
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        margin-bottom: var(--space-md);
    }

    .top-menu-nav-mobile {
        display: flex;
        flex-direction: column;
        list-style: none;
        margin: 0;
        padding: 0;
        gap: 0;
    }

    .top-menu-nav-mobile > li {
        position: relative;
    }

    .top-menu-nav-mobile a {
        display: block;
        padding: var(--space-md);
        color: var(--text-light);
        font-size: 14px;
        font-weight: var(--font-weight-medium);
        text-decoration: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        transition: background-color var(--transition-fast);
    }

    .top-menu-nav-mobile a:hover {
        background-color: rgba(225, 27, 34, 0.15);
        color: #e11b22;
    }

    /* Mobile Top Menu Submenu */
    .top-menu-nav-mobile ul {
        display: none;
        flex-direction: column;
        list-style: none;
        margin: 0;
        padding: 0;
        background: rgba(0, 0, 0, 0.2);
    }

    .top-menu-nav-mobile > li > a::after {
        content: '';
        display: inline-block;
        margin-left: 8px;
        transition: transform var(--transition-fast);
    }

    .top-menu-nav-mobile > li:has(> ul) > a::after {
        content: '▼';
        font-size: 10px;
    }

    .top-menu-nav-mobile > li.expanded > a::after {
        transform: rotate(180deg);
    }

    .top-menu-nav-mobile ul.active {
        display: flex;
    }

    .top-menu-nav-mobile ul a {
        padding-left: calc(var(--space-md) * 2);
        font-size: 13px;
        color: var(--text-secondary);
    }

    .top-menu-nav-mobile ul a:hover {
        background-color: rgba(225, 27, 34, 0.25);
        color: #e11b22;
    }
}

/* ============================================
   SEARCH FORM (Desktop)
   ============================================ */
.search-form-desktop {
    display: flex;
    align-items: center;
}

.search-form-inner {
    position: relative;
    display: flex;
    align-items: center;
}

.search-field {
    width: 200px;
    padding: var(--space-sm) var(--space-lg) var(--space-sm) var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 14px;
    transition: width var(--transition-base), background-color var(--transition-fast);
}

.search-field::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-field:focus {
    width: 260px;
    background: rgba(255, 255, 255, 0.15);
    outline: 2px solid rgba(255, 255, 255, 0.4);
}

.search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: background-color var(--transition-fast);
}

.search-submit:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-submit-text {
    display: none;
}

@media (max-width: 1024px) {
    .search-form-desktop {
        display: none;
    }
}

/* ============================================
   ACCESSIBILITY TOOLS
   ============================================ */
.accessibility-tools {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.accessibility-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.accessibility-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.accessibility-btn:active,
.accessibility-btn[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Wskaźnik aktywnego stanu - kropka */
.accessibility-btn[aria-pressed="true"]::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Font Size Controls — inline A- | 100% | A+ */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.font-size-btn {
    width: auto;
    min-width: 34px;
    height: 36px;
    padding: 0 8px;
    border: none;
    border-radius: 0;
    font-size: 12px;
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.3px;
    background: rgba(255, 255, 255, 0.1);
}

.font-size-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: none;
}

.font-size-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.font-size-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
}

.font-size-value-btn {
    min-width: 44px;
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

.font-size-value-btn {
    flex-direction: column;
    line-height: 1;
    padding: 3px 8px;
    gap: 1px;
}

.font-size-value-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.font-size-reset-label {
    font-size: 8px;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    line-height: 1;
}

/* Theme Dropdown */
.theme-dropdown {
    position: relative;
}

.theme-toggle-btn {
    width: auto;
    min-width: 52px;
    padding: 0 10px;
    gap: 4px;
}

.theme-icon {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.theme-icon-dark {
    display: none;
}

body.dark-mode .theme-icon-light {
    display: none;
}

body.dark-mode .theme-icon-dark {
    display: block;
}

.theme-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 140px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    list-style: none;
    margin: 0;
    padding: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: var(--z-index-dropdown);
}

.theme-dropdown.open .theme-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-dropdown-menu li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.theme-dropdown-menu li:hover {
    background: var(--bg-secondary);
}

.theme-dropdown-menu li[aria-selected="true"] {
    background: var(--color-primary);
    color: var(--text-light);
}

.theme-dropdown-menu li[aria-selected="true"] svg {
    color: var(--text-light);
}

/* Strzałka dropdown */
.theme-arrow {
    opacity: 0.7;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle-btn:hover .theme-arrow {
    opacity: 1;
}

.theme-dropdown.open .theme-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

@media (max-width: 768px) {
    .accessibility-tools {
        gap: 2px;
    }
    
    .accessibility-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .theme-arrow {
        display: none;
    }
    
    .theme-dropdown-menu {
        right: -10px;
    }
}

/* ============================================
   MOBILE COLOR INVERSION
   ============================================ */
@media (max-width: 768px) {
    .site-header {
        background: #fff;
        box-shadow: var(--shadow-md);
    }

    .mobile-menu-toggle .hamburger-line {
        background: var(--color-primary);
    }

    .accessibility-btn {
        background: #fff;
        border-color: rgba(225, 27, 34, 0.6);
        color: var(--color-primary);
    }

    .accessibility-btn:hover {
        background: rgba(225, 27, 34, 0.08);
    }

    .accessibility-btn:active,
    .accessibility-btn[aria-pressed="true"] {
        background: rgba(225, 27, 34, 0.16);
        border-color: rgba(225, 27, 34, 0.8);
        box-shadow: inset 0 0 0 2px rgba(225, 27, 34, 0.3);
    }
    
    .accessibility-btn[aria-pressed="true"]::after {
        background: #16a34a;
        border-color: rgba(225, 27, 34, 0.3);
    }
}

/* ==================================================
   SUBMENU — full-width dropdown bar (moved from inline header.php)
   ================================================== */

/* Parent overflow fix - !important needed to override other CSS */
.site-header,
.header-inner,
.main-navigation,
.nav-menu,
.nav-menu > li {
    overflow: visible !important;
}

/* Dropdown submenu — full-width secondary bar */
@media (min-width: 1025px) {
    .nav-menu > li {
        position: static !important;
    }
    .nav-menu > li > ul.sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        display: flex;
        flex-flow: row nowrap;
        align-items: center;
        justify-content: center;
        gap: 0;
        background: #f5f5f5;
        border-top: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        padding: 0 24px;
        margin-top: 0;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease 0.5s, visibility 0.2s ease 0.5s;
        z-index: 999999;
        list-style: none;
    }
    .nav-menu > li:hover > ul.sub-menu,
    .nav-menu > li:focus-within > ul.sub-menu,
    .nav-menu > li.submenu-open > ul.sub-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    .nav-menu > li > ul.sub-menu > li {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        min-width: 0;
        height: auto !important;
        background: transparent;
        list-style: none;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        position: relative;
    }
    /* Separator between items */
    .nav-menu > li > ul.sub-menu > li + li::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 14px;
        background: #ccc;
    }
    .nav-menu > li > ul.sub-menu > li > a {
        display: block;
        height: auto !important;
        color: #555;
        background: transparent;
        padding: 10px 16px;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        white-space: nowrap;
        text-decoration: none;
        transition: color 0.2s ease;
    }
    .nav-menu > li > ul.sub-menu > li > a:hover,
    .nav-menu > li > ul.sub-menu > li > a:focus {
        color: #e11b22;
    }
}
@media (max-width: 1024px) {
    .nav-menu > li > ul.sub-menu {
        display: none !important;
    }
}
