/*
 * Site header (shared/_header), on every page.
 *
 * Same rules as the other handoffs: no shadows, no transitions, secondary text
 * dark enough for WCAG AA. Values are the home feed handoff's.
 *
 * Unlayered CSS outranks Tailwind's layered utilities, so anything here that sets
 * `display` would beat Tailwind's `hidden`. The badges re-assert it explicitly,
 * because notification_controller toggles that class to show and hide them.
 */

:root {
  /* The header's height, for anything that sizes itself against the viewport.
     One row of 60px at 1020px and up; below that the nav adds a 44px second
     row. Plus the 1px bottom border (and 1px top border on the nav row). */
  --header-h: 106px;
}

@media (min-width: 1020px) {
  :root { --header-h: 61px; }
}

.hdr {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #F4EFD3;
  border-bottom: 1px solid #DCD5B4;
  color: #222222;
  /* iOS standalone mode: keep the header clear of the status bar. */
  padding-top: env(safe-area-inset-top);
}

.hdr :is(a, button):focus-visible {
  outline: 2px solid #2DC1FF;
  outline-offset: 2px;
}

.hdr__row {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
}

/* ------------------------------------------------------------------- brand */

.hdr__brand {
  order: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  color: #222222;
  text-decoration: none;
}

.hdr__brand:hover { color: #222222; }

.hdr__tile {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #222222;
  color: #F8F088;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
}

.hdr__name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

/* Narrow screens: the wordmark would push the right cluster onto its own row.
   The NP tile still says where you are and links home. */
@media (max-width: 479px) {
  .hdr__name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------- city picker */

/* Beside the brand: the city being browsed, opening a menu of the others
   (shared/_city_picker). Uses the account menu's .hdr__menu, opened leftward. */
.hdr__city {
  order: 1;
  position: relative;
}

.hdr__city-button {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1.5px solid #E2DCBC;
  background: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  color: #222222;
  cursor: pointer;
}

.hdr__city-button:hover,
.hdr__city-button[aria-expanded="true"] { border-color: #222222; }

.hdr__city-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Phones: just the pin. With the city's name the top row wrapped, pushing Sell
   and the account controls onto a row of their own. The button's label still
   names the city, and the menu marks it. */
@media (max-width: 639px) {
  .hdr__city-button { width: 34px; padding: 0; justify-content: center; }
  .hdr__city-name,
  .hdr__city-button > svg:last-child { display: none; }
}

.hdr__menu--left { left: 0; right: auto; top: 40px; }

.hdr__menu-label {
  padding: 6px 12px 2px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8A6206;
}

.hdr__city-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hdr__city-option--on { background: #FFF9D0; }

.hdr__menu-item--link { color: #0E6E9E; }
.hdr__menu-item--link:hover { color: #0A5477; }

/* --------------------------------------------------------------------- nav */

/* Below 1020px: a second row that scrolls sideways rather than wrapping. */
.hdr__nav {
  order: 3;
  flex: 1 1 100%;
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin: 0 -10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid #DCD5B4;
}

.hdr__nav::-webkit-scrollbar { display: none; }

.hdr__link {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: #555555;
  text-decoration: none;
}

.hdr__link:hover { color: #222222; }

.hdr__link--on {
  font-weight: 700;
  color: #222222;
}

.hdr__link--on::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: #222222;
}

/* One row from 1020px. Must stay above the one-row width (~950px), or the right
   cluster wraps on its own. */
@media (min-width: 1020px) {
  .hdr__nav {
    order: 1;
    flex: none;
    margin: 0 0 0 14px;
    overflow: visible;
    border-top: 0;
  }

  .hdr__link { height: 60px; }
}

/* ----------------------------------------------------------- right cluster */

.hdr__right {
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 60px;
}

.hdr__icon {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid #DCD5B4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222222;
  padding: 0;
  cursor: pointer;
}

.hdr__icon:hover { background: #F8F088; color: #222222; }

/* On Messages, the Messages button is the current page. */
.hdr__icon--on,
.hdr__icon--on:hover { background: #222222; border-color: #222222; color: #F8F088; }

.hdr__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #F86028;
  border: 2px solid #F4EFD3;
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hdr__badge.hidden { display: none; }

.hdr__bell { position: relative; }

/* The activity panel, restyled to the menu language: ink border, no shadow. */
.hdr__panel {
  top: 46px;
  background: #FFFFFF;
  border: 2px solid #222222;
  border-radius: 12px;
}

.hdr__panel.hidden { display: none; }

/* On a phone the bell sits well left of the screen edge, so a panel hung from its
   right edge runs off the left of the screen. Span the screen under the header
   instead. */
@media (max-width: 639px) {
  .hdr__panel {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top) + 6px);
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100dvh - var(--header-h) - env(safe-area-inset-top) - 24px);
    overflow-y: auto;
  }
}

.hdr__sell {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 0 11px;
  border-radius: 10px;
  background: #2DC1FF;
  border: 1.5px solid #2DC1FF;
  font-size: 14px;
  font-weight: 700;
  color: #10333F;
  text-decoration: none;
  white-space: nowrap;
}

.hdr__sell:hover { background: #96E0FF; border-color: #96E0FF; color: #10333F; }

/* On the Sell page: yellow with an ink border, like a pressed key. */
.hdr__sell--on,
.hdr__sell--on:hover { background: #F8F088; border-color: #222222; color: #222222; }

/* Guests: Log in / Sign up, in the account button's shape. */
.hdr__plain {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid #DCD5B4;
  font-size: 13.5px;
  font-weight: 700;
  color: #222222;
  text-decoration: none;
  white-space: nowrap;
}

.hdr__plain:hover { border-color: #222222; color: #222222; }

.hdr__plain--ink,
.hdr__plain--ink:hover {
  background: #222222;
  border-color: #222222;
  color: #FFF9D0;
}

/* ------------------------------------------------------------ account menu */

.hdr__account { position: relative; }

.hdr__account-button {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 3px;
  border-radius: 10px;
  border: 1px solid #DCD5B4;
  background: #FFFFFF;
  color: #222222;
  cursor: pointer;
}

.hdr__account-button:hover { border-color: #222222; }

/* On the Dashboard, the account button is the current page. */
.hdr__account-button--on { border: 1.5px solid #222222; }

.hdr__avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: #2DC1FF;
  color: #10333F;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  object-fit: cover;
}

.hdr__account-name {
  font-size: 13.5px;
  font-weight: 700;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 559px) {
  .hdr__account-name { display: none; }
}

.hdr__menu {
  position: absolute;
  right: 0;
  top: 46px;
  z-index: 2;
  min-width: 210px;
  background: #FFFFFF;
  border: 2px solid #222222;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hdr__menu[hidden] { display: none; }

.hdr__menu-head {
  padding: 8px 12px 10px;
  border-bottom: 1px solid #EDE7C8;
  margin-bottom: 4px;
}

.hdr__menu-name {
  font-size: 14px;
  font-weight: 700;
  color: #222222;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hdr__menu-profile {
  font-size: 12.5px;
  font-weight: 600;
  color: #0E6E9E;
  text-decoration: none;
}

.hdr__menu-profile:hover { color: #0A5477; }

.hdr__menu-form { display: contents; }

.hdr__menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  color: #222222;
  text-decoration: none;
  cursor: pointer;
}

.hdr__menu-item:hover { background: #FFF9D0; color: #222222; }

.hdr__menu-item--quiet { color: #666666; }

.hdr__menu-divider {
  height: 1px;
  background: #EDE7C8;
  margin: 4px 0;
}
