/* ============================================================
   TBB Pages: site header + footer (every front-end page)
   Markup: templates/site-header.php, templates/site-footer.php.
   Rules are scoped to .tbb-site-header / .tbb-site-footer at
   specificity (0,2,0) or more so theme and page-builder rules for
   a, ul and button never win.
   ============================================================ */

/* ── Shared ───────────────────────────────────────────────────── */
body.tbb-full-width { margin: 0; background: var(--tbb-bg); }

:is(.tbb-site-header, .tbb-site-footer),
:is(.tbb-site-header, .tbb-site-footer) * { box-sizing: border-box; }
:is(.tbb-site-header, .tbb-site-footer) :is(ul, li, p, h2):is(ul, li, p, h2) {
  margin: 0;
  padding: 0;
  list-style: none;
  font: inherit;
  color: inherit;
  letter-spacing: normal;
  text-transform: none;
}
:is(.tbb-site-header, .tbb-site-footer) :is(a, button):is(a, button) { text-decoration: none; box-shadow: none; }
:is(.tbb-site-header, .tbb-site-footer) :is(a, button):is(a, button):focus-visible { outline: 2px solid var(--tbb-fg); outline-offset: 2px; }
:is(.tbb-site-header, .tbb-site-footer) .tbb-icon { display: inline-flex; width: 1em; height: 1em; flex-shrink: 0; }
:is(.tbb-site-header, .tbb-site-footer) .tbb-icon svg { display: block; width: 100%; height: 100%; }
.tbb-site-header .tbb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:is(.tbb-site-header, .tbb-site-footer) .tbb-wordmark {
  font-family: var(--tbb-font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--tbb-fg);
}
:is(.tbb-site-header, .tbb-site-footer) .tbb-wordmark span { color: var(--tbb-hl); }

.tbb-skip-link.tbb-skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100000;
  padding: 8px 16px;
  border-radius: 0 0 var(--tbb-radius) var(--tbb-radius);
  background: var(--tbb-solid-bg);
  color: var(--tbb-solid-fg);
  font: 500 14px/1.4 var(--tbb-font);
}
.tbb-skip-link.tbb-skip-link:focus { top: var(--wp-admin--admin-bar--height, 0px); color: var(--tbb-solid-fg); }

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

/* ── Header ───────────────────────────────────────────────────── */
.tbb-site-header {
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 9990;
  width: 100%;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-family: var(--tbb-font);
  line-height: 1.5;
  color: var(--tbb-fg);
  transition: background-color .25s, border-color .25s;
}
.tbb-site-header.is-scrolled,
.tbb-site-header.is-open {
  border-bottom-color: var(--tbb-border);
  background: rgb(255 255 255 / .92);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
          backdrop-filter: blur(12px) saturate(1.4);
}
.tbb-header-fixed .tbb-site-header { position: fixed; left: 0; right: 0; }
@media (max-width: 600px) {
  .admin-bar .tbb-site-header { top: 0; }
}

.tbb-site-header .tbb-site-header__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: var(--tbb-wrap);
  height: var(--tbb-header-h);
  margin-inline: auto;
  padding-inline: 24px;
}
/* Logo with the site name centred below it. Sizes: logo 40px + name 15px
   on desktop, 32px + 13px on phones (fits the 72px header). */
.tbb-site-header { --tbb-logo-h: 40px; --tbb-logo-name: 15px; }
.tbb-site-header .tbb-site-header__brand {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: var(--tbb-fg);
  text-align: center;
}
.tbb-site-header .tbb-site-header__logo { display: block; width: auto; max-width: 192px; height: var(--tbb-logo-h); object-fit: contain; }
.tbb-site-header .tbb-site-header__name {
  font-family: var(--tbb-font-display);
  font-size: var(--tbb-logo-name);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--tbb-fg);
  white-space: nowrap;
}
@media (max-width: 600px) {
  .tbb-site-header { --tbb-logo-h: 32px; --tbb-logo-name: 13px; }
}

/* Menu (desktop) */
.tbb-site-header .tbb-site-nav { margin-left: auto; }
.tbb-site-header .tbb-site-nav__menu { display: flex; align-items: center; gap: 4px; }
.tbb-site-header .tbb-site-nav li { position: relative; }
.tbb-site-header .tbb-site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: calc(var(--tbb-radius) - 2px);
  color: var(--tbb-muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  transition: color .2s, background-color .2s;
}
.tbb-site-header .tbb-site-nav a:hover { color: var(--tbb-fg); background: var(--tbb-ghost-hover); }
.tbb-site-header .tbb-site-nav :is(.current-menu-item, .current-menu-ancestor) > a { color: var(--tbb-fg); }
.tbb-site-header .tbb-site-nav .menu-item-has-children > a::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3.2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: .6;
}
.tbb-site-header .tbb-site-nav .sub-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  display: grid;
  min-width: 224px;
  padding: 6px;
  border: 1px solid var(--tbb-edge);
  border-radius: calc(var(--tbb-radius) + 4px);
  background: #fff;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / .12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.tbb-site-header .tbb-site-nav .sub-menu::before { content: ""; position: absolute; inset: -8px 0 auto; height: 8px; }
.tbb-site-header .tbb-site-nav .sub-menu a { display: flex; width: 100%; }
.tbb-site-header .tbb-site-nav li:is(:hover, :focus-within):not(.is-dismissed) > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.tbb-site-header .tbb-subtoggle { display: none; }

/* Menu button */
.tbb-site-header .tbb-site-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-border);
  border-radius: var(--tbb-radius) 0 var(--tbb-radius) 0;
  background: transparent;
  color: var(--tbb-fg);
  font-size: 20px;
  cursor: pointer;
}
.tbb-site-header .tbb-site-header__toggle:is(:hover, :focus) { background: var(--tbb-ghost-hover); color: var(--tbb-fg); }
.tbb-site-header .tbb-site-header__icon-close,
.tbb-site-header.is-open .tbb-site-header__icon-open { display: none; }
.tbb-site-header.is-open .tbb-site-header__icon-close { display: inline-flex; }

/* Menu panel (mobile and tablet) */
@media (max-width: 991px) {
  .tbb-site-header .tbb-site-header__toggle { display: inline-flex; }
  .tbb-site-header .tbb-site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    max-height: calc(100vh - var(--tbb-header-h) - var(--wp-admin--admin-bar--height, 0px));
    overflow-y: auto;
    margin: 0;
    padding: 8px 24px 24px;
    border-bottom: 1px solid var(--tbb-border);
    background: #fff;
  }
  .tbb-site-header.is-open .tbb-site-nav { display: block; }
  .tbb-site-header .tbb-site-nav__menu { flex-direction: column; align-items: stretch; gap: 0; }
  .tbb-site-header .tbb-site-nav__menu > li { display: flex; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--tbb-border); }
  .tbb-site-header .tbb-site-nav__menu > li > a { flex: 1; padding: 14px 0; font-size: 16px; color: var(--tbb-fg); }
  .tbb-site-header .tbb-site-nav a:hover { background: transparent; color: var(--tbb-brand); }
  .tbb-site-header .tbb-site-nav .menu-item-has-children > a::after { display: none; }
  .tbb-site-header .tbb-site-nav .sub-menu {
    position: static;
    display: none;
    flex-basis: 100%;
    min-width: 0;
    margin-bottom: 12px;
    padding: 0 0 0 12px;
    border: 0;
    border-left: 1px solid var(--tbb-edge);
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .tbb-site-header .tbb-site-nav li.is-expanded > .sub-menu { display: grid; }
  .tbb-site-header .tbb-site-nav .sub-menu a { padding: 8px 0; font-size: 15px; }
  .tbb-site-header .tbb-subtoggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--tbb-border);
    border-radius: calc(var(--tbb-radius) - 2px);
    background: transparent;
    color: var(--tbb-fg);
    cursor: pointer;
  }
  .tbb-site-header .tbb-subtoggle:is(:hover, :focus) { background: var(--tbb-ghost-hover); color: var(--tbb-fg); }
  .tbb-site-header .tbb-subtoggle .tbb-icon { transition: transform .2s; }
  .tbb-site-header .is-expanded > .tbb-subtoggle .tbb-icon { transform: rotate(180deg); }
}
@media (min-width: 640px) {
  .tbb-site-header .tbb-site-header__inner { padding-inline: 48px; }
}

/* ── Footer ───────────────────────────────────────────────────── */
.tbb-site-footer {
  position: relative;
  clear: both;
  width: 100%;
  background: var(--tbb-bg);
  color: var(--tbb-fg);
  font-family: var(--tbb-font);
  font-size: 15px;
  line-height: 1.6;
}
.tbb-site-footer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tbb-edge-hover) 30%, var(--tbb-edge-hover) 70%, transparent);
}
.tbb-site-footer .tbb-site-footer__inner { max-width: var(--tbb-wrap); margin-inline: auto; padding: 64px 24px 32px; }
.tbb-site-footer .tbb-site-footer__grid { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 40px 32px; }
.tbb-site-footer .tbb-site-footer__logo { display: inline-flex; }
.tbb-site-footer .tbb-site-footer__tagline { max-width: 320px; margin-top: 12px; color: var(--tbb-muted); }
.tbb-site-footer .tbb-site-footer__social { display: flex; gap: 8px; margin-top: 20px; }
.tbb-site-footer .tbb-site-footer__social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--tbb-border);
  border-radius: calc(var(--tbb-radius) - 2px);
  color: var(--tbb-muted);
  font-size: 16px;
  transition: color .2s, border-color .2s;
}
.tbb-site-footer .tbb-site-footer__social a:hover { color: var(--tbb-brand); border-color: var(--tbb-edge-hover); }
.tbb-site-footer .tbb-site-footer__title { font-family: var(--tbb-font-display); font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--tbb-fg); }
.tbb-site-footer .tbb-site-footer__menu { display: grid; gap: 10px; margin-top: 16px; }
.tbb-site-footer .tbb-site-footer__inner a { color: var(--tbb-muted); transition: color .2s; }
.tbb-site-footer .tbb-site-footer__inner a:hover { color: var(--tbb-brand); }
.tbb-site-footer .tbb-site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--tbb-border);
  font-size: 14px;
  color: var(--tbb-subtle);
}
.tbb-site-footer .tbb-site-footer__legal { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.tbb-site-footer .tbb-site-footer__bottom a { color: var(--tbb-subtle); }
@media (min-width: 640px) {
  .tbb-site-footer .tbb-site-footer__inner { padding-inline: 48px; }
}
@media (max-width: 1023px) {
  .tbb-site-footer .tbb-site-footer__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tbb-site-footer .tbb-site-footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  .tbb-site-footer .tbb-site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbb-site-footer .tbb-site-footer__bottom { flex-direction: column; align-items: flex-start; }
}

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