/* ============================================================================
   Header + mega menu — ported 1:1 from the approved design
   (captain_updatedmenu.html). All selectors are scoped under .cc-topbar so the
   design's generic class names (.nav, .mega, .btn, ...) never leak globally.
   Uses tokens.css design variables, so light/dark both work.
   ============================================================================ */

.cc-topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.cc-topbar .topbar-inner { display: flex; align-items: center; gap: 32px; height: 64px; }
.cc-topbar .brand { display: flex; align-items: center; gap: 10px; }
.cc-topbar .brand img,
.cc-topbar .custom-logo { height: 26px; width: auto; display: block; }

.cc-topbar .nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.cc-topbar .nav-item {
  position: relative;
  padding: 8px 12px; border-radius: 6px;
  color: var(--fg-1); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: color 120ms ease, background 120ms ease;
}
.cc-topbar a.nav-item:hover { color: var(--fg); }
.cc-topbar .nav-item > .caret { opacity: .5; transition: transform 180ms ease, opacity 180ms ease; }
.cc-topbar .nav-item:hover { color: var(--fg); }
.cc-topbar .nav-item:hover > .caret { transform: rotate(180deg); opacity: 1; }
.cc-topbar .nav-item[data-open]::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
  opacity: 0; transform: scaleX(.4); transform-origin: center;
  transition: opacity 160ms ease, transform 220ms cubic-bezier(.2,.7,.2,1);
}
.cc-topbar .nav-item[data-open]:hover::after { opacity: 1; transform: scaleX(1); }
/* hover bridge: prevents gap-flicker between trigger and panel */
.cc-topbar .nav-item[data-open]::before {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; display: none;
}
.cc-topbar .nav-item[data-open]:hover::before { display: block; }

/* ---------- Mega menu ---------- */
.cc-topbar .mega {
  position: absolute; top: calc(100% + 12px); left: -16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -16px rgba(0,0,0,.45), 0 6px 16px -8px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.02) inset;
  display: none; opacity: 0; transform: translateY(-4px);
  transition: opacity 160ms ease, transform 200ms cubic-bezier(.2,.7,.2,1);
  overflow: hidden; z-index: 60;
}
[data-theme="light"] .cc-topbar .mega {
  box-shadow: 0 24px 64px -16px rgba(20,12,14,.14), 0 6px 16px -8px rgba(20,12,14,.08), 0 0 0 1px rgba(0,0,0,.02) inset;
}
.cc-topbar .nav-item:hover .mega,
.cc-topbar .nav-item:focus-within .mega { display: grid; opacity: 1; transform: translateY(0); }

.cc-topbar .mega-platform  { width: 880px; grid-template-columns: 1.15fr 1.15fr 1fr; }
.cc-topbar .mega-solutions { width: 1080px; grid-template-columns: 1fr 1fr; }
.cc-topbar .mega-regions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.cc-topbar .mega-region { padding: 16px 18px 14px; border-right: 1px solid var(--line); }
.cc-topbar .mega-region:last-child { border-right: 0; }
.cc-topbar .mega-region .rh { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-3); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cc-topbar .mega-region .rh::before { content: ""; width: 14px; height: 1px; background: var(--accent); display: inline-block; }
.cc-topbar .mega-reglink { display: block; padding: 5px 0; font-size: 13px; color: var(--fg-1); text-decoration: none; transition: color 120ms ease; }
.cc-topbar .mega-reglink:hover { color: var(--accent); }
.cc-topbar .mega-resources { width: 760px; grid-template-columns: 1.2fr 1fr 1fr; }
.cc-topbar .mega.anchor-right { left: auto; right: -16px; }

.cc-topbar .mega-col { padding: 18px 18px 14px; border-right: 1px solid var(--line); }
.cc-topbar .mega-col:last-child { border-right: 0; }

.cc-topbar .mega-eyebrow {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-3); display: flex; align-items: center; gap: 8px; margin: 2px 0 12px;
}
.cc-topbar .mega-eyebrow::before { content: ""; width: 14px; height: 1px; background: var(--accent); display: inline-block; }

.cc-topbar .mega-link {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px;
  padding: 9px 10px; border-radius: 8px; color: var(--fg-1);
  align-items: flex-start; margin: 0 -10px; cursor: pointer;
  transition: background 120ms ease, color 120ms ease; text-decoration: none;
}
.cc-topbar .mega-link:hover { background: var(--bg-1); color: var(--fg); }
.cc-topbar .mega-link:hover .mega-link-arrow { opacity: 1; transform: translateX(2px); }

.cc-topbar .mega-mark {
  width: 18px; height: 18px; position: relative; margin-top: 3px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--accent);
}
.cc-topbar .mega-mark .sq  { width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 2px; }
.cc-topbar .mega-mark .ci  { width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 999px; }
.cc-topbar .mega-mark .di  { width: 9px; height: 9px;  border: 1.5px solid currentColor; transform: rotate(45deg); }
.cc-topbar .mega-mark .ba  { width: 12px; height: 4px; background: currentColor; border-radius: 2px; }
.cc-topbar .mega-mark .ri  { width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 999px; }
.cc-topbar .mega-mark .ri::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; background: currentColor; border-radius: 999px; transform: translate(-50%, -50%); }
.cc-topbar .mega-mark .sl  { width: 12px; height: 2px; background: currentColor; transform: rotate(-30deg); box-shadow: 0 5px 0 currentColor; }
.cc-topbar .mega-mark .grid { width: 12px; height: 12px; background-image: linear-gradient(currentColor 1px, transparent 1px), linear-gradient(90deg, currentColor 1px, transparent 1px); background-size: 4px 4px; opacity: .85; }
.cc-topbar .mega-mark.dim { color: var(--fg-2); }

.cc-topbar .mega-link-body { min-width: 0; display: block; }
.cc-topbar .mega-link-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; display: flex; align-items: center; gap: 6px; color: inherit; }
.cc-topbar .mega-link-desc { display: block; font-size: 12px; line-height: 1.45; color: var(--fg-3); margin-top: 2px; }
.cc-topbar .mega-link-arrow { display: inline-block; font-family: var(--mono); font-size: 12px; color: var(--accent); opacity: 0; transform: translateX(-2px); transition: opacity 160ms ease, transform 200ms cubic-bezier(.2,.7,.2,1); }
.cc-topbar .mega-link-tag { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; background: var(--accent-tint); color: var(--accent); margin-left: 6px; vertical-align: middle; }
.cc-topbar .mega-link-tag.muted { background: var(--bg-2); color: var(--fg-2); }

/* Feature card column (right-side editable card) */
.cc-topbar .mega-feature { padding: 0; background: linear-gradient(180deg, var(--bg-1), var(--bg-2)); display: flex; flex-direction: column; }
.cc-topbar .mega-feature-art {
  position: relative; margin: 18px 18px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 124px;
  background: radial-gradient(ellipse 70% 60% at 75% 25%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%), linear-gradient(135deg, var(--bg-2), var(--panel));
}
.cc-topbar .mega-feature-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 16px 16px; opacity: .35; }
.cc-topbar .mega-feature-badge { position: absolute; left: 12px; top: 12px; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; background: color-mix(in oklab, var(--bg) 60%, transparent); padding: 4px 8px; border-radius: 999px; border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line)); backdrop-filter: blur(4px); }
.cc-topbar .mega-feature-badge i { width: 5px; height: 5px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent); }
.cc-topbar .mega-feature-num { position: absolute; right: 14px; bottom: 12px; font-family: var(--mono); font-size: 38px; font-weight: 600; letter-spacing: -.02em; color: var(--fg); line-height: 1; }
.cc-topbar .mega-feature-num small { font-size: 13px; font-weight: 500; color: var(--fg-2); letter-spacing: 0; display: block; text-align: right; margin-top: 2px; }
.cc-topbar .mega-feature-body { padding: 14px 18px 16px; }
.cc-topbar .mega-feature-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; color: var(--fg); }
.cc-topbar .mega-feature-desc { font-size: 12.5px; line-height: 1.5; color: var(--fg-2); margin-top: 4px; }
.cc-topbar .mega-feature-cta { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; cursor: pointer; text-decoration: none; }
.cc-topbar .mega-feature-cta::after { content: "→"; }

/* Bottom strip */
.cc-topbar .mega-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--bg-1); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em; color: var(--fg-2); }
.cc-topbar .mega-foot-links { display: flex; gap: 18px; flex-wrap: wrap; }
.cc-topbar .mega-foot a { color: var(--fg-1); border-bottom: 1px dashed transparent; padding-bottom: 1px; cursor: pointer; text-decoration: none; }
.cc-topbar .mega-foot a:hover { color: var(--fg); border-bottom-color: var(--line-2); }
.cc-topbar .mega-foot .kbd { font-family: var(--mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--fg-3); background: var(--panel); }

/* Red promo banner (editable) */
.cc-topbar .mega-banner {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 16px 22px; text-decoration: none;
  background: radial-gradient(120% 180% at 0% 50%, color-mix(in oklab, var(--accent) 90%, #000) 0%, var(--accent) 38%, color-mix(in oklab, var(--accent) 62%, #5b0d1c) 100%);
  border-top: 1px solid color-mix(in oklab, var(--accent) 55%, #000);
  transition: filter 140ms ease;
}
.cc-topbar .mega-banner:hover { filter: brightness(1.08); }
.cc-topbar .mega-banner .mb-text { min-width: 0; }
.cc-topbar .mega-banner .mb-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: #fff; display: inline-flex; align-items: center; gap: 8px; }
.cc-topbar .mega-banner .mb-title .mb-arrow { transition: transform 200ms cubic-bezier(.2,.7,.2,1); }
.cc-topbar .mega-banner:hover .mb-title .mb-arrow { transform: translateX(3px); }
.cc-topbar .mega-banner .mb-desc { margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: rgba(255,255,255,.82); max-width: 78ch; }
.cc-topbar .mega-banner .mb-cta { flex: none; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: #fff; padding: 9px 16px; border-radius: 8px; font-weight: 600; white-space: nowrap; }

/* CTA buttons (right of nav) */
.cc-topbar .topbar-cta { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cc-topbar .btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background 120ms ease, border-color 120ms ease, transform 120ms ease; }
.cc-topbar .btn-ghost { color: var(--fg-1); background: none; }
.cc-topbar .btn-ghost:hover { color: var(--fg); background: var(--bg-1); }
.cc-topbar .btn-secondary { color: var(--fg); background: transparent; border-color: color-mix(in oklab, var(--fg-3) 50%, var(--line)); }
.cc-topbar .btn-secondary:hover { background: var(--bg-1); border-color: var(--fg-3); }
.cc-topbar .btn-primary { background: var(--accent); color: var(--accent-fg); border-color: color-mix(in oklab, var(--accent) 60%, black); }
.cc-topbar .btn-primary:hover { transform: translateY(-1px); }
.cc-topbar .cc-theme-toggle { background: none; border: 0; color: var(--fg-2); cursor: pointer; padding: 6px; display: inline-flex; align-items: center; }
.cc-topbar .cc-theme-toggle:hover { color: var(--fg); }

/* ---------- Burger + mobile drawer ---------- */
/* Desktop: the burger and the drawer-only CTA row do not exist. */
.cc-topbar .cc-burger { display: none; }
.cc-topbar .nav-mobile-cta { display: none; }

/* Mobile (<= 900px): the same nav markup becomes a full-height drawer under
   the bar. Panels open as inline accordions driven by .is-open (menu.js), so
   the desktop hover/focus rules are switched off here to keep touch sane. */
@media (max-width: 900px) {
  .cc-topbar .topbar-inner { gap: 12px; }
  .cc-topbar .topbar-cta { gap: 6px; }
  .cc-topbar .topbar-cta .btn-ghost,
  .cc-topbar .topbar-cta .btn-secondary { display: none; }

  .cc-topbar .cc-burger {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    width: 40px; height: 40px; flex: none; padding: 0; margin: 0;
    border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); cursor: pointer;
  }
  .cc-topbar .cc-burger span { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px; transition: transform 200ms ease, opacity 160ms ease; }
  .cc-topbar.is-open .cc-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .cc-topbar.is-open .cc-burger span:nth-child(2) { opacity: 0; }
  .cc-topbar.is-open .cc-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .cc-topbar .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    height: calc(100vh - 100%); height: calc(100dvh - 100%);
    flex-direction: column; align-items: stretch; gap: 0; margin: 0;
    padding: 6px 20px 40px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    background: var(--bg); border-top: 1px solid var(--line); z-index: 55;
  }
  .cc-topbar.is-open .nav { display: flex; }
  body.cc-nav-open { overflow: hidden; }

  .cc-topbar .nav-item {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    padding: 16px 0; border-radius: 0; border-bottom: 1px solid var(--line);
    font-size: 16px; font-weight: 600; color: var(--fg);
  }
  .cc-topbar .nav-item[data-open]::before,
  .cc-topbar .nav-item[data-open]::after { display: none; content: none; }
  .cc-topbar .nav-item > .caret { margin-left: auto; width: 14px; height: 14px; opacity: .7; }
  .cc-topbar .nav-item.is-open > .caret { transform: rotate(180deg); opacity: 1; }

  .cc-topbar .mega,
  .cc-topbar .nav-item:hover .mega,
  .cc-topbar .nav-item:focus-within .mega { display: none; }
  .cc-topbar .nav-item.is-open .mega { display: grid; }
  .cc-topbar .mega {
    position: static; width: auto !important; flex-basis: 100%; margin-top: 6px;
    grid-template-columns: 1fr !important; opacity: 1; transform: none;
    background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible;
    font-weight: 400; cursor: default;
  }
  .cc-topbar .mega-col { padding: 4px 0 10px; border-right: 0; }
  .cc-topbar .mega-regions { grid-template-columns: 1fr 1fr; border-bottom: 0; }
  .cc-topbar .mega-region { padding: 6px 0 10px; border-right: 0; }
  .cc-topbar .mega-reglink { padding: 7px 0; font-size: 14px; }
  .cc-topbar .mega-feature,
  .cc-topbar .mega-foot { display: none; }
  .cc-topbar .mega-banner { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; border-radius: 10px; border-top: 0; margin: 6px 0 8px; }
  .cc-topbar .mega-banner .mb-desc { max-width: none; }
  .cc-topbar .mega-link { margin: 0; padding: 9px 0; grid-template-columns: 20px 1fr; gap: 10px; }
  .cc-topbar .mega-link:hover { background: transparent; }
  .cc-topbar .mega-link-title { font-size: 15px; }
  .cc-topbar .mega-link-desc { font-size: 12.5px; }
  .cc-topbar .mega-link-arrow { display: none; }

  /* Account actions hidden from the bar on phones live at the end of the drawer. */
  .cc-topbar .nav-mobile-cta { display: grid; gap: 10px; padding: 20px 0 0; }
  .cc-topbar .nav-mobile-cta .btn { justify-content: center; padding: 12px 16px; font-size: 14.5px; }
}
