/* ToolBaz Mobile Left Menu — v1.0.0
   Scoped entirely under .tbzlm-root / #tbzlm-* so it can never leak into
   or clash with Astra's or any other plugin's styles. Desktop is untouched
   (the toggle button is display:none above the breakpoint via inline CSS). */

.tbzlm-root, .tbzlm-root * , .tbzlm-root *::before, .tbzlm-root *::after {
  box-sizing: border-box;
}

.tbzlm-root {
  --tbzlm-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --tbzlm-text: #1e1b2e;
  --tbzlm-muted: #6b7280;
  --tbzlm-border: #ececf3;
  --tbzlm-surface: #f6f6fb;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Toggle icon ──────────────────────────────────────────────
   Colors are hardcoded here (not via the --tbzlm-* vars) on purpose:
   JS relocates this button out of .tbzlm-root into Astra's header, and
   CSS custom properties only resolve through the DOM's inheritance
   chain — once moved, a var scoped to .tbzlm-root would no longer
   resolve, which is why the icon previously looked invisible. */
#tbzlm-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(99,102,241,.3);
  transition: transform .18s ease;
}
#tbzlm-toggle svg { width: 18px; height: 18px; display: block; }
#tbzlm-toggle:active { transform: scale(.92); }
#tbzlm-toggle:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }

/* DOCKED (default): the space for this icon is reserved up front via
   padding-left on the header's left section (see below) — BEFORE any
   JS runs, so there's nothing to shift when the icon is later inserted.
   position:absolute takes it out of flex flow entirely, so even if JS
   inserts it a beat after first paint, sibling content (the logo) never
   moves — only the icon itself fades/pops into its already-reserved spot. */
#tbzlm-toggle.tbzlm-toggle--docked {
  display: flex;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
}
#tbzlm-toggle.tbzlm-toggle--docked:active { transform: translateY(-50%) scale(.92); }

/* Reserve room for the docked icon from the very first paint (plain CSS,
   no JS involved) so the logo never has to move once the icon appears.
   Undone via html.tbzlm-no-dock if JS falls back to the fixed icon instead. */
#ast-mobile-header .site-header-primary-section-left,
#ast-mobile-header .site-header-section-left {
  position: relative;
  padding-left: 46px;
}
html.tbzlm-no-dock #ast-mobile-header .site-header-primary-section-left,
html.tbzlm-no-dock #ast-mobile-header .site-header-section-left {
  padding-left: 0;
}

/* FALLBACK: only used if Astra's mobile header markup couldn't be
   found (e.g. a non-default header layout). Mirrors the mobile
   breakpoint set in the PHP file. */
#tbzlm-toggle.tbzlm-toggle--fallback {
  display: flex;
  position: fixed;
  top: 14px;
  left: 10px;
  z-index: 100000;
  width: 42px;
  height: 42px;
  box-shadow: 0 4px 16px rgba(99,102,241,.35), 0 1px 3px rgba(0,0,0,.08);
}

/* ── Backdrop ─────────────────────────────────────────────────── */
.tbzlm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(15,15,25,.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
.tbzlm-overlay.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease, visibility 0s linear 0s;
}

/* ── Slide-in panel ───────────────────────────────────────────── */
.tbzlm-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100002;
  width: min(86vw, 340px);
  background: #fff;
  color: var(--tbzlm-text);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .38s cubic-bezier(.22,.9,.28,1);
  box-shadow: 0 0 40px rgba(0,0,0,.18);
}
.tbzlm-panel.is-open { transform: translateX(0); }

.tbzlm-panel__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--tbzlm-border);
}
.tbzlm-panel__title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--tbzlm-text);
}
.tbzlm-panel__title svg { width: 19px; height: 19px; color: #6366f1; flex-shrink: 0; }

.tbzlm-panel__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--tbzlm-border);
  border-radius: 10px;
  background: var(--tbzlm-surface);
  color: var(--tbzlm-muted);
  cursor: pointer;
  transition: background .18s, color .18s;
}
.tbzlm-panel__close svg { width: 15px; height: 15px; }
.tbzlm-panel__close:hover { background: #eee9ff; color: #6366f1; }

.tbzlm-panel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 24px;
  scrollbar-width: thin;
}

/* ── Category block ───────────────────────────────────────────── */
.tbzlm-cat { margin-bottom: 4px; }

.tbzlm-cat__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background .16s;
}
.tbzlm-cat__head:hover { background: var(--tbzlm-surface); }

.tbzlm-cat__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: rgba(99,102,241,.1);
  color: #6366f1;
}
.tbzlm-cat__icon svg { width: 16px; height: 16px; }

.tbzlm-cat__name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tbzlm-text);
}

.tbzlm-cat__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  color: #6366f1;
  background: rgba(99,102,241,.1);
}

.tbzlm-cat__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--tbzlm-muted);
  transition: transform .28s ease;
}
.tbzlm-cat.is-collapsed .tbzlm-cat__chevron { transform: rotate(-90deg); }

/* Smooth collapse via the grid-rows technique — no JS height measuring,
   no layout jank, works great for performance. */
.tbzlm-cat__body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .32s ease;
}
.tbzlm-cat.is-collapsed .tbzlm-cat__body { grid-template-rows: 0fr; }
.tbzlm-cat__inner { overflow: hidden; }

.tbzlm-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 48px;
  font-size: 12.8px;
  font-weight: 500;
  color: var(--tbzlm-text);
  text-decoration: none;
  border-radius: 10px;
  transition: background .16s, color .16s, padding-left .16s;
}
.tbzlm-tool:hover, .tbzlm-tool:focus-visible {
  background: rgba(99,102,241,.08);
  color: #4f46e5;
  padding-left: 52px;
}
.tbzlm-tool__icon { font-size: 15px; flex-shrink: 0; }
.tbzlm-tool__title { flex: 1; line-height: 1.35; }

/* Lock background scroll while the panel is open */
body.tbzlm-lock { overflow: hidden !important; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tbzlm-panel, .tbzlm-overlay, .tbzlm-cat__body, .tbzlm-cat__chevron, #tbzlm-toggle {
    transition: none !important;
  }
}
