/* ============================================================
   TBB Academy: site header (every front-end page)
   Markup: tbb_academy_header_render(), behaviour:
   tbb-academy-header.js. The header is its own .tbb-ah root, so
   it has the tokens and the theme-proof reset from base.css.

   Sticky, transparent at the top, white + blur once scrolled.
   Dropdowns open on click (.is-expanded) at every width; without
   the script :focus-within still reveals them. At <= 1099px the
   menu is a panel behind the menu button and dropdowns become
   accordions. Account links sit at the right end: Log in + Sign
   up free, or My account ▾ + Log out (outline buttons; the one
   solid button per screen stays in the page).
   ============================================================ */

/* Fallback if the theme ignores ocean_display_header */
body.tbb-ah-has-header :is(#site-header, #top-bar-wrap, #site-header-sticky-wrapper) { display: none !important; }

.tbb-ah-skip.tbb-ah-skip {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100000;
  padding: 8px 16px;
  border-radius: 0 0 10px 10px;
  background: #171717;
  color: #fff;
  font: 500 14px/1.4 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-decoration: none;
}
.tbb-ah-skip.tbb-ah-skip:focus { top: var(--wp-admin--admin-bar--height, 0px); color: #fff; }

.tbb-ah-header-sentinel { position: absolute; top: 0; left: 0; width: 1px; height: 120px; pointer-events: none; }

/* ── Bar ──────────────────────────────────────────────────────── */
.tbb-ah.tbb-ah-header {
  --tbb-ah-header-h: 72px;
  --tbb-ah-logo-h: 40px;
  --tbb-ah-logo-name: 15px;
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 9990;
  overflow: visible;
  isolation: auto;
  border-bottom: 1px solid transparent;
  background: transparent;
  line-height: 1.5;
  transition: background-color .25s, border-color .25s;
}
.tbb-ah.tbb-ah-header:is(.is-scrolled, .is-open) {
  border-bottom-color: var(--tbb-ah-border);
  background: rgb(255 255 255 / .92);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
          backdrop-filter: blur(12px) saturate(1.4);
}
.tbb-ah-header-fixed .tbb-ah.tbb-ah-header { position: fixed; left: 0; right: 0; }
@media (max-width: 600px) {
  .admin-bar .tbb-ah.tbb-ah-header { top: 0; }
}

.tbb-ah .tbb-ah-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--tbb-ah-wrap);
  height: var(--tbb-ah-header-h);
  margin-inline: auto;
  padding-inline: 24px;
}

/* Brand: logo with the site name centred below it */
.tbb-ah .tbb-ah-header__brand,
.tbb-ah .tbb-ah-header__brand:is(:link, :visited, :hover) {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: var(--tbb-ah-fg);
  text-align: center;
}
.tbb-ah .tbb-ah-header__logo { display: block; width: auto; max-width: 192px; height: var(--tbb-ah-logo-h); object-fit: contain; }
.tbb-ah .tbb-ah-header__name {
  font-family: var(--tbb-ah-font-display);
  font-size: var(--tbb-ah-logo-name);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--tbb-ah-fg);
  white-space: nowrap;
}
.tbb-ah .tbb-ah-header__name--sub { font-family: var(--tbb-ah-font); font-size: 12px; font-weight: 500; color: var(--tbb-ah-subtle); }

/* ── Menu (desktop) ───────────────────────────────────────────── */
.tbb-ah .tbb-ah-nav { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.tbb-ah .tbb-ah-nav__menu { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.tbb-ah .tbb-ah-nav__account { display: flex; align-items: center; gap: 8px; padding-left: 16px; border-left: 1px solid var(--tbb-ah-border); }
.tbb-ah .tbb-ah-nav li { position: relative; }
.tbb-ah .tbb-ah-nav :is(.tbb-ah-nav__menu, .tbb-ah-nav__account) > li.menu-item-has-children { display: flex; align-items: center; }

.tbb-ah .tbb-ah-nav .menu-item > a,
.tbb-ah .tbb-ah-nav .menu-item > a:is(:link, :visited) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: calc(var(--tbb-ah-radius) - 2px);
  color: var(--tbb-ah-muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.tbb-ah .tbb-ah-nav .menu-item > a:is(:hover, :focus-visible) { color: var(--tbb-ah-fg); background: var(--tbb-ah-ghost-hover); }
.tbb-ah .tbb-ah-nav :is(.current-menu-item, .current-menu-ancestor, .current_page_item, .current-menu-parent, .is-expanded) > a:is(:link, :visited, *) { color: var(--tbb-ah-fg); }

.tbb-ah .tbb-ah-nav .tbb-ah-btn { height: 36px; padding-inline: 14px; }

/* No-JS chevron; with JS the caret below replaces it */
.tbb-ah.tbb-ah-header:not(.is-js) .tbb-ah-nav .menu-item-has-children > a::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 0 0 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: .6;
}

.tbb-ah .tbb-ah-nav .sub-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: grid;
  min-width: 232px;
  max-height: calc(100vh - var(--tbb-ah-header-h) - var(--wp-admin--admin-bar--height, 0px) - 24px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--tbb-ah-edge);
  border-radius: calc(var(--tbb-ah-radius) + 4px);
  background: #fff;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / .14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.tbb-ah .tbb-ah-nav__account .sub-menu,
.tbb-ah .tbb-ah-nav__menu > li:last-child > .sub-menu { left: auto; right: 0; }
.tbb-ah .tbb-ah-nav .sub-menu .menu-item > a { display: flex; width: 100%; padding: 9px 12px; }
.tbb-ah .tbb-ah-nav li.is-expanded > .sub-menu,
.tbb-ah.tbb-ah-header:not(.is-js) .tbb-ah-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }

.tbb-ah .tbb-ah-nav .tbb-ah-nav__who {
  margin-bottom: 4px;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--tbb-ah-border);
  font-size: 13px;
  line-height: 1.4;
  color: var(--tbb-ah-subtle);
  overflow-wrap: anywhere;
}
.tbb-ah .tbb-ah-nav .tbb-ah-nav__who strong { font-weight: 600; color: var(--tbb-ah-fg); }

/* Caret added inside each parent label by the script */
.tbb-ah .tbb-ah-caret { display: inline-flex; width: 14px; height: 14px; margin-right: -2px; opacity: .7; transition: transform .2s; }
.tbb-ah .tbb-ah-caret svg { display: block; width: 100%; height: 100%; }
.tbb-ah .is-expanded > a .tbb-ah-caret { transform: rotate(180deg); }
.tbb-ah .tbb-ah-nav .tbb-ah-parent-link { margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid var(--tbb-ah-border); }

/* Menu button */
.tbb-ah .tbb-ah-header__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 1px solid var(--tbb-ah-border);
  border-radius: var(--tbb-ah-radius) 0 var(--tbb-ah-radius) 0;
  background: transparent;
  color: var(--tbb-ah-fg);
  cursor: pointer;
}
.tbb-ah .tbb-ah-header__toggle:is(:hover, :focus) { background: var(--tbb-ah-ghost-hover); color: var(--tbb-ah-fg); }
.tbb-ah .tbb-ah-header__toggle svg { width: 20px; height: 20px; }
.tbb-ah .tbb-ah-header__icon-close,
.tbb-ah.is-open .tbb-ah-header__icon-open { display: none; }
.tbb-ah.is-open .tbb-ah-header__icon-close { display: block; }

/* ── Menu panel (mobile and tablet) ───────────────────────────── */
@media (max-width: 1099px) {
  .tbb-ah .tbb-ah-header__toggle { display: inline-flex; }
  .tbb-ah .tbb-ah-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: calc(100vh - var(--tbb-ah-header-h) - var(--wp-admin--admin-bar--height, 0px));
    overflow-y: auto;
    padding: 8px 24px 24px;
    border-bottom: 1px solid var(--tbb-ah-border);
    background: #fff;
  }
  .tbb-ah.is-open .tbb-ah-nav { display: flex; }
  .tbb-ah .tbb-ah-nav__menu { flex-direction: column; align-items: stretch; gap: 0; margin-left: 0; }
  .tbb-ah .tbb-ah-nav :is(.tbb-ah-nav__menu, .tbb-ah-nav__account) > li.menu-item { display: flex; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--tbb-ah-border); }
  .tbb-ah .tbb-ah-nav :is(.tbb-ah-nav__menu, .tbb-ah-nav__account) > li.menu-item > a { flex: 1; width: 100%; padding: 14px 0; font-size: 16px; color: var(--tbb-ah-fg); }
  .tbb-ah .tbb-ah-nav :is(.tbb-ah-nav__menu, .tbb-ah-nav__account) li.menu-item > a:is(:hover, :focus-visible) { background: transparent; color: var(--tbb-ah-brand); }
  .tbb-ah .tbb-ah-nav .sub-menu {
    position: static;
    display: none;
    flex-basis: 100%;
    min-width: 0;
    max-height: none;
    margin-bottom: 12px;
    padding: 0 0 0 12px;
    border: 0;
    border-left: 1px solid var(--tbb-ah-edge);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .tbb-ah .tbb-ah-nav li.is-expanded > .sub-menu,
  .tbb-ah.tbb-ah-header:not(.is-js) .tbb-ah-nav li:focus-within > .sub-menu { display: grid; }
  .tbb-ah .tbb-ah-nav .sub-menu .menu-item > a:is(:link, :visited, *) { padding: 10px 0; font-size: 15px; }
  .tbb-ah .tbb-ah-caret { width: 18px; height: 18px; margin-left: auto; }
  .tbb-ah .tbb-ah-nav .tbb-ah-parent-link { margin-bottom: 0; border-bottom: 0; }
  .tbb-ah .tbb-ah-nav .tbb-ah-nav__who { padding: 10px 0; border-bottom: 0; }

  /* Account: links like the menu, buttons in a row at the end */
  .tbb-ah .tbb-ah-nav__account { flex-wrap: wrap; align-items: stretch; gap: 0; padding-left: 0; border-left: 0; }
  .tbb-ah .tbb-ah-nav__account > li.menu-item { flex-basis: 100%; }
  .tbb-ah .tbb-ah-nav__account > .tbb-ah-nav__btn { margin-top: 20px; }
  .tbb-ah .tbb-ah-nav .tbb-ah-btn { height: 40px; padding-inline: 18px; }
}
@media (min-width: 640px) {
  .tbb-ah .tbb-ah-header__inner { padding-inline: 48px; }
  .tbb-ah .tbb-ah-nav { padding-inline: 48px; }
}
@media (min-width: 1100px) {
  .tbb-ah .tbb-ah-nav { padding-inline: 0; }
}
@media (min-width: 1100px) and (max-width: 1239px) {
  .tbb-ah .tbb-ah-header__inner { padding-inline: 24px; }
  .tbb-ah .tbb-ah-nav .menu-item > a { padding-inline: 9px; }
}
@media (max-width: 600px) {
  .tbb-ah.tbb-ah-header { --tbb-ah-logo-h: 32px; --tbb-ah-logo-name: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .tbb-ah.tbb-ah-header,
  .tbb-ah.tbb-ah-header * { transition: none !important; }
}
