/* ==========================================================
   WoodMart Category Accordion  |  wmca-frontend.css  v2.0
   ========================================================== */

/* ── CSS Variables – WoodMart palette ── */
:root {
  --wmca-primary:      #1a1a1a;
  --wmca-accent:       #d4a853;
  --wmca-accent-h:     #b8893a;
  --wmca-bg:           #ffffff;
  --wmca-bg2:          #f5f5f5;
  --wmca-border:       #e2e2e2;
  --wmca-text:         #333333;
  --wmca-muted:        #888888;
  --wmca-radius:       4px;
  --wmca-speed:        0.22s;
  --wmca-easing:       cubic-bezier(0.4,0,0.2,1);
  --wmca-indent:       14px;
}

/* ── Reset ── */
.wmca-nav *,
.wmca-nav *::before,
.wmca-nav *::after { box-sizing: border-box; }

/* ═══════════════════════════════════════
   NAV WRAPPER
═══════════════════════════════════════ */
.wmca-nav {
  font-family: inherit;
  color: var(--wmca-text);
  width: 100%;
  position: relative;
}

.wmca-nav__title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wmca-muted);
  padding: 0 0 10px 0;
  border-bottom: 2px solid var(--wmca-accent);
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════
   MOBILE TOGGLE  (hidden on desktop)
═══════════════════════════════════════ */
.wmca-mobile-toggle {
  display: none;                 /* shown via media query below */
  width: 100%;
  align-items: center;
  gap: 10px;
  background: var(--wmca-bg);
  border: 1px solid var(--wmca-border);
  border-radius: var(--wmca-radius);
  padding: 13px 14px;
  cursor: pointer;
  color: var(--wmca-text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
}

.wmca-mobile-toggle__bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.wmca-mobile-toggle__bars span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--wmca-text);
  border-radius: 2px;
  transition: transform var(--wmca-speed) var(--wmca-easing),
              opacity  var(--wmca-speed) var(--wmca-easing);
}

.wmca-mobile-toggle__label { flex: 1; text-align: left; }

.wmca-mobile-toggle .wmca-chevron {
  width: 16px; height: 16px;
  flex-shrink: 0;
  transition: transform var(--wmca-speed) var(--wmca-easing);
}

/* Animate hamburger → X when open */
.wmca-mobile-toggle[aria-expanded="true"] .wmca-mobile-toggle__bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.wmca-mobile-toggle[aria-expanded="true"] .wmca-mobile-toggle__bars span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.wmca-mobile-toggle[aria-expanded="true"] .wmca-mobile-toggle__bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.wmca-mobile-toggle[aria-expanded="true"] .wmca-chevron { transform: rotate(180deg); }

/* ═══════════════════════════════════════
   CATEGORY LIST
═══════════════════════════════════════ */
.wmca-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--wmca-border);
}

/* ── List item ── */
.wmca-item {
  border-bottom: 1px solid var(--wmca-border);
}

/* ── Row (link + toggle) ── */
.wmca-row {
  display: flex;
  align-items: stretch;
  min-height: 48px;            /* touch-friendly */
  background: var(--wmca-bg);
  transition: background var(--wmca-speed);
}

.wmca-item.is-current > .wmca-row,
.wmca-item.is-open    > .wmca-row {
  background: var(--wmca-bg2);
}

/* ── Category link ── */
.wmca-link {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 9px;
  padding: 11px 12px;
  text-decoration: none !important;
  color: var(--wmca-text);
  font-size: 0.875rem;
  line-height: 1.3;
  min-width: 0;
  transition: color var(--wmca-speed);
}

.wmca-link:hover,
.wmca-link:focus-visible {
  color: var(--wmca-accent);
  outline: none;
}

.wmca-link--active {
  color: var(--wmca-accent) !important;
  font-weight: 700;
}

/* Depth-based indent */
.wmca-d2 .wmca-link { padding-left: calc(12px + var(--wmca-indent));     font-size: 0.845rem; }
.wmca-d3 .wmca-link { padding-left: calc(12px + var(--wmca-indent) * 2); font-size: 0.82rem;  }
.wmca-d4 .wmca-link { padding-left: calc(12px + var(--wmca-indent) * 3); font-size: 0.8rem;   }

/* Accent left-bar for current & ancestors */
.wmca-item.is-current > .wmca-row > .wmca-link,
.wmca-item.is-open    > .wmca-row > .wmca-link {
  border-left: 3px solid var(--wmca-accent);
  padding-left: 9px;
}

/* Sub-level active: keep indent */
.wmca-d2.is-current > .wmca-row > .wmca-link { padding-left: calc(9px + var(--wmca-indent));     }
.wmca-d3.is-current > .wmca-row > .wmca-link { padding-left: calc(9px + var(--wmca-indent) * 2); }
.wmca-d4.is-current > .wmca-row > .wmca-link { padding-left: calc(9px + var(--wmca-indent) * 3); }

/* Thumbnail */
.wmca-thumb {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--wmca-bg2);
}
.wmca-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Name */
.wmca-name {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Count badge */
.wmca-count {
  flex-shrink: 0;
  background: var(--wmca-bg2);
  color: var(--wmca-muted);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  line-height: 1.5;
  min-width: 22px;
  text-align: center;
}

.wmca-link--active .wmca-count,
.wmca-link:hover   .wmca-count {
  background: var(--wmca-accent);
  color: #fff;
}

/* ── Toggle chevron button ── */
.wmca-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  background: none;
  border: none;
  border-left: 1px solid var(--wmca-border);
  cursor: pointer;
  color: var(--wmca-muted);
  padding: 0;
  transition: color var(--wmca-speed), background var(--wmca-speed);
}

.wmca-toggle:hover,
.wmca-toggle:focus-visible {
  color: var(--wmca-accent);
  background: var(--wmca-bg2);
  outline: none;
}

.wmca-toggle svg {
  width: 16px; height: 16px;
  pointer-events: none;
  transition: transform var(--wmca-speed) var(--wmca-easing);
}

.wmca-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* ═══════════════════════════════════════
   SUB-CATEGORY PANEL  (accordion body)
═══════════════════════════════════════ */
.wmca-sub {
  overflow: hidden;
  /* height animated by JS */
}

.wmca-sub[hidden] { display: none !important; }

.wmca-sublist {
  border-top: 1px solid var(--wmca-border);
  background: var(--wmca-bg2);
}

/* ═══════════════════════════════════════
   PRODUCT FILTER OVERLAY  (AJAX loading)
═══════════════════════════════════════ */
.wmca-loading-overlay {
  position: relative;
}
.wmca-loading-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.65);
  z-index: 10;
  border-radius: 4px;
}

.wmca-loader {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--wmca-primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  align-items: center;
  gap: 8px;
}
.wmca-loader.wmca-loader--visible { display: flex; }

.wmca-loader__spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wmca-spin 0.6s linear infinite;
}

@keyframes wmca-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════ */
.wmca-empty {
  font-size: 0.85rem;
  color: var(--wmca-muted);
  font-style: italic;
  padding: 8px 0;
}

/* ═══════════════════════════════════════
   MOBILE  ≤ 767px
═══════════════════════════════════════ */
@media (max-width: 767px) {

  /* Show the hamburger button */
  .wmca-mobile-toggle { display: flex; }

  /* List collapses by default on mobile */
  #wmca-list-root {
    display: none;
    border-top: none;
    margin-top: 4px;
    border: 1px solid var(--wmca-border);
    border-radius: 0 0 var(--wmca-radius) var(--wmca-radius);
    overflow: hidden;
  }
  #wmca-list-root.wmca-mobile-open { display: block; }

  .wmca-row   { min-height: 52px; }       /* bigger tap target */
  .wmca-link  { font-size: 0.9rem; }
  .wmca-toggle { width: 52px; }

  /* Slightly bolder names on mobile for readability */
  .wmca-d1 .wmca-name { font-weight: 600; }

  .wmca-loader { bottom: 16px; right: 16px; font-size: 0.72rem; }
}

/* ═══════════════════════════════════════
   REDUCED MOTION
═══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .wmca-toggle svg,
  .wmca-link,
  .wmca-row,
  .wmca-count,
  .wmca-mobile-toggle__bars span,
  .wmca-mobile-toggle .wmca-chevron {
    transition: none !important;
    animation: none !important;
  }
}
