/**
 * Будинок Затишку — mega-catalog overlay. See mebelvdom-redesign-spec.md §5.
 */

.bz-megacatalog {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--c-bg);
  overflow-y: auto;
  /* Safety net (owner report, 2026-09-04): the mobile header row inside
     (close button + logo + phone icon) is flex-wrap: nowrap by design --
     see the @media (max-width: 899px) block below -- and a row that
     still doesn't fit after that block's own fix (shorter close-button
     label) would otherwise force this whole fixed, viewport-covering
     overlay to scroll sideways, which can drag the real page along with
     it on some mobile browsers. */
  overflow-x: hidden;
}
.bz-megacatalog.is-open { display: block; }

.bz-megacatalog__header {
  background: var(--c-card);
  border-bottom: 1px solid var(--c-line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.bz-megacatalog__header .bz-container {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  flex-wrap: wrap;
}
.bz-megacatalog__close {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--c-ginger);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.bz-megacatalog__close:hover { opacity: .9; }
.bz-megacatalog__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.bz-megacatalog__search input {
  width: 100%;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-pill);
  padding: 10px 46px 10px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--c-bg);
}

.bz-megacatalog__body {
  display: flex;
  align-items: flex-start;
  /* The overlay's own header is a .bz-container, i.e. the site-wide
     --bz-container-wide grid (chrome.css). The body used to cap itself at a
     private 1280px instead, so on any screen wider than that the rail sat
     visibly inboard of the logo above it and the panel wasted the rest of
     the viewport. Sharing the header's max-width and gutter puts the rail's
     left edge on the same line as the logo and lets the catalog use the
     full screen, which is what the design asks for. */
  max-width: var(--bz-container-wide);
  margin: 0 auto;
  /* --bz-gutter, not --space-4: this band touches the viewport edge, so it
     takes the shared page gutter like every other one (chrome.css). Using
     component padding here would put the rail 16px from the edge while the
     logo directly above it sits at ~46px. */
  padding: var(--space-5) var(--bz-gutter);
  gap: var(--space-6);
}

.bz-megacatalog__rail {
  /* Wide enough that no category name wraps to a second line (owner,
     2026-09-01) -- a wrapped row makes the rail's rhythm ragged and costs
     more vertical space than the width costs horizontally.

     420px is measured, not guessed, and it must be measured in RUSSIAN:
     the rail is one component serving both languages, and Russian runs
     longer here. The binding label is «Модульные системы (Коллекции)» at
     265px of text (16px/600) -- its Ukrainian twin «Модульні системи
     (Колекції)» is only 227px, so sizing from the UK site alone would
     truncate the RU one. Add the 24px icon, the 12px gaps,
     the chevron and the paddings and 420px is what is left, with the
     Russian label landing almost exactly on the edge.

     (This first read 289px for «Меблі за індивідуальними розмірами». That
     category was renamed to «Меблі на замовлення» / «Мебель под заказ» on
     2026-09-01, which freed 24px of the constraint but did not change the
     width, because Russian's longest label then became the binding one.) */
  width: 420px;
  flex-shrink: 0;
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  background: var(--c-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
/* No rules between rail items (design): the rows are separated by their own
   spacing and by the selected row's highlight, not by a drawn line. Each
   row is its own rounded block, so the highlight reads as a selection
   rather than as a band cutting across a bordered list. */
.bz-megacatalog__rail li + li { margin-top: 2px; }
.bz-megacatalog__rail button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  /* Root categories and their subcategories sit ABOVE the 14px body token
     on purpose (owner, 2026-09-01): this is the site's primary navigation,
     read at a glance from across the panel, not running copy. Recorded as a
     deliberate exception in BUSINESS-RULES.md's type-scale section. */
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background-color .15s ease, color .15s ease;
}
.bz-megacatalog__rail-name {
  min-width: 0;
  /* The width above fits every current name; this guarantees the rule holds
     for a longer one added later -- it truncates rather than wrapping, so a
     row can never become two lines. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Category icon. bzCategoryIcon() always returns a symbol (index.php), so
   every row has this leading column and the names start on one left edge.
   currentColor, so it takes the row's own colour -- including the ginger of
   the selected row below. */
.bz-megacatalog__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: block;
  color: var(--c-muted);
  transition: color .15s ease;
}
.bz-megacatalog__rail li.is-active .bz-megacatalog__icon,
.bz-megacatalog__rail button:hover .bz-megacatalog__icon {
  color: var(--c-ginger);
}

/* Selected category (design): ginger tint, a ginger bar down the leading
   edge, and the arrow at the far end -- which is hidden on every other row,
   so the arrow itself is part of the selection, not a permanent glyph on
   all fifteen. Hover previews the same state because hovering a rail item
   already switches the panel (megacatalog.js). */
.bz-megacatalog__rail li.is-active button,
.bz-megacatalog__rail button:hover {
  background: rgba(232, 130, 30, .10);
  color: var(--c-coffee);
}
.bz-megacatalog__rail li.is-active button::before,
.bz-megacatalog__rail button:hover::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--c-ginger);
}
.bz-megacatalog__chevron {
  margin-left: auto; /* pushes the chevron to the row's right edge (the product count that did it was removed, owner 2026-11-02) */
  color: var(--c-ginger);
  font-weight: 700;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .15s ease, transform .15s ease;
}
.bz-megacatalog__rail li.is-active .bz-megacatalog__chevron,
.bz-megacatalog__rail button:hover .bz-megacatalog__chevron {
  opacity: 1;
  transform: translateX(0);
}

.bz-megacatalog__panel { display: none; flex: 1; min-width: 0; }
.bz-megacatalog__panel.is-active { display: block; }
.bz-megacatalog__panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.bz-megacatalog__panel-title h2,
.bz-megacatalog__panel-title .h2 { margin: 0; }
/* The panel title and column labels are <div class="h2/h3">, not headings
   (2026-10-06: the overlay is on every page, and real <h2>/<h3> made every
   page's first dozen headings menu labels). .h2 keeps the token heading look
   of :root h2 (tokens.css), which no longer reaches a <div>. */
.bz-megacatalog__panel-title .h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--c-coffee);
  font-size: 20px;
  line-height: 26px;
}
.bz-megacatalog__panel-title a { font-size: 14px; font-weight: 600; text-decoration: none; color: var(--c-coffee); }

/* Lists on the left, the category picture on the right. The lists take the
   space they need and the figure takes what is left, capped -- so a panel
   with one short column still shows a generous picture and a panel with two
   long columns is never squeezed by it. */
.bz-megacatalog__panel-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
}
.bz-megacatalog__cols {
  flex: 1;
  min-width: 0;
  display: grid;
  /* auto-fill, never auto-fit: the panel has only two columns and a wide
     screen now has room for more tracks -- auto-fit would collapse the
     empty ones and stretch "Категорії"/"За фабрикою" across the whole
     viewport. See BUSINESS-RULES.md "A sparse section must never inflate
     its items". */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
}
/* A rail item that merges several categories ($bzMenuMerges): one column per category, narrower minimum so both sit
   side by side next to the photo on a 1440px screen (2 x 210 + gap fits the ~490px the list gets there). */
.bz-megacatalog__cols--merged {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  column-gap: calc(var(--space-6) + var(--space-4)); /* 48px: the two named columns read as separate lists (owner, 2026-10-31) */
}

.bz-megacatalog__figure {
  flex-shrink: 0;
  width: clamp(260px, 26vw, 460px);
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--c-card);
}
.bz-megacatalog__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.bz-megacatalog__col h3,
.bz-megacatalog__col .h3 {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin: 0 0 var(--space-3);
}
.bz-megacatalog__col ul { list-style: none; margin: 0; padding: 0; }
.bz-megacatalog__col li { margin-bottom: var(--space-2); }
.bz-megacatalog__col a {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--c-text);
  text-decoration: none;
  font-size: 15px;   /* same deliberate exception as the rail above */
  padding: 5px 0;
}
.bz-megacatalog__col a:hover { color: var(--c-ginger); }

.bz-megacatalog__panel-back {
  display: none;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: none;
  color: var(--c-coffee);
  font-weight: 700;
  font-size: 14px;
  padding: 0 0 var(--space-4);
  cursor: pointer;
}

/* Mobile drill-down (§5): tapping a category slides its panel in from the
   RIGHT over the category rail (owner, 2026-09-04 — final call, after
   trying "left, same as the whole overlay": the panel is its own level,
   opposite direction from opening the catalog below, so swiping either
   one back out stays a "give it back where it came from" gesture instead
   of both levels sharing one direction), with a "‹ Усі категорії" back
   button to return — rather than the desktop side-by-side rail+panel
   layout, which on a narrow screen just stacked the panel below the rail
   (requiring a scroll to see it, easy to miss/read as "not working"). The
   panel's .is-active class (which category is selected) and the body's
   .is-drilled class (whether we're currently showing a panel at all) are
   deliberately separate — .bz-megacatalog.js adds .is-drilled only once a
   rail item is actually tapped, so the overlay opens on the category list
   first, never a pre-selected panel. */
@media (max-width: 899px) {
  /* Leaves the bottom nav's own strip clear rather than covering the
     full viewport — the nav (fixed, bottom:0) then simply shows through
     underneath, no z-index fight needed. Catalog/Пошук there already
     work while the overlay is open (chrome.js toggles/closes it). */
  .bz-megacatalog { bottom: 56px; }

  /* The whole overlay slides in from the LEFT like a drawer and slides
     back out to the left (owner, 2026-09-04). The rail->panel drill-down
     one level in (below) is the opposite direction, from the RIGHT --
     see the comment above this media query for why. display can't be
     transitioned, so opening/closing drives transform instead, with
     visibility staggered a transition-length behind it so the closed
     overlay stays out of hit-testing and the accessibility tree while
     off-screen, but stays visible and interactive throughout the slide
     itself. */
  .bz-megacatalog {
    display: block;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform .3s ease, visibility 0s linear .3s;
  }
  .bz-megacatalog.is-open {
    visibility: visible;
    transform: translateX(0);
    transition: transform .3s ease, visibility 0s;
  }

  .bz-megacatalog__body {
    flex-direction: column;
    position: relative;
    overflow: hidden;
    padding: 0;
    gap: 0;
  }
  .bz-megacatalog__rail { width: 100%; border-radius: 0; box-shadow: none; }
  .bz-megacatalog__cols { grid-template-columns: 1fr; }
  .bz-megacatalog__panel-body { display: block; }
  /* Dropped on a phone: the panel is a drill-down list someone is scanning
     for one link, and a 4:3 photo above it would push every one of those
     links below the fold for no navigational gain. */
  .bz-megacatalog__figure { display: none; }

  .bz-megacatalog__panel {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--c-bg);
    padding: var(--space-4);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .25s ease;
  }
  .bz-megacatalog__body.is-drilled .bz-megacatalog__panel.is-active {
    transform: translateX(0);
  }
  .bz-megacatalog__panel-back { display: inline-flex; }

  /* Header (§5 top bar): search, "Обране" and cart are dropped here —
     the bottom nav underneath already carries all three (and stays
     reachable, see above), so only the close button and a phone icon
     (opens the same contacts popup, no number text at this width — see
     .bz-megacatalog__phone) remain, next to the logo. */
  .bz-megacatalog__header .bz-container { gap: var(--space-2); flex-wrap: nowrap; }
  .bz-megacatalog__header .brand-logo { margin-right: auto; min-width: 0; }
  .bz-megacatalog__header .bz-megacatalog__search,
  .bz-megacatalog__header .bz-header__icon-btn,
  .bz-megacatalog__header .bz-megacatalog__cart-slot {
    display: none;
  }
  .bz-megacatalog__phone .bz-header__phone-number { display: none; }
  .bz-megacatalog__phone {
    padding: 9px;
    border-radius: 50%;
    background: var(--c-pillow);
    flex-shrink: 0;
  }
}

/* Desktop (≥900px): the rail and the active panel scroll independently
   within a viewport-bounded overlay, instead of the whole overlay being
   one tall scrolling page (competitor reference: dybok.com.ua's catalog
   flyout). Before this, .bz-megacatalog__body's height was just
   "however tall its content is" and the OUTER .bz-megacatalog scrolled
   as one block — so browsing a long rail scrolled a currently-open
   panel out of view with it, and a category with a long subcategory/
   manufacturer list forced the whole page to scroll even though the
   14-item rail itself would've fit on screen alone. Turning the overlay
   into a flex column (header auto-height, body flex:1) gives body a
   *definite* height (viewport minus header) for the first time, which
   is what lets align-items:stretch size the rail and the active panel
   to exactly that height — each then scrolls internally via its own
   overflow-y:auto only if ITS content doesn't fit, never the other. */
@media (min-width: 900px) {
  .bz-megacatalog.is-open {
    display: flex;
    flex-direction: column;
  }
  .bz-megacatalog {
    overflow: hidden;
  }
  .bz-megacatalog__header {
    flex-shrink: 0;
  }
  .bz-megacatalog__body {
    /* Becoming a flex item of the new column layout above cost body its
       old block-level "fill the available width" sizing — with
       margin:0 auto and no explicit width, flexbox's auto-margin cross-
       axis centering shrink-wraps it to its CONTENT's width instead of
       filling max-width:1280px. Content width varies by category (a
       longer category name, a panel needing its own scrollbar, a wider
       manufacturers column…), so body — and the rail sitting inside it —
       visibly shifted left/right as you switched categories. Forcing
       width:100% restores the old fill-then-cap-at-max-width sizing, so
       the rail's screen position is stable regardless of which panel is
       showing. */
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
  }
  .bz-megacatalog__rail {
    overflow-y: auto;
    overflow-x: hidden;
  }
  .bz-megacatalog__panel.is-active {
    overflow-y: auto;
    height: 100%;
  }
}

/* Quiet scrollbars (owner, 2026-09-01): the catalog's scrollable areas --
   the category rail and the open panel (and, under the mobile breakpoint,
   the overlay itself) -- used to carry a permanent full-width platform
   scrollbar each, so an overlay whose whole point is a clean uninterrupted
   list showed two grey gutters at once. Here the track is always reserved
   but the thumb is drawn only while that area is actually being scrolled,
   and megacatalog.js drops the marker class ~900ms after the last scroll
   event, so it disappears again on its own.

   Reserving the track rather than using overflow:overlay is deliberate:
   overlay is deprecated and gone from current Chrome, and a thumb drawn
   over the content is what makes an auto-hiding bar feel unstable.

   The two engines must NOT be styled at once. Since Chrome 121, setting
   the standard scrollbar-width/scrollbar-color on an element makes it
   ignore that element's ::-webkit-scrollbar rules completely -- doing both
   here first yielded an 11px "thin" platform bar instead of the 6px one
   the pseudo-element asks for. So WebKit/Blink gets the pseudo-elements
   only, and the standard properties are fenced behind an @supports test
   that is false exactly where ::-webkit-scrollbar exists. */
.bz-megacatalog::-webkit-scrollbar,
.bz-megacatalog__rail::-webkit-scrollbar,
.bz-megacatalog__panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.bz-megacatalog::-webkit-scrollbar-track,
.bz-megacatalog__rail::-webkit-scrollbar-track,
.bz-megacatalog__panel::-webkit-scrollbar-track {
  background: transparent;
}
.bz-megacatalog::-webkit-scrollbar-thumb,
.bz-megacatalog__rail::-webkit-scrollbar-thumb,
.bz-megacatalog__panel::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--radius-pill);
}
.bz-megacatalog.is-scrolling::-webkit-scrollbar-thumb,
.bz-megacatalog__rail.is-scrolling::-webkit-scrollbar-thumb,
.bz-megacatalog__panel.is-scrolling::-webkit-scrollbar-thumb {
  background: rgba(74, 52, 38, .35);
}

/* Firefox: no ::-webkit-scrollbar, so it takes the standard properties --
   which do animate, so there it actually fades rather than cutting. */
@supports not selector(::-webkit-scrollbar) {
  .bz-megacatalog,
  .bz-megacatalog__rail,
  .bz-megacatalog__panel {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color .35s ease;
  }
  .bz-megacatalog.is-scrolling,
  .bz-megacatalog__rail.is-scrolling,
  .bz-megacatalog__panel.is-scrolling {
    scrollbar-color: rgba(74, 52, 38, .35) transparent;
  }
}

/* Mobile: no scrollbar at all, not even the quiet flash-while-scrolling
   one above (owner, 2026-09-04) -- a touch list scrolls by the gesture
   itself, no persistent chrome needed to say so. Desktop keeps the
   flash-on-scroll bar above, where a mouse/trackpad still expects one.
   Must win the cascade over the same selectors above, so it has to stay
   textually AFTER that block (same specificity, tie goes to source
   order) -- moving this earlier in the file would silently re-enable
   the flash on mobile. */
@media (max-width: 899px) {
  .bz-megacatalog,
  .bz-megacatalog__rail,
  .bz-megacatalog__panel {
    scrollbar-width: none;
  }
  .bz-megacatalog::-webkit-scrollbar,
  .bz-megacatalog__rail::-webkit-scrollbar,
  .bz-megacatalog__panel::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}

/* Motion-sensitive visitors get the instant open/close the desktop
   layout already has, not the slide. */
@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  .bz-megacatalog,
  .bz-megacatalog.is-open {
    transition: none;
  }
}

/* Landing pages under a subcategory (the «Популярні підбірки» pages switched on for the menu): an indented, quieter list. */
.bz-megacatalog__sub { margin: 2px 0 var(--space-2) var(--space-3); padding-left: var(--space-3); border-left: 1px solid var(--c-line); }
.bz-megacatalog__col .bz-megacatalog__sub li { margin-bottom: 0; }
.bz-megacatalog__col .bz-megacatalog__sub a { font-size: 14px; padding: 3px 0; color: var(--c-muted); }
.bz-megacatalog__col .bz-megacatalog__sub a:hover { color: var(--c-ginger); }

/* Hot-offer row under a panel's lists (design 3a): modules in the template position
   «megacatalog-offers», one card each, rendered by chrome-top.php for the panel's category.
   On desktop the open panel is a column, so the row is pushed to the panel's bottom and to its
   right edge (owner, 2026-10-31: docked in the bottom-right corner of the menu, limited width);
   a panel taller than the menu scrolls and the row simply follows the lists. */
.bz-megacatalog__offers {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-4);
  padding-top: var(--space-5);
}
.bz-megacatalog__offers:empty { display: none; }
@media (min-width: 900px) {
  .bz-megacatalog__panel.is-active { display: flex; flex-direction: column; }
  .bz-megacatalog__offers { margin-top: auto; }
}
.bz-offercard {
  flex: 0 1 340px;
  max-width: 340px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--c-coffee);
  color: var(--c-card);
  text-decoration: none;
}
.bz-offercard__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bz-offercard__title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.bz-offercard__text { font-size: 12.5px; line-height: 1.45; color: var(--c-muted-on-dark); }
.bz-offercard__arrow { flex: none; font-size: 18px; font-weight: 800; color: var(--c-ginger); transition: transform .15s ease; }
.bz-offercard:hover { color: var(--c-card); }
.bz-offercard:hover .bz-offercard__arrow { transform: translateX(3px); }
.bz-offercard:focus-visible { outline: 2px solid var(--c-ginger); outline-offset: 2px; }
/* On a phone the drill-down panel is narrow: the card takes its full width there. */
@media (max-width: 899px) {
  .bz-offercard { flex-basis: 100%; max-width: none; }
}
