/* ============================================================================
   The top bar — one bar, every page, every width.

   Three stylesheets used to argue about this header: editorial.css styles
   `.app-top` only above 1200px, homepage-refresh.css restyles it for the home
   page at every width, and below 1200px an entirely different header
   (`.top-chrome` in base.html) used to take over on every other page. The site
   therefore had two unrelated navbars and three sets of measurements.

   This file loads last and settles it: `.app-top` is the bar on every page at
   every width, and the old `.top-chrome` header steps aside (its ticker stays).
   Selectors carry a `body` prefix so they out-rank `.home-refresh .x`.

   The rules of the bar:
     - one baseline: every control is 40px tall and vertically centred
     - five groups, even gaps: brand | search | live stats | actions | language
     - pills for the primary button and the stat chips, 10px for everything else
     - existing tokens only (--blue, --blue-dark, --ink, --muted, --line, --coral)
       plus --line for every hairline, because --edge is redefined inside
       .home-refresh and would make the home page's borders a different grey.
   ========================================================================= */

/* ---------------------------------------------------------------- the frame */

body .app-top,
body.home-refresh .app-top {
  display: block;
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  backdrop-filter: none;
}

/* A row, never a fixed column count: the bar gains and loses pieces (the stats,
   the tagline, the write button, the bell, the avatar) and a grid with a set
   number of columns pushed the last group onto a second line. 72px on every
   page at every width above 719px: 40px of control with 16px of air either side. */
body .app-top .app-top-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 18px;
  width: calc(100% - 64px);
  max-width: 1450px;
  min-height: 72px;
  margin: 0 auto;
  padding: 0;
}

body .app-top .app-brand { flex: 0 0 auto; width: auto; }
body .app-top .app-live,
body .app-top .app-top-actions,
body .app-top .language-switch { flex: 0 0 auto; }

/* the search takes what is left up to its cap; the auto right margin hands the
   rest to whatever comes after it, so the right-hand groups stay on the edge
   whether or not the stats are on the page */
body .app-top .app-search { flex: 1 1 auto; margin: 0 auto 0 0; }

/* ------------------------------------------------------------- the dividers
   Thin rules keep the groups apart: after the search, between the live stat and
   the actions, and before the language switch. They are pseudo-elements on the
   groups themselves, so a group that is not on the page takes its rule with it.
   The margins add up to 18px of air on either side of every rule. */

body .app-top .app-live::before,
body .app-top .app-top-actions::before {
  content: "";
  flex: 0 0 auto;
  width: 1px;
  height: 24px;
  background: var(--line);
}

body .app-top .app-live::before { margin-right: 10px; }
body .app-top .app-top-actions::before { margin-right: 8px; }
/* no divider after the last control: it sat against the edge of the bar */

/* The second navbar, retired. `.top-chrome` held a date strip, a whole other
   header and the ticker, and took over below 1200px on every page except home.
   Nothing it carried is lost: shell.css already hid the date strip and the
   ticker site-wide, the five section links it showed are a subset of the left
   rail (which becomes a scrolling strip on narrow screens), and its search,
   account and language controls are in the bar above. */
body .top-chrome > .site-header,
body .top-chrome > .live-strip { display: none; }

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

body .app-top .app-brand {
  display: flex;
  height: 40px;
  min-height: 40px;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

body .app-top .app-brand .brand-image {
  width: 120px;
  height: auto;
  max-width: 100%;
}

/* The tagline was taken out of the bar; if it ever comes back it sits beside the
   wordmark behind a hairline instead of stacking under it and making the left
   group taller than the row. */
body .app-top .app-brand-line {
  display: none;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
  white-space: nowrap;
}

/* --------------------------------------------------------------- the search */

body .app-top .app-search {
  display: flex;
  height: 40px;
  min-height: 40px;
  min-width: 0;
  max-width: 640px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8fc;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

body .app-top .app-search:focus-within {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}

body .app-top .app-search > .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

body .app-top .app-search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14.5px;
}

body .app-top .app-search input::placeholder { color: var(--muted); opacity: 1; }

/* the ring is on the box, so the field itself does not need a second one */
body .app-top .app-search input:focus,
body .app-top .app-search input:focus-visible { outline: none; }

/* ----------------------------------------------------------- the live stats */

body .app-top .app-live {
  display: flex;
  align-items: center;
  gap: 8px;
}

body .app-top .app-stat {
  display: inline-flex;
  height: 40px;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

body .app-top a.app-stat:hover { border-color: #9dbcf8; color: var(--blue-dark); }

body .app-top .app-stat .icon { width: 17px; height: 17px; color: #e8a13c; }

body .app-top .app-stat b {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* editorial.css hides every span inside a chip below 1500px; now that the
   exchange-rate chip is gone there is room for the weather word to stay. */
body .app-top .app-stat [data-live="weather-label"] { display: inline; }

/* -------------------------------------------------------------- the actions */

body .app-top .app-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* the one pill: write a post, or sign up */
body .app-top .app-write {
  display: inline-flex;
  position: relative;
  height: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--blue) 18%, transparent);
  transition: background-color 0.15s;
}

body .app-top .app-write:hover { background: var(--blue-dark); }
body .app-top .app-write > .icon { display: block; width: 16px; height: 16px; }

/* log in: the same button, outlined */
body .app-top .app-login {
  display: inline-flex;
  height: 40px;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

body .app-top .app-login:hover {
  border-color: #9dbcf8;
  background: #f6f9ff;
  color: var(--blue-dark);
}

body .app-top .app-login .icon { width: 15px; height: 15px; color: var(--muted); }
body .app-top .app-login:hover .icon { color: var(--blue-dark); }

/* Glyph and label share one centre line. The buttons drop the inherited 1.65
   line-height (site.css sets it on body) so the text box is no taller than the
   text, and the labels are wrapped in a span of their own so the flex box
   centres a real box rather than an anonymous run of text. */
body .app-top .app-write,
body .app-top .app-login,
body .app-top .app-stat,
body .app-top .language-switch a { line-height: 1; }

body .app-top .app-write > .icon,
body .app-top .app-login > .icon,
body .app-top .app-stat > .icon {
  display: block;
  flex: 0 0 auto;
  align-self: center;
}

body .app-top .app-write > span,
body .app-top .app-login > span {
  display: block;
  align-self: center;
  line-height: 1;
}

/* notifications: a real button with a shape, not a floating glyph */
body .app-top .app-icon-button {
  display: grid;
  position: relative;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  place-items: center;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

body .app-top .app-icon-button:hover {
  border-color: #9dbcf8;
  background: #f6f9ff;
  color: var(--blue-dark);
}

body .app-top .app-icon-button .icon { width: 19px; height: 19px; }

body .app-top .app-badge {
  display: grid;
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  place-items: center;
}

/* the avatar and its chevron are one control, not two */
body .app-top .app-account { position: relative; }

body .app-top .app-account > summary {
  display: flex;
  height: 40px;
  min-height: 40px;
  align-items: center;
  gap: 5px;
  padding: 0 8px 0 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  list-style: none;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

body .app-top .app-account > summary::-webkit-details-marker { display: none; }
body .app-top .app-account > summary::marker { content: ""; }
body .app-top .app-account > summary:hover { border-color: #9dbcf8; background: #f6f9ff; }
body .app-top .app-account[open] > summary { border-color: #9dbcf8; background: #f1f5fd; }

body .app-top .app-account > summary .mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 12.5px;
}

/* the chevron glyph points right; turn it down, and up again when the menu is open */
body .app-top .app-account > summary .icon {
  width: 13px;
  height: 13px;
  color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.15s;
}

body .app-top .app-account[open] > summary .icon { transform: rotate(-90deg); }

/* ------------------------------------------------------------ account menu */
/* The 20px icon column, 11px gap and 38px rows come from editorial.css and
   homepage-refresh.css; they are kept here so the menu is identical on the home
   page (which loads homepage-refresh.css) and everywhere else. */

body .app-top .app-account-menu {
  display: grid;
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 40px #16274a1f;
}

body .app-top .app-account-menu a,
body .app-top .app-account-menu button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

body .app-top .app-account-menu a:hover,
body .app-top .app-account-menu button:hover { background: #f1f5fd; color: var(--blue-dark); }

body .app-top .app-account-menu .icon {
  width: 17px;
  height: 17px;
  justify-self: center;
  color: var(--muted);
}

body .app-top .app-account-menu a:hover .icon,
body .app-top .app-account-menu button:hover .icon { color: var(--blue-dark); }

body .app-top .app-account-menu .count-badge { justify-self: end; margin: 0; }

body .app-top .app-account-who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

body .app-top .app-account-who .mark { width: 28px; height: 28px; border-radius: 50%; font-size: 12.5px; }

body .app-top .app-account-group {
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body .app-top .app-account-menu .logout-form {
  display: grid;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}

/* ------------------------------------------------------------- the language */

body .app-top .language-switch {
  display: inline-flex;
  height: 40px;
  min-height: 40px;
  align-items: center;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8fc;
  font-size: 12.5px;
  font-weight: 700;
}

body .app-top .language-switch > span { display: none; }

body .app-top .language-switch a {
  display: flex;
  height: 32px;
  min-height: 0;
  align-items: center;
  padding: 0 11px;
  border-radius: 7px;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

body .app-top .language-switch a:hover { color: var(--ink); }

body .app-top .language-switch a[aria-current] {
  background: #fff;
  color: var(--blue-dark);
  box-shadow: 0 1px 2px #16274a24;
}

/* ================================================== 720–1199px: one row still
   The stats and the tagline are the first things to go; the five groups become
   four and everything keeps its 40px baseline. This is also the answer to the
   1100–1199px band, where the bar used to disappear in favour of `.top-chrome`. */

@media (max-width: 1199px) {
  body .app-top .app-top-inner {
    gap: 16px;
    width: calc(100% - 48px);
    max-width: 1360px;
  }

  body .app-top .app-live { display: none; }
}

@media (max-width: 899px) {
  body .app-top .app-top-actions { gap: 8px; }
  body .app-top .app-write { padding: 0 15px; }
  body .app-top .language-switch a { padding: 0 9px; }
}

/* ===================================================== 719px and under: phone
   Two rows, each 40px: brand and the account affordances on top, search and the
   language switch underneath. */

@media (max-width: 719px) {
  body .app-top,
  body.home-refresh .app-top { position: relative; }

  /* two explicit rows, so the pieces cannot land anywhere unexpected */
  body .app-top .app-top-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand  actions"
      "search search";
    gap: 10px 12px;
    min-height: 0;
    padding: 12px 0;
  }

  body .app-top .app-brand { grid-area: brand; height: 36px; }
  body .app-top .app-top-actions { grid-area: actions; justify-self: end; }
  body .app-top .app-search { grid-area: search; margin: 0; }
  body .app-top .app-brand .brand-image { width: 108px; }
  body .app-top .app-search { max-width: none; }
  body .app-top .app-search input { font-size: 16px; }   /* no zoom-on-focus */

  /* the member's write button becomes a square; the label stays for screen readers */
  body .app-top .app-write:not(.app-join) { width: 40px; padding: 0; }

  body .app-top .app-write:not(.app-join) > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    border: 0;
    margin: -1px;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body .app-top .app-write.app-join { padding: 0 14px; }
  body .app-top .app-login { padding: 0 12px; }
  body .app-top .language-switch { justify-self: end; }
  body .app-top .app-account-menu { min-width: 232px; }
}

@media (max-width: 620px) {
  body .app-top .app-top-inner { width: calc(100% - 32px); }
}

@media (max-width: 400px) {
  body .app-top .app-brand .brand-image { width: 98px; }
  body .app-top .app-top-actions { gap: 6px; }
  body .app-top .app-write.app-join { padding: 0 12px; font-size: 13.5px; }
  body .app-top .app-login { padding: 0 10px; font-size: 13.5px; }
  body .app-top .language-switch a { padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  body .app-top * { transition: none; }
}

/* ------------------------------------------------------ search, everywhere
   A search box should look like something you can type in: a real border, a field colour that is not the
   page colour, and a placeholder you can read. This was the owner's "search is hard to see" on every page. */
.app-search,
.board-search,
.dining-search,
.rail-search form,
.listing-search {
  border: 1px solid #cdd8e8;
  background: #fff;
  box-shadow: inset 0 1px 2px #16274a08;
}

.app-search:focus-within,
.board-search:focus-within,
.dining-search:focus-within,
.rail-search form:focus-within,
.listing-search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 12%, transparent);
}

.board-search input,
.dining-search input,
.listing-search input,
.app-search input,
.rail-search input { color: var(--ink); font-size: 14.5px; }

.board-search input::placeholder,
.dining-search input::placeholder,
.listing-search input::placeholder,
.app-search input::placeholder,
.rail-search input::placeholder { color: #7286a3; opacity: 1; }

.board-search .icon,
.dining-search .icon,
.app-search .icon,
.rail-search .icon { color: #5f7290; }

.board-search button .icon,
.dining-search button .icon { color: #5f7290; }

/* ------------------------------------------------ today's weather, in the bar
   The strip fills its slot and opens into the sky: the scene art, how it feels, and the days after. */
@media (min-width: 1200px) {
  body .app-top .app-live { position: relative; width: 236px; flex-shrink: 0; }

  body .app-top .app-weather { width: 100%; }

  body .app-top .app-weather > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--edge);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
  }

  body .app-top .app-weather > summary::-webkit-details-marker { display: none; }
  body .app-top .app-weather > summary:hover { border-color: #b9cdf5; }
  body .app-top .app-weather[open] > summary { border-color: var(--blue); background: #f6f9ff; }

  body .app-top .app-weather-now .icon { width: 19px; height: 19px; color: #e8a13c; }
  body .app-top .app-weather > summary b { color: var(--ink); font-size: 14.5px; font-weight: 800; }
  body .app-top .app-weather > summary > span:not(.app-weather-now) {
    overflow: hidden;
    flex: 1;
    text-overflow: ellipsis;
  }
  body .app-top .app-weather > summary > .icon { width: 14px; height: 14px; color: var(--ink-3); }
  body .app-top .app-weather[open] > summary > .icon { transform: rotate(90deg); }

  .app-weather-panel {
    position: absolute;
    z-index: 40;
    top: calc(100% + 10px);
    left: 0;
    width: 330px;
    max-height: calc(100dvh - 90px);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--edge);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 20px 44px #16274a24;
  }
}

.app-weather-art { position: relative; isolation: isolate; aspect-ratio: 3 / 2; overflow: hidden; background: #dbeafe; }

body .app-top .app-weather-art .home-welcome-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 1;
}

.app-weather-art::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(90deg, #0d1b337d, #0d1b3300 62%), linear-gradient(0deg, #0d1b3380, #0d1b3300 62%);
  content: "";
}

.app-weather-read {
  position: absolute;
  z-index: 2;
  bottom: 12px;
  left: 14px;
  max-width: calc(55% - 14px);
  display: grid;
  gap: 1px;
  color: #fff;
  text-align: left;
}

.app-weather-read strong { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.app-weather-read span { color: #fff; font-size: 13px; }

.app-weather-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--edge-soft);
}

.app-weather-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.app-weather-facts dt { color: #5f6e86; font-size: 13px; }
.app-weather-facts dd { color: var(--ink); font-size: 13px; font-weight: 700; }

.app-weather-days { display: grid; padding: 6px 8px 8px; }

.app-weather-days li {
  display: grid;
  grid-template-columns: 1fr 24px auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.app-weather-days li:hover { background: #f6f9ff; }
.app-weather-days span { color: var(--ink-2); }
.app-weather-days .icon { width: 18px; height: 18px; color: #7d9dd6; }
.app-weather-days b { color: var(--ink); font-weight: 750; }
.app-weather-days em { color: var(--ink-3); font-style: normal; }

.app-weather-foot {
  padding: 0 16px 14px;
  color: #5f6e86;
  font-size: 13px;
}

/* ---------------------------------------------- defects found while measuring
   Fixes for five things the measurements turned up after the bar was rebuilt. */

/* 1. home stacked the bar into four rows on a phone: homepage-refresh.css wraps the actions and caps them */
body .app-top .app-top-actions {
  flex-wrap: nowrap;
  max-width: none;
}

/* 2. the one-letter language toggle had no button shape below 1200px */
body .app-top .app-lang-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  place-items: center;
}

body .app-top .app-lang-toggle:hover { border-color: #9dbcf8; background: #f6f9ff; color: var(--blue-dark); }

/* 3. the unread count sat outside the account control instead of inside it */
body .app-top .app-account > summary .app-badge {
  position: static;
  top: auto;
  right: auto;
  border: 0;
}

/* 4. the profile row at the head of the menu keeps its larger avatar */
body .app-top .app-account-menu a.app-account-who { grid-template-columns: 34px 1fr; }
body .app-top .app-account-who .mark { width: 34px; height: 34px; }

/* 5. the bar is 72px now, so the sticky rails start just under it rather than 24px adrift */
@media (min-width: 1200px) {
  .rail-column,
  .sidebar .rail-ads,
  .sidebar .advertisement { top: 88px; }
}

/* the bar carries the search at every width, so the rail's narrow copy is redundant */
.rail-search-narrow { display: none; }

/* the name at the head of the account menu needs air around it, not just under it */
body .app-top .app-account-menu { padding: 10px; }

body .app-top .app-account-menu a.app-account-who {
  gap: 12px;
  padding: 12px 12px 14px;
  margin-bottom: 8px;
}

body .app-top .app-account-who strong { display: block; margin-bottom: 2px; }
