/* ===========================================================================
   Brickray — design tokens
   =========================================================================== */

:root {
    /* Type scale */
    --font-sans: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Menlo, Consolas, monospace;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Layout */
    --nav-h: 64px;
    --sidebar-w: 280px;
    --max-w: 1440px;

    /* Motion */
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ----- Dark theme (default) -------------------------------------------- */
:root,
:root[data-theme='dark'] {
    --bg: #0b0d10;
    --bg-elev: #11141a;
    --surface: #14181f;
    --surface-2: #14181f;
    --surface-3: #20262f;
    --border: #232a35;
    --border-strong: #2f3744;
    --text: #e8ecf2;
    --text-muted: #98a3b3;
    --text-dim: #6b7585;

    /* Brand: Lumibricks orange + cyan X-ray contrast */
    --accent: #f97316;
    --accent-2: #22d3ee;
    --accent-soft: #fb923c;
    --accent-glow: rgba(249, 115, 22, 0.35);
    --accent-fade: rgba(249, 115, 22, 0.12);

    --good: #22c55e;
    --good-soft: #16a34a;
    --good-fade: rgba(34, 197, 94, 0.14);
    --warn: #f59e0b;
    --warn-fade: rgba(245, 158, 11, 0.14);
    --bad: #ef4444;
    --bad-soft: #dc2626;
    --bad-fade: rgba(239, 68, 68, 0.14);
    --info: #38bdf8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 0 1px rgba(249, 115, 22, 0.32), 0 8px 24px rgba(249, 115, 22, 0.20);
}

/* ----- Light theme ----------------------------------------------------- */
:root[data-theme='light'] {
    --bg: #f7f8fa;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --surface-3: #e8eaef;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #0f172a;
    --text-muted: #4b5563;
    --text-dim: #9ca3af;

    /* Brand: deeper orange in light mode for contrast on white */
    --accent: #ea580c;
    --accent-2: #0891b2;
    --accent-soft: #f97316;
    --accent-glow: rgba(234, 88, 12, 0.22);
    --accent-fade: rgba(234, 88, 12, 0.08);

    --good: #059669;
    --good-soft: #047857;
    --good-fade: rgba(5, 150, 105, 0.08);
    --warn: #d97706;
    --warn-fade: rgba(217, 119, 6, 0.08);
    --bad: #dc2626;
    --bad-soft: #b91c1c;
    --bad-fade: rgba(220, 38, 38, 0.08);
    --info: #0284c7;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10);
    --shadow-glow: 0 0 0 1px rgba(234, 88, 12, 0.20), 0 8px 24px rgba(234, 88, 12, 0.14);
}

/* ===========================================================================
   Reset & base
   =========================================================================== */

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

* {
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    scrollbar-gutter: stable;
}

html {
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:root[data-theme='light'] {
    color-scheme: light;
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent-soft);
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    background: none;
    border: 0;
}

input,
select,
textarea {
    font: inherit;
    color: inherit;
}

ul {
    list-style: none;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

::selection {
    background: var(--accent-glow);
    color: var(--text);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 12px;
    background: var(--accent);
    color: white;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    z-index: 1000;
}

.skip-link:focus {
    left: 12px;
}

.mobile-only {
    display: none !important;
}

/* ===========================================================================
   Top nav
   =========================================================================== */

.site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--nav-h);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.site-nav__inner {
    max-width: var(--max-w);
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.brand__mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px var(--accent-glow));
}

.brand__mark--sm {
    width: 24px;
    height: 24px;
}

.brand__wordmark {
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    background: orange;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.site-nav__spacer {
    flex: 1;
}

.site-nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s var(--ease);
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-2);
    transform: translateY(-1px);
}

.icon-btn--small {
    width: 32px;
    height: 32px;
}

.icon-btn .icon {
    width: 18px;
    height: 18px;
}

/* Theme-toggle: show only the relevant icon */
.icon-btn .icon--moon {
    display: none;
}
:root[data-theme='light'] .icon-btn .icon--sun {
    display: none;
}
:root[data-theme='light'] .icon-btn .icon--moon {
    display: block;
}

/* ===========================================================================
   Buttons
   =========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid transparent;
    transition: all 0.18s var(--ease);
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px var(--accent-glow);
    color: white;
}

.btn--ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn--ghost:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.btn--block {
    width: 100%;
}

.btn-link {
    background: none;
    color: var(--accent-soft);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 6px;
    border-radius: 4px;
}

.btn-link:hover {
    color: var(--accent);
    background: var(--accent-fade);
}

/* ===========================================================================
   Layout: sidebar + results
   =========================================================================== */

.layout {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--space-8) var(--space-6) var(--space-16);
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: var(--space-8);
    align-items: flex-start;
}

/* ===========================================================================
   Sidebar
   =========================================================================== */

.sidebar {
    position: sticky;
    top: calc(var(--nav-h) + var(--space-4));
    max-height: calc(100vh - var(--nav-h) - var(--space-8));
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--radius-pill);
}

.sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.sidebar__title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar__apply {
    margin-top: var(--space-5);
}

.sidebar-backdrop {
    display: none;
}

/* Filter blocks */
.filter-block {
    padding: var(--space-3) 0;
    border-bottom: 1px dashed var(--border);
}

.filter-block:last-of-type {
    border-bottom: 0;
}

.filter-block__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-2);
}

.filter-block__label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.filter-block__head .filter-block__label {
    margin-bottom: 0;
}

.range-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
}

/* Search box */
.search-wrap {
    position: relative;
}

.search-wrap__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-input::placeholder {
    color: var(--text-dim);
}

.search-input:hover {
    border-color: var(--border-strong);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-fade);
    background: var(--surface);
}

/* Range sliders */
.dual-range {
    position: relative;
    height: 24px;
    margin-top: var(--space-2);
}

.dual-range-track,
.dual-range-progress {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    border-radius: var(--radius-pill);
    pointer-events: none;
}

.dual-range-track {
    background: var(--surface-3);
}

.dual-range-progress {
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
    left: 0%;
    right: 0%;
}

.dual-range input[type='range'] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 24px;
    margin: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.dual-range input[type='range']::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

.dual-range input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--accent);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s var(--ease);
}

.dual-range input[type='range']::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.dual-range input[type='range']::-moz-range-track {
    height: 4px;
    background: transparent;
}

.dual-range input[type='range']::-moz-range-thumb {
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Activity date inputs */
.activity-date-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.activity-date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-date-field input[type='date'] {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.85rem;
    transition: border-color 0.18s var(--ease);
}

.activity-date-field input[type='date']:hover {
    border-color: var(--border-strong);
}

.activity-date-field input[type='date']:focus {
    outline: none;
    border-color: var(--accent);
}

.activity-date-filter:not(:has(#activity-date-enabled:checked)) .activity-date-inputs {
    opacity: 0.45;
    pointer-events: none;
}

/* Facet groups (Retailers, Warehouse, Collection) */
.facet {
    border-bottom: 1px dashed var(--border);
    padding: var(--space-3) 0;
}

.facet[open] .facet__head::after {
    transform: rotate(180deg);
}

.facet__head {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}

.facet__head::-webkit-details-marker {
    display: none;
}

.facet__head::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    margin-right: 6px;
    transition: transform 0.18s var(--ease);
}

.facet__count {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    margin-right: var(--space-3);
}

.facet__body {
    margin-top: var(--space-3);
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.facet__body::-webkit-scrollbar {
    width: 6px;
}

.facet__body::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--radius-pill);
}

.facet__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-right: 4px;
}

/* Toggle/checkbox rows */
.checkbox-row,
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
    transition: background 0.15s var(--ease);
    -webkit-user-select: none;
    user-select: none;
}

.checkbox-row:hover,
.toggle-row:hover {
    background: var(--surface-2);
}

.checkbox-row input[type='checkbox'],
.toggle-row input[type='checkbox'] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.facet__list .toggle-row,
.facet__list .checkbox-row {
    font-size: 0.88rem;
}

.facet__option-count {
    margin-left: auto;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.toggle-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: var(--space-2);
}

.toggle-row--btn {
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-align: left;
    width: 100%;
    transition: all 0.18s var(--ease);
}

.toggle-row__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.toggle-row--btn[aria-pressed='true'] {
    border-color: var(--bad);
    background: var(--bad-fade);
    color: var(--text);
}

.toggle-row--btn[aria-pressed='true'] .toggle-row__dot {
    background: var(--bad);
    box-shadow: 0 0 0 3px var(--bad-fade);
}

.toggle-row--hot {
    background: linear-gradient(135deg, var(--accent-fade), transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
    margin-bottom: 4px;
    font-weight: 600;
}

.toggle-row--hot:hover {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
    border-color: var(--accent);
}

.toggle-row--hot:has(input:checked) {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.toggle-row__hint {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

.toggle-row--hot:has(input:checked) .toggle-row__hint {
    color: rgba(255, 255, 255, 0.85);
}

/* ===========================================================================
   Results: applied-filter chips, toolbar, grid
   =========================================================================== */

.applied-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.applied-filters__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.applied-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--accent-fade);
    border: 1px solid var(--accent);
    color: var(--text);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s var(--ease);
}

.chip__remove {
    color: var(--text-muted);
    line-height: 1;
    padding: 0 0 0 2px;
    font-size: 0.95rem;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chip__remove:hover {
    background: var(--accent);
    color: white;
}

.results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) 0 var(--space-5);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}

.results-toolbar__count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.results-toolbar__count strong {
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 700;
    margin-right: 4px;
}

.results-toolbar__controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.select-wrap {
    position: relative;
}

.select-wrap select {
    -webkit-appearance: none;
    appearance: none;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.18s var(--ease);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8.7 1.4 4.1l.9-.9L6 6.9l3.7-3.7.9.9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.select-wrap select:hover {
    border-color: var(--border-strong);
}

.select-wrap select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-fade);
}

/* ===========================================================================
   Product cards
   =========================================================================== */

/* Default 4-column layout: floor sized so 4 cards fit comfortably at the
   typical results-pane width (~1100 px after sidebar). On narrower windows
   the grid wraps gracefully to 3 / 2 / 1 columns without leaving cards
   awkwardly wide. */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-10);
}

.product-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    isolation: isolate;
}

.product-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
}

.product-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Special states */
.product-card.all-time-low-match {
    border-color: var(--bad);
    box-shadow: 0 4px 14px var(--bad-fade);
}

.product-card.all-time-low-match:hover {
    border-color: var(--bad);
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.25);
}

.product-card.new-listing {
    border-color: var(--good);
    box-shadow: 0 4px 14px var(--good-fade);
}

.product-card.new-listing:hover {
    border-color: var(--good);
    box-shadow: 0 8px 22px rgba(34, 197, 94, 0.25);
}

.product-card.retired-listing {
    border-color: var(--warn);
    box-shadow: 0 4px 14px var(--warn-fade);
}

.product-card.retired-listing:hover {
    border-color: var(--warn);
    box-shadow: 0 8px 22px rgba(245, 158, 11, 0.25);
}

.product-card.overpriced {
    border-color: var(--warn);
    background: linear-gradient(165deg, var(--surface) 0%, color-mix(in srgb, var(--warn) 8%, var(--surface)) 100%);
    box-shadow: 0 4px 18px rgba(217, 119, 6, 0.18);
}

/* Image area */
.product-card__media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    overflow: hidden;
}

.product-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    transition: transform 0.4s var(--ease);
}

.product-card:hover .product-image {
    transform: scale(1.04);
}

/* Top-right discount / overpriced corner ribbon — flush with the image edge,
   mirrors the NEW / RETIRED banners on the opposite corner. */
.image-corner-ribbon {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 3;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border-radius: 0 0 0 var(--radius-md);
    font-weight: 800;
    font-size: 0.95rem;
    line-height: 1;
    letter-spacing: 0.01em;
    box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.25);
}

.image-corner-ribbon__text {
    line-height: 1;
    color: white;
    letter-spacing: 0.01em;
}

.image-corner-ribbon--overpriced {
    background: var(--bad);
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-red {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-orange {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-yellow {
    background: linear-gradient(135deg, #eab308, #ca8a04);
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-yellow .image-corner-ribbon__text {
    color: #1a1a1a;
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-green {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.image-corner-ribbon--discount.image-corner-ribbon--tier-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

/* Top-left vertical NEW / RETIRED */
.image-corner-new-vertical,
.image-corner-retired-vertical {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    padding: 8px 6px;
    border-radius: 0 0 var(--radius-md) 0;
    box-shadow: var(--shadow-sm);
    font-family: var(--font-mono);
    font-weight: 800;
}

.image-corner-new-vertical {
    background: linear-gradient(165deg, #15803d, var(--good));
}

.image-corner-retired-vertical {
    background: linear-gradient(165deg, #92400e, var(--warn));
    pointer-events: auto;
    cursor: help;
}

.image-corner-new-vertical span,
.image-corner-retired-vertical span {
    display: block;
    font-size: 1rem;
    line-height: 1;
    text-align: center;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.image-corner-new-vertical span + span,
.image-corner-retired-vertical span + span {
    margin-top: 2px;
}

/* Card body */
.product-info {
    padding: var(--space-4) var(--space-5) var(--space-5);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Retailer pill */
.retailer-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    align-self: flex-start;
    max-width: 100%;
}

.retailer-pill__icon {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 800;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.retailer-pill__name {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.retailer-pill__sep {
    color: var(--text-dim);
}

.retailer-pill__warehouse {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Lumibricks location chips */
.lumibricks-locations__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.lumibricks-location-chip {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--good-fade);
    border: 1px solid color-mix(in srgb, var(--good) 50%, transparent);
    color: var(--good);
}

.lumibricks-location-chip--preorder {
    background: var(--warn-fade);
    border-color: color-mix(in srgb, var(--warn) 50%, transparent);
    color: var(--warn);
}

.variant-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    color: var(--text-muted);
    text-transform: capitalize;
    align-self: flex-start;
}

.collection-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.collection-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-fade);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    color: var(--accent-soft);
    line-height: 1.3;
    font-weight: 500;
}

/* Price block */
.price-info {
    margin-top: auto;
    padding-top: var(--space-2);
}

.current-price {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--accent-soft);
    line-height: 1;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

.current-price.overpriced-price {
    color: var(--bad);
}

.original-price {
    color: var(--text-dim);
    text-decoration: line-through;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
}

.shipping-note {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.all-time-low {
    margin-top: var(--space-2);
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.all-time-low .label {
    color: var(--text-dim);
}

.all-time-low .price {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--good);
}

/* ===========================================================================
   Loading / empty states
   =========================================================================== */

.loading {
    text-align: center;
    padding: var(--space-12) 0;
    color: var(--text-muted);
}

.loading__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto var(--space-4);
    animation: spin 0.8s linear infinite;
}

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

.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}

.empty-state svg {
    color: var(--text-dim);
    margin: 0 auto var(--space-4);
    display: block;
}

.empty-state h3 {
    font-size: 1.15rem;
    margin-bottom: 6px;
    color: var(--text);
}

.empty-state p {
    margin-bottom: var(--space-5);
}

/* Card skeletons */
.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: 380px;
    position: relative;
}

.skeleton-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, var(--surface-3) 50%, transparent 100%);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===========================================================================
   Dev upload box
   =========================================================================== */

.file-upload-section {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--space-6);
}

.upload-box {
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
}

.upload-box code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text);
    font-size: 0.85rem;
}

#json-file-input {
    display: none;
}

#file-name {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: var(--space-3);
}

/* ===========================================================================
   Footer
   =========================================================================== */

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-6);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer__inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.site-footer__brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.site-footer__brand strong {
    color: var(--text);
    font-weight: 700;
}

.site-footer__tagline {
    color: var(--text-muted);
}

.site-footer__sep {
    color: var(--text-dim);
}

.site-footer__meta {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-dim);
}

.site-footer__meta #footer-last-sync {
    color: var(--text-muted);
}

/* ===========================================================================
   Responsive
   =========================================================================== */

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(360px, 92vw);
        max-height: 100vh;
        height: 100vh;
        z-index: 100;
        border-radius: 0;
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.25s var(--ease);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 99;
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    .sidebar-backdrop.is-open {
        display: block;
    }

    .mobile-only {
        display: inline-flex !important;
    }
}

@media (max-width: 720px) {
    :root {
        --space-6: 16px;
    }

    .layout {
        padding: var(--space-6) var(--space-4) var(--space-12);
    }

    .results-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .results-toolbar__controls {
        width: 100%;
        justify-content: space-between;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: var(--space-4);
    }

    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
