/* ==========================================================================
   Mega-menu top bar — Option A (Phase MegaNav-1, 2026-06-28). Loaded after
   app.css. The top bar replaces the left sidebar on DESKTOP for standard
   tenant users (.layout--topnav). Mobile (<=900px) keeps the off-canvas
   sidebar + bottom tab bar untouched, so this whole file is gated to
   >=901px except the base `.topnav { display:none }`.
   ========================================================================== */
.topnav { display: none; }

@media (min-width: 901px) {
  /* Flip the standard layout from "sidebar | main" grid to a stacked
     top-bar + full-width main. Scoped to .layout--topnav so CA / pro
     chrome (plain .layout) keeps its sidebar. */
  .layout--topnav { display: block; }
  .layout--topnav > .sidebar { display: none; }
  .layout--topnav > .layout__hamburger,
  .layout--topnav > .layout__overlay { display: none; }

  .topnav {
    display: block;
    position: sticky;
    top: 0;
    /* Above content chrome (tenant-switcher z:60, banners z:50) so the bar's
       dropdowns aren't covered, but below modals/overlays/palette (z:100+). */
    z-index: 70;
    background: var(--paper, #faf7f1);
    border-bottom: 1px solid var(--ink-12, #e3ddd2);
  }
  .topnav__bar {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Extra right padding clears the fixed floating "?" help launcher
       (top:14px right:18px, 32px) so the profile never sits under it. */
    padding: 10px 64px 10px 22px;
    max-width: 1500px;
    margin: 0 auto;
  }

  .topnav__brand {
    font-family: var(--font-serif, Georgia, serif);
    font-weight: 700;
    font-size: 19px;
    text-decoration: none;
    color: var(--ink, #2b2620);
    flex: 0 0 auto;
  }
  .topnav__brand .brand-mark__os { color: var(--bronze, #9a6b1f); }
  /* Persona badge (SA / CA) — small pill after the wordmark. */
  .topnav__brand .brand-mark__beta {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 9.5px; font-weight: 700; letter-spacing: .06em;
    vertical-align: super; margin-left: 4px;
    padding: 1px 5px; border-radius: 5px;
  }

  /* ── Roots ── */
  .topnav__roots { display: flex; align-items: center; gap: 2px; }
  .topnav__rw { position: relative; }
  .topnav__root {
    appearance: none;
    display: inline-flex; align-items: center; gap: 6px;
    background: none;
    border: 0;
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-65, #5b544a);
    text-decoration: none;
    padding: 8px 13px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
  }
  /* Count badge on a direct-link root (CA/pro "What's Next"). */
  .topnav__root-badge {
    font-size: 10.5px; font-weight: 700; line-height: 1;
    background: var(--bronze, #9a6b1f); color: #fff;
    border-radius: 10px; padding: 2px 6px;
  }
  .topnav__root:hover { background: var(--ink-07, rgba(43,38,32,.05)); color: var(--ink, #2b2620); }
  .topnav__root.is-active { color: var(--ink, #2b2620); font-weight: 600; }
  .topnav__root.is-open { background: var(--bronze-soft, rgba(154,107,31,.09)); color: var(--bronze, #9a6b1f); }

  /* ── Dropdown panel ── */
  .topnav__panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    /* One shared column unit drives EVERY panel, so a column is the same width
       in 1-, 2- and 3-column menus and across all personas (uniform mega-menu).
       Panels grow by column count; the divider sits centered in the gap. */
    --tn-col: 208px;
    --tn-gap: 40px;
    min-width: 0;
    background: var(--card, #fffdf9);
    border: 1px solid var(--ink-12, #e3ddd2);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(24, 26, 23, .14);
    padding: 16px;
    z-index: 50;
  }
  /* Transparent bridge across the bar↔panel gap so hover-traverse from a
     root down into its menu doesn't pass through dead space and close it. */
  .topnav__panel::before {
    content: ""; position: absolute; left: 0; right: 0;
    top: -12px; height: 12px;
  }
  .topnav__panel--wide { min-width: 0; }
  /* Equal-width columns: one fixed unit (var(--tn-col)) everywhere, so a column
     looks identical in 1-, 2- and 3-column panels and across personas. */
  .topnav__grid { display: grid; grid-template-columns: var(--tn-col); row-gap: 6px; }
  /* Auto-flow columns: one track per VISIBLE group, so a panel with an
     access-hidden column shrinks to fit — no dead space (Phase MenuEmptyCol). */
  .topnav__grid--2, .topnav__grid--3 {
    grid-auto-flow: column; grid-auto-columns: var(--tn-col); column-gap: var(--tn-gap);
  }
  /* Vertical separator centered in the gap (counterpart to the rule under each
     group heading). A pseudo-element keeps the column content width uniform. */
  .topnav__group { position: relative; }
  .topnav__grid--2 > .topnav__group:not(:first-child)::before,
  .topnav__grid--3 > .topnav__group:not(:first-child)::before {
    content: ""; position: absolute; top: 2px; bottom: 2px;
    left: calc(var(--tn-gap) / -2);
    border-left: 1px solid var(--ink-12, #e3ddd2);
  }
  .topnav__group h5 {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bronze, #9a6b1f);
    margin: 4px 0 8px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--ink-12, #e3ddd2);
  }
  /* A SECOND heading inside a group (Phase LB-1, 2026-08-04 — Lending sits
     under Insurance in one column). The 4px top margin is tuned for a heading
     at the top of a column; following a list of items it needs real
     separation, or the new section reads as part of the one above. */
  .topnav__group h5 ~ h5 { margin-top: 18px; }
  .topnav__item {
    display: flex;
    gap: 10px;
    /* Uniform row height + vertical centering so items with a description
       (2-line) and without (1-line) occupy the same height across panels. */
    align-items: center;
    min-height: 48px;
    box-sizing: border-box;
    padding: 8px 8px;
    margin: 0 -8px;
    border-radius: 7px;
    text-decoration: none;
    color: var(--ink, #2b2620);
  }
  .topnav__item:hover { background: var(--bronze-soft, rgba(154,107,31,.08)); }
  .topnav__item.is-current { background: var(--bronze-soft, rgba(154,107,31,.10)); }
  .topnav__ico { width: 18px; height: 18px; flex: 0 0 auto; color: var(--ink-65, #5b544a); }
  .topnav__item-body { display: flex; flex-direction: column; line-height: 1.25; }
  .topnav__item-body .nm { font-size: 13.5px; font-weight: 500; }
  .topnav__item-body .ds { font-size: 11.5px; color: var(--ink-45, #8b8377); }

  /* ── Right cluster ── */
  .topnav__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
  .topnav__search {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--ink-04, rgba(43,38,32,.035));
    border: 1px solid var(--ink-12, #e3ddd2);
    border-radius: 8px;
    padding: 7px 11px;
    color: var(--ink-45, #8b8377);
    cursor: pointer;
    font: inherit; font-size: 12.5px;
  }
  .topnav__search:hover { background: var(--ink-07, rgba(43,38,32,.05)); }
  .topnav__kbd {
    font-size: 11px; font-weight: 600; color: var(--ink-65, #5b544a);
    border: 1px solid var(--ink-12, #e3ddd2); border-radius: 5px;
    padding: 1px 6px; background: var(--paper, #faf7f1);
  }
  .topnav__iconbtn {
    appearance: none; -webkit-appearance: none;
    background: transparent;   /* kill the <button> UA default light fill */
    position: relative; display: inline-grid; place-items: center;
    width: 38px; height: 38px; border-radius: 8px;
    color: var(--ink-65, #5b544a); text-decoration: none; cursor: pointer;
  }
  .topnav__iconbtn:hover { background: var(--ink-07, rgba(43,38,32,.05)); }
  .topnav__iconbtn .topnav__ico { width: 19px; height: 19px; }
  .topnav__badge {
    position: absolute; top: 3px; right: 3px;
    background: var(--bronze, #9a6b1f); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1;
    border-radius: 10px; padding: 2px 5px;
  }

  /* ── Profile menu ── */
  .topnav__profile { position: relative; }
  .topnav__avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-grid; place-items: center; line-height: 1;
    flex: 0 0 auto;
    border: 1px solid var(--ink-12, #e3ddd2);
    background: var(--bronze-soft, rgba(154,107,31,.12));
    color: var(--bronze, #9a6b1f);
    font-weight: 700; font-size: 14px; cursor: pointer;
  }
  .topnav__menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 200px;
    background: var(--card, #fffdf9);
    border: 1px solid var(--ink-12, #e3ddd2);
    border-radius: 10px;
    box-shadow: 0 12px 34px rgba(24, 26, 23, .14);
    padding: 6px; z-index: 50;
  }
  .topnav__menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--ink-12, #e3ddd2); margin-bottom: 4px; display: flex; flex-direction: column; }
  .topnav__menu-head .muted { font-size: 12px; color: var(--ink-45, #8b8377); }
  .topnav__menu a,
  .topnav__menu .topnav__signout button {
    display: block; width: 100%; text-align: left;
    padding: 8px 10px; border-radius: 6px;
    color: var(--ink, #2b2620); text-decoration: none;
    background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer;
  }
  .topnav__menu a:hover,
  .topnav__menu .topnav__signout button:hover { background: var(--ink-07, rgba(43,38,32,.05)); }
  .topnav__signout { margin-top: 2px; border-top: 1px solid var(--ink-12, #e3ddd2); padding-top: 2px; }
  .topnav__menu-ver { margin-top: 4px; padding: 6px 10px 2px; border-top: 1px solid var(--ink-12, #e3ddd2);
    font-size: 11.5px; color: var(--ink-45, #8b8377); letter-spacing: .02em; }

  /* ── Dark "forest" bar — matches the old sidebar identity. Bar chrome only;
     the dropdown panels + profile menu stay light/paper (chosen for readable
     item lists). Mirrors the sidebar's --sb-* palette. ── */
  .topnav { background: #131b14; border-bottom: 1px solid rgba(214, 220, 210, .08); }
  /* Nightfall: uniform ivory italic "vansh" + flat warm bronze "OS" (#c67a34,
     same as every other surface). */
  .topnav__brand .brand-mark__v,
  .topnav__brand .brand-mark__ansh { color: #e8e5dc; font-style: italic; }
  .topnav__brand .brand-mark__os { color: #c67a34; }
  .topnav__brand .brand-mark__beta { background: rgba(193, 161, 115, .22); color: #d8bd92; }
  /* SVG wordmark lockup (Phase BrandLockup, 2026-07-27): this dark forest bar
     is a FIXED dark ground (like the sidebar), so force the nightfall wordmark
     here — mirrors the ivory/bronze text overrides just above. */
  .topnav__brand .brand-mark__img { background-image: url("/static/brand/wordmark-nightfall.svg"); }
  .topnav__root { color: rgba(232, 229, 220, .70); }
  .topnav__root:hover { background: #1f2c24; color: #f1efe8; }
  .topnav__root.is-active { color: #fff; }
  .topnav__root.is-open { background: rgba(193, 161, 115, .18); color: #d8bd92; }
  .topnav__search {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(214, 220, 210, .14);
    color: rgba(232, 229, 220, .60);
  }
  .topnav__search:hover { background: rgba(255, 255, 255, .09); }
  .topnav__kbd { color: #e8e5dc; border-color: rgba(214, 220, 210, .18); background: rgba(255, 255, 255, .06); }
  /* Search / messages: match the "?" help launcher exactly — circular,
     transparent fill, white ring + white glyph, translucent-white hover
     (Phase Colours-2 → -3, 2026-06-29). */
  .topnav__iconbtn {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 50%;
  }
  .topnav__iconbtn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .55); }
  /* The icon class carries its own dark ink colour (for the light dropdown
     panels); force white inside the bar's icon buttons so the glyph shows. */
  .topnav__iconbtn .topnav__ico { color: #fff; }

  /* Profile trigger with name + role (light text on the dark bar). */
  .topnav__profile-btn {
    display: flex; align-items: center; gap: 9px;
    background: none; border: 0; cursor: pointer; font: inherit;
    padding: 4px 8px 4px 4px; border-radius: 999px; color: #e8e5dc;
  }
  .topnav__profile-btn:hover { background: #1f2c24; }
  .topnav__profile-btn .topnav__avatar { background: rgba(193, 161, 115, .22); color: #d8bd92; border: 0; }
  .topnav__who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
  .topnav__who-name { font-size: 13px; font-weight: 600; color: #f1efe8; }
  .topnav__who-role { font-size: 11px; color: rgba(232, 229, 220, .55); }
  .topnav__chev { width: 14px; height: 14px; color: rgba(232, 229, 220, .5); flex: 0 0 auto; }
  /* Tighter desktop widths → drop the name, keep the avatar. */
  @media (max-width: 1140px) {
    .topnav__who, .topnav__chev { display: none; }
  }
}
