/**
 * Directive Design Token Stylesheet (~2KB gzipped)
 *
 * All rules wrapped in :where() for zero specificity —
 * site CSS and Bootstrap always win on conflicts.
 *
 * Two-tier token inheritance:
 *   --bx-d-* reads from --bx-* (site tokens), falls back to hardcoded defaults.
 */

/* ── Tokens ── */
:where(.bx-d) {
  --bx-d-primary: var(--bx-primary, #6366f1);
  --bx-d-secondary: var(--bx-secondary, #ec4899);
  --bx-d-text: var(--bx-text, #1f2937);
  --bx-d-text-muted: var(--bx-text-muted, #6b7280);
  --bx-d-bg: var(--bx-bg, #ffffff);
  --bx-d-border: var(--bx-border, #e5e7eb);
  --bx-d-radius: var(--bx-radius, 8px);
  --bx-d-font-heading: var(--bx-font-heading, inherit);
  --bx-d-font-body: var(--bx-font-body, inherit);
  --bx-d-shadow: var(--bx-shadow, 0 1px 3px rgba(0,0,0,0.1));

  color: var(--bx-d-text);
  font-family: var(--bx-d-font-body);
  box-sizing: border-box;
}

/* ── Card ── */
:where(.bx-d-card) {
  background: var(--bx-d-bg);
  border: 1px solid var(--bx-d-border);
  border-radius: var(--bx-d-radius);
  box-shadow: var(--bx-d-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, transform .15s;
}

:where(.bx-d-card:hover) {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

:where(.bx-d-card-body) {
  padding: 16px;
}

:where(.bx-d-card-accent) {
  border-left: 4px solid var(--bx-d-primary);
  border-radius: 0;
}

/* ── Layout ── */
:where(.bx-d-row) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

:where(.bx-d-row-tight) {
  gap: 6px;
}

:where(.bx-d-stack) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Images ── */
:where(.bx-d-img-cover) {
  object-fit: cover;
  width: 100%;
}

:where(.bx-d-img-contain) {
  object-fit: contain;
  width: 100%;
  background: #f9fafb;
}

:where(.bx-d-img-hero) {
  aspect-ratio: 16 / 9;
  max-height: 280px;
}

:where(.bx-d-img-product) {
  aspect-ratio: 1 / 1;
  max-height: 320px;
}

:where(.bx-d-img-thumb) {
  width: 80px;
  height: 80px;
  border-radius: var(--bx-d-radius);
  object-fit: cover;
  flex-shrink: 0;
}

:where(.bx-d-img-placeholder) {
  background: var(--bx-d-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bx-d-text-muted);
  font-size: 14px;
}

/* ── Typography ── */
:where(.bx-d-title) {
  font-family: var(--bx-d-font-heading);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  color: var(--bx-d-text);
}

:where(.bx-d-subtitle) {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  color: var(--bx-d-text-muted);
}

:where(.bx-d-meta) {
  font-size: 13px;
  color: var(--bx-d-text-muted);
}

/* ── Interactive ── */
:where(.bx-d-link) {
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease;
}

:where(.bx-d-link:hover) {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

:where(.bx-d-link:focus-visible) {
  outline: 2px solid var(--bx-d-primary);
  outline-offset: 2px;
}

:where(.bx-d-badge) {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bx-d-primary) 10%, transparent);
  color: var(--bx-d-primary);
  font-weight: 500;
}

/* ── Stars ── */
:where(.bx-d-stars) {
  color: #f59e0b;
  letter-spacing: 1px;
  line-height: 1;
}

/* ── Accordion ── */
:where(.bx-d-accordion) {
  border: 1px solid var(--bx-d-border);
  border-radius: var(--bx-d-radius);
  overflow: hidden;
}

:where(.bx-d-accordion-body) {
  padding: 12px 16px;
}

:where(.bx-d-divider) {
  border: none;
  border-top: 1px solid var(--bx-d-border);
  margin: 0;
}

/* ── Preview Images ── */
:where(.bx-d-img-preview) {
  max-height: var(--bx-d-preview-img-h, 120px);
  object-fit: cover;
  width: 100%;
  border-radius: var(--bx-d-radius);
}

:where(.bx-d-img-preview-product) {
  --bx-d-preview-img-h: 160px;
  object-fit: contain;
  background: #f9fafb;
}

:where(.bx-d-img-preview-hero) {
  --bx-d-preview-img-h: 200px;
}

/* ── Price & Favicon ── */
:where(.bx-d-badge-price) {
  background: #059669;
  color: #fff;
  font-weight: 600;
}

:where(.bx-d-price-original) {
  text-decoration: line-through;
  opacity: 0.6;
}

:where(.bx-d-favicon) {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  vertical-align: -2px;
  margin-right: 4px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  :where(.bx-d-row) {
    flex-direction: column;
    align-items: stretch;
  }
  :where(.bx-d-img-hero) {
    max-height: 200px;
  }
  :where(.bx-d-img-thumb) {
    width: 60px;
    height: 60px;
  }
}
