/* ==========================================================================
   The menu that drops from the header's menu button (Views/Shared/_LayoutHome.cshtml and
   Views/Shared/_Layout.cshtml).

   The layouts load this file only for the widths where the menu button shows (their
   navMenuMedia). Today that is every width in every language: the header is always the short bar.
   If the row comes back for wide English screens (navAlwaysMenu false), the file is loaded below
   1200px only, so nothing here needs a breakpoint of its own to tell the menu from the row.

   A card under the bar: the links in one list, the gift cards link as a lime chip, then the
   buttons one under the other, at every width. Its colours are custom properties, so
   a theme recolours the menu without repeating these rules: css/theme-night.css for the night,
   css/autumn.css (tools/season/make_autumn_css.py, HAND) for the autumn day.
   ========================================================================== */

.header-sticky {
  --tw-menu-bg: #fff;
  --tw-menu-line: rgba(0, 0, 0, 0.07);
  --tw-menu-shadow: 0 24px 48px -20px rgba(51, 49, 54, 0.3);
  --tw-menu-hover: rgba(0, 0, 0, 0.045);
  --tw-menu-muted: #8a8a8a;
  --tw-menu-gift-bg: rgba(229, 238, 128, 0.5);
  --tw-menu-gift-hover: rgba(229, 238, 128, 0.85);
  --tw-menu-gift-text: #333136;
}

.header-sticky .navbar {
  position: relative;
  overflow: visible;
}

/* Override legacy `.navbar-expand-lg .navbar-brand { padding: 20px 0 }` from style.css, which
   pushes the brand taller than the bar and off centre against the menu button */
.header-sticky .navbar-brand {
  padding-top: 0;
  padding-bottom: 0;
}

/* ---------- Name Your Price in the bar, before the language switch ---------- */
.header-sticky .navbar .tw-bar-cta {
  flex-shrink: 0;
  height: 38px;
  padding: 0 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Gift cards in the bar, before Name Your Price ----------
   A soft pill with the animated present; on a phone the present alone (its name is its aria-label) */
.header-sticky .navbar .tw-bar-gift {
  flex-shrink: 0;
  height: 38px;
  padding: 0 0.85rem;
  border-radius: 999px;
  background: var(--tw-menu-gift-bg);
  color: var(--tw-menu-gift-text);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.header-sticky .navbar .tw-bar-gift:hover,
.header-sticky .navbar .tw-bar-gift:focus-visible {
  background: var(--tw-menu-gift-hover);
  color: var(--tw-menu-gift-text);
}

.header-sticky .navbar .tw-bar-gift .tw-gift-nav__icon {
  width: 1.2rem;
  height: 1.2rem;
}

/* Below 768px the present alone: with its name the bar does not fit */
@media (max-width: 767.98px) {
  .header-sticky .navbar .tw-bar-gift {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .header-sticky .navbar .tw-bar-gift__label {
    display: none;
  }
}

/* The theme switch: in the bar from 576px; on a phone a row of the menu, under the links */
.header-sticky .tw-menu-theme {
  display: none;
}

@media (max-width: 575.98px) {
  .header-sticky .navbar .tw-bar-theme {
    display: none;
  }

  .header-sticky .tw-menu-theme {
    display: block;
    margin-top: 2px;
  }

  .header-sticky .tw-menu-theme .theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    height: auto;
    min-height: 48px;
    padding: 0.75rem 0.875rem;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 500;
    color: inherit;
    text-align: left;
  }

  .header-sticky .tw-menu-theme .theme-toggle:hover {
    background: var(--tw-menu-hover);
  }

  /* The two icons share one spot; the label names the theme a click leads to */
  .header-sticky .tw-menu-theme .theme-toggle svg {
    position: absolute;
    left: 0.875rem;
  }

  .header-sticky .tw-menu-theme .theme-toggle__label {
    margin-left: calc(20px + 0.625rem);
  }

  .header-sticky .tw-menu-theme .theme-toggle__label--to-dark { display: inline; }
  html[data-theme="dark"] .header-sticky .tw-menu-theme .theme-toggle__label--to-dark { display: none; }
  html[data-theme="dark"] .header-sticky .tw-menu-theme .theme-toggle__label--to-light { display: inline; }
}

/* The bar stays one line: the menu card is placed under it, not in it */
.header-sticky .navbar > .container-fluid {
  flex-wrap: nowrap;
}

/* A phone: the button, the language switch, the theme switch and the menu button do not fit beside
   the brand's name, so the star alone stands for the brand */
@media (max-width: 767.98px) {
  /* Only the home layout's bar (.tw-navbar-home), which also holds Gift cards and Name Your Price.
     The inner pages' bar has room for the name. */
  .header-sticky .tw-navbar-home .brand-text {
    display: none;
  }
}

/* A narrow phone: a smaller button and closer controls */
@media (max-width: 419.98px) {
  .header-sticky .navbar .tw-bar-cta {
    height: 34px;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
  }

  .header-sticky .navbar .tw-bar-gift {
    width: 34px;
    height: 34px;
  }

  /* The flag alone; the list it opens still names both languages */
  .header-sticky .navbar .lang-switcher__toggle {
    padding-left: 6px;
    padding-right: 6px;
  }

  .header-sticky .navbar .lang-switcher__toggle .lang-switcher__code {
    display: none;
  }
}

/* The smallest phones (320px): tighter still, the flag without its arrow */
@media (max-width: 359.98px) {
  .header-sticky .navbar .tw-bar-cta {
    padding: 0 0.6rem;
    font-size: 0.75rem;
  }

  .header-sticky .navbar .lang-switcher__toggle::after {
    display: none;
  }

  .header-sticky .navbar .lang-switcher {
    margin: 0 -2px;
  }

  .header-sticky .navbar .navbar-brand {
    margin-right: 0.25rem;
  }
}

/* ---------- The card ---------- */
.header-sticky .navbar-collapse {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1040;
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-top: 8px;
  padding: 0.625rem;
  border: 1px solid var(--tw-menu-line);
  border-radius: 22px;
  background: var(--tw-menu-bg);
  box-shadow: var(--tw-menu-shadow);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0.22s;
  pointer-events: none;
}

.header-sticky .navbar-collapse.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0s;
  pointer-events: auto;
}

/* ---------- The links: one list, top to bottom, at every width ---------- */
.header-sticky .navbar-collapse .navbar-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
}

.header-sticky .navbar-collapse .navbar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 48px;
  padding: 0.75rem 0.875rem;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 500;
  white-space: normal;
}

.header-sticky .navbar-collapse .navbar-nav .nav-link:hover,
.header-sticky .navbar-collapse .navbar-nav .nav-link:focus-visible {
  opacity: 1;
  background: var(--tw-menu-hover);
}

/* Gift cards: a lime chip, so the newest thing on the site stands out in the list. The id keeps it
   ahead of the seasonal link hovers (css/autumn.css). */
#navbarNav .nav-link.tw-gift-nav {
  background: var(--tw-menu-gift-bg);
  color: var(--tw-menu-gift-text);
  font-weight: 600;
}

#navbarNav .nav-link.tw-gift-nav:hover,
#navbarNav .nav-link.tw-gift-nav:focus-visible {
  background: var(--tw-menu-gift-hover);
  color: var(--tw-menu-gift-text);
}

/* ---------- The buttons: full width, one under the other ---------- */
.header-sticky .tw-menu-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.625rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--tw-menu-line);
}

.header-sticky .tw-menu-actions .btn {
  width: 100%;
  height: 48px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ---------- Signed in: the profile, then the account links in the same list ---------- */
.header-sticky .mobile-profile-top .mobile-profile-card {
  padding: 0.375rem 0.875rem 0.875rem;
  border-bottom-color: var(--tw-menu-line);
}

.header-sticky .navbar-collapse .mobile-section-label {
  margin: 0.75rem 0.875rem 0.25rem;
  color: var(--tw-menu-muted);
}

.header-sticky .navbar-collapse .mobile-account-section {
  margin-top: 0.625rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--tw-menu-line);
}

.header-sticky .navbar-collapse .mobile-profile-links {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 0;
}

.header-sticky .navbar-collapse .mobile-profile-links a {
  min-height: 48px;
  padding: 0.75rem 0.875rem;
  border-radius: 14px;
  transition: background-color 0.2s ease;
}

.header-sticky .navbar-collapse .mobile-profile-links a:hover,
.header-sticky .navbar-collapse .mobile-profile-links a:focus-visible {
  opacity: 1;
  background: var(--tw-menu-hover);
}

@media (min-width: 992px) {
  .header-sticky .navbar-collapse {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-sticky .navbar-collapse,
  .header-sticky .navbar-collapse.show {
    transform: none;
    transition: none;
  }
}
