/* Madbax Chrome — M3 Top App Bar + Academy Filter Bar
 * Spec: docs/madbax-home-design.md + plan Top App Bar Filter
 */

.mbx-chrome {
  --md-sys-color-primary: #00e599;
  --md-sys-color-on-primary: #0a0a0a;
  --md-sys-color-surface: #f2f2f2;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-high: #e8e8eb;
  --md-sys-color-surface-container-highest: #e2e2e6;
  --md-sys-color-secondary-container: #c8f5e4;
  --md-sys-color-on-secondary-container: #003826;
  --md-sys-color-on-surface: #17191a;
  --md-sys-color-on-surface-variant: #5c6570;
  --md-sys-color-outline: #79747e;
  --md-sys-color-outline-variant: #c7c5d0;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 999px;
  --md-sys-state-hover: 0.08;
  --md-sys-motion: 150ms cubic-bezier(0.2, 0, 0, 1);
  --md-sys-typescale-brand: "Inter Tight", system-ui, sans-serif;
  --md-sys-typescale-plain: Inter, system-ui, sans-serif;
  --mbx-tab-h: 64px;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  font-family: var(--md-sys-typescale-plain);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
  /* No idle transform — it creates a containing block and traps
     position:fixed descendants (drawer/scrim) to chrome height. */
  transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
}

/* Never use generic .is-hidden — Bopea maps it to display:none */
.mbx-chrome.mbx-chrome--away {
  transform: translate3d(0, calc(-100% - 1px), 0);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .mbx-chrome {
    transition: none;
  }
  body.mbx-chrome-on {
    transition: none;
  }
}

.mbx-chrome *,
.mbx-chrome *::before,
.mbx-chrome *::after {
  box-sizing: border-box;
}

/* Hide Bopea / theme header everywhere chrome is present */
body:has(.mbx-chrome) header.jlc-hmain-w,
body:has(.mbx-chrome) .tp_head_off > header,
body:has(.mbx-chrome) .options_header,
body:has(.mbx-chrome) .jl_mobile_nav,
body:has(.mbx-chrome) .menu_mobile_large,
body:has(.mbx-chrome) #jl_mobile_nav,
body:has(.mbx-chrome) .mobile_menu_wrap,
body.mbx-chrome-on header.jlc-hmain-w,
body.mbx-chrome-on .tp_head_off > header {
  display: none !important;
}

body.mbx-chrome-on {
  padding-top: var(--mbx-chrome-offset, 0px) !important;
  transition: padding-top 200ms cubic-bezier(0.2, 0, 0, 1);
}

/* WP admin bar */
body.admin-bar .mbx-chrome {
  top: 32px;
}
@media screen and (max-width: 782px) {
  body.admin-bar .mbx-chrome {
    top: 46px;
  }
}

/* —— Top App Bar —— */
.mbx-tab {
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  min-height: var(--mbx-tab-h);
}

.mbx-tab__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: var(--mbx-tab-h);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mbx-tab__brand {
  flex: 0 0 auto;
  font-family: var(--md-sys-typescale-brand);
  font-size: 18px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -0.02em;
  color: var(--md-sys-color-on-surface) !important;
  text-decoration: none !important;
}

.mbx-tab__brand:hover {
  color: var(--md-sys-color-on-surface) !important;
}

.mbx-tab__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
}

.mbx-tab__link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--md-sys-shape-corner-small);
  font-family: var(--md-sys-typescale-brand);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.01em;
  color: var(--md-sys-color-on-surface-variant) !important;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background-color var(--md-sys-motion), color var(--md-sys-motion);
}

.mbx-tab__link:hover,
.mbx-tab__link:focus-visible {
  color: var(--md-sys-color-on-surface) !important;
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.mbx-tab__link:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.mbx-tab__search {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 220px;
  max-width: 320px;
  margin-left: auto;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: var(--md-sys-color-surface-container-highest);
  border: 0;
}

.mbx-tab__search-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  background-color: var(--md-sys-color-on-surface-variant);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5Zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14Z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5Zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14Z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
}

.mbx-tab__search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font-family: var(--md-sys-typescale-plain);
  font-size: 14px !important;
  font-weight: 400 !important;
  line-height: 20px !important;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface) !important;
}

.mbx-tab__search-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 1;
}

.mbx-tab__search:focus-within {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.mbx-tab__cta {
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding: 0 20px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: var(--md-sys-shape-corner-full) !important;
  background: var(--md-sys-color-primary) !important;
  color: #0a0a0a !important;
  -webkit-text-fill-color: #0a0a0a !important;
  font-family: var(--md-sys-typescale-brand) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  letter-spacing: -0.01em !important;
  text-decoration: none !important;
  text-transform: none !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  transition: filter var(--md-sys-motion);
}

.mbx-tab__cta:hover {
  filter: brightness(1.05);
  color: #0a0a0a !important;
  -webkit-text-fill-color: #0a0a0a !important;
}

.mbx-tab__cta:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.mbx-tab__menu-btn {
  display: none;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: #17191a !important;
  -webkit-text-fill-color: #17191a !important;
}

.mbx-tab__menu-icon {
  width: 24px;
  height: 24px;
  background-color: #17191a !important;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z'/%3E%3C/svg%3E") center / 24px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z'/%3E%3C/svg%3E") center / 24px no-repeat;
}

.mbx-tab__menu-btn:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Drawer */
.mbx-tab__scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 10060;
}

.mbx-tab__drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  background: var(--md-sys-color-surface-container-lowest);
  z-index: 10070;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.mbx-tab__drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mbx-tab__drawer-nav a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  font-family: var(--md-sys-typescale-brand);
  font-size: 16px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface) !important;
  text-decoration: none !important;
}

.mbx-tab__drawer-nav a:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.mbx-tab__drawer-cta {
  margin-top: 12px !important;
  justify-content: center !important;
  background: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
  font-weight: 600 !important;
  border-radius: var(--md-sys-shape-corner-full) !important;
}

/* —— Filter bar —— */
.mbx-filter {
  background: var(--md-sys-color-surface);
  padding: 10px 0 0;
}

.mbx-filter__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-medium);
  min-height: 52px;
}

.mbx-filter__left,
.mbx-filter__right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mbx-filter__field {
  position: relative;
}

.mbx-filter__trigger {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 12px 0 14px !important;
  margin: 0 !important;
  border-radius: var(--md-sys-shape-corner-small) !important;
  border: 1px solid var(--md-sys-color-outline) !important;
  background: var(--md-sys-color-surface-container-lowest) !important;
  color: #5c6570 !important;
  -webkit-text-fill-color: #5c6570 !important;
  font-family: var(--md-sys-typescale-plain) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: -0.01em !important;
}

.mbx-filter__trigger-label {
  color: inherit !important;
  -webkit-text-fill-color: inherit !important;
  font: inherit !important;
  line-height: 1 !important;
}

.mbx-filter__trigger[aria-expanded="true"],
.mbx-filter__trigger.is-active {
  border-color: transparent !important;
  background: var(--md-sys-color-secondary-container) !important;
  color: #003826 !important;
  -webkit-text-fill-color: #003826 !important;
}

.mbx-filter__trigger:focus-visible {
  outline: 2px solid var(--md-sys-color-primary) !important;
  outline-offset: 2px !important;
}

.mbx-filter__chev {
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px !important;
  background-color: currentColor !important;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") center / 16px no-repeat;
}

.mbx-tab__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  box-shadow: 0 4px 16px rgba(23, 25, 26, 0.12);
}

.mbx-tab__menu-item {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  text-align: left !important;
  border: 0 !important;
  background: transparent !important;
  padding: 10px 14px !important;
  margin: 0 !important;
  font-family: var(--md-sys-typescale-plain) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 18px !important;
  color: #17191a !important;
  -webkit-text-fill-color: #17191a !important;
  cursor: pointer !important;
  text-transform: none !important;
  box-shadow: none !important;
}

.mbx-tab__menu-item:hover,
.mbx-tab__menu-item[aria-checked="true"] {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent) !important;
}

.mbx-tab__menu-item[aria-checked="true"] {
  font-weight: 500 !important;
  color: #003826 !important;
  -webkit-text-fill-color: #003826 !important;
  background: var(--md-sys-color-secondary-container) !important;
}

.mbx-filter__badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  min-width: 24px !important;
  width: auto !important;
  height: 24px !important;
  padding: 0 7px !important;
  margin: 0 !important;
  border-radius: var(--md-sys-shape-corner-full) !important;
  background: var(--md-sys-color-secondary-container) !important;
  color: #003826 !important;
  -webkit-text-fill-color: #003826 !important;
  font-family: var(--md-sys-typescale-plain) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
}

.mbx-filter__badge[data-count="0"],
.mbx-filter__right:has(.mbx-filter__badge[data-count="0"]) .mbx-filter__reset {
  display: none !important;
}

.mbx-filter__reset {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: var(--md-sys-shape-corner-full) !important;
  background: transparent !important;
  color: #008f5a !important;
  -webkit-text-fill-color: #008f5a !important;
  font-family: var(--md-sys-typescale-plain) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  letter-spacing: -0.01em !important;
  cursor: pointer !important;
  box-shadow: none !important;
  text-transform: none !important;
  vertical-align: middle !important;
}

.mbx-filter__reset:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent) !important;
  color: #007a4d !important;
  -webkit-text-fill-color: #007a4d !important;
}

.mbx-filter__reset:focus-visible {
  outline: 2px solid var(--md-sys-color-primary) !important;
  outline-offset: 2px !important;
}

/* Compact */
@media (max-width: 899px) {
  .mbx-tab__nav {
    display: none;
  }

  .mbx-tab__search {
    display: none;
  }

  .mbx-tab__menu-btn {
    display: inline-flex;
    margin-left: auto;
  }

  .mbx-tab__inner {
    padding: 0 16px;
    gap: 8px;
  }

  .mbx-filter__inner {
    margin: 0 16px;
    padding: 8px 12px;
  }
}

@media (max-width: 599px) {
  .mbx-tab__cta {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 16px !important;
    font-size: 14px !important;
  }

  .mbx-filter__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .mbx-filter__left,
  .mbx-filter__right {
    width: 100%;
    justify-content: space-between;
  }

  .mbx-filter__trigger {
    flex: 1 1 auto;
  }
}
