/* The one header of the site (templates/_header.html), on the planner and on every other page; light, the planner's own style.
 *
 *   brand | main navigation: Plan Library Highlights Journey Convoy Tours | (API status, planner only) Messages, People, bell, account menu
 *
 * Widths: from 1280 px the brand has its tagline and the API status its words; below 1100 px People is no longer in the bar but the first entry of the account
 * menu, and the name beside the avatar goes; up to 1000 px Messages is the envelope alone (with its badge); up to 820 px the bar has two rows (brand and account, then the
 * navigation, which scrolls sideways when it does not fit). Nothing is taken away without being somewhere else. On the planner the bar is exactly 76 px high
 * (.workspace is 100vh minus that) as long as the pointer is not a finger. */

.topbar { height: 76px; display: flex; align-items: center; gap: clamp(16px, 2.5vw, 40px); padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.96); position: relative; z-index: 1100; }

/* skip link: first in the tab order, visible while it has the focus */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 3000; padding: 10px 16px; border-radius: 10px; background: var(--forest); color: #fff; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 8px; }

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex: 0 0 auto; }
.brand-mark { width: 37px; height: 40px; flex: 0 0 37px; display: block; }   /* the mark (docs/REBRAND-CORNER-SOCIETY.md section 3) is 364 x 391, not square */
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; letter-spacing: -.4px; }
.brand small { color: var(--muted); font-size: 11px; }

/* the main navigation: buttons on the planner (they switch the panel in the page), links elsewhere; both look the same */
.topnav { display: flex; align-self: stretch; gap: 24px; min-width: 0; flex: 0 0 auto; }   /* (it keeps its width: where the bar is short of room the name beside the avatar gives way, not the navigation) */
.nav-button { border: 0; background: none; padding: 0 4px; color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; }
.topnav .nav-link { display: flex; align-items: center; padding: 0 4px; color: var(--muted); text-decoration: none; cursor: pointer; position: relative; white-space: nowrap; }
.nav-button:hover, .nav-button.is-active, .topnav .nav-link:hover, .topnav .nav-link.is-current { color: var(--ink); }
.nav-button.is-active::after, .topnav .nav-link.is-current::after { content: ""; position: absolute; height: 3px; border-radius: 5px; background: var(--forest); left: 0; right: 0; bottom: 0; }
.nav-button:focus-visible, .topnav .nav-link:focus-visible, .account-link:focus-visible, .user-chip:focus-visible, .brand:focus-visible,
.user-menu-list a:focus-visible, .user-menu-list button:focus-visible { outline: 2px solid var(--forest-2); outline-offset: 2px; border-radius: 6px; }

/* the right side */
.topbar-account { margin-left: auto; display: flex; align-items: center; gap: 12px; white-space: nowrap; min-width: 0; }
.topbar-account form { margin: 0; }
.account-nav { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-pill { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.status-pill > span:first-child { width: 8px; height: 8px; border-radius: 50%; background: #d59d38; box-shadow: 0 0 0 4px rgba(213,157,56,.14); }
.status-pill.is-online > span:first-child { background: #58a76f; box-shadow: 0 0 0 4px rgba(88,167,111,.14); }
.account-link { display: inline-flex; align-items: center; padding: 6px 4px; border-radius: 6px; color: var(--muted); font-size: 13px; text-decoration: none; }
.account-link:hover { color: var(--ink); }
.account-link.is-current { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }
.account-link-cta { padding: 8px 14px; border-radius: 9px; background: var(--forest); color: #fff; font-weight: 700; }
.account-link-cta:hover { color: #fff; background: var(--forest-2); }
/* Messages: the envelope with its name and the unread count; up to 1000 px the envelope alone (the count stays; the link's aria-label carries the name either way) */
.nav-messages { color: var(--ink); font-weight: 700; gap: 6px; }
.nav-messages-icon { display: block; flex: none; }
.nav-messages .nav-badge { margin-left: 0; }

/* the account menu behind the avatar: a disclosure (button + list of links; static/js/site-header.js) */
.user-menu { position: relative; min-width: 0; }
.user-chip { display: flex; width: 100%; min-width: 0; align-items: center; gap: 7px; border: 0; background: none; padding: 3px 8px 3px 3px; border-radius: 999px; color: var(--ink); font-size: 12px; font-weight: 750; cursor: pointer; }
.user-chip:hover, .user-chip[aria-expanded="true"] { background: rgba(127,140,132,.18); }
.user-chip-name { max-width: 150px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* (a long name ends in an ellipsis when the bar has no room for it) */
.user-chip.is-current .user-chip-name { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.user-chip img, .user-chip i { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--forest); color: white; display: grid; place-items: center; font-style: normal; flex: none; }
.user-chip-caret { flex: none; color: var(--muted); transition: transform .15s; }
.user-chip[aria-expanded="true"] .user-chip-caret { transform: rotate(180deg); }
.user-menu-list { position: absolute; right: 0; top: calc(100% + 8px); z-index: 2000; min-width: 200px; margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); text-align: left; white-space: normal; }
.user-menu-list li { margin: 0; }
.user-menu-list a, .user-menu-list button { display: flex; align-items: center; width: 100%; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.user-menu-list a:hover, .user-menu-list button:hover { background: #eff4ed; }
.user-menu-list [aria-current="page"] { font-weight: 800; }
.user-menu-list .user-menu-logout { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }
.user-menu-people { display: none; }

/* wider than 1279 px the brand has its tagline; up to that the bar is tighter: the API status is its dot (the words stay for a screen reader) */
@media (max-width: 1279px) {
  .brand small { display: none; }
  .status-pill > span:last-child { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
}
/* below 1100 px: People goes into the account menu, and the avatar stands without the name */
@media (max-width: 1099px) {
  .topnav { gap: 12px; }
  .account-link-people { display: none; }
  .user-menu-people { display: block; }
  .user-chip-name { display: none; }
}
/* the navigation is a little tighter still where the bar has no room to spare (821 - 900 px) */
@media (max-width: 900px) {
  .topnav { gap: 8px; }
}
/* up to 1000 px: Messages is the envelope alone */
@media (max-width: 1000px) {
  .nav-messages-label { display: none; }
  .nav-messages { min-width: 32px; justify-content: center; gap: 0; }
  .nav-messages .nav-badge { margin-left: 3px; }
}
/* up to 820 px: two rows - the brand with the account on the first, the navigation across the second (it scrolls sideways when it is wider than the screen) */
@media (max-width: 820px) {
  .topbar { height: auto; min-height: 68px; padding: 10px 16px; flex-wrap: wrap; gap: 6px 10px; }
  .brand { min-width: 0; flex: 1 1 0; }
  .topnav { order: 3; flex: 1 1 100%; width: 100%; height: 40px; overflow-x: auto; overflow-y: hidden; justify-content: space-between; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav > * { flex: 0 0 auto; }
  .topbar-account { gap: 6px; }
  .account-nav { gap: 4px; }
}
/* on a phone the wordmark gets smaller, and on a very small one the mark stands for it (the link's aria-label has the name) */
@media (max-width: 420px) {
  .brand { gap: 9px; }
  .brand strong { font-size: 17px; }
}
@media (max-width: 340px) {
  .brand > span { display: none; }
}
@media (max-width: 560px) {
  /* six items instead of five: a little tighter so that they still fit one row (the buttons and the links alike) */
  .topnav { gap: 2px; }
  .topnav .nav-button, .topnav .nav-link { padding: 0 2px; font-size: 13.5px; }
}
@media (max-width: 360px) {
  .topnav .nav-button, .topnav .nav-link { font-size: 12.5px; }
}
/* a finger needs 44 px */
@media (pointer: coarse) {
  .topnav { min-height: 44px; }
  .topnav .nav-button, .topnav .nav-link, .account-link, .user-chip, .notif-bell { min-height: 44px; }
  .notif-bell { width: 44px; height: 44px; }
  .user-chip { padding-right: 10px; }
  .nav-messages, .account-link-cta { min-width: 44px; justify-content: center; }
  .user-menu-list a, .user-menu-list button { min-height: 44px; }
  .skip-link { padding: 14px 18px; }
}
@media (pointer: coarse) and (max-width: 820px) {
  .topnav { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .user-chip-caret { transition: none; }
}
