/* ──────────────────────────────────────────────────────────────────────────
   Global site header (topbar) — STANDALONE.

   Markup: templates/parts/_topbar.php, rendered sitewide by the [ww_topbar]
   shortcode from a Divi Theme Builder global header template.

   Why this file exists separately from home.css/wwt.css: those copies are
   scoped .wwh / .wwt, i.e. they only work when the header sits INSIDE a plugin
   template wrapper. Rendered globally the header has no such ancestor (on a
   cart or blog page there is no .wwh/.wwt at all), so every rule here is
   scoped to .ww-topbar and self-contained down to its own custom properties.
   Do not reference --sans/--mono/--sun/--gutter here; those live on .wwh/.wwt.
   ────────────────────────────────────────────────────────────────────────── */

/* Divi's normal template sets body{overflow-x:hidden}, which makes <body> a
   scroll container and TRAPS position:sticky (header shows but won't stick).
   clip does the same horizontal clipping without creating a scroll container.
   Must be clip, not hidden — see the 1.7.56 sticky-header regression.

   Gated on :has() so this only changes pages our header is actually on. This
   stylesheet loads sitewide, and production already runs its own Divi Theme
   Builder header — an ungated rule would alter pages we have no business
   touching. */
body:has(.ww-topbar){overflow-x:clip!important}

/* Collapse Divi's empty leading Theme-Builder-body section (an empty .et_pb_section
   with default 27px+27px padding) that adds a ~54px blank band above the header.
   Lived in the partial's inline CSS; moved here because the partial no-ops once the
   global header renders, which would have let the band back in on landing pages.

   The section must have NEITHER a row NOR a module — a genuinely empty one. A
   fullwidth Code module attaches straight to its section with NO row, so the
   original row-only check matched the CONTENT section and blanked whole pages
   (the 6.141 outage). Do not simplify this selector. */
.et-l--body .et_builder_inner_content > .et_pb_section:first-child:not(:has(.et_pb_row)):not(:has(.et_pb_module)){display:none!important}

.ww-topbar{
  --ww-night:#181818;
  --ww-sun:#EFBC6C;
  --ww-rebel:#F1582C;
  --ww-sans:"DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ww-mono:"Roboto Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --ww-max:1180px;
  --ww-gutter:clamp(20px,5vw,64px);
  position:sticky;top:0;z-index:60;
  background:rgba(24,24,24,.72);
  backdrop-filter:blur(10px);
  border-bottom:1px solid rgba(255,255,255,.08);
  font-family:var(--ww-sans);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
.ww-topbar *{box-sizing:border-box}
.ww-topbar img{display:block;max-width:100%}
.ww-topbar a{text-decoration:none}

.ww-topbar .wrap{max-width:var(--ww-max);margin:0 auto;padding:0 var(--ww-gutter)}
.ww-topbar .topbar-in{display:flex;align-items:center;justify-content:space-between;height:64px}

.ww-topbar .brand{margin-right:auto}
.ww-topbar .brand--logo{display:inline-flex;align-items:center;line-height:0}
.ww-topbar .brand--logo img{height:34px;width:auto;display:block}

.ww-topbar .nav{display:flex;gap:20px;align-items:center}

/* Colors carry !important to beat Divi's .et-db #et-boc .et-l a{color:#3A3D35}
   (ID specificity 1,2,1 — a class selector cannot out-specify it). Rendered
   from a Theme Builder header the topbar lives inside .et-l, so this rule DOES
   apply here. Target .navlink/.navphone specifically, NOT `.ww-topbar a` — a
   blanket link rule bleeds onto the CTA and washes its text to 70% white. */
.ww-topbar .navlink{font-family:var(--ww-mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:rgba(255,255,255,.7)!important;white-space:nowrap;transition:color .15s}
.ww-topbar .navlink:hover{color:#fff!important}

/* ── Resources dropdown ─────────────────────────────────────────────────── */
.ww-topbar .navgroup{position:relative;display:inline-flex;align-items:center;gap:4px}
.ww-topbar .navcaret{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;background:transparent;cursor:pointer;color:rgba(255,255,255,.6);transition:color .15s,transform .2s ease}
.ww-topbar .navgroup:hover .navcaret,.ww-topbar .navgroup.open .navcaret{color:#fff}
.ww-topbar .navgroup.open .navcaret{transform:rotate(180deg)}
/* Panel links need their own !important colors for the same reason .navlink does —
   Divi's #et-boc .et-l a rule outranks any class selector. */
.ww-topbar .navpanel a{display:block;padding:9px 20px;font-family:var(--ww-mono);font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:rgba(255,255,255,.72)!important;transition:color .15s,background .15s}
.ww-topbar .navpanel a:hover{color:#fff!important;background:rgba(255,255,255,.07)}
.ww-topbar .navpanel-lbl{display:block;padding:9px 20px 5px;font-family:var(--ww-mono);font-size:9.5px;font-weight:500;letter-spacing:.2em;text-transform:uppercase;color:var(--ww-sun)}
.ww-topbar .navpanel-lbl~.navpanel-lbl{margin-top:6px;padding-top:12px;border-top:1px solid rgba(255,255,255,.08)}
/* Start-a-build picker. The trigger is a <button> carrying .btn/.btn--primary, so it
   inherits the CTA styling; buttons do not inherit font-family, but .btn sets it. */
.ww-topbar .navcta .ctacaret{transition:transform .2s ease}
.ww-topbar .navgroup--cta.open .ctacaret{transform:rotate(180deg)}

.ww-topbar .navphone{display:inline-flex;align-items:center;gap:7px;font-family:var(--ww-mono);font-size:12.5px;letter-spacing:.04em;color:rgba(255,255,255,.85)!important;white-space:nowrap}
.ww-topbar .navphone:hover{color:#fff!important}
.ww-topbar .navphone .pico{color:var(--ww-sun);flex:none}

.ww-topbar .btn{display:inline-flex;align-items:center;gap:12px;font-family:var(--ww-mono);font-size:11.5px;font-weight:500;letter-spacing:.14em;text-transform:uppercase;padding:11px 18px;border-radius:2px;cursor:pointer;border:1px solid transparent;transition:transform .18s ease,filter .18s ease,background .18s,color .18s}
.ww-topbar .btn .arw{font-family:var(--ww-sans);font-size:15px;transition:transform .2s ease}
.ww-topbar .btn:hover .arw{transform:translateX(4px)}
.ww-topbar .btn--primary{background:var(--ww-rebel);color:#fff!important}
.ww-topbar .btn--primary:hover{filter:brightness(1.06);transform:translateY(-1px)}

/* Cart link. Lives in .topbar-in rather than inside .nav so it stays visible on mobile
   instead of being buried in the collapsed dropdown — the whole point is that there was
   no way to reach the cart. DOM order is brand, cart, hamburger, so mobile reads
   naturally; desktop reorders below to put it last. */
.ww-topbar .navcart{position:relative;display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex:none;color:rgba(255,255,255,.78)!important;transition:color .15s}
.ww-topbar .navcart:hover{color:#fff!important}
.ww-topbar .navcart svg{width:19px;height:19px;display:block}
/* Badge is Sun, not Rebel Yell — the brand guide reserves #F1582C for the primary CTA. */
.ww-topbar .cartcount{position:absolute;top:1px;right:-1px;min-width:16px;height:16px;padding:0 4px;border-radius:9px;background:var(--ww-sun);color:var(--ww-night);font-family:var(--ww-mono);font-size:10px;font-weight:500;line-height:16px;text-align:center}
.ww-topbar .cartcount[hidden]{display:none}

.ww-topbar .navtoggle{display:none;width:38px;height:38px;border:0;background:transparent;cursor:pointer;padding:9px;flex-direction:column;justify-content:center;gap:5px}
.ww-topbar .navtoggle span{display:block;height:2px;width:100%;background:#fff;border-radius:2px;transition:transform .25s ease,opacity .2s ease}

@media(max-width:1024px){
  .ww-topbar .navphone{display:none}
}
/* Desktop puts the cart last, right of the CTA. Set only here so mobile keeps DOM
   order (brand, cart, hamburger) with no ordering rules to unwind. */
@media(min-width:861px){
  .ww-topbar .nav{order:2}
  .ww-topbar .navcart{order:3;margin-left:14px}
  /* Invisible bridge across the gap between the bar and the panel, so the pointer
     does not leave the group on the way down and snap the panel shut. */
  .ww-topbar .navgroup::after{content:"";position:absolute;top:100%;left:0;right:0;height:16px}
  .ww-topbar .navpanel{position:absolute;top:calc(100% + 14px);left:50%;transform:translateX(-50%) translateY(-6px);min-width:255px;padding:12px 0;background:rgba(18,17,15,.98);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:3px;box-shadow:0 18px 42px rgba(0,0,0,.5);opacity:0;visibility:hidden;transition:opacity .18s ease,transform .18s ease;z-index:70}
  .ww-topbar .navpanel a{white-space:nowrap}
  .ww-topbar .navgroup:hover .navpanel,
  .ww-topbar .navgroup:focus-within .navpanel,
  .ww-topbar .navgroup.open .navpanel{opacity:1;visibility:visible;transform:translateX(-50%) translateY(0)}
  /* The CTA is the last item in the bar, so a centre-anchored panel would hang off the
     right edge. Anchor this one to the right instead. Higher specificity than the
     generic rules above, and later, so it wins both transform declarations. */
  .ww-topbar .navpanel--right{left:auto;right:0;min-width:215px;transform:translateX(0) translateY(-6px)}
  .ww-topbar .navgroup--cta:hover .navpanel--right,
  .ww-topbar .navgroup--cta:focus-within .navpanel--right,
  .ww-topbar .navgroup--cta.open .navpanel--right{transform:translateX(0) translateY(0)}
}
@media(max-width:860px){
  .ww-topbar .navtoggle{display:flex}
  .ww-topbar .nav{position:absolute;top:100%;left:0;right:0;flex-direction:column;align-items:stretch;gap:0;background:rgba(18,17,15,.98);backdrop-filter:blur(10px);border-bottom:1px solid rgba(255,255,255,.1);max-height:0;overflow:hidden;transition:max-height .32s ease}
  .ww-topbar .nav .navlink{display:block;padding:15px var(--ww-gutter);font-size:12px;letter-spacing:.12em;color:rgba(255,255,255,.82)!important;border-top:1px solid rgba(255,255,255,.06)}
  .ww-topbar .nav .navphone{display:flex;padding:15px var(--ww-gutter);border-top:1px solid rgba(255,255,255,.06);color:var(--ww-sun)!important;font-size:13.5px}
  /* flex, not block: the CTA is now a button holding label + caret, and display:block
     drops the flex centring that keeps those two aligned. */
  .ww-topbar .navgroup--cta{display:block}
  /* Width is explicit because the trigger is a <button>: form controls resolve
     width:auto as shrink-to-fit even as a block-level flex container, so it came out
     171px where the old <a display:block> filled the row. */
  .ww-topbar .nav .btn--primary{display:flex;width:calc(100% - var(--ww-gutter)*2);margin:14px var(--ww-gutter) 6px;text-align:center;justify-content:center}
  /* Accordion inside the collapsed menu, so Resources adds one tappable row rather
     than nine, and the menu stays short enough to not need scrolling on open. */
  .ww-topbar .navgroup{display:block;position:relative}
  .ww-topbar .navcaret{position:absolute;top:0;right:calc(var(--ww-gutter) - 8px);width:46px;height:46px}
  .ww-topbar .navpanel{max-height:0;overflow:hidden;background:rgba(255,255,255,.03);transition:max-height .3s ease}
  .ww-topbar .navgroup.open .navpanel{max-height:640px}
  .ww-topbar .navpanel a{padding:12px var(--ww-gutter) 12px calc(var(--ww-gutter) + 14px);white-space:normal;border-top:1px solid rgba(255,255,255,.05)}
  .ww-topbar .navpanel-lbl{padding:10px var(--ww-gutter) 4px;border-top:1px solid rgba(255,255,255,.06)}
  .ww-topbar .navpanel-lbl~.navpanel-lbl{margin-top:0;padding-top:10px}
  /* Expanded accordion can outgrow 70vh — let the menu scroll rather than clip. */
  .ww-topbar.open .nav{max-height:70vh;overflow-y:auto}
  .ww-topbar.open .navtoggle span:nth-child(1){transform:translateY(7px) rotate(45deg)}
  .ww-topbar.open .navtoggle span:nth-child(2){opacity:0}
  .ww-topbar.open .navtoggle span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}
}
@media(max-width:600px){
  .ww-topbar .brand--logo img{height:30px}
}

/* ── Divi Theme Builder header host ───────────────────────────────────────
   When rendered from a TB global header, Divi wraps the Code module in
   section > row > column, each with its own padding and a ~1080px row width
   that would box in a full-bleed bar. Strip that, and move the sticky onto
   the .et-l--header wrapper: position:sticky on a child only holds while its
   PARENT is in view, and that wrapper is exactly header-height tall, so the
   bar would unstick on the first scroll tick.

   Every rule here is gated on :has(.ww-topbar). This stylesheet loads sitewide and
   production already has its own Divi Theme Builder header — ungated, these would
   flatten and stick THAT header as soon as the code deploys, i.e. during the window
   before the [ww_topbar] module is swapped in. */
.et-l--header:has(.ww-topbar){position:sticky;top:0;z-index:60}
.et-l--header:has(.ww-topbar) .ww-topbar{position:static}
.et-l--header:has(.ww-topbar) .et_pb_section,
.et-l--header:has(.ww-topbar) .et_pb_row,
.et-l--header:has(.ww-topbar) .et_pb_column,
.et-l--header:has(.ww-topbar) .et_pb_module{margin:0!important;padding:0!important;width:100%!important;max-width:none!important}
.et-l--header:has(.ww-topbar) .et_pb_row{display:block}
