/*
 * Header + menu bar (approved 23 Oct 2026; previewed on /draft/ first). Loaded after roast.css, same scope.
 *
 * Desktop: logo | search with one suggestion line (Top Searches / Trending / New Listings taking turns) | four
 * shortcut tiles, then a dark espresso menu bar with centred items. Tablet: logo | search (the menu bar carries
 * the shortcuts' categories). Phone: logo with the menu button beside it, search underneath; no separate menu bar.
 */
/* The suggestion rows' track/links wrappers must not pick up the theme's
   `#header-search .search-sample span { margin-right: 10px }`. */
#header-search .search-sample .search-sample-track,
#header-search .search-sample .search-sample-links {
  margin-right: 0;
}

html:has(.ad-roast) {
  /* ---------------------------------------------------------- Top row */
  & #primary-header,
  & .primary-header {
    padding: 18px 0 !important;
    border-bottom: 0 !important;
  }
  & .primary-header > .container {
    grid-template-columns: 210px minmax(0, 1fr) auto;
    column-gap: 24px;
    align-items: center;
    padding-left: 24px !important;
    padding-right: 24px !important;
  }
  & .site-header .logo_area {
    display: flex;
    align-items: center;
  }
  & .site-header .logo_area img {
    width: 210px;
  }
  & .header_right {
    padding-top: 0 !important;
  }

  /* Search: one 48px bar with an offset shadow, magnifier on the button */
  & #header-search .header-search-input {
    height: 48px;
    box-shadow: var(--rw-shadow-sm);
  }
  & #header-search .header-search-input input.prompt {
    height: 48px !important;
    padding: 0 16px !important;
    font-size: 15px !important;
  }
  & #header-search .header-search-submit {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 22px !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  & #header-search .header-search-submit::before {
    content: "\f002";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
  }
  & #header-search .header-search-submit-mobile.ui.button {
    height: 48px;
    width: 52px;
    padding: 0 !important;
    justify-content: center;
    align-items: center;
  }

  /* Suggestions: one line under the search box that takes turns: Top Searches, then Trending, then New Listings,
     2 seconds each, fading up into place. The three rows share one grid cell; hovering or focusing a link pauses
     the turn. With reduced motion the three rows simply stack. Names that don't fit are hidden whole. */
  & #header-search {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
  }
  & #header-search > .clear {
    display: none;
  }
  & .search-sample {
    display: flex !important;
    grid-row: 2;
    grid-column: 1;
    align-items: flex-start;
    margin: 12px 0 0 !important;
    font-size: 0 !important; /* hides the ", " separators between the links */
    white-space: nowrap;
    animation: ad-turn 6s ease-in-out infinite both;
  }
  & .search-sample + .search-sample {
    animation-delay: 2s;
  }
  & .search-sample + .search-sample + .search-sample {
    animation-delay: 4s;
  }
  & #header-search:hover .search-sample,
  & #header-search:focus-within .search-sample {
    animation-play-state: paused;
  }
  & .search-sample,
  & .search-sample > *,
  & .search-sample .search-sample-links {
    line-height: 19px !important;
  }
  @media (prefers-reduced-motion: reduce) {
    & .search-sample {
      grid-row: auto;
      margin-top: 4px !important;
      animation: none;
    }
    & .header-search-input + .clear + .search-sample {
      margin-top: 12px !important;
    }
  }
  & .search-sample > span:first-child {
    flex: 0 0 88px;
    color: var(--rw-orange) !important;
    font-size: 10px !important;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  & .search-sample .search-sample-track {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 0 !important;
  }
  & .search-sample .search-sample-links {
    display: flex;
    flex-wrap: wrap;
    height: 19px; /* one line: names that don't fit wrap below it, out of sight */
    overflow: hidden;
    font-size: 0 !important;
  }
  & .search-sample a {
    color: var(--rw-ink) !important;
    font-size: 12px !important;
    font-weight: 600;
    text-decoration: none;
    text-underline-offset: 3px;
  }
  & .search-sample a:hover {
    color: var(--rw-orange) !important;
    text-decoration: underline;
  }
  & .search-sample a + a::before {
    content: "·";
    display: inline-block;
    margin: 0 7px;
    color: var(--rw-muted);
    font-weight: 700;
    text-decoration: none;
  }

  /* Shortcut tiles: four equal columns with even gaps; long labels wrap onto two lines */
  & .header-highlight {
    display: grid !important;
    grid-template-columns: repeat(4, 76px);
    align-items: start;
    column-gap: 6px;
  }
  & .header-highlight > a,
  & .header-highlight a:first-child {
    width: 76px !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
  }
  & .header-highlight .highlight-icon {
    width: 46px;
    height: 46px;
    margin: 0 0 9px !important;
    box-shadow: 3px 3px 0 0 var(--rw-ink) !important;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  }
  & .header-highlight > a:hover .highlight-icon {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 0 var(--rw-ink) !important;
  }
  & .header-highlight .highlight-text {
    font-size: 10.5px !important;
    letter-spacing: 0.05em;
    line-height: 1.3 !important;
    white-space: normal !important;
  }

  /* ---------------------------------------------------------- Menu bar */
  & .site-navigation {
    background: var(--rw-ink) !important;
    border-top: var(--rw-border) !important;
    border-bottom: 0 !important;
    backdrop-filter: none !important;
  }
  & .site-navigation > .container {
    display: flex;
    justify-content: center;
  }
  & .site-navigation .primary-navigation {
    float: none !important;
  }
  @media (min-width: 791px) {
    & .site-navigation .st-menu {
      display: flex !important;
      flex-wrap: wrap;
      justify-content: center;
    }
    & .site-navigation .st-menu > li + li {
      border-left: 1px solid var(--rw-dark-line);
    }

    /* "There's more" arrows: a down chevron on menu items that open a dropdown (turns up while open), a right
       chevron on dropdown items that open a side panel. Dropdowns also open for keyboard focus, not only hover. */
    & .site-navigation .st-menu li.menu-item-has-children > a::after {
      font-family: "Font Awesome 5 Free";
      font-weight: 900;
      font-style: normal;
      -webkit-font-smoothing: antialiased;
      transition: transform 0.15s ease;
    }
    & .site-navigation .st-menu > li.menu-item-has-children > a::after {
      content: "\f107"; /* angle-down */
      display: inline-block;
      margin-left: 7px;
      color: var(--rw-mustard);
      font-size: 12px;
    }
    & .site-navigation .st-menu > li.menu-item-has-children:hover > a::after,
    & .site-navigation .st-menu > li.menu-item-has-children:focus-within > a::after {
      transform: rotate(180deg);
    }
    & .site-navigation .st-menu .sub-menu li.menu-item-has-children > a {
      padding-right: 30px !important;
    }
    & .site-navigation .st-menu .sub-menu li.menu-item-has-children > a::after {
      content: "\f105"; /* angle-right */
      position: absolute;
      top: 50%;
      right: 12px;
      margin-top: -0.5em;
      color: var(--rw-orange);
      font-size: 12px;
      line-height: 1;
    }
    & .site-navigation .st-menu .sub-menu li.menu-item-has-children:hover > a::after,
    & .site-navigation .st-menu .sub-menu li.menu-item-has-children:focus-within > a::after {
      transform: translateX(3px);
    }
    & .site-navigation .st-menu li:focus-within > ul {
      display: block;
    }
  }

  /* ------------------------------------------ Space below the menu bar */
  /* Every page's first section starts the same distance below the menu bar: the dark title band of text pages
     (.hero, which would otherwise merge with the dark bar), store/category/search headers, the 404 box and the
     loading placeholder (so nothing moves when the content arrives). The home page has its own spacing. */
  & #content .hero,
  & #content .custom-page-header,
  & #content .error-404,
  & #content .ad-loading-shell {
    margin-top: 24px !important;
  }
  @media (max-width: 790px) {
    & #content .hero,
    & #content .custom-page-header,
    & #content .error-404,
    & #content .ad-loading-shell {
      margin-top: 16px !important;
    }
  }
  & .site-navigation .st-menu > li > a {
    padding: 15px 20px !important;
    color: var(--rw-cream) !important;
    font-size: 13px !important;
    letter-spacing: 0.07em !important;
    text-transform: uppercase;
    transition: color 0.15s ease, box-shadow 0.15s ease;
  }
  & .site-navigation .st-menu > li > a::before {
    color: var(--rw-mustard);
  }
  & .site-navigation .st-menu > li:hover > a,
  & .site-navigation .st-menu > li > a:hover,
  & .site-navigation .st-menu > li > a:focus-visible {
    color: #fff !important;
    box-shadow: inset 0 -3px 0 0 var(--rw-orange);
  }

  /* ------------------------------------------------------------ Tablet */
  @media (min-width: 791px) and (max-width: 1099px) {
    & .primary-header > .container {
      grid-template-columns: 190px minmax(0, 1fr);
      column-gap: 24px;
    }
    & .site-header .logo_area img {
      width: 190px;
    }
    & .header-highlight {
      display: none !important;
    }
    & .site-navigation .st-menu > li > a {
      padding: 14px 13px !important;
      font-size: 12px !important;
    }
  }

  /* ------------------------------------------------------------- Phone */
  @media (max-width: 790px) {
    & #stickable {
      position: relative;
    }
    & #primary-header,
    & .primary-header {
      padding: 10px 0 12px !important;
    }
    & #primary-header > .container {
      grid-template-columns: minmax(0, 1fr);
      row-gap: 10px;
      padding: 0 14px !important;
    }
    & #header-search .header-search-submit {
      display: none !important;
    }
    & #header-search .header-search-submit-mobile.ui.button {
      display: inline-flex !important;
    }
    & .site-header .logo_area {
      grid-column: 1;
      grid-row: 1;
      justify-content: flex-start !important;
      min-height: 50px;
      padding-right: 60px;
    }
    & .site-header .logo_area img {
      width: 156px;
    }
    & .header_right {
      grid-column: 1;
      grid-row: 2;
    }
    & .header-highlight {
      display: none !important;
    }
    & .search-sample,
    & .search-sample > *,
    & .search-sample .search-sample-links {
      line-height: 22px !important;
    }
    & .search-sample .search-sample-links {
      height: 44px; /* up to two lines of names on a phone */
    }
    & .search-sample > span:first-child {
      flex-basis: 86px;
    }

    /* The menu button sits on the logo row; the open menu drops down over the page from there */
    & .site-navigation {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 0;
      border: 0 !important;
      background: transparent !important;
      z-index: 60;
    }
    & .site-navigation > .container,
    & .site-navigation .primary-navigation {
      position: static;
      padding: 0 !important;
    }
    & #nav-toggle,
    & #nav_toggle_close {
      position: absolute;
      top: 12px;
      right: 14px;
      width: 46px;
      height: 46px;
      padding: 0;
      align-items: center;
      justify-content: center;
      border: var(--rw-border) !important;
      background: var(--rw-card) !important;
      box-shadow: 3px 3px 0 0 var(--rw-ink) !important;
      color: var(--rw-ink) !important;
    }
    & #nav-toggle {
      display: flex !important;
    }
    & #nav-toggle i.icon,
    & #nav_toggle_close i.icon {
      margin: 0;
    }
    & .st-menu.st-menu-mobile {
      top: 70px;
      left: 14px !important;
      right: 14px;
      width: auto !important;
      background: var(--rw-card) !important;
      border: var(--rw-border) !important;
      box-shadow: var(--rw-shadow-sm);
    }
    & .st-menu.st-menu-mobile > li {
      border-left: 0 !important;
      border-bottom: 1px solid var(--rw-sand) !important;
    }
    & .st-menu.st-menu-mobile > li:last-child {
      border-bottom: 0 !important;
    }
    & .st-menu.st-menu-mobile > li > a {
      padding: 14px 18px !important;
      color: var(--rw-ink) !important;
      font-size: 13px !important;
      letter-spacing: 0.06em !important;
      text-transform: uppercase;
      box-shadow: none !important;
    }
    & .st-menu.st-menu-mobile > li > a::before {
      color: var(--rw-orange);
    }
  }
}

/* Suggestion lines taking turns (each shown for a third of the 6s cycle): fade up in, hold, fade up out. */
@keyframes ad-turn {
  0% {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
  }
  4%,
  29% {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  33.3%,
  100% {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
  }
}
