/*
 * Naya Laptop — catalog, filters and offer detail.
 * Buildless: plain CSS, no preprocessor, no build step, no external CDN.
 * Thresholds follow docs/design-contract.md (C-BREAKPOINT): 1200 / 992 / 776 / 576 / 330.
 * Reflow behaviour follows docs/design-reference/rozetka-layout.md:
 *   R-GRID   — 5 → 4 → 3 → 2 columns, never 1
 *   R-SIDEBAR— the filter column disappears before the grid does
 *   R-TOOLBAR— [Фільтри] [Знайдено N] … [сортування]/[Показати] on one line, and when the
 *              line cannot fit, exactly two full-width rows (never a right-aligned
 *              island or a lone control on a half-empty row)
 *   R-TARGETS— controls keep a stable height; M-TAP (≥44px) stays mandatory
 *   R-NOOVERFLOW — documentElement.scrollWidth === clientWidth on every width
 */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Header and toolbar buttons must honour M-TAP (44px), site.css keeps 42px. */
.header-inner .button-small,
.catalog-toolbar .button-small {
    min-height: 44px;
}

/* One container width for the whole storefront: the shared header, the footer
 * and the catalog body all line up on the same 1200px gutter. */
.catalog-shell {
    width: min(1200px, calc(100% - 48px));
    margin-inline: auto;
    overflow-wrap: break-word;
}

/* ------------------------------------------------------------------ crumbs --- */

.crumbs { padding-block: 26px 0; }

.crumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: 12px;
}

.crumbs li + li::before {
    margin-right: 6px;
    color: var(--line-strong);
    content: "/";
}

.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }

/* -------------------------------------------------------------- page head --- */

/* The catalog head is the first surface after a click from the home page, so it
 * carries a photo band cut by tools/make_banners.py. The wash stays opaque under
 * the copy on the left and opens up over the desk close-up on the right, which
 * keeps the shipped on-dark / on-dark-accent contrast pairs intact. */
.catalog-head {
    position: relative;
    margin-block: 22px 26px;
    padding: 34px 38px 36px;
    border-radius: var(--nl-radius);
    background: var(--brand-dark);
    overflow: hidden;
}

.catalog-head-art {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(64%, 780px);
}

.catalog-head-art picture { display: block; width: 100%; height: 100%; }
.catalog-head-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: right center; }

.catalog-head::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--band-wash-strong) 0 36%, var(--band-wash-mid) 60%, var(--band-wash-soft) 100%);
    content: "";
}

.catalog-head-body { position: relative; z-index: 1; max-width: 640px; }
.catalog-head .eyebrow { color: var(--on-dark-accent); }
.catalog-head h1 { margin-bottom: 14px; color: var(--on-dark); }
.catalog-head .catalog-lead { color: var(--on-dark); }
.catalog-head .text-link { color: var(--on-dark-accent); }

.catalog-lead {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.75;
}

/* ---------------------------------------------------------------- toolbar --- */

.catalog-layout { padding-bottom: 8px; }
.catalog-body { display: grid; gap: 18px; }

/* Grid, not wrapping flex: wrapping flex is what let the sort group drift to a
 * right-aligned island while the count fell onto a half-empty row of its own. */
.catalog-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.filters-toggle {
    display: none;
    justify-self: start;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.filters-toggle:hover { border-color: var(--brand); color: var(--brand); }

.catalog-count { margin: 0; color: var(--muted); font-size: 14px; }
.catalog-count strong { color: var(--ink); font-size: 15px; }

.toolbar-sort {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    max-width: 100%;
}

.toolbar-sort select {
    max-width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

/* ---------------------------------------------------------------- columns --- */

.catalog-columns {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.filters-panel {
    display: grid;
    gap: 12px;
    min-width: 0;
    align-content: start;
}

.filter-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.filter-group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    list-style: none;
}

.filter-group > summary::-webkit-details-marker { display: none; }

.filter-group > summary::after {
    color: var(--muted-2);
    font-size: 15px;
    content: "+";
}

.filter-group[open] > summary::after { content: "−"; }

.filter-total { color: var(--muted-2); font-size: 11px; font-weight: 700; }

.filter-body { display: grid; gap: 2px; padding: 2px 8px 10px; }

.filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding-inline: 6px;
    border-radius: 6px;
    color: var(--muted-strong);
    cursor: pointer;
    font-size: 13px;
}

.filter-option:hover { background: var(--soft); }

.filter-option input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.filter-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.filter-count { flex: 0 0 auto; color: var(--muted-2); font-size: 11px; }

.filter-group-plain { border: 0; background: none; }
.filter-caption { margin: 0 0 6px; color: var(--ink); font-size: 13px; font-weight: 700; }
.filter-group-plain .filter-body { padding: 0; }

.filter-select { display: block; }

.filter-select select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.filter-actions { display: grid; gap: 10px; padding-top: 4px; }
.filter-actions .button { width: 100%; }

.reset-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}

.reset-link:hover { color: var(--brand); text-decoration: underline; }

/* ------------------------------------------------------------------- grid --- */

.offer-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.offer-card { min-width: 0; }

.offer-card-link {
    height: 100%;
    display: grid;
    grid-template-rows: 8fr auto auto auto;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.offer-card-link:hover {
    transform: translateY(-10px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-card-hover);
}

.offer-thumb {
    position: relative;
    display: grid;
    place-items: center;
    /* One ratio for both artwork and photo: a card with a real photo and a card
     * with the line drawing keep the same height inside one grid row. */
    aspect-ratio: 3 / 2;
    min-height: 84px;
    border-radius: 6px;
    background: var(--line-soft);
    overflow: hidden;
}

.offer-thumb-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offer-thumb-art { width: min(78%, 132px); height: auto; fill: var(--line-strong); }

.offer-cond {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 7px;
    border-radius: 30px;
    background: var(--soft);
    color: var(--brand);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.offer-cond-new { background: var(--accent); color: var(--on-accent); }

/* Brand badge on the card media: the same vendored simple-icons mark the home
 * tiles use, kept small enough to read as a sticker rather than a second photo.
 * The pale pill is what keeps it legible over a busy product shot. */
.offer-brand {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: grid;
    place-items: center;
    padding: 4px 7px;
    border-radius: 6px;
    background: var(--veil);
    box-shadow: var(--shadow-badge);
    color: var(--brand);
}
.offer-brand .nl-brand-mark { display: block; height: 13px; width: auto; max-width: 34px; }

.offer-title {
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.offer-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.offer-foot { display: grid; gap: 2px; align-content: end; }
.offer-price { color: var(--ink); font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.offer-note { color: var(--muted-2); font-size: 11px; line-height: 1.4; }

/* ------------------------------------------------------------- pagination --- */

/* Centred across the full width of the results column: with the grid left of
 * it, a left-aligned bar reads as another column of cards rather than as the
 * control that pages the grid above it. `width: 100%` keeps the box spanning
 * the block even when only one page-link exists at the far end of the list. */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 28px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}

.page-link:hover { border-color: var(--brand); color: var(--brand); }
.page-link-current { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.page-link-disabled { background: var(--paper); color: var(--muted-2); }

/* How many page numbers fit is a width question, so the server renders one
 * window per band (`NAYA_PAGER_BANDS` in public/lib/catalog.php) and each number
 * carries the narrowest band that has room for it. These four rules — 3 numbers
 * on a phone, 5 from 576px, 9 from 776px, 13 from 992px — are what turns “show
 * more pages where there is space” into something the browser measures instead
 * of something the server guesses. The windows are nested, so turning a band on
 * only ever adds numbers around the current one; a hidden number is never a
 * missing one in the middle of the row. */
.page-num { display: none; }
.pagination .page-num-bsm { display: inline-flex; }

@media (min-width: 576px) {
    .pagination .page-num-bmd { display: inline-flex; }
}

@media (min-width: 776px) {
    .pagination .page-num-blg { display: inline-flex; }
}

@media (min-width: 992px) {
    .pagination .page-num-bxl { display: inline-flex; }
}

/* ------------------------------------------------------------ empty state --- */

.catalog-empty {
    padding: 38px 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.catalog-empty h1,
.catalog-empty h2 { margin-bottom: 10px; font-size: clamp(26px, 3.4vw, 38px); }

.catalog-empty p {
    max-width: 640px;
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.catalog-empty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
/* The secondary link on this row is a tap target like any other (M-TAP). */
.catalog-empty-actions .text-link { min-height: 44px; }
.catalog-empty-page { margin-bottom: 56px; }

/* ------------------------------------------------------------------ product --- */

.product {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 34px;
    align-items: start;
    padding-block: 24px 0;
}

.product-gallery { min-width: 0; }

.product-figure {
    display: grid;
    place-items: center;
    gap: 16px;
    padding: 30px 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.product-figure-art { width: min(84%, 300px); height: auto; fill: var(--line-strong); }

.product-figure-note {
    max-width: 320px;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

/* Gallery of the seller's own photos: three radio inputs plus their labels, so
 * switching needs no JavaScript and the native keyboard behaviour of a radio
 * group is preserved (arrows move, the ring follows focus). The swatches are one
 * full-width row of equal thirds — R-TOOLBAR's "no half-empty row" applies here
 * too, and every swatch stays well above the 44px tap minimum. */
.product-gallery-set { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.product-shot {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}
.product-stage {
    display: grid;
    place-items: center;
    /* Fixed box for both orientations: the albums mix portrait phone shots and
     * landscape ones, and the info column must not jump when they differ. */
    /* The stage keeps the full column width at every threshold (a capped height
     * would shrink it and leave the swatch row sticking out past the hero). */
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    overflow: hidden;
}
.product-image { display: none; width: 100%; height: 100%; object-fit: contain; }
.product-shot-1:checked ~ .product-stage .product-image-1,
.product-shot-2:checked ~ .product-stage .product-image-2,
.product-shot-3:checked ~ .product-stage .product-image-3 { display: block; }
.product-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.product-thumb {
    display: block;
    /* Ratio lives on the label, not the img: the width/height attributes on the
     * img would otherwise win and stretch the row. */
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--line-soft);
    cursor: pointer;
}
.product-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.product-shot-1:checked ~ .product-thumbs .product-thumb-1,
.product-shot-2:checked ~ .product-thumbs .product-thumb-2,
.product-shot-3:checked ~ .product-thumbs .product-thumb-3 {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand);
}
.product-shot-1:focus-visible ~ .product-thumbs .product-thumb-1,
.product-shot-2:focus-visible ~ .product-thumbs .product-thumb-2,
.product-shot-3:focus-visible ~ .product-thumbs .product-thumb-3 {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
}
.product-gallery-set .product-figure-note { max-width: none; text-align: left; }

.product-info { min-width: 0; }
.product-info h1 { margin-bottom: 12px; font-size: clamp(28px, 3.6vw, 44px); }
.product-meta { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.7; }

.product-price {
    display: grid;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.product-price-value { color: var(--ink); font-size: 26px; font-weight: 760; letter-spacing: -.02em; }
.product-price-note { color: var(--muted); font-size: 12px; line-height: 1.6; }

.product-facts {
    display: grid;
    gap: 10px;
    margin: 20px 0;
    padding: 0;
    list-style: none;
}

.product-facts li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--muted-strong);
    font-size: 13px;
}

.product-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.product-actions .text-link { min-height: 44px; }

.product-section {
    margin-top: 36px;
    padding-top: 34px;
    border-top: 1px solid var(--line);
}

.product-section h2 { margin-bottom: 18px; font-size: clamp(22px, 2.6vw, 32px); }

.spec-table {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 34px;
    margin: 0;
}

.spec-table > div {
    display: grid;
    grid-template-columns: minmax(120px, .6fr) 1fr;
    gap: 16px;
    padding-block: 13px;
    border-bottom: 1px solid var(--line-soft);
}

.spec-table dt { color: var(--muted-strong); font-size: 13px; font-weight: 650; }
.spec-table dd { margin: 0; color: var(--ink); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }

.section-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.spec-raw {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.spec-raw summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    list-style: none;
}

.spec-raw summary::-webkit-details-marker { display: none; }

.spec-raw p {
    margin: 0;
    padding: 0 16px 16px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.variant-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.variant-card { min-width: 0; }

.variant-card a {
    height: 100%;
    display: grid;
    gap: 6px;
    align-content: start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}

.variant-card a:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.variant-cond { color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.variant-title { color: var(--ink); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.variant-meta { color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.variant-price { color: var(--ink); font-size: 15px; font-weight: 750; }

/* --------------------------------------------------------------------- cta --- */

.catalog-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-block: 48px 64px;
    padding: 34px 36px;
    border-radius: 8px;
    background: var(--brand-dark);
}

.catalog-cta h2 {
    max-width: 560px;
    margin-bottom: 10px;
    color: var(--on-dark);
    font-size: clamp(22px, 2.8vw, 34px);
}

.catalog-cta p { max-width: 620px; margin: 0; color: var(--on-dark); font-size: 14px; line-height: 1.7; }
.catalog-cta .button { flex: 0 0 auto; }

/* ------------------------------------------------------------- thresholds --- */

@media (max-width: 1200px) {
    .catalog-columns { grid-template-columns: 240px minmax(0, 1fr); gap: 22px; }
    .offer-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
}

@media (max-width: 992px) {
    .catalog-columns { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .filters-toggle { display: inline-flex; }
    .catalog-layout[data-filters-open="0"] .filters-panel { display: none; }
    .catalog-layout[data-filters-open="1"] .filters-panel { display: grid; }
    .offer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .variant-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product { grid-template-columns: minmax(0, 1fr); gap: 26px; }
    .catalog-head h1 { font-size: clamp(38px, 8vw, 58px); }
}

@media (max-width: 776px) {
    .catalog-shell { width: calc(100% - 32px); }
    /* Narrow: the copy runs the full card, so the photo becomes a vertical wash
     * that stays nearly opaque everywhere the heading and lead sit. */
    .catalog-head { padding: 26px 24px 28px; }
    .catalog-head-art { width: 100%; }
    .catalog-head::after { background: linear-gradient(180deg, var(--band-wash-mid), var(--band-wash-strong)); }
    /* M-TAP: breadcrumb links are interactive, so they need a 44px-tall hit box. */
    .crumbs ol { align-items: center; }
    .crumbs li { display: inline-flex; align-items: center; }
    .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
    .offer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .spec-table { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .product-section { margin-top: 28px; padding-top: 26px; }
    .catalog-cta { margin-block: 38px 52px; }
}

@media (max-width: 576px) {
    .offer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    /* Two full-width rows: [Фільтри] [Знайдено N] then the whole sort group. */
    .catalog-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
    .catalog-count { text-align: right; }
    .toolbar-sort { grid-column: 1 / -1; justify-content: stretch; }
    .toolbar-sort select { flex: 1 1 auto; min-width: 0; }
    .toolbar-sort .button { flex: 0 0 auto; }
    .variant-grid { grid-template-columns: minmax(0, 1fr); }
    .catalog-cta { padding: 26px 22px; }
    .catalog-cta .button { width: 100%; }
    .offer-card-link { padding: 8px; }
    .offer-title { font-size: 13px; }
    .filter-actions .button { width: 100%; }
}

@media (max-width: 330px) {
    .catalog-shell { width: calc(100% - 20px); }
    .offer-grid { gap: 8px; }
    .offer-card-link { gap: 4px; padding: 6px; }
    .offer-thumb { min-height: 70px; }
    .offer-title { font-size: 12px; }
    .offer-meta { font-size: 11px; }
    .offer-price { font-size: 14px; }
    .offer-note { font-size: 10px; }
    .catalog-toolbar { gap: 8px; }
    .catalog-head { padding: 20px 18px 22px; }
    .crumbs { padding-block: 18px 0; }
    .catalog-empty { padding: 26px 16px; }
    .product-figure { padding: 20px 14px; }
    /* Button + text-link pairs no longer fit on one line: full-width rows instead
     * of a 60px leftover on the second row. */
    .catalog-empty-actions { flex-direction: column; align-items: stretch; }
    .catalog-empty-actions .button,
    .catalog-empty-actions .text-link { width: 100%; }
    .product-actions { flex-direction: column; align-items: stretch; }
    .product-actions .button,
    .product-actions .text-link { width: 100%; }
}
