/* Hand-written, no framework and no CDN - the demo stays self-contained. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1b1f24;
    --muted: #6b7280;
    --accent: #2f6f4f;
    --accent-soft: #e7f2ec;
    --danger: #b3261e;
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171a;
        --surface: #1c2024;
        --border: #2c3238;
        --text: #e8eaed;
        --muted: #9aa3ad;
        --accent: #6cc294;
        --accent-soft: #23342c;
        --danger: #f2b8b5;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); font-size: .875rem; }

/* boot splash - replaced by Blazor once the runtime is up */
.boot {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
    font: 15px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--muted);
}
.boot-logo { max-width: 70vw; height: auto; }
.boot-bar {
    width: 210px; max-width: 60vw; height: 3px;
    background: var(--border); border-radius: 2px; overflow: hidden;
}
.boot-bar span {
    display: block; width: 40%; height: 100%;
    background: var(--accent); border-radius: 2px;
    animation: boot-slide 1.1s ease-in-out infinite;
}
@keyframes boot-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}
.boot-note { margin: 0; font-size: .8rem; letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) {
    .boot-bar span { animation: none; width: 100%; }
}

/* ---------- chrome ---------- */

.topbar {
    display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
    padding: .75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}

.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); }
.brand img { height: 26px; width: auto; display: block; }
.brand .brand-suffix { font-weight: 600; font-size: .95rem; color: var(--muted); }

.context-selector { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
/* direct children only - the price-list dropdown lives inside this container and must not inherit the
   column layout or the uppercase caption treatment */
.context-selector > label { display: flex; flex-direction: column; gap: .15rem; }
.field-caption {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}

select, input[type="number"] {
    font: inherit;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.shell { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.footer { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.panel.error { border-color: var(--danger); }
.panel.error h1, .panel.error h2 { color: var(--danger); }

.button {
    display: inline-block;
    padding: .45rem .9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.button:hover:not(:disabled) { border-color: var(--accent); }
.button:disabled { opacity: .45; cursor: default; }

.link {
    background: none; border: none; padding: 0;
    color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline;
}

/* ---------- listing ---------- */

.listing-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .listing-layout { grid-template-columns: 1fr; } }

.sidebar, .results { min-width: 0; }

.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.results-head {
    display: flex; flex-wrap: wrap; gap: .75rem;
    align-items: baseline; justify-content: space-between;
    margin-bottom: 1rem;
}
.results-tools { display: flex; gap: .75rem; align-items: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex; flex-direction: column; justify-content: space-between; gap: .75rem;
    min-height: 120px;
}
.card-link h3 { color: var(--text); margin: 0; }
.card-link:hover h3 { color: var(--accent); }

.card.skeleton {
    background: linear-gradient(90deg, var(--surface), var(--bg), var(--surface));
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .card.skeleton { animation: none; } }

.price-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.price-row.large .price { font-size: 1.5rem; }
.price { font-weight: 700; }
.price-reference { color: var(--muted); text-decoration: line-through; font-size: .875rem; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.5rem; }

/* ---------- categories ---------- */

.category-tree { list-style: none; margin: 0; padding-left: .75rem; }
.sidebar > .category-tree { padding-left: 0; }

.category-row {
    display: flex; justify-content: space-between; gap: .5rem; align-items: baseline;
    padding: .2rem .4rem; border-radius: 5px;
}
.category-row.active { background: var(--accent-soft); }
.category-row .count { color: var(--muted); font-size: .75rem; }

/* ---------- facets ---------- */

.facets { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.facets-head { display: flex; justify-content: space-between; align-items: baseline; }

.facet-reference { margin-top: 1rem; }
.facet-reference > h3 {
    text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; color: var(--muted);
}
.facet-group { margin-bottom: .75rem; }
.facet-group h4 { font-size: .85rem; margin: .5rem 0 .25rem; }
.facet-group ul { list-style: none; margin: 0; padding: 0; }

.facet {
    display: flex; gap: .4rem; align-items: baseline;
    padding: .15rem .3rem; border-radius: 5px; cursor: pointer;
}
.facet:hover { background: var(--bg); }
.facet.selected { background: var(--accent-soft); }
.facet-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* The two numbers say different things, so they must not look alike:
     .facet-count  - how many products carry the option (plain, unboxed, dimmed)
     .facet-impact - what the result count becomes if ticked (boxed pill, arrow, tinted) */
.facet-count {
    color: var(--muted); font-size: .75rem;
    font-variant-numeric: tabular-nums;
    min-width: 2.6em; text-align: right;
}

.facet-impact {
    font-size: .7rem; font-variant-numeric: tabular-nums;
    display: inline-flex; align-items: center; gap: .1em;
    min-width: 3.6em; justify-content: flex-end;
    padding: .05rem .3rem; border-radius: 999px;
    border: 1px solid transparent;
}
.facet-impact .arrow { font-size: .85em; opacity: .8; }
.facet-impact.narrows { background: var(--bg); border-color: var(--border); color: var(--muted); }
.facet-impact.widens { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.facet-impact.empty { background: none; border-color: transparent; color: var(--muted); opacity: .45; }

.facet-legend {
    display: flex; gap: .75rem; flex-wrap: wrap;
    margin: .5rem 0 0; font-size: .68rem; color: var(--muted);
}
.facet-legend span { display: inline-flex; align-items: center; gap: .25rem; }
.facet-legend .swatch { width: 9px; height: 9px; border-radius: 2px; }
.facet-legend .swatch.count { background: var(--muted); opacity: .55; }
.facet-legend .swatch.impact { background: var(--accent-soft); border: 1px solid var(--border); border-radius: 999px; }

/* ---------- histograms ---------- */

.histogram { margin-top: 1rem; }
.histogram > h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.histogram-bars {
    display: flex; align-items: flex-end; gap: 2px; height: 56px;
    padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
}
.histogram-bars .bar { flex: 1; background: var(--border); border-radius: 2px 2px 0 0; }
.histogram-bars .bar.in-range { background: var(--accent); }

.histogram-head { display: flex; justify-content: space-between; align-items: baseline; }
.histogram-scale { display: flex; justify-content: space-between; font-size: .7rem; margin-top: .15rem; }
.histogram-scale .active { color: var(--accent); font-weight: 600; }
.histogram-scale .muted { font-size: .7rem; }

/* --- dual-handle range slider ---
   Two stacked range inputs. The tracks are transparent and pointer-events are re-enabled only on the
   thumbs, so both handles stay grabbable even where they overlap. */
.range-slider { position: relative; height: 24px; margin-top: .35rem; }
.range-track, .range-fill { position: absolute; top: 11px; height: 3px; border-radius: 2px; }
.range-track { left: 0; right: 0; background: var(--border); }
.range-fill { background: var(--accent); }

.range-input {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 24px; margin: 0;
    background: none; border: none; padding: 0;
    -webkit-appearance: none; appearance: none;
    pointer-events: none;
}
.range-input:focus { outline: none; }
.range-input.high { z-index: 2; }

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent);
    cursor: grab; pointer-events: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.range-input::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }
.range-input::-moz-range-thumb {
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent);
    cursor: grab; pointer-events: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.range-input::-moz-range-track { background: none; }
.range-input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- soft reload state (instead of tearing the grid down to skeletons) --- */
.grid.reloading { opacity: .45; transition: opacity .12s ease-out; pointer-events: none; }
.grid { transition: opacity .18s ease-in; }

.spinner {
    width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent);
    display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .grid, .grid.reloading { transition: none; }
    .spinner { animation: none; }
}

/* ---------- detail ---------- */

.breadcrumb { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; font-size: .875rem; }
.breadcrumb span { color: var(--muted); }

.detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.detail-block { margin-top: 2rem; }
.description { max-width: 70ch; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 0; padding: 0; }
.tag {
    padding: .15rem .55rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: .75rem;
}

.parameters { border-collapse: collapse; width: 100%; max-width: 720px; }
.parameters th, .parameters td {
    text-align: left; vertical-align: top;
    padding: .4rem .6rem; border-bottom: 1px solid var(--border);
}
.parameters th { width: 34%; font-weight: 600; color: var(--muted); }

/* ---------- blazor error bar ---------- */

#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: .6rem 1.25rem;
    background: #ffe9e7; color: #7f1d1d;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, .2);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ---------- product cards (enriched) ---------- */

.card-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; min-height: 1rem; }
.card-brand {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .04em;
    padding: .1rem .4rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.card-foot { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.price-prefix { font-size: .72rem; color: var(--muted); }
.card-rating { display: inline-flex; align-items: baseline; gap: .25rem; font-size: .72rem; }
.card-rating .stars { color: var(--accent); letter-spacing: -.05em; }

/* ---------- price list picker ---------- */

.pricelist-picker { position: relative; display: flex; flex-direction: column; gap: .15rem; }
.pricelist-toggle {
    font: inherit; padding: .35rem .5rem; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text);
    display: inline-flex; align-items: center; gap: .4rem; min-width: 9rem; justify-content: space-between;
}
.pricelist-toggle:hover { border-color: var(--accent); }
.pricelist-toggle .caret { color: var(--muted); font-size: .7rem; }

/* Invisible click-catcher behind the open menu - see ShopContextSelector.razor. z-index one below the menu
   so the menu keeps receiving its own clicks. It is painted inside the sticky bar's stacking context
   (z-index 10), which is above the page content, so a click anywhere on the page reaches it. */
.pricelist-backdrop { position: fixed; inset: 0; z-index: 19; background: transparent; }

.pricelist-menu {
    position: absolute; top: 100%; right: 0; z-index: 20; margin-top: .25rem;
    width: 17rem; max-height: 60vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16); padding: .6rem;
}
.pricelist-menu p { margin: 0 0 .4rem; }
.pricelist-menu ul { list-style: none; margin: 0; padding: 0; }
.pricelist-menu label {
    display: flex; flex-direction: row; align-items: center; gap: .5rem;
    padding: .25rem .35rem; border-radius: 5px; cursor: pointer;
    text-transform: none; letter-spacing: normal;
}
.pricelist-menu input[type="checkbox"] { flex: none; margin: 0; }
.pricelist-menu label:hover { background: var(--bg); }
.pricelist-menu label.selected { background: var(--accent-soft); }
.pricelist-name {
    flex: 1; min-width: 0; overflow-wrap: anywhere;
    font-size: .82rem; text-transform: none; letter-spacing: normal; color: var(--text);
    text-align: left;
}
.pricelist-order {
    font-size: .65rem; min-width: 1.3em; text-align: center;
    border-radius: 999px; background: var(--accent); color: var(--surface); padding: .05rem .25rem;
}

/* ---------- facet panel extras ---------- */

.facet-more { font-size: .72rem; margin-top: .2rem; }
.facets-all { width: 100%; margin-top: 1rem; }

/* ---------- modal ---------- */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, .45);
    display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    width: min(1000px, 100%); max-height: 86vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; align-items: center; gap: .75rem; }
.modal-body { overflow-y: auto; padding: 1rem 1.25rem 1.5rem; }
/* groups stack vertically - a multi-column grid interleaved unrelated groups and read as noise */
.modal-groups { display: flex; flex-direction: column; gap: .25rem; }
.modal-groups .facet-group {
    border-top: 1px solid var(--border); padding-top: .6rem; margin-bottom: .6rem;
}
.modal-groups .facet-group:first-child { border-top: none; padding-top: 0; }
.modal-groups .facet-group ul {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1.25rem;
}

.variants th { width: 60%; font-weight: 500; color: var(--text); }

/* ---------- variants ---------- */

.variant-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.variant {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); text-decoration: none;
}
.variant:hover { border-color: var(--accent); background: var(--bg); text-decoration: none; }
.variant-name { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.variant-params { font-size: .75rem; color: var(--muted); }
.variant-price { font-weight: 600; white-space: nowrap; }

/* ---------- imported rich text ----------
   The description is a vendor marketing page whose own stylesheet we do not have (and would not want).
   These rules give the surviving structure a readable shape of our own. */

.rich-text {
    max-width: 68ch;
    position: relative;
    overflow-wrap: anywhere;
}
.rich-text.collapsed {
    max-height: 22rem;
    overflow: hidden;
    /* fade the cut instead of slicing a line of text in half */
    mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
}
.rich-text h1, .rich-text h2, .rich-text h3 {
    font-size: 1.05rem; margin: 1.5rem 0 .4rem; line-height: 1.3;
}
.rich-text h1:first-child, .rich-text h2:first-child { margin-top: 0; }
.rich-text p { margin: 0 0 .85rem; }
.rich-text section { margin: 0 0 1.25rem; }
.rich-text section + section { border-top: 1px solid var(--border); padding-top: 1.25rem; }
.rich-text ul, .rich-text ol { margin: 0 0 1rem; padding-left: 1.1rem; }
.rich-text li { margin-bottom: .5rem; }
.rich-text a { text-decoration: underline; }
.rich-text sup { font-size: .65em; vertical-align: super; color: var(--muted); }
.rich-text strong, .rich-text b { font-weight: 650; }
.rich-text img { max-width: 100%; height: auto; border-radius: 6px; }
.rich-text table { border-collapse: collapse; width: 100%; }
.rich-text td, .rich-text th { border-bottom: 1px solid var(--border); padding: .35rem .5rem; text-align: left; }
.rich-text-toggle { margin-top: .5rem; }

.detail-teaser { max-width: 68ch; color: var(--text); font-size: 1.02rem; margin: 1rem 0 0; }

.identifiers { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0; }
.identifiers div { display: flex; flex-direction: column; gap: .1rem; }
.identifiers dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.identifiers dd { margin: 0; font-variant-numeric: tabular-nums; }

.card-teaser {
    margin: 0; font-size: .78rem; line-height: 1.4; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
