/* Merchandise Heatmap v1.0.5 */
.mh-wrapper * { box-sizing: border-box !important; }
.mh-wrapper a { line-height: inherit !important; text-decoration: none !important; }

:root {
    --brand-primary: #20C997;
    --brand-primary-dark: #1AA67D;
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-md: 12px;
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --transition-smooth: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mh-wrapper {
    font-family: var(--font-primary);
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-md);
    margin: 0 0 1.5rem;
}

/* Header */
.mh-header { margin-bottom: 1.25rem; }

.mh-heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.mh-subtitle {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0;
}

/* Bar rows — CSS grid for perfect alignment */
.mh-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mh-row {
    display: grid;
    /* emoji | tag label | bar | count | avg */
    grid-template-columns: 1.5rem 7rem 1fr auto auto;
    align-items: center;
    gap: 0.6rem;
    min-height: 32px;
}

.mh-emoji {
    font-size: 1rem;
    line-height: 1;
    text-align: center;
    flex-shrink: 0;
}

.mh-tag {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mh-bar-wrap {
    height: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
    min-width: 40px;
}

.mh-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-dark));
    border-radius: 5px;
    transition: width var(--transition-smooth);
}

.mh-count {
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    text-align: right;
}

/* BUG FIX: #9ca3af on #fff had ~2.38:1 — below WCAG AA. Changed to #6b7280 (~4.5:1). */
.mh-deals-label {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.72rem;
}

/* BUG FIX: --brand-primary-dark (#1AA67D) on #fff had ~3.07:1 — below WCAG AA.
   Changed to #047857 which achieves ~5.8:1 contrast on white. */
.mh-avg {
    font-size: 0.78rem;
    font-weight: 700;
    color: #047857;
    white-space: nowrap;
    min-width: 3.5rem;
    text-align: right;
}

/* Top tag highlighted */
.mh-row:first-child .mh-bar-fill {
    background: linear-gradient(90deg, #10b981, var(--brand-primary-dark));
    box-shadow: 0 0 8px rgba(32,201,151,0.4);
}

.mh-row:first-child .mh-tag {
    color: #111827;
    font-weight: 700;
}

/* Mobile: collapse 5-col grid to 3-col + bar on own row */
@media (max-width: 600px) {
    .mh-row {
        grid-template-columns: 1.5rem 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.3rem 0.5rem;
    }
    .mh-bar-wrap {
        grid-column: 1 / -1;
        grid-row: 2;
        height: 8px;
    }
    .mh-avg { display: none; }
    .mh-count { font-size: 0.75rem; }
}

/*
 * Dark mode — DESIGN_GUIDE Rule 4.
 *
 * BUG FIX 3: Missing dark mode overrides for .mh-subtitle, .mh-avg, and .mh-deals-label.
 * - .mh-subtitle was #6b7280 on a #1f2937 background: contrast ratio ~3.0, below WCAG AA (4.5).
 *   Fixed to #9ca3af which achieves ~4.6 contrast on #1f2937.
 * - .mh-avg used var(--brand-primary-dark) = #1AA67D on #1f2937: very dark green, contrast
 *   ratio ~2.1, unreadable. Fixed to var(--brand-primary) = #20C997 (~5.3 contrast on dark bg).
 * - .mh-deals-label was #9ca3af — acceptable on dark (~4.6) so left as-is, but made explicit.
 */
@media (prefers-color-scheme: dark) {
    .mh-wrapper  { background: #1f2937; }
    .mh-heading  { color: #f9fafb; }
    .mh-subtitle { color: #9ca3af; } /* was #6b7280 — insufficient contrast on dark bg */
    .mh-tag      { color: #d1d5db; }
    .mh-bar-wrap { background: #374151; }
    .mh-count    { color: #d1d5db; }
    .mh-deals-label { color: #9ca3af; } /* explicit dark override */
    .mh-avg      { color: var(--brand-primary); } /* was brand-primary-dark — too dark on dark bg */
    .mh-row:first-child .mh-tag { color: #f9fafb; }
}

/* Reduced motion — DESIGN_GUIDE Rule 5 */
@media (prefers-reduced-motion: reduce) {
    .mh-bar-fill { transition: none; }
}
