/* ---------------------------------------------------------------
   Header — topbar, brand, search, nav, mobile drawer
   Mobile-first: nav and search collapse into the drawer below 900px.
   --------------------------------------------------------------- */

@keyframes slide-down-from-top {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-up-from-bottom {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.jb-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  /* flow-root, so the bar's margin stays inside the header box instead of
     collapsing through it — the sticky offset and the hero's pull-up both
     depend on the header's measured height including that margin. */
  display: flow-root;
}

/* The header drops in only on the home page, alongside the hero's own entrance
   — everywhere else it is already part of the page the visitor asked for, and
   animating it just delays the content. `home` is WordPress's own body class
   for the front page. */
body.home .jb-header {
  animation: slide-down-from-top .5s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  body.home .jb-header { animation: none; }
}

/* The bar floats: margin all round, rounded corners, no border. The
   background lives here rather than on .jb-header so the page shows through
   the gap around it. */
.jb-headbar {
  margin: 10px;
  border-radius: 12px;
  background: var(--jb-white);
  box-shadow: 0 2px 10px rgba(16, 21, 27, .08);
  transition: box-shadow .2s ease, background .25s ease;
}
.jb-header.is-stuck .jb-headbar {
  box-shadow: 0 6px 22px rgba(16, 21, 27, .16);
}

@media (min-width: 900px) {
  .jb-headbar {
    /* Cap the bar to the content column plus its padding, and centre it.
       Left full-width, the bar kept stretching on large screens while its
       contents stayed capped at 1200px — logo and nav ended up marooned in
       the middle with a few hundred pixels of empty glass at each end. */
    max-width: min(calc(var(--jb-max) + 2 * var(--jb-s5)), calc(100% - 32px));
    margin: 14px auto;
    border-radius: 14px;
  }
}

/* ---------- Head bar ---------- */

.jb-headbar__inner {
  display: flex;
  align-items: center;
  gap: var(--jb-s4);
  min-height: 64px;
  padding-block: var(--jb-s3);
}

/* ---------- Brand ---------- */

.jb-brand { margin-inline-end: auto; }
.jb-brand img { max-height: 56px; width: auto; }

.jb-brand__text {
  display: flex;
  align-items: center;
  gap: var(--jb-s3);
  line-height: 1.05;
}

/* Placeholder mark — swapped out the moment a real logo is uploaded. */
.jb-brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--jb-radius);
  background: var(--jb-amber);
  color: var(--jb-ink);
}
.jb-brand__mark .jb-icon {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}
@media (min-width: 900px) {
  .jb-brand__mark { width: 50px; height: 50px; }
  .jb-brand__mark .jb-icon { width: 30px; height: 30px; }
}
.jb-brand__name {
  display: block;
  font-family: var(--jb-font-display);
  font-size: 1.5rem;
  font-weight: var(--jb-display-weight);
  letter-spacing: var(--jb-display-tracking);
  text-transform: uppercase;
  color: var(--jb-ink);
}
/* The amber underscore is the brand's only decorative flourish — it reads as
   a hazard stripe, which is the right note for a safety supplier. */
.jb-brand__name::after {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-top: 3px;
  background: var(--jb-amber);
}
.jb-brand__slogan {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--jb-500);
}

@media (min-width: 900px) {
  .jb-brand__name { font-size: 1.75rem; }
  .jb-brand__slogan { font-size: 11px; }
}

/* ---------- Search ---------- */

.jb-searchform {
  display: flex;
  align-items: center;
  width: 100%;
  /* No outline border: a soft fill is what separates the field from the bar.
     The border stays declared but transparent so the box metrics never change
     between states — swapping it for a colour would shift the layout by 1px. */
  background: var(--jb-100);
  border: 1px solid transparent;
  border-radius: var(--jb-radius);
  overflow: hidden;
  transition: background .15s ease, box-shadow .15s ease;
}
/* The ring is the only focus affordance on this control (the input's own
   outline is suppressed below), so it mirrors the global amber focus ring. */
.jb-searchform:focus-within {
  background: var(--jb-white);
  box-shadow: 0 0 0 3px var(--jb-amber);
}
.jb-searchform__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px var(--jb-s4);
  border: 0;
  background: transparent;
  /* Must stay >= 16px on mobile: iOS Safari zooms the whole page when a
   smaller field takes focus. Only shrink once we're on a desktop viewport. */
  font-size: var(--jb-fs-md);
  color: var(--jb-ink);
}
@media (min-width: 900px) {
  .jb-searchform__input { font-size: var(--jb-fs-sm); }
}
.jb-searchform__input:focus { outline: none; }
.jb-searchform__input::placeholder { color: var(--jb-500); }
.jb-searchform__submit {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  align-self: stretch;
  border: 0;
  background: var(--jb-amber);
  color: var(--jb-ink);
  transition: background .15s ease;
}
.jb-searchform__submit:hover { background: var(--jb-amber-dark); }

/* In the bar from tablet portrait up. The nav stays in the drawer until
   900px, but at 768 there is already room for brand + search + burger, and
   search is the one control a catalog visitor reaches for first. */
.jb-search--desktop { display: none; }
@media (min-width: 768px) {
  .jb-search--desktop {
    display: block;
    flex: 1 1 auto;
    max-width: 420px;
  }
}

/* ---------- Primary nav ---------- */

.jb-nav { display: none; }
@media (min-width: 900px) { .jb-nav { display: block; } }

.jb-nav__list {
  display: flex;
  align-items: center;
  gap: var(--jb-s5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.jb-nav__list a {
  position: relative;
  display: block;
  padding-block: var(--jb-s2);
  font-size: var(--jb-fs-sm);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--jb-ink);
  white-space: nowrap;
}
.jb-nav__list a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--jb-amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .18s ease;
}
.jb-nav__list a:hover::after,
.jb-nav__list .current-menu-item > a::after,
.jb-nav__list .current_page_item > a::after { transform: scaleX(1); }

/* ---------- Burger ---------- */

.jb-burger {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--jb-200);
  border-radius: var(--jb-radius);
  background: var(--jb-white);
  color: var(--jb-ink);
}
.jb-burger .jb-icon { width: 22px; height: 22px; }
@media (min-width: 900px) { .jb-burger { display: none; } }

/* ---------- Mobile drawer ---------- */

body.jb-drawer-open {
  position: fixed;
  inset-inline: 0;
  width: 100%;
  overflow: hidden;
}

.jb-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
}
.jb-drawer[hidden] { display: none; }

.jb-drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 21, 27, .5);
  opacity: 0;
  transition: opacity .22s ease;
}
.jb-drawer.is-open .jb-drawer__scrim { opacity: 1; }

.jb-drawer__panel {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 1;
  width: min(86vw, 340px);
  padding: var(--jb-s6) var(--jb-s5);
  background: var(--jb-white);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
}
.jb-drawer.is-open .jb-drawer__panel { transform: translateX(0); }

@media (prefers-reduced-motion: reduce) {
  .jb-drawer__panel, .jb-drawer__scrim { transition: none; }
}

.jb-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--jb-s4);
  margin-bottom: var(--jb-s5);
  padding-bottom: var(--jb-s3);
  border-bottom: 1px solid var(--jb-100);
}
.jb-drawer__title {
  font-size: var(--jb-fs-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--jb-500);
}
.jb-drawer__close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-inline-end: -6px;   /* optical alignment with the panel edge */
  border: 1px solid var(--jb-200);
  border-radius: var(--jb-radius);
  background: var(--jb-white);
  color: var(--jb-ink);
  transition: background .15s ease, border-color .15s ease;
}
.jb-drawer__close:hover {
  background: var(--jb-50);
  border-color: var(--jb-300);
}
.jb-drawer__close .jb-icon { width: 20px; height: 20px; }

.jb-search--drawer { margin-bottom: var(--jb-s5); }
/* Redundant once the bar carries its own search. */
@media (min-width: 768px) {
  .jb-search--drawer { display: none; }
}

.jb-drawer__list {
  margin: 0 0 var(--jb-s5);
  padding: 0;
  list-style: none;
}
.jb-drawer__list li + li { border-top: 1px solid var(--jb-100); }
.jb-drawer__list a {
  display: block;
  padding: var(--jb-s3) 0;
  font-size: var(--jb-fs-lg);
  font-weight: 600;
}
.jb-drawer__list a:hover { color: var(--jb-amber-dark); }

/* ---------------------------------------------------------------
   Overlay header (front page only)

   The hero slider runs full-bleed underneath the header, which turns
   into frosted glass so the image shows through. Two things make this
   safe rather than pretty-but-broken:

   1. A gradient scrim behind the header (see slider.css) guarantees
      contrast no matter what photo the client uploads — light text on
      an unknown image is otherwise a coin toss.
   2. Once scrolled away from the hero the header returns to its solid
      state, so the rest of the site is unaffected.
   --------------------------------------------------------------- */

.jb-header--overlay {
  position: sticky;
  background: transparent;
  transition: background .25s ease, backdrop-filter .25s ease;
}

/* --- Transparent state: only while sitting over the hero --- */

.jb-header--overlay:not(.is-stuck) .jb-headbar {
  background: rgba(16, 21, 27, .34);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
}

/* Wordmark, nav and burger flip to white over the image. */
.jb-header--overlay:not(.is-stuck) .jb-brand__name,
.jb-header--overlay:not(.is-stuck) .jb-nav__list a {
  color: #fff;
}
.jb-header--overlay:not(.is-stuck) .jb-brand__slogan {
  color: rgba(255, 255, 255, .72);
}
.jb-header--overlay:not(.is-stuck) .jb-burger {
  border-color: rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

/* Search becomes a glass pill rather than a grey box. */
.jb-header--overlay:not(.is-stuck) .jb-searchform {
  background: rgba(255, 255, 255, .16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.jb-header--overlay:not(.is-stuck) .jb-searchform__input { color: #fff; }
.jb-header--overlay:not(.is-stuck) .jb-searchform__input::placeholder {
  color: rgba(255, 255, 255, .75);
}
/* Amber can sink into a warm hero photo, so the glass pill rings in white. */
.jb-header--overlay:not(.is-stuck) .jb-searchform:focus-within {
  background: rgba(255, 255, 255, .28);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .8);
}

/* --- Scrolled state: back to the standard solid header --- */

.jb-header--overlay.is-stuck .jb-headbar {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}

/* Backdrop-filter is unsupported on a few older browsers; fall back to a
   solid tint so the header never becomes unreadable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .jb-header--overlay:not(.is-stuck) .jb-headbar { background: rgba(16, 21, 27, .74); }
  .jb-header--overlay.is-stuck .jb-headbar { background: var(--jb-white); }
  /* Without the blur behind it the 16% fill nearly vanishes on the dark bar. */
  .jb-header--overlay:not(.is-stuck) .jb-searchform { background: rgba(255, 255, 255, .22); }
}
