/*
 * @author      Luděk Nezmar
 * @copyright   2018-2026 ACRESIA Consulting s.r.o.
 * @license     Proprietary – použití podléhá licenčnímu ujednání
 *
 * mod_acresia_header — globální horní lišta ACRESIA Tools.
 * Všechny barvy/typografie/rozměry řídí CSS custom properties nastavované
 * z PHP helperu (admin params); soubor je statický.
 */

/*
 * Modul je globální top bar — musí být na 100 % šířky viewportu, ne jen
 * sloupce, do kterého ho šablona vnoří. Trik:
 *   - width: 100vw + margin-left calc(50% - 50vw) vystoupí z parent paddingu
 *     a zabere celou šířku okna BEZ JS injektáže do body, BEZ úpravy šablony.
 *   - position: relative + z-index udržuje překryv nad cokoliv pod ním (gradient
 *     obrázku šablony, brand logo atd.).
 *   - margin-top/bottom: calc(-1 * padding) vytlačí z vertikálního paddingu
 *     wrapperu (some templates add padding-top na .container-nav).
 */
.acresia-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    min-height: var(--ah-height, 86px);
    height: var(--ah-height, 86px);
    padding: 0 var(--ah-padding-x, 28px);
    color: #fff;
    font-family: var(--ah-font-ui, Inter, system-ui, sans-serif);
    background:
        radial-gradient(1100px 260px at 82% -40%, var(--ah-bg-glow, rgba(64,106,168,.38)), transparent 65%),
        linear-gradient(100deg,
            var(--ah-bg-start, #121E35) 0%,
            var(--ah-bg-mid,   #1B2C4D) 55%,
            var(--ah-bg-end,   #16233E) 100%);
    box-sizing: border-box;
    position: relative;
    z-index: 50;
}

/*
 * Když je modul vykreslen uvnitř template hlavičky `.container-header`
 * (Cassiopeia + odvozeniny), schoval by ho parent gradient. Tyhle pravidla
 * zruší template brand/topbar/below-top/search uvnitř téže hlavičky, takže
 * modul je jediný obsah a vypadá jako standalone full-width header.
 *
 * Selektor je scoped přes :has() — pokud parent toto pravidlo nepodporuje
 * (Safari ≤16, FF ≤120), fallback je benign: modul je stále 100 % wide díky
 * margin trickům výše, jen pod ním probleskne template brand. V tom případě
 * doporučujeme přiřadit modul do pozice mimo `.container-header`.
 */
header.container-header:has(.acresia-header) {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: var(--ah-height, 86px) !important;
}
header.container-header:has(.acresia-header) > .container-topbar,
header.container-header:has(.acresia-header) > .container-below-top,
header.container-header:has(.acresia-header) > .grid-child:not(.container-nav),
header.container-header:has(.acresia-header) .container-search,
header.container-header:has(.acresia-header) .navbar-brand {
    display: none !important;
}
header.container-header:has(.acresia-header) .grid-child.container-nav {
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    max-width: 100vw;
}
/* Skryj VŠECHNY ostatní moduly v pozici menu (např. Main menu CZ z mod_maximenuck),
   modul `acresia-header` poskytuje vlastní navigaci. Když chce admin nechat oba,
   stačí v params nastavit `replace_template_header=0` (vypnout :has() override). */
header.container-header:has(.acresia-header) .container-nav > *:not(.acresia-header) {
    display: none !important;
}

.acresia-header *,
.acresia-header *::before,
.acresia-header *::after { box-sizing: border-box; }

/* ===== Logo lockup ===== */
.acresia-header .ah-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    justify-self: start;
    color: var(--ah-active, var(--ah-brand-orange, #EB953A));
    transition: color .25s ease;
}
.acresia-header .ah-mark {
    display: inline-block;
    width: 42px; height: 42px;
    line-height: 0;
}
.acresia-header .ah-mark svg {
    width: 100%; height: 100%; display: block;
    color: inherit;
    fill: currentColor;
    transition: color .25s ease;
}
.acresia-header .ah-wordmark {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}
.acresia-header .ah-wordmark-1 {
    font-family: var(--ah-font-wordmark, Manrope, system-ui, sans-serif);
    font-weight: 800;
    font-size: var(--ah-wordmark-size-1, 21px);
    letter-spacing: 0.03em;
    color: #fff;
}
.acresia-header .ah-wordmark-2 {
    font-family: var(--ah-font-wordmark, Manrope, system-ui, sans-serif);
    font-weight: 800;
    font-size: var(--ah-wordmark-size-2, 12px);
    letter-spacing: 0.43em;
    margin-top: 4px;
    color: rgba(255,255,255,.45);
}

/* ===== Pill nav ===== */
.acresia-header .ah-nav { display: flex; justify-content: center; }
.acresia-header .ah-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 9999px;
    background: var(--ah-pill-bg, rgba(255,255,255,.07));
    border: 1px solid var(--ah-pill-border, rgba(255,255,255,.10));
    list-style: none;
    margin: 0;
}
.acresia-header .ah-pill li { display: inline-flex; }
.acresia-header .ah-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 13px;
    border-radius: 9999px;
    font-family: var(--ah-font-ui, Inter, system-ui, sans-serif);
    font-weight: 600;
    font-size: var(--ah-item-size, 14px);
    color: var(--ah-item-color, rgba(255,255,255,.72));
    text-decoration: none;
    background: transparent;
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
}
.acresia-header .ah-item:hover {
    color: var(--ah-item-hover-fg, #fff);
    background: var(--ah-item-hover-bg, rgba(255,255,255,.09));
}
.acresia-header .ah-item.is-active {
    color: #fff;
    background: var(--ah-item-active-bg, #2463EB);
}
.acresia-header .ah-item.is-active:hover {
    background: var(--ah-item-active-bg-hover, var(--ah-item-active-bg, #1D4ED8));
}

/* ===== Right cluster ===== */
.acresia-header .ah-right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-self: end;
}

/* Language pill */
.acresia-header .ah-lang { position: relative; }
.acresia-header .ah-lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border-radius: 9999px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.16);
    color: #fff;
    font-family: var(--ah-font-ui, Inter, system-ui, sans-serif);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease;
}
.acresia-header .ah-lang-toggle:hover { background: rgba(255,255,255,.14); }
.acresia-header .ah-flag {
    display: inline-block;
    width: 19px; height: 19px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(15,23,42,.12);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex: 0 0 auto;
}
.acresia-header .ah-flag-cz {
    background-image: linear-gradient(180deg, #fff 0% 50%, #D7141A 50% 100%),
                      linear-gradient(135deg, #11457E 0% 50%, transparent 50% 100%);
    background-blend-mode: normal;
    background:
        linear-gradient(135deg, #11457E 0%, #11457E 50%, transparent 50% 100%),
        linear-gradient(180deg, #fff 0%, #fff 50%, #D7141A 50%, #D7141A 100%);
}
.acresia-header .ah-flag-en {
    background-color: #012169;
    background-image:
        linear-gradient(45deg,  transparent 47%, #fff 47% 53%, transparent 53%),
        linear-gradient(-45deg, transparent 47%, #fff 47% 53%, transparent 53%),
        linear-gradient(0deg,   transparent 42%, #C8102E 42% 58%, transparent 58%),
        linear-gradient(90deg,  transparent 42%, #C8102E 42% 58%, transparent 58%);
}
.acresia-header .ah-flag-de {
    background-image: linear-gradient(180deg, #000 0% 33%, #DD0000 33% 66%, #FFCE00 66% 100%);
}
.acresia-header .ah-flag-sk {
    background-image: linear-gradient(180deg, #fff 0% 33%, #0B4EA2 33% 66%, #EE1C25 66% 100%);
}
.acresia-header .ah-flag-pl {
    background-image: linear-gradient(180deg, #fff 0% 50%, #DC143C 50% 100%);
}
.acresia-header .ah-chevron { opacity: .55; }

.acresia-header .ah-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 10px 15px -3px rgba(15,23,42,.10), 0 4px 6px -4px rgba(15,23,42,.05);
    z-index: 1000;
}
.acresia-header .ah-lang-menu[hidden] { display: none; }
.acresia-header .ah-lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    color: #0F172A;
    text-decoration: none;
    font-family: var(--ah-font-ui, Inter, system-ui, sans-serif);
    font-size: 14px;
}
.acresia-header .ah-lang-item:hover { background: #F1F5F9; }
.acresia-header .ah-lang-item.is-active { font-weight: 600; }
.acresia-header .ah-lang-item.is-active .ah-check { color: var(--ah-brand-orange-hover, #D97F22); margin-left: auto; }
.acresia-header .ah-lang-label { flex: 1; }

/* Auth button */
.acresia-header .ah-auth {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 9999px;
    font-family: var(--ah-font-ui, Inter, system-ui, sans-serif);
    font-weight: 600;
    font-size: 13.5px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, transform .05s ease;
}
.acresia-header .ah-auth:active { transform: scale(.98); }
.acresia-header .ah-auth-ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,.28);
    color: #fff;
}
.acresia-header .ah-auth-ghost:hover { background: rgba(255,255,255,.09); }
.acresia-header .ah-auth-filled {
    background: #fff;
    color: #0F172A;
    border: 1px solid #fff;
}
.acresia-header .ah-auth-filled:hover { background: #E2E8F0; }

/* Responsive: shrink on narrow viewports — keep one-row, no hamburger */
@media (max-width: 1100px) {
    .acresia-header .ah-pill { flex-wrap: wrap; padding: 4px; }
    .acresia-header .ah-item { padding: 6px 10px; font-size: calc(var(--ah-item-size, 14px) - 1px); }
}
@media (max-width: 880px) {
    .acresia-header {
        grid-template-columns: auto 1fr auto;
        height: auto;
        padding: 12px var(--ah-padding-x, 16px);
        gap: 12px;
        row-gap: 8px;
    }
    .acresia-header .ah-nav { grid-column: 1 / -1; justify-content: flex-start; overflow-x: auto; }
    .acresia-header .ah-pill { flex-wrap: nowrap; }
}
