/* ============================================================================
   ib-nav.css — the SINGLE source of truth for the nav's styles.
   Used by <ib-nav> on every surface (static pages, calculator SPA, homepage,
   Next.js account pages). Dark is the default; overrides.
   ============================================================================ */

/* ── Canonical button / CTA tokens. Defined here because ib-nav.css loads on every
   surface (static, SPA, Next), so the CTA classes here + in ib-rail.css inherit one
   brand teal. Values are unchanged — this only centralises them. ── */
:root {
  --ib-cta-accent: #0fbcad;
  --ib-cta-accent-hover: #12d0bf;
  --ib-cta-fg: #0e0e10;
  --ib-teal-rgb: 15, 188, 173;
  --ib-fg: #f0f0f2;
  --ib-fg-rgb: 240, 240, 242;

  /* ── Shared frosted-popover surface. One recipe consumed by .ib-dropdown-menu
     (this file) and .ib-notify-panel (ib-chat.css) — only their border-radius
     differs (5 vs 8). Defined here because ib-nav.css loads on every surface.
     Light values are overridden in the block below. ── */
  --ib-popover-bg: rgba(20,22,26,0.72);
  --ib-popover-border: 1px solid rgba(255,255,255,0.16);
  --ib-popover-shadow: 0 16px 40px rgba(0,0,0,0.5),inset 0 1px 0 rgba(255,255,255,0.18);
  --ib-popover-blur: blur(40px) saturate(150%);
}

ib-nav { display: block; }

/* ── Top bar ── */
.ib-nav { position: sticky; top: 0; z-index: 200; background: rgba(14,14,16,0.80); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.07); transition: transform .28s ease; will-change: transform; }
.ib-nav-inner { max-width: 1180px; margin: 0 auto; padding: 0 36px; height: 48px; display: flex; align-items: center; gap: 28px; }
.ib-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; text-decoration: none; min-height: 44px; }
.ib-brand-text { font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size: 15px; color: var(--ib-fg); letter-spacing: -0.01em; }
.ib-brand-text strong { color: var(--ib-cta-accent); font-weight: 500; }
.ib-nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
/* Reserve a fixed width for the auth slot so the post-paint /api/me re-render
   (signed-out links <-> signed-in avatar) can't change its width and shift the
   nav row — a primary desktop CLS source. Right-aligned so content hugs the edge. */
.ib-auth-slot { display: inline-flex; align-items: center; justify-content: flex-end; min-width: 120px; }
.ib-nav-divider { width: 1px; height: 18px; background: rgba(255,255,255,0.07); margin: 0 4px; }
.ib-nav-signin { font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size: 12px; color: var(--ib-cta-accent); letter-spacing: 0.03em; padding: 5px 12px; border-radius: 5px; border: 1px solid rgba(var(--ib-teal-rgb),0.35); text-decoration: none; transition: background 0.15s,border-color 0.15s; white-space: nowrap; margin-left: 4px; }
.ib-nav-signin:hover { background: rgba(var(--ib-teal-rgb),0.1); border-color: rgba(var(--ib-teal-rgb),0.6); }
.ib-nav-signup { background: rgba(var(--ib-teal-rgb),0.08); }

/* ── Dropdowns (always in DOM; shown when the wrap has .open) ── */
.ib-dropdown-wrap { position: relative; }
.ib-dropdown-btn { display: flex; align-items: center; gap: 5px; font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size: 12px; color: rgba(var(--ib-fg-rgb),0.5); letter-spacing: 0.03em; padding: 6px 10px; background: none; border: none; cursor: pointer; border-radius: 5px; transition: color 0.15s; white-space: nowrap; text-decoration: none; }
.ib-dropdown-btn:hover, .ib-dropdown-wrap.open .ib-dropdown-btn { color: var(--ib-fg); }
.ib-dropdown-caret { font-size: 9px; opacity: 0.6; transition: transform 0.15s; }
.ib-dropdown-wrap.open .ib-dropdown-caret { transform: rotate(180deg); }
.ib-dropdown-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--ib-popover-bg); border: var(--ib-popover-border); border-radius: 5px; box-shadow: var(--ib-popover-shadow); min-width: 190px; max-height: min(72vh,560px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; z-index: 300; }
.ib-dropdown-wrap.open > .ib-dropdown-menu { display: block; }
@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) { .ib-dropdown-menu { backdrop-filter: var(--ib-popover-blur); -webkit-backdrop-filter: var(--ib-popover-blur); } }
.ib-dropdown-menu a, .ib-dropdown-menu .ib-dropdown-item { display: block; width: 100%; text-align: left; padding: 10px 16px; font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size: 13px; color: rgba(var(--ib-fg-rgb),0.6); transition: background 0.12s,color 0.12s; text-decoration: none; background: none; border: none; cursor: pointer; }
.ib-dropdown-menu a:hover, .ib-dropdown-menu .ib-dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--ib-fg); }
.ib-dropdown-menu .ib-dropdown-item.active { color: var(--ib-cta-accent); }
.ib-dropdown-menu--2col { min-width: 360px; column-count: 2; }

/* ── Theme toggle (desktop) ── */
.ib-theme-toggle { background: none; border: 1px solid rgba(255,255,255,0.13); border-radius: 6px; cursor: pointer; padding: 5px 8px; color: rgba(var(--ib-fg-rgb),0.45); display: flex; align-items: center; line-height: 1; transition: color 0.15s,border-color 0.15s; margin-left: 34px; }
.ib-theme-toggle:hover { color: var(--ib-fg); }

/* ── Avatar + user menu ── */
.ib-avatar-btn { position: relative; display: flex; align-items: center; text-decoration: none; background: none; border: none; padding: 0; cursor: pointer; }
.ib-avatar-pic { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; display: block; border: 1.5px solid rgba(var(--ib-teal-rgb),0.33); flex-shrink: 0; }
.ib-avatar-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ib-avatar-initials { display: flex; align-items: center; justify-content: center; background: rgba(var(--ib-teal-rgb),0.13); font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 11px; font-weight: 500; color: var(--ib-cta-accent); }
.ib-user-wrap { margin-left: 4px; }
.ib-user-menu { padding: 8px; min-width: 180px; }
/* The dropdown header (name + founder badge + email) is a link to /account/.
   Higher specificity than the generic .ib-dropdown-menu a so it keeps the header
   padding (not the menu-item 10px 16px); subtle hover signals it's clickable. */
.ib-dropdown-menu a.ib-user-head { display: block; padding: 6px 12px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 4px; color: inherit; text-decoration: none; cursor: pointer; transition: background 0.12s; }
.ib-dropdown-menu a.ib-user-head:hover { background: rgba(255,255,255,0.05); }
.ib-user-name { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 13px; font-weight: 600; color: var(--ib-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 156px; }
.ib-user-email { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 10px; color: rgba(var(--ib-fg-rgb),0.45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 156px; }
.ib-user-founder { display: inline-block; margin-top: 3px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #e0b341; background: rgba(224,179,65,0.13); border: 1px solid rgba(224,179,65,0.4); border-radius: 999px; padding: 1px 8px; }
.ib-user-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 0; }
.ib-user-signout { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 12px; color: #ff5757; padding: 7px 12px; border-radius: 6px; cursor: pointer; background: none; border: none; width: 100%; text-align: left; }

/* ── CTA quick icons (homepage) ── */
.ib-nav-cta-wrap { display: flex; align-items: center; gap: 2px; }
.ib-nav-cta { display: flex; align-items: center; padding: 6px; color: rgba(var(--ib-fg-rgb),0.55); text-decoration: none; border-radius: 6px; transition: color 0.15s,background 0.15s; }
.ib-nav-cta:hover { color: var(--ib-cta-accent); background: rgba(255,255,255,0.05); }

/* ── Hamburger + mobile pfp (mobile only) ── */
.ib-hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; color: var(--ib-fg); margin-left: 10px; min-width: 44px; min-height: 44px; justify-content: center; }
.ib-nav-pfp { display: none; }

@media (max-width: 767px) {
  .ib-nav-inner { padding: 0 18px; }
  .ib-nav-links { display: none; }
  .ib-hamburger { display: flex; align-items: center; }
  .ib-nav-cta-wrap { display: none; }
  /* leftDrawer mode: burger LEFT, brand centred, pfp RIGHT */
  .ib-nav--drawer .ib-nav-inner { position: relative; }
  .ib-nav--drawer .ib-brand { position: absolute; left: 50%; transform: translateX(-50%); }
  .ib-nav--drawer .ib-hamburger { order: -1; margin-left: 0; margin-right: auto; }
  .ib-nav--drawer .ib-nav-pfp { display: flex; align-items: center; margin-left: auto; -webkit-tap-highlight-color: transparent; text-decoration: none; }
  /* default mode (homepage / content pages): show the sign-in / avatar on the
     mobile bar too, right-aligned beside the burger */
  .ib-nav:not(.ib-nav--drawer) .ib-nav-pfp { display: flex; align-items: center; margin-left: auto; -webkit-tap-highlight-color: transparent; text-decoration: none; }
  /* 44px touch target for the mobile Sign-in pill (it renders as the pfp slot). */
  .ib-nav-signin { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; }
}
.ib-nav-pfp .ib-avatar-pic { width: 30px; height: 30px; }

/* ── Off-canvas master-detail drawer (the canonical TRT-calculator sidebar) ── */
.ib-calc-rail { display: none; }
.ib-rail-overlay { display: none; }
@media (max-width: 767px) {
  .ib-calc-rail { display: block; position: fixed; top: 0; left: 0; height: 100dvh; width: 300px; max-width: 86vw; z-index: 400; transform: translateX(-100%); visibility: hidden; transition: transform .25s ease,visibility 0s linear .25s; background: rgba(14,14,16,0.85); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-right: 1px solid rgba(255,255,255,0.13); box-shadow: 4px 0 30px rgba(0,0,0,.45); }
  .ib-calc-rail.open { transform: translateX(0); visibility: visible; transition: transform .25s ease,visibility 0s; }
  .ib-rail-inner { height: 100%; overflow-y: auto; padding: 14px 14px 28px; display: flex; flex-direction: column; gap: 18px; }
  .ib-rail-overlay { display: block; position: fixed; inset: 0; z-index: 399; background: rgba(0,0,0,.42); opacity: 0; visibility: hidden; backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); transition: opacity .25s ease,backdrop-filter .25s ease,-webkit-backdrop-filter .25s ease,visibility 0s linear .25s; }
  .ib-rail-overlay.open { opacity: 1; visibility: visible; backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); transition: opacity .25s ease,backdrop-filter .25s ease,-webkit-backdrop-filter .25s ease,visibility 0s; }
  /* padding-top:6 + padding-left:18 lands the close button's icon at exactly the
     same screen spot as the burger (.ib-nav-inner pad 18 + .ib-hamburger pad 8,
     vertically centred in the 48px bar → top 6). */
  .ib-rail-mhead { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; justify-content: flex-start; background: rgba(14,14,16,0.92); margin: -14px -14px 4px; padding: 6px 14px 10px 18px; transition: background .5s ease; }
  .ib-rail-mhead-brand { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 16px; color: var(--ib-fg); }
  .ib-rail-mhead-brand strong { color: var(--ib-cta-accent); font-weight: 500; }
  /* Mirrors .ib-hamburger (20px icon, 8px pad, var(--ib-fg)); align-self:flex-start so
     its top edge sits at the burger's, independent of taller siblings (pfp). */
  .ib-rail-close { display: flex; align-items: center; justify-content: center; align-self: flex-start; background: none; border: none; color: var(--ib-fg); cursor: pointer; padding: 8px; line-height: 0; transition: background .28s ease; min-width: 44px; min-height: 44px; }
  /* Scroll-down inside the drawer fades the header away (same .5s fade as the main
     nav on mobile) but the close button stays — gets the same legibility pill the
     hidden burger uses. Toggled by .ib-rail-hidden in ib-nav.js. */
  .ib-rail-mhead > * { transition: opacity .5s ease; }
  .ib-calc-rail.ib-rail-hidden .ib-rail-mhead { background: transparent; }
  .ib-calc-rail.ib-rail-hidden .ib-rail-mhead > *:not(.ib-rail-close) { opacity: 0; pointer-events: none; }
  .ib-calc-rail.ib-rail-hidden .ib-rail-close { background: rgba(127,127,127,0.34); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-radius: 8px; border: 1px solid rgba(127,127,127,0.5); }
  .ib-rail-pfp { margin-left: auto; display: flex; align-items: center; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  .ib-rail-pfp .ib-avatar-pic { width: 40px; height: 40px; }
  /* Suggestions button docked in the drawer header (beside the profile picture),
     replacing the floating #ib-suggest-bubble on mobile. */
  .ib-rail-suggest { margin-left: auto; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--ib-cta-accent); text-decoration: none; -webkit-tap-highlight-color: transparent; flex-shrink: 0; }
  .ib-rail-suggest:active { background: rgba(var(--ib-teal-rgb),0.14); }
  .ib-rail-mhead .ib-rail-pfp { margin-left: 8px; }
  /* The floating suggestion bubble (#ib-suggest-bubble — Next + static twins) is
     redundant on mobile now that it lives in the drawer header. */
  #ib-suggest-bubble { display: none !important; }
  .ib-rail-proto-slot:empty { display: none; }
  .ib-rail-md { display: flex; gap: 9px; align-items: flex-start; flex: 0 0 auto; }
  .ib-rail-md-cats { display: flex; flex-direction: column; gap: 4px; flex: 0 0 104px; }
  .ib-rail-cat { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 12.5px; font-weight: 600; text-align: left; padding: 11px 10px; border: none; border-radius: 6px; background: rgba(255,255,255,0.04); color: rgba(var(--ib-fg-rgb),0.78); cursor: pointer; line-height: 1.25; display: flex; align-items: center; min-height: 44px; }
  /* Active header marked by a teal bar on the LEFT column (selected-tab style).
     inset box-shadow avoids any text shift. */
  .ib-rail-cat.active { background: rgba(var(--ib-teal-rgb),0.16); color: var(--ib-cta-accent); box-shadow: inset 3px 0 0 var(--ib-cta-accent); }
  .ib-rail-md-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 6px; }
  .ib-rail-md-pane { display: flex; flex-direction: column; }
  .ib-rail-md-pane[hidden] { display: none; }
  /* Calculators read as one connected list (joined to the header), separated by
     hairline rules so each link is still distinct. */
  .ib-rail-mditem { font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 12.5px; color: rgba(var(--ib-fg-rgb),0.82); padding: 10px 11px; background: none; border: none; border-bottom: 1px solid rgba(255,255,255,0.07); border-radius: 0; text-align: left; width: 100%; text-decoration: none; display: flex; align-items: center; min-height: 44px; line-height: 1.3; cursor: pointer; }
  .ib-rail-mditem:last-child { border-bottom: none; }
  .ib-rail-mditem:hover { background: rgba(var(--ib-teal-rgb),0.10); }
  .ib-rail-mditem.active { color: var(--ib-cta-accent); font-weight: 600; }
  .ib-rail-foot { flex: 0 0 auto; margin-top: 16px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.07); }
  .ib-rail-link { display: flex; align-items: center; min-height: 44px; width: 100%; text-align: left; font-family: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif; font-size: 13px; color: rgba(var(--ib-fg-rgb),0.7); padding: 9px 2px; background: none; border: none; border-bottom: 1px solid rgba(255,255,255,0.07); text-decoration: none; cursor: pointer; }
  .ib-rail-link.danger { color: #ff5757; }
  .ib-theme-row { display: flex; align-items: center; gap: 10px; border-bottom: none; }
}

/* ── Hide-on-scroll (root class toggled by ib-nav.js) ── */
html.ib-nav-hidden .ib-nav { transform: translateY(-100%); }
.ib-hamburger { transition: transform .28s ease; }
html.ib-nav-hidden .ib-hamburger { transform: translateY(48px); z-index: 250; pointer-events: auto; background: rgba(127,127,127,0.34); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-radius: 8px; border: 1px solid rgba(127,127,127,0.5); }
@media (max-width: 767px) {
  html.ib-nav-hidden .ib-nav { transform: none; background: transparent !important; border-bottom-color: transparent !important; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); -webkit-mask-image: linear-gradient(to bottom,#000 55%,transparent 100%); mask-image: linear-gradient(to bottom,#000 55%,transparent 100%); pointer-events: none; }
  .ib-nav-inner > * { transition: opacity .5s ease; }
  html.ib-nav-hidden .ib-nav-inner > * { opacity: 0; pointer-events: none; }
  html.ib-nav-hidden .ib-hamburger { opacity: 1; transform: none; pointer-events: auto; z-index: 250; background: rgba(127,127,127,0.34); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-radius: 8px; border: 1px solid rgba(127,127,127,0.5); }
  html.ib-nav-hidden .ib-nav-pfp { opacity: 1; pointer-events: auto; z-index: 250; }
}
@media (prefers-reduced-motion: reduce) { .ib-nav, .ib-hamburger, .ib-nav-pfp, .ib-nav-inner > * { transition: none; } }

/* The calculator-page nav auto-minimise block (html.ib-calc-page / html.ib-calc-navmin
   restyling .ib-nav / .ib-hamburger / .ib-nav-pfp / .ib-brand into floating pills) is
   gone with the nav. app.js still adds those classes on calc pages, but there is no
   .ib-nav / .ib-hamburger / .ib-nav-pfp there any more — the universal rail's own fixed
   burger + avatar (.ib-uni-burger / .ib-uni-mpfp) replaced them. The one selector that
   still matched, `html.ib-calc-navmin .ib-brand`, was hitting the FOOTER logo (the only
   .ib-brand left on a calc page) and spuriously forcing z-index:250 + opacity on it.
   These rules never applied on the surfaces the nav survives on (/admin, /embed, auth):
   those are not calc pages, so ib-calc-page/navmin are never set there. */

/* ── Light theme ── */
/* Light values for the shared frosted-popover surface (see :root). Consumed by
   .ib-dropdown-menu here and .ib-notify-panel in ib-chat.css. The blur is
   theme-independent so it isn't overridden. */
:root {
  --ib-popover-bg: rgba(255,255,255,0.72);
  --ib-popover-border: 1px solid rgba(0,0,0,0.08);
  --ib-popover-shadow: 0 16px 36px rgba(31,38,55,0.18),inset 0 1px 0 rgba(255,255,255,0.9);
}
.ib-nav { background: rgba(248,248,252,0.80); border-bottom-color: rgba(0,0,0,0.08); }
.ib-brand-text { color: #1a1a1e; }
.ib-hamburger { color: #1a1a1e; }
.ib-nav-divider { background: rgba(0,0,0,0.08); }
.ib-dropdown-btn { color: rgba(20,20,28,0.7); }
.ib-dropdown-btn:hover, .ib-dropdown-wrap.open .ib-dropdown-btn { color: #1a1a1e; }
.ib-dropdown-menu { background: var(--ib-popover-bg); border: var(--ib-popover-border); box-shadow: var(--ib-popover-shadow); }
.ib-dropdown-menu a, .ib-dropdown-menu .ib-dropdown-item { color: rgba(20,20,28,0.7); }
.ib-dropdown-menu a:hover, .ib-dropdown-menu .ib-dropdown-item:hover { background: rgba(0,0,0,0.04); color: #1a1a1e; }
.ib-theme-toggle { color: rgba(20,20,28,0.55); border-color: rgba(0,0,0,0.13); }
.ib-user-name { color: #1a1a1e; }
.ib-calc-rail { background: rgba(244,244,246,0.85); border-right-color: rgba(0,0,0,0.14); }
.ib-rail-mhead { background: rgba(244,244,246,0.9); }
.ib-rail-mhead-brand { color: #1a1a1e; }
.ib-rail-close { color: #1a1a1e; }
.ib-rail-cat { background: rgba(0,0,0,0.04); color: rgba(20,20,28,0.78); }
.ib-rail-cat.active { background: rgba(var(--ib-teal-rgb),0.16); color: #0c8479; box-shadow: inset 3px 0 0 #0c8479; }
.ib-rail-md-panel { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.10); }
.ib-rail-mditem { background: none; color: rgba(20,20,28,0.82); border-bottom-color: rgba(0,0,0,0.08); }
.ib-rail-mditem:hover { background: rgba(var(--ib-teal-rgb),0.12); }
.ib-rail-foot { border-top-color: rgba(0,0,0,0.08); }
.ib-rail-link { color: rgba(20,20,28,0.7); border-bottom-color: rgba(0,0,0,0.08); }
