/* =========================================
   HEADER
   ========================================= */
/* z-index: 1000, BELOW the cart/menu overlay backdrops (4000/8000) —
   deliberately, so the header dims/blurs together with the rest of
   the page when they open, matching ByMax (their header is part of
   the same blurred backdrop, not held separately sharp above it).
   Апдейт 90 tried raising this above the overlays instead, which
   just moved the header on top of the drawers' own title bars
   (.cart-header lives in the same 0-80px band). Апдейт 91 tried
   keeping the header un-dimmed via a separate lower dim layer, which
   turned out to be the wrong visual entirely — confirmed against a
   ByMax screenshot, its header is not held apart like that. Апдейт 93
   reverted both: back to this single shared backdrop, with its
   opacity lowered (see .cart-overlay/.mobile-menu-overlay in
   overlays.css) so the header dims/blurs like everything else instead
   of reading as fully erased. */
header {
    position: sticky;
    top: var(--stick-strip, 0px);
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    /* resting depth: a thin crisp edge + a soft wide shadow, so the white bar lifts off the white page */
    box-shadow: 0 1px 2px rgba(15, 30, 51, 0.06), 0 8px 22px -6px rgba(15, 30, 51, 0.12);
    transition: all 0.3s ease;
    transform: translateZ(0);
}
/* soft shadow once the page scrolls under the sticky header — a
   scroll-driven animation (no JS); browsers without it keep the border */
@supports (animation-timeline: scroll()) {
    header {
        animation: headerLift linear both;
        animation-timeline: scroll(root block);
        animation-range: 0 80px;
    }
    @keyframes headerLift {
        from { box-shadow: 0 1px 2px rgba(15, 30, 51, 0.06), 0 8px 22px -6px rgba(15, 30, 51, 0.12); }
        to { box-shadow: 0 1px 2px rgba(15, 30, 51, 0.08), 0 12px 30px -6px rgba(15, 30, 51, 0.22); }
    }
}
/* Апдейт 95: position: sticky depends on its scrolling ancestor (html)
   actually being scrollable to compute its "stuck" state. Reported:
   opening the cart while already scrolled down the page made the
   header disappear entirely — but only when scrolled; opening it from
   the very top worked fine (dimmed/visible, per Апдейт 93). Root
   cause: js/utils/scroll-lock.js's lockScroll() sets `overflow:
   hidden` directly on <html> to freeze the page — and browsers can
   un-stick a position: sticky element the instant its scrolling
   ancestor's overflow is hidden, since sticky positioning is no longer
   well-defined without a live scroll context. The header then rendered
   at its normal in-flow document position instead of pinned to the
   viewport — invisible, because that position is wherever in the
   (frozen, scrolled-down) page the header naturally sits, off-screen
   above the visible viewport. Fix: while body carries .no-scroll
   (added/removed by the very same lockScroll()/unlockScroll(), so no
   JS changes needed here), force the header to position: fixed instead
   — fixed positioning doesn't depend on any scroll-container state at
   all, so it stays correctly pinned to the viewport regardless of
   scroll depth or the overflow freeze. Reverts to sticky the instant
   the overlay closes and .no-scroll comes off, restoring normal
   scroll-following behavior. */
/* While scroll is locked the sticky header stack is pinned by js/utils/scroll-lock.js (freezeStickyStack). */

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
}

.header-left { display: flex; align-items: center; gap: 20px; }

.logo {
    font-size: 20px; font-weight: 500; letter-spacing: 2px;
    color: var(--text-main); text-transform: uppercase;
    display: flex; align-items: center; gap: 10px; z-index: 1002;
}
/* ByMax logo — the owner's artwork as an image (icon/logo.png, 814×283;
   the navy footer uses icon/logo-white.png). Height drives the size. */
.logo { color: var(--navy); font-weight: 800; gap: 0; }
.logo-accent { color: var(--accent); }
.logo-img { display: block; height: 30px; width: auto; }
@media (max-width: 768px) { .logo-img { height: 24px; } }

.main-nav { display: flex; gap: 40px; }
.nav-link {
    font-size: 13px; font-weight: 500; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-secondary);
    position: relative; padding: 10px 0;
}
.nav-link::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 1px;
    background: var(--accent-gold); transition: 0.3s;
}
@media (hover: hover) and (pointer: fine) {
    .nav-link:hover { color: var(--navy); }
    .nav-link:hover::after { width: 100%; }
}

/* ---- top strip (scrolls away): secondary links, phone, hours ---- */
/* The strip and the white row stick together: the strip at the top, the row right under it.
   --strip-height is 0 where the strip isn't shown (tablet/phone, or switched off in the admin:
   html.topbar-off); --sticky-top = what everything else that sticks must clear. */
/* How much of the header stack sticks is chosen in the admin («Сайт → Верхня плашка → Поведінка при
   прокрутці», html[data-sticky]); the default is the strip + the white row. --stick-* are the
   heights that really stay on screen; everything else that sticks clears --sticky-top. */
:root {
    --strip-height: 0px; --catbar-height: 52px;
    --stick-strip: var(--strip-height); --stick-header: var(--header-height); --stick-cats: 0px;
    --sticky-top: calc(var(--stick-strip) + var(--stick-header) + var(--stick-cats));
}
@media (min-width: 1025px) { :root { --strip-height: 36px; } }
@media (max-width: 1319px) { :root { --catbar-height: 44px; } }
:root.topbar-off { --strip-height: 0px; }
html[data-sticky="all"] { --stick-cats: var(--catbar-height); }
html[data-sticky="header"] { --stick-strip: 0px; }
html[data-sticky="header_cats"] { --stick-strip: 0px; --stick-cats: var(--catbar-height); }
html[data-sticky="none"] { --stick-strip: 0px; --stick-header: 0px; }
html[data-sticky="header"] .top-strip, html[data-sticky="header_cats"] .top-strip, html[data-sticky="none"] .top-strip { position: relative; }
html[data-sticky="none"] header { position: relative; }
/* phone / tablet: the white row is always pinned, whatever the admin chose for the computer layout */
@media (max-width: 1024px) {
    html[data-sticky="none"] { --stick-header: var(--header-height); }
    html[data-sticky="none"] header { position: sticky; }
}
html[data-sticky="all"] .cat-bar, html[data-sticky="header_cats"] .cat-bar {
    position: sticky; top: calc(var(--stick-strip) + var(--stick-header)); z-index: 999;
}
.topbar-off .top-strip { display: none; }
.top-strip { background: var(--strip-bg, var(--accent)); color: var(--strip-color, #fff); font-size: 13px; position: sticky; top: 0; z-index: 1001; }
.top-strip-inner { display: flex; justify-content: space-between; align-items: center; height: var(--strip-height, 36px); }
.top-strip .main-nav { display: flex; gap: 26px; }
.top-strip .nav-link {
    color: var(--strip-color, #fff); font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; padding: 0;
    width: auto; border: 0; opacity: 0.92;
}
.top-strip .nav-link::after { background: currentColor; bottom: -6px; }
.top-strip .nav-link.active { opacity: 1; }
.top-strip .nav-link.active::after { width: 100%; }
@media (hover: hover) and (pointer: fine) {
    .top-strip .nav-link:hover { color: var(--strip-color, #fff); opacity: 1; }
}
.top-strip-contact { display: flex; align-items: center; gap: 24px; white-space: nowrap; }
.top-strip-contact a { color: var(--strip-color, #fff); font-weight: 500; }
.top-strip-contact [hidden] { display: none; }
.ts-note { margin: 0 auto; padding: 0 24px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: inherit; }
.ts-note[hidden] { display: none; }
a.ts-note:hover { text-decoration: underline; }
@media (max-width: 1240px) { .ts-note { display: none; } }
.ts-phone::before, .ts-hours::before { font-family: 'Font Awesome 6 Free'; margin-right: 8px; font-size: 12px; }
.ts-phone::before { content: '\f879'; font-weight: 900; }
.ts-hours { opacity: 0.88; }
.ts-hours::before { content: '\f017'; font-weight: 400; }

/* ---- the white row: logo, search, phone, icons ---- */
.header-inner { gap: 36px; }
.header-search {
    flex: 1; display: flex; align-items: center; justify-content: space-between; height: 46px; padding: 0 16px 0 18px;
    border: 1.5px solid var(--border-strong); border-radius: 10px; background: var(--bg-card, #f7f9fc);
    color: var(--text-muted); font: inherit; font-size: 15px; cursor: text; text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.header-search i { color: var(--accent); font-size: 16px; }
@media (hover: hover) and (pointer: fine) {
    .header-search:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
}
.header-phone { display: flex; align-items: center; gap: 12px; white-space: nowrap; color: var(--navy); }
.hp-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 16px; }
.hp-text { display: flex; flex-direction: column; line-height: 1.3; }
.hp-text b { font-size: 16px; font-weight: 600; color: var(--navy); }
.hp-text small { font-size: 12px; color: var(--text-secondary); }
.act-label { display: none; }
.header-actions .hdr-search-icon { display: none; }
@media (min-width: 1025px) {
    .header-actions { gap: 6px; }
    .header-actions .action-btn { width: auto; height: auto; min-width: 58px; padding: 8px 10px; border-radius: 10px; flex-direction: column; gap: 6px; font-size: 21px; }
    .act-label { display: block; font-size: 11px; line-height: 1; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-secondary); }
    /* the signed-in customer's first name in place of «Вхід»: a long one is cut, not widening the header */
    .desktop-user-btn .act-label { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-actions .mobile-heart-btn { display: flex; }
    .cart-count { top: 2px; right: 12px; }
}
@media (max-width: 1024px) {
    .top-strip, .header-search, .header-phone { display: none; }
    .header-actions .hdr-search-icon { display: flex; }
    .header-inner { gap: 12px; }
}

.header-actions { display: flex; align-items: center; gap: 25px; z-index: 1002; }

/* the signed-in customer's Google/Facebook photo in place of the person icon
   (header button and the mobile menu's account row), sized like that icon */
.hdr-avatar { width: 1em; height: 1em; border-radius: 50%; object-fit: cover; display: block; }

.action-btn {
    color: var(--navy); font-size: 20px; position: relative; transition: color 0.3s;
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent;
}
@media (hover: hover) and (pointer: fine) {
    .action-btn:hover { color: var(--accent); border-color: rgba(5, 83, 156, 0.2); background: var(--accent-soft); }
}
.action-btn:active { transform: scale(0.93); }

.action-btn.disabled-heart { color: var(--text-muted) !important; cursor: default !important; pointer-events: none; }

/* Апдейт 97: hidden by default (not display:flex) so a fresh page load
   never paints a static "0" badge before JS has had a chance to read the
   real cart count from localStorage and decide whether to show it at
   all — see updateCartBadge() in js/components/cart-ui.js, called as the
   very first thing in core-bridge.js's initCoreBridge(), before it. */
.cart-count {
    position: absolute; top: 0; right: 0;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 600;
    width: 18px; height: 18px; border-radius: 50%;
    display: none; justify-content: center; align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
/* the cart just emptied: the badge shrinks away (updateCartBadge()) */
.cart-count.is-leaving { animation: cartCountOut 0.2s ease-in forwards; }
@keyframes cartCountOut { to { opacity: 0; transform: scale(0.5); } }
@keyframes cartCountFade { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .cart-count.is-leaving { animation-name: cartCountFade; }
}

.burger-menu { display: none; font-size: 24px; color: var(--navy); z-index: 1002; cursor: pointer; }
.mobile-heart-btn { display: none; }

/* Category bar right under the header (scripts/build-chrome.py → the
   «catbar» block): a navy band in the logo's colour that separates the
   white header from the page, with the six top categories and, on desktop,
   their subcategories on hover/focus. Phones: one swipeable row. */
.cat-bar {
    background: linear-gradient(180deg, #0a63b3 0%, var(--accent) 55%, #044a8c 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 8px 20px -8px rgba(5, 40, 90, 0.45);
    position: relative; z-index: 950;
} /* #05539C, the bymax.com.ua blue */
/* one line per item, spread over the width of the site's container; the type
   scales with the window so seven items always fit (below 1320px the bar
   becomes a swipeable row instead, see the media query at the bottom) */
.cat-bar-inner { display: flex; align-items: stretch; justify-content: space-between; }
.cat-bar-item { position: relative; display: flex; flex: 0 0 auto; }
.cat-bar-link {
    display: flex; align-items: center; justify-content: center;
    min-height: 52px; padding: 0 clamp(6px, 0.5vw, 12px); text-align: center;
    color: #fff; font-size: clamp(11px, 0.8vw, 13px); font-weight: 600;
    letter-spacing: clamp(0.1px, 0.02vw, 0.4px); text-transform: uppercase; white-space: nowrap;
}
.cat-bar-item.has-sub > .cat-bar-link::after {
    content: ''; width: 6px; height: 6px; margin-left: 9px; margin-top: -3px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg); opacity: 0.7; transition: transform 0.2s ease;
}
.cat-bar-drop {
    position: absolute; top: 100%; left: 0; min-width: 280px; padding: 8px;
    background: #fff; border: 1px solid var(--border-light); border-top: 0;
    border-radius: 0 0 12px 12px; box-shadow: 0 14px 34px rgba(27, 49, 82, 0.14);
    display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.cat-bar-item:last-child .cat-bar-drop { left: auto; right: 0; }
.cat-bar-sublink {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 14px 6px 6px; border-radius: 8px; font-size: 14px; font-weight: 500;
    color: var(--text-main); white-space: nowrap;
}
/* the subcategory's picture (scripts/make-menu-thumbs.py): a product on white;
   multiply lets the white melt into the row's hover tint */
.cat-bar-thumb {
    flex: 0 0 40px; width: 40px; height: 40px; border-radius: 6px;
    object-fit: contain; mix-blend-mode: multiply;
}
.cat-bar-item:focus-within > .cat-bar-drop {
    opacity: 1; visibility: visible; transform: none; transition-delay: 0s;
}
@media (hover: hover) and (pointer: fine) {
    .cat-bar-link:hover, .cat-bar-item:hover > .cat-bar-link { background: var(--accent-hover); color: #fff; }
    .cat-bar-item:hover > .cat-bar-drop { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
    .cat-bar-item.has-sub:hover > .cat-bar-link::after { transform: rotate(225deg); margin-top: 3px; }
    .cat-bar-sublink:hover { background: var(--accent-soft); color: var(--accent); }
}
@media (max-width: 1319px) {
    .cat-bar-inner {
        overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: 4px;
    }
    .cat-bar-inner::-webkit-scrollbar { display: none; }
    .cat-bar-item { flex: 0 0 auto; }
    .cat-bar-link { min-height: 44px; padding: 0 12px; font-size: 12px; white-space: nowrap; }
    .cat-bar-item.has-sub > .cat-bar-link::after { display: none; }
    .cat-bar-drop { display: none; }
}

/* Ticker (js/components/ticker.js). The track moves by exactly one
   whole-pixel group width (--ticker-w), so the loop has no seam. */
/* Light strip: a faint blue-tinted pane with a hairline blue border; the
   text fades out at both ends (.ticker-viewport mask). */
.live-line {
    position: relative; overflow: hidden; height: 40px; display: flex; align-items: center; width: 100%; z-index: 1;
    border-radius: 12px; color: var(--tk-text, var(--navy));
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 60%),
        var(--accent-soft);
    border: 1px solid rgba(5, 83, 156, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 4px 16px rgba(15, 30, 51, 0.05);
}
/* the admin's colours («Сайт → Динамічна стрічка»): glass tinted with the chosen
   background colour; plain = a solid band in it, no sheen or shadow */
.live-line[style*="--tk-bg"] {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 60%),
        color-mix(in srgb, var(--tk-bg) 12%, #fff);
    border-color: color-mix(in srgb, var(--tk-bg) 38%, transparent);
}
.live-line.live-line--plain {
    background: var(--tk-bg, var(--accent-soft));
    border: 1px solid transparent;
    box-shadow: none;
}
.ticker-viewport {
    flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
}
/* container-width strip between the header and the promo banner;
   margin, not padding: responsive.css's `.container { padding: 0 15px }`
   shorthand loads last and would zero a padding-top on phones */
.ticker-wrap { margin-top: 20px; }
.alf-ticker-off .ticker-wrap { display: none; } /* off in the admin: hidden from the first paint (index.html) */
@media (max-width: 768px) {
    .ticker-wrap { margin-top: 12px; }
    /* phones: edge to edge like the banner under it */
    .container.ticker-wrap { padding-left: 0; padding-right: 0; }
    .live-line { border-radius: 0; border-left: 0; border-right: 0; }
}
.ticker-track { display: flex; flex-shrink: 0; will-change: transform; backface-visibility: hidden; }
.live-line.is-running .ticker-track { animation: ticker-loop linear infinite; }
@keyframes ticker-loop { to { transform: translate3d(calc(-1 * var(--ticker-w, 0px)), 0, 0); } }
@media (hover: hover) and (pointer: fine) {
    .live-line:hover .ticker-track { animation-play-state: paused; }
}
@media (prefers-reduced-motion: reduce) {
    .live-line.is-running .ticker-track { animation: none; }
}
.ticker-group { display: flex; align-items: center; flex-shrink: 0; white-space: nowrap; }
.ticker-item { font-weight: 500; text-transform: uppercase; font-size: 12px; letter-spacing: 2px; padding: 0 10px; flex-shrink: 0; }
.ticker-brand { color: var(--tk-brand, var(--accent)); margin: 0 30px; font-weight: 800; }


/* Category bar in swipe mode: double arrows on the edges say «there is more, scroll» (and click-scroll;
   js/utils/site-info.js initCatBarArrows) */
.cat-bar-arrow {
    display: none; position: absolute; top: 0; bottom: 0; z-index: 3; width: 40px; align-items: center;
    border: 0; padding: 0; color: #fff; font-size: 15px; cursor: pointer;
}
/* no coloured glow behind the arrows: the category names blur out barely noticeably under them,
   strongest at the very edge and fading quickly towards the menu (the arrow itself stays sharp) */
.cat-bar-arrow { background: transparent; }
.cat-bar-arrow::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
}
.cat-bar-arrow--prev { left: 0; justify-content: flex-start; padding-left: 10px; }
.cat-bar-arrow--next { right: 0; justify-content: flex-end; padding-right: 10px; }
.cat-bar-arrow--prev::before { -webkit-mask-image: linear-gradient(90deg, #000 15%, transparent); mask-image: linear-gradient(90deg, #000 15%, transparent); }
.cat-bar-arrow--next::before { -webkit-mask-image: linear-gradient(270deg, #000 15%, transparent); mask-image: linear-gradient(270deg, #000 15%, transparent); }
.cat-bar-arrow-glyph { position: relative; }
.cat-bar-arrow.is-on { display: flex; }
.cat-bar-arrow-glyph { font-size: 26px; font-weight: 400; line-height: 1; padding-bottom: 4px; }
.cat-bar-arrow.is-on .cat-bar-arrow-glyph { animation: catArrowNudge 1.5s ease-in-out 3; }
.cat-bar-arrow--prev.is-on .cat-bar-arrow-glyph { animation-name: catArrowNudgeL; }
@keyframes catArrowNudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
@keyframes catArrowNudgeL { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-4px); } }
@media (min-width: 1320px) { .cat-bar-arrow { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .cat-bar-arrow.is-on .cat-bar-arrow-glyph { animation: none; } }
