/* Bearing — header & main navigation */

:root {
  --trailside-header-row-offset: 0px;
  --trailside-header-offset: 0px;
  --color-primary: #1b3a5c;
  --color-accent: #e6c463;
}

.tenant-construction .header,
.header.header-with-nav {
  background: var(--color-primary, #1b3a5c);
  color: #fff;
  border-bottom: 2px solid var(--color-accent, #e6c463);
  padding: 0;
}

.header-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.65rem;
  position: relative;
}

.header-brand,
.header-brand:visited {
  color: #fff;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  text-align: center;
  max-width: min(720px, 100%);
}

.header-row > .header-brand:only-child {
  grid-column: 1 / -1;
}

.header-advisor {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.header-brand .brand-name {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
}

.header-brand .brand-logo {
  display: block;
  max-height: 2rem;
  max-width: min(160px, 40vw);
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto 0.15rem;
}

.header-brand .brand-sub,
.header-brand .header-greeting {
  font-size: 0.78rem;
  opacity: 0.88;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  width: 100%;
}

.header-advisor {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.header-advisor-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  flex-shrink: 0;
}

.header-advisor-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.header-advisor-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.header-advisor-role {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.header-weather {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
}

.header-session {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-signout {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  position: static;
  top: auto;
  right: auto;
  opacity: 1;
  text-decoration: none;
}

.header-signout:hover {
  background: rgba(255, 255, 255, 0.12);
}

#main-nav {
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--color-primary, #1b3a5c);
}

.trailside-main-nav {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  min-height: 2.75rem;
}

.trailside-nav-toggle {
  display: none;
}

.trailside-nav-backdrop {
  display: none;
}

.trailside-nav-inner {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.15rem 2rem;
  width: 100%;
  padding: 0.55rem 1.25rem;
}

.trailside-nav-link-top {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.35rem 0.1rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 120ms ease, border-color 120ms ease;
}

.trailside-nav-link-top:hover {
  color: #fff;
  border-bottom-color: rgba(230, 196, 99, 0.55);
}

.trailside-nav-link-top.is-active {
  color: #fff;
  border-bottom-color: var(--color-accent, #e6c463);
}

.trailside-nav-label-full,
.trailside-nav-label-short {
  display: inline;
}

.trailside-nav-item,
.trailside-nav-trigger,
.trailside-nav-dropdown {
  display: none;
}

.header-qc-center-brand {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}

.trailside-offline-status-banner {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: center;
  padding: 0.55rem 1rem;
  background: #fffbeb;
  color: #92400e;
  border-bottom: 1px solid #f59e0b;
  position: sticky;
  top: 0;
  z-index: 950;
  letter-spacing: normal;
  font-variant-ligatures: none;
}

.trailside-offline-status-banner.is-offline {
  background: #fffbeb;
  color: #92400e;
  border-bottom-color: #f59e0b;
}

.trailside-offline-status-banner.is-at-risk {
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 2px solid #dc2626;
  font-weight: 600;
}

.trailside-offline-status-banner.is-syncing {
  background: #eff6ff;
  color: #1e3a8a;
  border-bottom: 1px solid #93c5fd;
  font-weight: 500;
}

.trailside-offline-status-banner.is-offline.is-at-risk {
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 2px solid #dc2626;
  font-weight: 600;
}

.trailside-offline-status-banner[hidden] {
  display: none !important;
}

@media (max-width: 768px) {
  .trailside-offline-status-banner {
    position: relative;
    z-index: 30;
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
}

.header-nav-toggle-slot {
  display: none;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-items: center;
}

@media (max-width: 768px) {
  .header-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem 0.55rem;
  }

  .header-advisor,
  .header-brand,
  .header-session,
  .header-nav-toggle-slot {
    grid-column: unset;
    grid-row: unset;
    justify-self: unset;
  }

  .header-brand {
    flex: 1 1 auto;
    align-items: center;
    text-align: center;
    max-width: none;
  }

  .header-advisor-meta {
    display: none;
  }

  .header-row {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .header-brand .brand-name {
    font-size: 0.95rem;
  }

  .header-brand .brand-sub {
    display: none;
  }

  .header-session {
    gap: 0.4rem;
    flex-shrink: 0;
    min-width: 0;
  }

  .header-row .header-signout,
  .header.header-with-nav .header-signout,
  .header .header-signout,
  .header-signout {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: transparent;
    border-radius: 4px;
    color: #fff;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.3rem 0.55rem;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    opacity: 1;
    cursor: pointer;
    position: static;
    top: auto;
    right: auto;
    min-height: auto;
  }

  .header-row .header-signout:hover,
  .header.header-with-nav .header-signout:hover,
  .header .header-signout:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
    opacity: 1;
  }

  html.mead-notes-quick-capture .header-row .header-signout,
  html.mead-notes-quick-capture .header.header-with-nav .header-row .header-signout,
  body.quick-capture-active:not(.notes-full-view) .header-row .header-signout,
  body.quick-capture-active:not(.notes-full-view) .header.header-with-nav .header-row .header-signout {
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: transparent;
    border-radius: 4px;
    padding: 0.3rem 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
    text-decoration: none;
    opacity: 1;
  }

  html.mead-notes-quick-capture .header-row .header-signout:hover,
  html.mead-notes-quick-capture .header.header-with-nav .header-row .header-signout:hover,
  body.quick-capture-active:not(.notes-full-view) .header-row .header-signout:hover,
  body.quick-capture-active:not(.notes-full-view) .header.header-with-nav .header-row .header-signout:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
    color: #fff;
  }

  .header-advisor-avatar {
    width: 1.85rem;
    height: 1.85rem;
    font-size: 0.8rem;
  }

  .trailside-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0.35rem 0.5rem 0.35rem 0.75rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
  }

  .trailside-nav-toggle-icon {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: currentColor;
    box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
  }

  .trailside-main-nav.is-menu-open .trailside-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
  }

  .trailside-nav-inner {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--color-primary, #1b3a5c);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }

  .trailside-main-nav.is-menu-open .trailside-nav-inner {
    display: flex;
  }

  .trailside-nav-link-top {
    display: block;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid transparent;
  }

  .trailside-nav-link-top.is-active {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--color-accent, #e6c463);
  }

  body.trailside-nav-menu-open {
    overflow: hidden;
  }

  .header.trailside-nav-toggle-in-header .header-nav-toggle-slot {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
  }

  /* Single-bar header: collapse empty nav mount; dropdown still anchors to .trailside-main-nav */
  .header.trailside-nav-toggle-in-header #main-nav {
    border-top: none;
    background: transparent;
    height: 0;
    min-height: 0;
    overflow: visible;
    position: relative;
    z-index: 100;
  }

  .header.trailside-nav-toggle-in-header .trailside-main-nav {
    min-height: 0;
    height: 0;
    overflow: visible;
  }

  .header.trailside-nav-toggle-in-header .header-row {
    flex-wrap: nowrap;
    gap: 0.35rem;
  }

  .header.trailside-nav-toggle-in-header .header-brand {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  .header.trailside-nav-toggle-in-header .header-advisor {
    flex: 0 0 auto;
  }

  .header.trailside-nav-toggle-in-header .header-row > .header-nav-toggle-slot {
    margin-left: auto;
  }

  .header.trailside-nav-toggle-in-header .header-session {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .header.trailside-nav-toggle-in-header .trailside-nav-toggle {
    margin: 0;
    width: 2.25rem;
    height: 2.25rem;
  }

  /* Navy brand header on mobile (override legacy near-black .header from styles.css) */
  .tenant-construction .header,
  .header.header-with-nav {
    background: var(--color-primary, #1b3a5c);
    color: #fff;
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .tenant-construction .header .header-row,
  .header.header-with-nav .header-row {
    background: transparent;
  }

  html.mead-notes-quick-capture .tenant-construction .header,
  html.mead-notes-quick-capture .header.header-with-nav,
  body.quick-capture-active:not(.notes-full-view).tenant-construction .header,
  body.quick-capture-active:not(.notes-full-view) .header.header-with-nav {
    background: var(--color-primary, #1b3a5c);
  }

  html.mead-notes-quick-capture .header-row,
  body.quick-capture-active:not(.notes-full-view) .header-row {
    background: transparent;
  }
}
