/*
 * Utility bar + site header + mega menus + mobile action bar (port of prototype/css/components/header.css).
 * One black block: utility line (base rules in utility.css, loaded first) + main header.
 * Desktop ≥1180px: inline nav with disclosure mega panels.
 * Mobile <1180px: nav becomes a full-height drawer; bottom action bar after scroll.
 * Loaded on every page (the header and footer parts are global).
 */

/* ---------- Main header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--on-ink);
  border-bottom: 1px solid var(--ink-line);
  transition: transform var(--dur) var(--ease);
}

.site-header.is-hidden {
  transform: translateY(-101%);
}

.site-header:focus-within {
  transform: none;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  flex: none;
}

.brand__mark {
  width: auto;
  height: 28px;
}

.brand__text {
  display: grid;
  line-height: 1;
}

.brand__name {
  font-family: var(--font-display);
  font-size: 1.375rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand__tag {
  margin-top: 6px;
  color: var(--gold-on-ink);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

/* Nav list (desktop) */
.main-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.main-nav__list {
  display: flex;
  align-items: center;
  /* The container stops growing at 1280px, so the gap must stop growing too. */
  gap: clamp(14px, 1.5vw, 22px);
}

.main-nav__link,
.main-nav__trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--on-ink);
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
}

.main-nav__link::after,
.main-nav__trigger::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 2px;
  background: var(--gold-on-ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-fast) var(--ease);
}

.main-nav__link:hover::after,
.main-nav__trigger:hover::after,
.main-nav__trigger[aria-expanded='true']::after,
.main-nav__link[aria-current]::after {
  transform: scaleX(1);
}

.main-nav__chevron {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--gold-on-ink);
  transition: transform var(--dur-fast) var(--ease);
}

.main-nav__trigger[aria-expanded='true'] .main-nav__chevron {
  transform: rotate(180deg);
}

.main-nav__extra {
  display: none;
}

/* Header actions */
.site-header__actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--s-4);
  margin-left: auto;
}

.header-icon svg,
.menu-toggle svg,
.utility__contact svg,
.btn__icon {
  flex: none;
}

.header-cta {
  min-height: 44px;
}

.header-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-1);
  color: var(--on-ink);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}

.header-icon svg {
  width: 20px;
  height: 20px;
}

/* Icon-only on every width (conventional user/bag icons); the label stays in the accessible name. */
.header-icon__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.header-icon:hover {
  color: var(--gold-on-ink);
}

.menu-toggle {
  display: none;
}

/* ---------- Mega panels (desktop) ---------- */
.mega {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--ink-line);
  box-shadow: var(--shadow-pop);
  --focus: var(--ink);
  animation: mega-in var(--dur-fast) var(--ease);
}

.mega[hidden] {
  display: none;
}

@keyframes mega-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.mega__grid {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  gap: var(--s-7);
  padding-block: var(--s-6) var(--s-7);
}

.mega__intro-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: var(--lh-tight);
}

.mega__intro-title em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--gold-text);
}

.mega__intro p:not(.mega__intro-title) {
  margin: var(--s-3) 0 var(--s-4);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.mega__title {
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line);
  color: var(--gold-text);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.mega__links a {
  display: flex;
  align-items: center;
  min-height: 36px;
  font-size: 0.9375rem;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.mega__links a:hover {
  color: var(--gold-text);
  transform: translateX(3px);
}

.mega__links .mega__all {
  margin-top: var(--s-1);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold-ui);
  text-underline-offset: 4px;
}

.mega__help {
  padding: var(--s-5);
  border-radius: 6px;
  background: var(--stone);
}

.mega__help p {
  margin-bottom: var(--s-4);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.mega__help .btn {
  width: 100%;
  margin-top: var(--s-2);
}

.mega__feature {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-5);
  background: var(--ink);
  color: var(--on-ink);
  --focus: var(--gold-on-ink);
}

.mega__feature p {
  color: var(--on-ink-muted);
  font-size: var(--fs-sm);
}

.mega__gift {
  width: 116px;
  height: auto;
  margin: var(--s-1) 0 var(--s-2) var(--s-2);
  border-radius: 8px;
  box-shadow: 0 18px 30px -16px rgba(0, 0, 0, 0.8);
  transform: rotate(-4deg);
}

.mega--compact .mega__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) 1fr;
}

.mega-store {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-5);
  border-radius: 6px;
  background: var(--stone);
}

.mega-store .mega-store__name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
}

.mega-store p {
  color: var(--text-soft);
  font-size: var(--fs-sm);
}

.mega-store__status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
}

/* Light panels inside the dark header: use the light-surface status colours. */
.on-ink .mega .is-open .status-dot {
  background: var(--open);
  box-shadow: 0 0 0 3px rgba(63, 107, 79, 0.18);
}

.on-ink .mega .is-closed .status-dot {
  background: var(--closed);
}

.mega-store__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

/* ---------- Mobile action bar (appears after the header scrolls away) ---------- */
.action-bar {
  display: none;
}

/* ---------- WordPress additions ---------- */

/* Logged-in staff: the sticky header sits below the admin bar (fixed only above 600px). */
.admin-bar .site-header {
  top: var(--wp-admin--admin-bar--height, 0px);
}

@media (max-width: 600px) {
  .admin-bar .site-header {
    top: 0;
  }
}

/* WooCommerce Mini-Cart block styled as a header icon (count is rendered client-side: cache-safe). */
.site-header .wc-block-mini-cart {
  display: inline-flex;
  align-items: center;
}

.site-header .wc-block-mini-cart__button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--s-1);
  border: 0;
  background: none;
  color: var(--on-ink);
  font-size: var(--fs-sm);
}

.site-header .wc-block-mini-cart__button:hover {
  color: var(--gold-on-ink);
}

.site-header .wc-block-mini-cart__icon {
  width: 20px;
  height: 20px;
}

/* VERIFY: badge class name and colours against the Mini-Cart markup of the WooCommerce version in use. */
.site-header .wc-block-mini-cart__badge {
  border: 0;
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
}

/* Cart and checkout pages: the header cart is not rendered (inc/shop.php); its slot stays. */
.site-header .header-cart-slot {
  display: inline-block;
  flex: none;
  width: 44px;
  height: 44px;
}

/* Drawer title: the theme prints it as a <p> (inc/shop.php), and WooCommerce only spaces the <h2>.
   The drawer lives in the footer, so no .site-header prefix. */
.wc-block-mini-cart__title {
  display: flex;
  align-items: baseline;
  margin: var(--s-4) var(--s-4) 0;
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.wc-block-mini-cart__title span:first-child {
  margin-right: var(--s-2);
}

/* ---------- Breakpoints ---------- */

@media (max-width: 1439px) {
  .utility__price--wide,
  .brand__tag {
    display: none;
  }

  .site-header__inner {
    gap: var(--s-4);
  }
}

/* Priority+ : on narrow desktops the gift-card entry lives inside «Comprar» (and the hero tabs). */
@media (min-width: 1180px) and (max-width: 1439px) {
  .main-nav__item--optional {
    display: none;
  }

  /* Russian labels are longer: a tighter gap keeps the last item clear of the header button. */
  html:lang(ru) .main-nav__list {
    gap: var(--s-3);
  }
}

@media (max-width: 1179px) {
  html {
    scroll-padding-top: calc(var(--header-h-mobile) + var(--s-4));
    scroll-padding-bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
  }

  body {
    padding-bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
  }

  .utility__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .utility__prices {
    gap: 2px var(--s-3);
    padding-block: var(--s-2) 6px;
    border-bottom: 1px solid var(--ink-line);
  }

  /* Visually hidden but kept in the link's accessible name: the whole strip is the link, and
     a lone «›» wrapped onto its own line on phones. */
  .utility__more {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .utility__meta {
    justify-content: space-between;
    gap: var(--s-2);
    min-height: 36px;
  }

  .utility__hours {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
  }

  .utility__contacts {
    display: flex;
    gap: var(--s-1);
  }

  .utility__contact {
    justify-content: center;
    min-width: 44px;
    min-height: 36px;
  }

  .utility__contact-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .site-header__inner {
    min-height: var(--header-h-mobile);
  }

  .brand__mark {
    height: 24px;
  }

  .brand__name {
    font-size: 1.125rem;
  }

  .brand {
    flex: 0 1 auto;
    min-width: 0;
  }

  .site-header__inner,
  .site-header__actions {
    gap: var(--s-3);
  }

  .header-cta,
  .header-icon--account {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: 0 var(--s-3);
    border: 1px solid #5b584e;
    border-radius: var(--radius);
    background: none;
    color: var(--on-ink);
    font-size: var(--fs-sm);
    font-weight: 600;
  }

  .menu-toggle svg {
    width: 18px;
    height: 18px;
  }

  .menu-toggle[aria-expanded='true'] {
    border-color: var(--gold-on-ink);
  }

  /* Drawer */
  .main-nav {
    position: fixed;
    top: var(--nav-top, var(--header-h-mobile));
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 49;
    display: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--paper);
    color: var(--ink);
    --focus: var(--ink);
  }

  .main-nav.is-open {
    display: block;
    animation: mega-in var(--dur-fast) var(--ease);
  }

  .main-nav__list {
    display: block;
    padding: var(--s-2) var(--gutter) 0;
  }

  .main-nav__item {
    border-bottom: 1px solid var(--line);
  }

  .main-nav__link,
  .main-nav__trigger {
    width: 100%;
    justify-content: space-between;
    min-height: 56px;
    color: var(--ink);
    font-size: var(--fs-md);
  }

  .main-nav__link::after,
  .main-nav__trigger::after {
    display: none;
  }

  .main-nav__chevron {
    width: 16px;
    height: 16px;
    color: var(--gold-text);
  }

  .mega {
    position: static;
    border: 0;
    box-shadow: none;
    background: transparent;
    animation: none;
  }

  .mega > .wrap {
    padding: 0;
  }

  .mega__grid,
  .mega--compact .mega__grid {
    grid-template-columns: 1fr;
    gap: var(--s-5);
    padding: 0 0 var(--s-5);
  }

  .mega__intro-title,
  .mega__feature {
    display: none;
  }

  .mega__links a {
    min-height: 44px;
  }

  .main-nav__extra {
    display: grid;
    gap: var(--s-4);
    padding: var(--s-5) var(--gutter) var(--s-7);
  }

  .main-nav__extra-links a {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-weight: 500;
  }

  .main-nav__extra-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
  }

  /* Action bar */
  .action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--ink);
    border-top: 1px solid var(--ink-line);
    transition: transform var(--dur) var(--ease);
  }

  /* visibility:hidden removes the off-screen links from tab order and the a11y tree. */
  .action-bar.is-hidden,
  .has-open-nav .action-bar {
    transform: translateY(100%);
    visibility: hidden;
    transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
  }

  /* Cookie banner open (consent.js sets the class on <html>): both sit at the bottom of the
     screen, so the bar leaves at once, also before action-bar.js runs. */
  html.has-trioni-consent [data-action-bar] {
    display: none;
  }

  .action-bar a {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    color: var(--on-ink);
    font-size: var(--fs-2xs);
    font-weight: 600;
  }

  .action-bar a + a {
    border-left: 1px solid var(--ink-line);
  }

  .action-bar svg {
    width: 20px;
    height: 20px;
    color: var(--gold-on-ink);
  }
}

@media (max-width: 359px) {
  .brand__mark {
    height: 20px;
  }

  .brand__name {
    font-size: 0.9375rem;
    letter-spacing: 0.03em;
  }

  .menu-toggle [data-menu-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (max-width: 1179px) and (max-height: 500px) {
  .action-bar {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

@media (min-width: 1180px) {
  .action-bar {
    display: none !important;
  }
}
