/**
 * Header (redesign step 1): templates/layout/region--top-bar.html.twig,
 * js/header.js. Desktop 88px, mobile 64px; full-screen menu below 992px.
 */

.museo-header {
  --museo-header-height: 88px;
  --museo-header-gutter: 40px;
  position: sticky;
  top: 0;
  z-index: 1030;
  height: auto;
  margin: 0;
  padding: 0;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-rule);
  color: var(--fg-default);
  font-family: var(--museo-font-sans);
}

/* Page scrolled (js/header.js): light shadow under the sticky header. */
.museo-header.is-scrolled {
  box-shadow: 0 8px 16px -12px rgba(26, 24, 21, 0.35);
}

/* Admin toolbar (logged-in editors) sits above the sticky header. */
body.toolbar-fixed .museo-header {
  top: var(--drupal-displace-offset-top, 0px);
}

.museo-header__bar {
  display: flex;
  align-items: center;
  gap: 36px;
  width: min(100%, 1520px);
  min-height: var(--museo-header-height);
  margin: 0 auto;
  padding: 0 var(--museo-header-gutter);
}

.museo-header__brand {
  display: inline-flex;
  flex: 0 0 auto;
  margin-right: auto;
}

.museo-header__logo {
  display: block;
  width: auto;
  height: 50px;
}

/* ── Desktop menu ── */
.museo-nav__list {
  display: flex;
  align-items: center;
  gap: 36px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.museo-nav__item {
  position: relative;
  margin: 0;
}

.museo-nav__link,
.museo-header__cart,
.museo-header__menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-default);
  font-family: var(--museo-font-sans);
  font-size: 16px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.museo-nav__link[aria-current="page"],
.museo-nav__toggle.is-in-trail {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

@media (hover: hover) {
  .museo-nav__link:hover,
  .museo-header__cart:hover,
  .museo-header__menu-toggle:hover,
  .museo-nav__sublink:hover {
    color: var(--fg-default);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
  }
}

.museo-nav__caret {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  transition: transform 150ms ease-out;
}

.museo-nav__toggle[aria-expanded="true"] .museo-nav__caret {
  transform: rotate(180deg);
}

.museo-nav__sub {
  position: absolute;
  top: calc(100% + 22px);
  left: -24px;
  min-width: 300px;
  margin: 0;
  padding: 8px 24px;
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--border-rule);
  box-shadow: 0 18px 48px rgba(26, 24, 21, 0.08);
}

.museo-nav__sub[hidden] {
  display: none;
}

.museo-nav__sub li + li {
  border-top: 1px solid var(--border-rule);
}

.museo-nav__sublink {
  display: block;
  padding: 14px 0;
  color: var(--fg-default);
  font-size: 16px;
  text-decoration: none;
}

.museo-nav__sublink[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

/* ── Cart: separated from the menu by a vertical rule ── */
.museo-header__end {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Cart: icon only (handoff v2), 44 x 44px, after a vertical rule on
   desktop. The word "Carrello" stays for screen readers. */
.museo-header__cart {
  position: relative;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.museo-header__end::before {
  content: "";
  align-self: center;
  width: 1px;
  height: 28px;
  background: var(--border-rule);
}

.museo-header__cart-label {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.museo-header__cart .museo-header__badge {
  position: absolute;
  top: 2px;
  right: 0;
}

/* Bag icon: 22px before "Carrello" on desktop, alone (24px) on mobile. */
.museo-header__bag {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.museo-header__cart:focus-visible,
.museo-header__menu-toggle:focus-visible {
  outline: 2px solid var(--museo-ink);
  outline-offset: 2px;
}

.museo-header__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--museo-radius-pill);
  background: var(--action-bg);
  color: var(--action-fg);
  font-size: 12px;
  line-height: 1;
}

.museo-header__menu-toggle {
  display: none;
}

/* Hamburger: three 22 x 1.5px lines, 5px apart; open = a cross. */
.museo-hamburger {
  position: relative;
  display: block;
  width: 22px;
  height: 14px;
}

.museo-hamburger span {
  position: absolute;
  left: 0;
  width: 22px;
  height: 1.5px;
  background: var(--museo-ink);
  transition: transform 200ms ease, opacity 200ms ease, top 200ms ease;
}

.museo-hamburger span:nth-child(1) { top: 0; }
.museo-hamburger span:nth-child(2) { top: 6.25px; }
.museo-hamburger span:nth-child(3) { top: 12.5px; }

[aria-expanded="true"] > .museo-hamburger span:nth-child(1) {
  top: 6.25px;
  transform: rotate(45deg);
}

[aria-expanded="true"] > .museo-hamburger span:nth-child(2) {
  opacity: 0;
}

[aria-expanded="true"] > .museo-hamburger span:nth-child(3) {
  top: 6.25px;
  transform: rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
  .museo-hamburger span {
    transition: none;
  }
}

/* The cart block stays in the header only for its drawer: its own round
   trigger (floating bottom right) is replaced by "Carrello". */
.museo-header .museo-mini-cart-trigger > .cart-block__menu-item,
.region-top-bar #block-museodelpaesaggio-shopping-cart .museo-mini-cart-trigger--mode-floating > .cart-block__menu-item {
  display: none !important;
}

.museo-header #block-museodelpaesaggio-shopping-cart {
  position: static;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
}

/* ── Mobile ── */
.museo-menu-mobile {
  display: none;
}

@media (max-width: 991.98px) {
  .museo-header {
    --museo-header-height: 64px;
    --museo-header-gutter: 20px;
  }

  .museo-header__bar {
    gap: 20px;
  }

  .museo-header__end::before {
    content: none;
  }

  .museo-header__end {
    gap: 4px;
    /* The last button's glyph lines up with the 20px page margin. */
    margin-right: -10px;
  }

  .museo-header__logo {
    height: 36px;
  }

  .museo-nav {
    display: none;
  }

  .museo-header__cart,
  .museo-header__menu-toggle {
    font-size: 15px;
  }

  /* Icon-only buttons, 44 x 44px. */
  .museo-header__cart,
  .museo-header__menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-left: 0;
  }

  .museo-header__bag {
    width: 24px;
    height: 24px;
  }

  .museo-header__cart-label {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
  }

  .museo-header__badge {
    position: absolute;
    top: 4px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
  }

  /* Open menu: the header stays at the top (the page behind is pinned, see
     .museo-scroll-locked) and the panel covers the screen down to the
     bottom, also when Safari's bars change the viewport height. */
  html.museo-menu-open .museo-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
  }

  .museo-menu-mobile:not([hidden]) {
    position: fixed;
    inset: var(--museo-header-height) 0 0;
    z-index: 1031;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--museo-header-height));
    height: calc(100dvh - var(--museo-header-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 24px env(safe-area-inset-bottom, 0px);
    background: var(--bg-raised);
  }

  .museo-menu-mobile__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .museo-menu-mobile__item {
    padding: 22px 0 20px;
    border-bottom: 1px solid var(--border-rule);
  }

  .museo-menu-mobile__link {
    display: block;
    color: var(--fg-default);
    font-size: 36px;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-decoration: none;
  }

  .museo-menu-mobile__sub {
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
  }

  .museo-menu-mobile__sublink {
    display: block;
    padding: 5px 0;
    color: var(--fg-muted);
    font-size: 17px;
    text-decoration: none;
  }

  .museo-menu-mobile__link[aria-current="page"],
  .museo-menu-mobile__sublink[aria-current="page"] {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
  }

  .museo-menu-mobile__info {
    margin: auto -24px 0;
    padding: 24px;
    border-top: 1px solid var(--border-rule);
  }

  .museo-menu-mobile__info p {
    margin: 0;
  }

  .museo-menu-mobile__hours {
    margin-top: 4px;
    color: var(--fg-default);
    font-size: 17px;
  }
}

/* Anchors (#biglietti, #visita, #contatti) land below the sticky header. */
html {
  scroll-padding-top: 104px;
}

/* Menu or cart panel open (js/header.js): the page behind does not scroll,
   also on iOS Safari, where overflow: hidden on the body is not enough. */
html.museo-scroll-locked body {
  position: fixed;
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
}

/* ── Language switch "IT | EN" (templates/layout/region--top-bar.html.twig) ── */
.museo-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.12em;
}

.museo-lang__item {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  color: var(--fg-muted);
  text-decoration: none;
}

.museo-lang a.museo-lang__item:hover,
.museo-lang a.museo-lang__item:focus-visible {
  color: var(--fg-default);
  text-decoration: underline;
  text-underline-offset: 6px;
}

.museo-lang__item.is-current {
  color: var(--fg-default);
}

.museo-lang__sep {
  color: var(--border-rule);
}

.museo-lang--menu {
  margin-top: auto;
  padding: 16px 0 8px;
  font-size: 15px;
}

@media (max-width: 991.98px) {
  .museo-lang--header {
    display: none;
  }
}

@media (min-width: 992px) {
  .museo-lang--menu {
    display: none;
  }
}
