/* ==========================================================================
   MOSKIDKA — Frontend Styles
   ==========================================================================
   All classes are namespaced with .moskidka-*.
   No global rules for body / a / h1 / h2 etc. (master prompt §36).
   Mobile-first responsive grid.
   ========================================================================== */

.moskidka-main,
.moskidka-catalog {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

.moskidka-main__title,
.moskidka-catalog__title {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    color: inherit;
}

.moskidka-main__updated,
.moskidka-main__count,
.moskidka-catalog__meta {
    color: #666;
    font-size: 0.875rem;
    margin: 0.25rem 0 1rem 0;
}

.moskidka-section__title {
    margin: 2rem 0 1rem 0;
    font-size: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
}

.moskidka-categories__nav ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.moskidka-categories__nav a {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #333;
    text-decoration: none;
}

.moskidka-categories__nav a:hover,
.moskidka-categories__nav a:focus {
    background: #e0e0e0;
}

.moskidka-categories__count {
    color: #888;
    font-size: 0.8rem;
}

.moskidka-category-block {
    margin-bottom: 2rem;
}

.moskidka-category-block__title {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.moskidka-all-link {
    text-align: center;
    margin: 2rem 0;
}

.moskidka-all-link a {
    display: inline-block;
    padding: 0.625rem 1.5rem;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

.moskidka-all-link a:hover,
.moskidka-all-link a:focus {
    background: #005a87;
}

/* --------------------------------------------------------------------------
   Product Card
   -------------------------------------------------------------------------- */

.moskidka-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 480px) {
    .moskidka-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .moskidka-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .moskidka-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .moskidka-grid--top10 {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* --------------------------------------------------------------------------
   Cycle 114: mobile column count for the catalog/search grids.

   The catalog and search templates add .moskidka-grid--catalog-mobile-1 or -2
   from the `catalog_mobile_columns` UI setting. Only the 2-column variant
   overrides the single-column base rule below 480px; value 1 (and a missing
   setting) keeps the existing one-card-per-row layout. The desktop/tablet
   ladder above (2 / 3 / 4 columns at 480 / 768 / 1024px) is not touched.

   Cycle 114.2: the mobile 2-column scope also relaxes the grid item's default
   min-width: auto (which otherwise let the 1fr track grow to the card's
   min-content width and overflow the viewport at 360-430px) and keeps long
   unbreakable words / the current+old price row inside the narrowed track.
   Font sizes, card padding, image size and markup are unchanged.
   -------------------------------------------------------------------------- */

@media (max-width: 479.98px) {
    .moskidka-grid--catalog.moskidka-grid--catalog-mobile-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* Cycle 114.2 — grid items keep the CSS default min-width: auto, so the 1fr
       track could not shrink below each card's min-content width and the second
       column overflowed the viewport at 360-430px. min-width: 0 lets the track
       resolve to minmax(0, 1fr); the two rules below keep the card's own content
       inside that narrowed track. */
    .moskidka-grid--catalog.moskidka-grid--catalog-mobile-2 > .moskidka-card {
        min-width: 0;
    }

    .moskidka-grid--catalog.moskidka-grid--catalog-mobile-2 .moskidka-card__title,
    .moskidka-grid--catalog.moskidka-grid--catalog-mobile-2 .moskidka-card__title a {
        overflow-wrap: anywhere;
    }

    .moskidka-grid--catalog.moskidka-grid--catalog-mobile-2 .moskidka-card__price-row {
        flex-wrap: wrap;
    }
}

.moskidka-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.875rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    transition: box-shadow 0.15s ease;
}

.moskidka-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.moskidka-card__image-link {
    display: block;
    margin-bottom: 0.625rem;
    text-align: center;
}

.moskidka-card__image {
    max-width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: contain;
}

/* --------------------------------------------------------------------------
   Cycle 45.7 — Image Resilience: stable container + placeholder
   --------------------------------------------------------------------------
   Goals (D-157):
     - Reserved image area (no layout collapse when image is NULL/missing).
     - aspect-ratio: 1/1 (square — product packaging friendly).
     - object-fit: contain (no crop).
     - Placeholder for NULL image AND broken image (via onerror→data attribute).
     - No external placeholder URL — local CSS-only background.
     - Single reusable pattern for ProductCard / Similar / Comparison / Hero.

   Lifecycle:
     1. Render always: container + (img OR placeholder div).
     2. If image URL is NULL/empty → render placeholder div directly (no <img>).
     3. If image URL present → render <img loading="lazy" onerror="...">.
        On error: JS swaps the <img> for a placeholder div in the same
        container, then nulls the onerror handler (no retry loop).
   -------------------------------------------------------------------------- */

.moskidka-image-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fafafa;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    /* Prevent content from poking out of the frame while the image is
       loading. img uses object-fit: contain, so it stays inside. */
    min-height: 80px;
}

.moskidka-image-frame img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* Image takes the full frame; aspect-ratio + object-fit: contain
       ensures no crop and no overflow. */
    display: block;
}

/* Variant sizing — small frames for compact Similar/Comparison cards. */
.moskidka-image-frame--sm img {
    /* Image already constrained by the frame's aspect-ratio. */
}

/* Placeholder state — shown when image URL is NULL OR on image load error.
   Pure CSS background — no external placeholder URL (D-159). */
.moskidka-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    color: #999;
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem;
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(0, 0, 0, 0.02) 8px,
            rgba(0, 0, 0, 0.02) 16px
        ),
        #fafafa;
    box-sizing: border-box;
    line-height: 1.4;
}

.moskidka-image-placeholder__icon {
    /* Minimal inline SVG icon (gray placeholder box) — no external image. */
    display: block;
    width: 32px;
    height: 32px;
    margin-bottom: 0.25rem;
    opacity: 0.4;
}

.moskidka-image-placeholder__text {
    color: #888;
    font-size: 0.78rem;
}

/* When the image frame contains BOTH a broken <img> (about to be replaced)
   and the placeholder, hide the broken <img> first via CSS to prevent
   the broken-image icon from showing during the JS swap. */
.moskidka-image-frame img.moskidka-image-broken {
    display: none;
}

/* Mobile (≤600px) — keep frame visible, prevent horizontal overflow. */
@media (max-width: 600px) {
    .moskidka-image-frame {
        min-height: 60px;
    }

    .moskidka-image-placeholder__icon {
        width: 24px;
        height: 24px;
    }

    .moskidka-image-placeholder__text {
        font-size: 0.72rem;
    }
}

.moskidka-card__discount {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #d63638;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: bold;
}

.moskidka-card__title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    line-height: 1.3;
}

.moskidka-card__title a {
    color: inherit;
    text-decoration: none;
}

.moskidka-card__title a:hover,
.moskidka-card__title a:focus {
    text-decoration: underline;
}

.moskidka-card__brand,
.moskidka-card__weight {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.moskidka-card__price-row {
    margin: 0.5rem 0;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.moskidka-card__price {
    font-size: 1.1rem;
    font-weight: bold;
    color: #d63638;
}

.moskidka-card__old-price {
    color: #999;
    font-size: 0.95rem;
}

.moskidka-card__weekly {
    font-size: 0.825rem;
    color: #0073aa;
    margin-bottom: 0.25rem;
}

.moskidka-card__rating {
    font-size: 0.85rem;
    color: #f0b840;
    margin-bottom: 0.25rem;
}

.moskidka-card__reviews {
    color: #666;
}

.moskidka-card__notice {
    font-size: 0.825rem;
    color: #555;
    background: #fff8e5;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    margin: 0.25rem 0;
    line-height: 1.4;
}

.moskidka-card__promo-end {
    font-size: 0.825rem;
    color: #d63638;
    margin-top: 0.25rem;
}

.moskidka-card__discount-type {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.7rem;
    color: #999;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Filters (full catalog)
   -------------------------------------------------------------------------- */

.moskidka-filters {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.moskidka-filters__row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.moskidka-filters__row label {
    font-size: 0.8rem;
    color: #666;
}

.moskidka-filters__row input,
.moskidka-filters__row select {
    padding: 0.375rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 150px;
}

.moskidka-filters__submit {
    padding: 0.5rem 1rem;
    background: #0073aa;
    color: #fff;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.moskidka-filters__submit:hover,
.moskidka-filters__submit:focus {
    background: #005a87;
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.moskidka-pagination ul {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
}

.moskidka-pagination a,
.moskidka-pagination span {
    display: inline-block;
    padding: 0.375rem 0.625rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-decoration: none;
    color: #0073aa;
}

.moskidka-pagination .current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.moskidka-pagination a:hover {
    background: #eee;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.moskidka-empty {
    text-align: center;
    color: #666;
    padding: 2rem;
    font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   Accessibility: focus styles (WCAG 2.4.7 Focus Visible)
   -------------------------------------------------------------------------- */

.moskidka-card a:focus-visible,
.moskidka-categories__nav a:focus-visible,
.moskidka-all-link a:focus-visible,
.moskidka-filters input:focus-visible,
.moskidka-filters select:focus-visible,
.moskidka-filters button:focus-visible,
.moskidka-pagination a:focus-visible,
.moskidka-breadcrumb a:focus-visible,
.moskidka-product-back a:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Skip-link target style */
.moskidka-main:focus,
.moskidka-catalog:focus {
    outline: none;
}

/* --------------------------------------------------------------------------
   Long title handling (line-clamp to 2 lines)
   -------------------------------------------------------------------------- */

.moskidka-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.6em;
}

.moskidka-card__notice {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Touch-friendly tap targets (min 44x44 px per WCAG 2.5.5)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .moskidka-categories__nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.5rem 0.875rem;
    }

    .moskidka-filters__submit {
        min-height: 44px;
        min-width: 44px;
    }

    .moskidka-pagination a,
    .moskidka-pagination span {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* --------------------------------------------------------------------------
   Print styles (basic)
   -------------------------------------------------------------------------- */

@media print {
    .moskidka-filters,
    .moskidka-pagination,
    .moskidka-all-link {
        display: none;
    }

    .moskidka-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion (WCAG 2.3.3 Animation from Interactions)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .moskidka-card {
        transition: none;
    }

    .moskidka-categories__nav a {
        transition: none;
    }
}

/* --------------------------------------------------------------------------
   High-contrast mode (Windows)
   -------------------------------------------------------------------------- */

@media (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .moskidka-card {
        border: 1px solid WindowText;
    }

    .moskidka-card__title a {
        color: LinkText;
    }

    .moskidka-card__discount {
        background: HighlightText;
        color: Highlight;
        border: 1px solid WindowText;
    }
}

/* --------------------------------------------------------------------------
   Admin dashboard tweaks
   -------------------------------------------------------------------------- */

.moskidka-admin .widefat code,
.moskidka-admin .widefat .code {
    background: #f0f0f0;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.875em;
}

/* --------------------------------------------------------------------------
   Cycle 28 — Admin overview stats cards
   -------------------------------------------------------------------------- */

.moskidka-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0 2rem;
}

.moskidka-stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #2271b1;
    border-radius: 4px;
    padding: 1rem 1.25rem;
}

.moskidka-stat-card__label {
    color: #646970;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.moskidka-stat-card__value {
    font-size: 2em;
    font-weight: 600;
    line-height: 1;
    color: #1d2327;
}

/* Shortcode error notice (invalid source attr) */
.moskidka-shortcode-error {
    background: #fff3e0;
    border-left: 4px solid #f0b849;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

/* Source badge coloring — re-applied for any new store added later.
 *
 * Cycle 66.1: previously only 3 stores had source-specific CSS classes
 * (.moskidka-source-vkusvill, .moskidka-source-dixy, .moskidka-source-pyaterochka).
 * The other 9 stores (added in Cycles 44/46/55.1/57/64) had NO matching CSS
 * class, causing their store badges to render as white text on transparent
 * background — invisible.
 *
 * Fix: add the 9 missing source-specific rules + ensure that any unknown
 * future source also gets a visible default background via the base
 * .moskidka-card__source-badge / .moskidka-similar-store rules.
 */

/* --- Base badge rules (visible defaults, can be overridden by .moskidka-source-*) --- */

/* Cycle 66.1: .moskidka-card__source-badge had NO base CSS rule before.
 * It relied entirely on .moskidka-source-* for background color, which
 * meant badges for the 9 newer stores were invisible on listing pages.
 * Add a visible default background here so any future source without a
 * specific color rule still renders a visible badge. Source-specific
 * rules (.moskidka-source-<source>) override this default.
 */
.moskidka-card__source-badge {
    background: #6c757d; /* default gray for unknown sources */
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

/* Source-specific colors (override the defaults above).
 * Cycle 28: original 3 stores.
 */
.moskidka-source-vkusvill {
    background: #2a9d8f;
    color: #fff;
}

.moskidka-source-dixy {
    background: #e63946;
    color: #fff;
}

.moskidka-source-pyaterochka {
    background: #f4a261;
    color: #fff;
}

/* Cycle 66.1 — add 9 missing source-specific colors for newer stores.
 * Brand-inspired palette (visible on white background, sufficient contrast
 * with #fff text). Color choices are arbitrary but distinguishable.
 */
.moskidka-source-lenta {
    background: #1d3557;
    color: #fff;
}

.moskidka-source-magnit_cosmetic {
    background: #c9184a;
    color: #fff;
}

.moskidka-source-perekrestok {
    background: #b5651d;
    color: #fff;
}

.moskidka-source-yarche {
    background: #588157;
    color: #fff;
}

.moskidka-source-auchan {
    background: #003566;
    color: #fff;
}

.moskidka-source-magnit {
    background: #d62828;
    color: #fff;
}

.moskidka-source-chizhik {
    background: #fcbf49;
    color: #1a1a1a; /* yellow background needs dark text for contrast */
}

.moskidka-source-myasnitsky {
    background: #6a040f;
    color: #fff;
}

.moskidka-source-da {
    background: #4a4e69;
    color: #fff;
}

/* Cycle 68 — add source color for new Smart store. */
.moskidka-source-smart {
    background: #2c7a7b;
    color: #fff;
}

/* Cycle 70.1 — add source color for new Fix Price store. */
.moskidka-source-fixprice {
    background: #e85d04;
    color: #fff;
}

/* Cycle 71.2 — add source color for new Globus store. */
.moskidka-source-globus {
    background: #6a4c93;
    color: #fff;
}

/* --------------------------------------------------------------------------
   Cycle 29 — Category block "Показать ещё" + hidden cards
   -------------------------------------------------------------------------- */

.moskidka-card.is-hidden {
    display: none;
}

.moskidka-category-block__title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.moskidka-category-block__count {
    color: #646970;
    font-size: 0.85em;
    font-weight: normal;
}

.moskidka-category-block__more {
    margin-top: 1rem;
    text-align: center;
}

.moskidka-show-more-link {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: #f0f0f0;
    color: #2271b1;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background 0.2s, border-color 0.2s;
}

.moskidka-show-more-link:hover,
.moskidka-show-more-link:focus {
    background: #e0e0e0;
    border-color: #2271b1;
    color: #135e96;
}

.moskidka-show-more-link:active {
    background: #d0d0d0;
}

/* --------------------------------------------------------------------------
   Cycle 33 — Disabled store placeholder
   -------------------------------------------------------------------------- */

.moskidka-main--disabled .moskidka-disabled-placeholder {
    padding: 3rem 1.5rem;
    text-align: center;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin: 2rem 0;
}

.moskidka-main--disabled .moskidka-disabled-text {
    font-size: 1.1em;
    color: #666;
    margin: 0;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Cycle 40 — Product page
   -------------------------------------------------------------------------- */

.moskidka-product {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.moskidka-breadcrumb {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 1.5rem;
}

.moskidka-breadcrumb a {
    color: #2271b1;
    text-decoration: none;
}

.moskidka-breadcrumb a:hover {
    text-decoration: underline;
}

/* Cycle 115 — shared breadcrumb component (visual only; the BreadcrumbList
   JSON-LD stays in Seo.php and is never emitted from here). The desktop look
   above is unchanged; the rules below add the child hooks and keep the trail
   inside the viewport on narrow screens (Cycle 114.2 lesson: no auto minimum
   on flex/grid items, the long current level ellipsizes instead of overflowing). */
@media (max-width: 767.98px) {
    .moskidka-breadcrumb {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.15rem 0.35rem;
        min-width: 0;
    }

    .moskidka-breadcrumb__item,
    .moskidka-breadcrumb__sep,
    .moskidka-breadcrumb__current {
        min-width: 0;
    }

    .moskidka-breadcrumb__current {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .moskidka-product-back a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

.moskidka-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .moskidka-product-grid {
        grid-template-columns: 1fr;
    }
}

/* Cycle 45.7 — Hero image uses the same reusable image-frame pattern.
   Kept as a separate selector for legacy compatibility (some themes may
   target .moskidka-product-image directly). */
.moskidka-product-image {
    /* Frame takes the left grid column (1fr) on desktop, full width on mobile. */
}

.moskidka-product-image .moskidka-image-frame {
    /* Hero is larger than card images. */
    aspect-ratio: 1 / 1;
    min-height: 200px;
    border-radius: 8px;
}

.moskidka-product-image .moskidka-image-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Legacy: any non-frame hero img (older themes overriding) — still resilient. */
.moskidka-product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.moskidka-product-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.moskidka-product-store {
    /* Cycle 82.1: chip chrome only — background/color come from the paired
       .moskidka-source-{source} class (existing palette, Cycles 28/66.1).
       Sources without a color rule keep a plain-text fallback; the store
       name is always real text, never color-only. */
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.moskidka-product-title {
    font-size: 1.6em;
    margin: 0;
}

.moskidka-product-brand,
.moskidka-product-weight {
    color: #555;
    font-size: 0.95em;
}

.moskidka-product-price-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.moskidka-product-price {
    font-size: 1.8em;
    font-weight: 700;
    color: #1d2327;
}

.moskidka-product-old-price {
    color: #999;
    font-size: 1.1em;
}

.moskidka-product-discount {
    background: #dc3232;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9em;
}

.moskidka-product-notice,
.moskidka-product-promo-end,
.moskidka-product-updated {
    font-size: 0.9em;
    color: #555;
}

.moskidka-product-weekly,
.moskidka-product-events {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Cycle 41 — Compact variant: when the weekly section has only 1 line
   (a single delta label), do not reserve the full 1.5rem padding. */
.moskidka-product-weekly--compact {
    padding: 0.875rem 1.25rem;
}

.moskidka-product-weekly--compact h2 {
    margin-bottom: 0.375rem;
}

.moskidka-product-weekly--compact p {
    margin: 0;
}

/* Cycle 41 — Empty-events compact variant: avoid the large empty box
   when there's only a one-line "история недоступна" message. */
.moskidka-product-events--empty {
    padding: 0.875rem 1.25rem;
}

.moskidka-product-events--empty h2 {
    margin-bottom: 0.375rem;
}

.moskidka-product-events--empty .moskidka-product-events-empty {
    margin: 0;
}

.moskidka-product-weekly h2,
.moskidka-product-events h2 {
    margin-top: 0;
    font-size: 1.2em;
}

.moskidka-event-timeline {
    width: 100%;
    border-collapse: collapse;
}

.moskidka-event-timeline th,
.moskidka-event-timeline td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.9em;
}

.moskidka-event-timeline th {
    color: #666;
    font-weight: 600;
}

/* Cycle 41 — Mobile horizontal overflow protection: keep the event
   table inside the viewport on small screens. The table will scroll
   horizontally if needed (rare — only when old/new values are long),
   rather than breaking the page layout. */
@media (max-width: 600px) {
    .moskidka-event-timeline {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .moskidka-event-timeline thead,
    .moskidka-event-timeline tbody,
    .moskidka-event-timeline tr,
    .moskidka-event-timeline th,
    .moskidka-event-timeline td {
        display: block;
    }

    .moskidka-event-timeline tr {
        border-bottom: 1px solid #e0e0e0;
        padding: 0.5rem 0;
        white-space: normal;
    }

    .moskidka-event-timeline th {
        display: none; /* Hide table headers on mobile — the row layout makes them redundant. */
    }

    .moskidka-event-timeline td {
        border-bottom: none;
        padding: 0.15rem 0.5rem;
        /* Cycle 116.1: long unbreakable values must not widen the table. */
        overflow-wrap: anywhere;
    }

    /* Cycle 116.1: the header row is hidden on small screens, so every cell
       carries its own field label through data-label. */
    .moskidka-event-timeline td::before {
        content: attr(data-label) ":";
        display: inline-block;
        min-width: 4.5rem;
        padding-right: 0.35rem;
        font-weight: 600;
        color: #666;
        white-space: normal;
    }
}

.moskidka-product-events-empty {
    color: #999;
    font-style: italic;
}

.moskidka-card__image-link {
    display: block;
    text-decoration: none;
}

.moskidka-card__title a {
    color: inherit;
    text-decoration: none;
}

.moskidka-card__title a:hover {
    color: #2271b1;
}

/* --------------------------------------------------------------------------
   Cycle 45 — Cross-store comparison + Similar products
   -------------------------------------------------------------------------- */

.moskidka-product-comparison,
.moskidka-product-similar {
    margin-bottom: 1.5rem;
}

.moskidka-product-comparison h2,
.moskidka-product-similar h2 {
    margin: 0 0 1rem 0;
    font-size: 1.2em;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
}

/* Comparison grid */
.moskidka-comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.moskidka-comparison-card {
    display: flex;
    flex-direction: column;
    padding: 0.875rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease;
}

.moskidka-comparison-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Cycle 45.7 — Comparison card image uses reusable image-frame pattern.
   Frame is sized via aspect-ratio + grid column width. No max-height
   needed — the frame is naturally square via aspect-ratio. */
.moskidka-comparison-card .moskidka-image-frame {
    margin-bottom: 0.5rem;
}

/* Legacy: any comparison card img NOT wrapped in a frame (older markup). */
.moskidka-comparison-card img {
    max-width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}

.moskidka-comparison-store {
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.moskidka-comparison-price {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.moskidka-comparison-price-current {
    font-size: 1.1rem;
    font-weight: 700;
    color: #d63638;
}

.moskidka-comparison-price-old {
    color: #999;
    font-size: 0.9rem;
}

.moskidka-comparison-discount {
    background: #dc3232;
    color: #fff;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
}

.moskidka-comparison-updated {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

/* Similar products grid */
.moskidka-similar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.moskidka-similar-card {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease;
}

.moskidka-similar-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Cycle 45.7 — Similar card image uses reusable image-frame pattern. */
.moskidka-similar-card .moskidka-image-frame {
    margin-bottom: 0.5rem;
}

/* Legacy: any similar card img NOT wrapped in a frame (older markup). */
.moskidka-similar-card img {
    max-width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}

.moskidka-similar-title {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.moskidka-similar-brand,
.moskidka-similar-weight {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.15rem;
}

.moskidka-similar-store {
    /* Cycle 66.1: add default visible background so that any source
     * without a specific .moskidka-source-* color rule still renders
     * a visible badge (previously: white text on transparent background
     * = invisible for 9 of the 12 stores). Source-specific rules
     * (.moskidka-source-<source>) override this default. */
    background: #6c757d; /* default gray for unknown sources */
    font-size: 0.75rem;
    color: #fff;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    margin-bottom: 0.25rem;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.moskidka-similar-price {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.moskidka-similar-price-current {
    font-size: 1.05rem;
    font-weight: 700;
    color: #d63638;
}

.moskidka-similar-price-old {
    color: #999;
    font-size: 0.85rem;
}

.moskidka-similar-discount {
    background: #dc3232;
    color: #fff;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mobile: ensure no horizontal overflow. Image frames are already
   responsive via aspect-ratio — no max-height override needed.
   The legacy img max-height is kept for backward compat with older
   markup that hasn't been wrapped in a frame yet. */
@media (max-width: 600px) {
    .moskidka-comparison-grid,
    .moskidka-similar-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .moskidka-comparison-card,
    .moskidka-similar-card {
        padding: 0.5rem;
    }

    .moskidka-similar-card img,
    .moskidka-comparison-card img {
        max-height: 80px;
    }
}

/* ==========================================================================
   Cycle 82.1 — Product Page header/info UI
   --------------------------------------------------------------------------
   .moskidka-product-store: chip chrome added in place above; background and
   color come from the existing .moskidka-source-* palette (no new color
   system, other components untouched).
   ========================================================================== */

/* Promo end: ended state is muted; the active date text stays emphasized. */
.moskidka-product-promo--ended {
    color: #888;
}

/* Source note — native <details>/<summary>: keyboard + screen-reader
   accessible, works on mobile via tap, requires no JS. */
.moskidka-source-note {
    display: inline-block;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.moskidka-source-note summary {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: #2271b1;
    list-style: none;
}

.moskidka-source-note summary::-webkit-details-marker {
    display: none;
}

.moskidka-source-note[open] summary {
    margin-bottom: 0.25rem;
}

.moskidka-source-note p {
    margin: 0.25rem 0 0 0;
    font-size: 0.85em;
    color: #666;
    max-width: 34em;
}

/* Visually hidden helper for accessible labels (screen readers only). */
.moskidka-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Cycle 82.3 — Product Page price history chart (inline SVG)
   Minimal, namespaced styles. Colors reuse the existing palette.
   ========================================================================== */

.moskidka-price-chart {
    margin: 0.75rem 0 1rem;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.moskidka-price-chart__svg {
    display: block;
    width: 100%;
    height: auto;
    min-width: 300px;
}

.moskidka-price-chart__line {
    fill: none;
    stroke: #0073aa;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.moskidka-price-chart__grid {
    stroke: #e0e0e0;
    stroke-width: 1;
}

.moskidka-price-chart__point {
    fill: #fff;
    stroke: #0073aa;
    stroke-width: 1.5;
}

.moskidka-price-chart__label {
    font-size: 10px;
    fill: #666;
}

/* --- Cycle 97 (Stage 1): History UI v2 --- */

.moskidka-price-chart__point.is-last {
    fill: #0073aa;
    stroke: #0073aa;
    stroke-width: 2;
}

.moskidka-price-chart__last-ring {
    fill: none;
    stroke: #0073aa;
    stroke-width: 1.5;
    opacity: 0.45;
    pointer-events: none;
}

.moskidka-history-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2.25rem;
    margin: 0.5rem 0 0.75rem;
    padding: 0.7rem 0.95rem;
    background: #f7f9fb;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
}

.moskidka-history-summary__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.moskidka-history-summary__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.moskidka-history-summary__value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: #1f2430;
    font-variant-numeric: tabular-nums;
}

.moskidka-history-summary__value--delta-up {
    color: #1e8449;
}

.moskidka-history-summary__value--delta-down {
    color: #c0392b;
}

.moskidka-history-caption {
    margin: 0.25rem 0 0.9rem;
    font-size: 0.9rem;
    color: #444;
}

.moskidka-history-details {
    margin: 0.25rem 0 0.5rem;
}

.moskidka-history-details summary {
    cursor: pointer;
    color: #0073aa;
    font-weight: 600;
    padding: 0.3rem 0;
}

.moskidka-history-details[open] summary {
    margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
    .moskidka-history-summary {
        flex-direction: column;
        gap: 0.6rem;
    }

    /* Cycle 116.1: on small screens the chart shrinks to the available
       width instead of forcing an inner horizontal scroll. Desktop
       (601px+) keeps .moskidka-price-chart__svg { min-width: 300px }. */
    .moskidka-price-chart__svg {
        min-width: 0;
    }
}

