/* ── Price-comparison page (/compare/{slug}-{id}) ─────────────────────────
   Server-rendered by CompareController; only the page's own furniture lives
   here. Buttons, badges and the Splide arrows are the shared ones
   (components.css) — do not restyle them here. */

.cmp-crumbs,
.cmp-hero,
.cmp-offers,
.cmp-related {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
}

/* clip, not hidden: hidden forces overflow-y to auto, which cut the bottom
   search bar's dropdown off at <main>'s edge. hidden = fallback for old Safari. */
.page-compare { width: 100%; overflow-x: hidden; overflow-x: clip; }

/* ── Desktop ≥ 1201px: content | Hot Products (336px), /search's right
   column — same width, same inner scroll and sticky header
   (search.css .page-search .desktop-col-right). The column is only mounted
   at this width (compare-page.js isWide). ──────────────────────────────── */
@media (min-width: 1201px) {
    .cmp-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 336px;
        gap: 20px;
        align-items: start;
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 16px;
    }
    .cmp-layout .cmp-crumbs,
    .cmp-layout .cmp-hero,
    .cmp-layout .cmp-offers,
    .cmp-layout .cmp-related { max-width: none; padding-left: 0; padding-right: 0; }
    .cmp-aside {
        margin-top: 18px;
        max-height: 1000px;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--bg-light);
        border-radius: 12px;
    }
    .cmp-aside .hot-products-content { display: flex; flex-direction: column; height: 100%; }
    /* z-index 20: above the card bookmark (z-index 10). */
    .cmp-aside .component-header {
        flex-shrink: 0;
        position: sticky;
        top: 0;
        background: var(--bg-light);
        z-index: 20;
    }
    .cmp-aside .items-wrapper { flex: 1; overflow-y: auto; padding: 10px; }
}

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */
.cmp-crumbs { padding-top: 18px; }
.cmp-crumbs [aria-current] { overflow-wrap: anywhere; }

/* ── Hero: product image + the group's facts ────────────────────────────── */
.cmp-hero {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 16px 32px;
    align-items: start;
    padding-top: 16px;
    padding-bottom: 12px;
}

/* Brand + title across the top; the image sits under them. */
.cmp-hero-head { grid-column: 1 / -1; }
.cmp-hero-head .page-title { margin: 0; overflow-wrap: anywhere; }

.cmp-hero-media {
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cmp-hero-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
/* No image, or it failed: the logo mark instead of a broken icon. */
.cmp-hero-media.is-empty,
.cmp-hero-media:empty {
    background: var(--surface-sunken) url('/assets/logo.svg') center / 40% no-repeat;
    opacity: 0.6;
}

.cmp-intro {
    margin: 0 0 14px;
    font-size: var(--fs-lg);
    line-height: 1.55;
    color: var(--text-color);
    max-width: 68ch;
}

/* The price-history modal's tiles, one size up: here they are the page's
   headline facts, not a modal footnote. Shared look, compare-only scale. */
.cmp-hero .price-stat-card { padding: 10px 12px; gap: 4px; border-color: var(--border-color); box-shadow: var(--shadow-sm); }   /* border = .btn-neutral, shadow = .product-card */
.cmp-hero .price-stat-label { font-size: var(--fs-2xs); }
.cmp-hero .price-stat-value { font-size: var(--fs-xl); }
.cmp-hero .price-stat-date { font-size: var(--fs-xs); }
.cmp-hero .price-stat-card .product-shop-link { align-self: center; margin: 0; max-width: 100%; }

.cmp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* The main facts (.cmp-fact: brand, 90-day views, lists, Stars and
   the categories label) read one step up and in body colour. The categories
   (.cmp-cats) sit under the offers carousel: a hairline, the shared .section-title,
   then one row per shop (.cmp-cat) at the
   facts' size and colour, favicon (.shop-icon) first. Links = .filter-crumb-back. */
.cmp-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 14px;   /* first in the hero copy, above the intro */
    font-size: var(--fs-sm);
    color: var(--text-light);
}
/* Hero facts + actions → intro: the page's section hairline between them. */
.cmp-hero-copy > .cmp-actions { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-color); }
.cmp-cat { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0; font-size: var(--fs-md); color: var(--text-color); }
.cmp-fact { margin: 0; font-size: var(--fs-md); color: var(--text-color); }
.cmp-meta .separator-line { margin: 4px 0; }
/* Brand + category links: the shared pink .filter-crumb-back, minus its underline (hover still darkens). */
.cmp-meta .filter-crumb-back { text-decoration: none; }
/* The divider sits between the carousel and the title (same hairline as
   the Offers and search sections), so the title drops its own bottom rule. */
.cmp-meta.cmp-cats { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid var(--border-color); }
.cmp-cats .section-title { margin: 0 0 6px; padding-bottom: 0; border-bottom: 0; }
/* Label + the card's star stack on one line. The faces are links here, so
   the stack's img + img overlap is re-said for a + a. The card's 34px faces
   would make this row twice a text line: 22px here, and the -3px block margin
   lays the stack out at the 17px text line so the rows keep one rhythm (the
   faces spill into the column's 6px gaps). */
.cmp-stars { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.cmp-stars .pm-stack { margin-block: -3px; }
.cmp-stars .pm-stack > a { display: inline-flex; }
.cmp-stars .pm-stack > a + a,
.cmp-stars .pm-stack-more { margin-left: -6px; }
.cmp-stars .pm-stack-avatar { width: 22px; height: 22px; }
.cmp-stars .pm-stack-more { min-width: 22px; min-height: 22px; padding: 0 4px; border-radius: 11px; font-size: var(--fs-3xs); }

/* ── Offers: the shop-logo carousel ─────────────────────────────────────── */
/* Divider = the same hairline as the bottom search section (.cmp-search).
   The related comparisons below the offers open with the same rule. */
.cmp-offers,
.cmp-related { padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--border-color); }

/* ── Related comparisons: the rails' .compact-card as a link tile, in a grid ── */
.cmp-related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
/* Desktop shows every tile at once, so no "more" slide. */
.cmp-related-more { display: none; }
/* Phones: a swipeable 2×2 page at a time, no JS — two rows filled column by
   column, snapping at every 4th tile (the top-left of each page). A tenth of
   the next page peeks in, as the offers carousel's part-slide does, to say
   "swipe"; the links stay plain server HTML for crawlers. */
@media (max-width: 600px) {
    .cmp-related-grid {
        grid-template-columns: none;
        grid-template-rows: repeat(2, auto);
        grid-auto-flow: column;
        grid-auto-columns: calc((100% - 20px) / 2.1);
        gap: 10px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }
    .cmp-related-grid::-webkit-scrollbar { display: none; }
    .cmp-related-grid > li:nth-child(4n + 1) { scroll-snap-align: start; }
    /* The last tile, under the 9th: one CTA, so the final page is a full 2×2. */
    .cmp-related-more { display: block; }
    .cmp-related-more .compact-card { height: 100%; justify-content: center; }
    .cmp-related-more .compact-card { gap: 16px; }
    .cmp-related-logo { display: block; width: 110px; max-width: 100%; height: auto; }
    .cmp-related-more .btn { white-space: nowrap; }
}
.cmp-related-grid .compact-card { gap: 4px; color: var(--text-color); text-decoration: none; }
.cmp-related-grid .product-title { margin: 0; font-size: var(--fs-sm); }
.cmp-related-grid .product-price { color: var(--pink-highlight); }
/* One square image box per tile, so a row lines up whatever the photo's shape
   (and a missing photo keeps its place). */
.cmp-related-grid .compact-image-container { flex: none; width: 110px; height: 110px; max-width: 100%; }
.cmp-related-grid .compact-img { display: block; width: 100%; height: 100%; max-width: none; object-fit: contain; }
/* Who sells it: the cheapest shops' favicons on the star-avatar stack
   (components.css), contained — a logo is never cropped to a circle — then
   "в N магазина" on its own row under them. */
.cmp-related-shops { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; color: var(--text-light); font-size: var(--fs-xs); }
.cmp-related-grid .pm-stack { cursor: inherit; }
.cmp-related-grid .pm-stack-avatar { width: 26px; height: 26px; object-fit: contain; border-color: var(--border-color); }
.cmp-related-grid .pm-stack-avatar + .pm-stack-avatar,
.cmp-related-grid .pm-stack-more { margin-left: -8px; }
.cmp-related-grid .pm-stack-more { min-width: 26px; min-height: 26px; padding: 0 4px; border-radius: 13px; border-color: var(--border-color); font-size: var(--fs-3xs); }
@media (hover: hover) {
    .cmp-related-grid .compact-card:hover .product-title { color: var(--pink-highlight); }
}

.cmp-offers-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin: 0 0 12px;
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-color);
}
.cmp-offers-range { font-size: var(--fs-md); font-weight: 500; color: var(--text-light); }

/* Splide hides .splide until it mounts. These offers are the page's content —
   a crawler and a no-JS visitor must see them — so before mount the row is a
   plain horizontal scroller with the same slide widths. */
.cmp-splide { visibility: visible; }
.cmp-splide:not(.is-initialized) .splide__track {
    overflow-x: auto;
    scrollbar-width: thin;
}
.cmp-splide:not(.is-initialized) .splide__list { gap: 12px; }
.cmp-splide:not(.is-initialized) .cmp-offer { flex: 0 0 248px; }
@media (min-width: 1201px) {
    .cmp-splide:not(.is-initialized) .cmp-offer { flex-basis: calc((100% - 36px) / 3.2); }
}
/* Everything fits: no arrows pointing nowhere. */
.cmp-splide:not(.is-overflow) .splide__arrows { display: none; }

.cmp-offer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);   /* = .product-card */
}

/* Logos come in every shape (wordmarks, squares, SVG and PNG) — one fixed box,
   contained, so a row of them lines up. The name under it is the text fallback
   and the accessible label either way. */
.cmp-offer-logo {
    /* A <button> (opens the Shop overview): the UA button chrome off. */
    width: 100%;
    border: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 84px;
    padding: 8px;
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
}
/* Fixed-height frame, logo centred inside: every shape of logo takes the
   same 48px, so the shop name under it sits on one line across the slides. */
.cmp-offer-logo-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    flex-shrink: 0;
}
.cmp-offer-logo img {
    display: block;
    max-width: 100%;
    max-height: 48px;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}
/* A very horizontal wordmark (wider than 3:1, flagged on load) at full box
   width reads louder than a square logo — cap it a step down. */
.cmp-offer-logo img.is-wide { max-width: 78%; max-height: 36px; }
/* Same hover as the card image (.product-image-container:hover .product-img). */
@media (hover: hover) {
    .cmp-offer-logo:hover img { transform: scale(1.1); }
}
.cmp-offer-logo-name {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-color);
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cmp-offer-logo.is-empty .cmp-offer-logo-name { font-size: var(--fs-lg); }

.cmp-offer-badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; }

/* The card's price pair and title (components.css), set to the slide's
   scale the way .hot-products-content / .compact-card scope theirs. */
.cmp-offer-price { font-size: var(--fs-xl); justify-content: flex-start; }
.cmp-offer .product-title { margin: 0; font-size: var(--fs-md); -webkit-line-clamp: 2; line-clamp: 2; }

/* ProductCard's action block; the rules are the card's own (components.css
   .separator-line / .product-actions / .btn-split). Pinned to the slide's
   foot so every slide's buttons line up whatever the title length. */
.cmp-offer-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}
.cmp-offer-actions .separator-line,
.cmp-offer-actions .product-actions { margin-bottom: 0; }
.cmp-offer-actions .product-actions li:last-child { margin-bottom: 0; }

/* ── Tablet / phone ─────────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .cmp-hero {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .cmp-hero-media {
        width: min(250px, 70vw);
        margin: 0 auto;
    }
}

@media (max-width: 600px) {
    /* Two equal buttons; the base 24px side padding would wrap their labels. */
    .cmp-actions > * { flex: 1 1 0; padding-left: 10px; padding-right: 10px; }
    .cmp-splide:not(.is-initialized) .cmp-offer { flex-basis: calc((100% - 10px) / 1.8); }
    /* 1.8 slides a screen leaves ~190px a slide: tighter padding keeps
       "Track price" on one line. */
    .cmp-offer { padding: 10px; }
    .cmp-offer .btn-primary-pale { padding-left: 8px; padding-right: 8px; gap: 6px; white-space: nowrap; }
}

/* ── Search on ─────────────────────────────────────────────────────────────
   Divider = the page's hairline token; the bar, dropdown and chips are all
   components.css (.search-hero-input-wrap, .search-suggest-menu,
   .search-hero-recents). Only width and spacing here — the 640px /search's
   empty state holds its bar to. */
.cmp-search {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 16px 48px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}
.cmp-search .cmp-offers-title { justify-content: center; margin-bottom: 6px; }
/* = search.css .search-hero-sub (that sheet isn't loaded here). */
.cmp-search-sub { margin: 0 0 20px; font-size: var(--fs-lg); color: var(--text-light); }
.cmp-search .search-suggest-bar { max-width: 640px; margin: 0 auto; }
.cmp-search .search-hero-recents { margin-top: 12px; }
/* Platform overview beside the search: .explainer-panel (components.css), the
   track-price modal's right column, laid out the modal's way — 2fr/1fr on
   desktop, stacked under the search below it. */
.cmp-search { display: grid; gap: 24px; }
.cmp-search-main { min-width: 0; }
.cmp-search .explainer-panel { text-align: left; }
@media (min-width: 901px) {
    .cmp-search { grid-template-columns: 2fr 1fr; align-items: center; }
}
