/* =============================================================================
   CGM Product — Design Sprint D
   v3.0 | DS-aligned: sage palette, radius 4px, no shadows
   Relies on curly-global.css for --brand, --cgm-amber, --cgm-crimson, etc.
   ============================================================================= */

/* ── Local fallback tokens (if curly-global.css not loaded) ──────────────── */
:root {
    /* CGM-валидация: success green зарезервирован под «safe/ok» (DS #5C8A6A) */
    --cgm-safe-bg:    rgba(92,138,106, 0.12);
    --cgm-safe-text:  #5C8A6A;
    --cgm-caution-bg: rgba(217,119,6,  0.10);
    --cgm-caution-text:#D97706;
    --cgm-danger-bg:  rgba(220,38,38,  0.08);
    --cgm-danger-text: #DC2626;
    --cgm-border:     #EDE6DD;   /* hairline (DS) */
    --cgm-stone:      #F4EEE6;   /* surface-alt cream (DS) */
    --cgm-text:       #2B2622;   /* warm near-black */
    --cgm-text-mid:   #8A817A;   /* muted */
    --cgm-text-light: #B8AFA6;
    --cgm-white:      #ffffff;
    --cgm-r:         16px;       /* cards (было 4px) */
    --cgm-r-sm:       8px;       /* small (было 2px) */
}

/* ── Шрифты: тело → Inter; заголовки наследуют Fraunces (из curly-global) ──── */
.cgm-product-wrap,
.cgm-archive-wrap {
    font-family: var(--font-body, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
}
.cgm-product-wrap *,
.cgm-archive-wrap * {
    box-sizing: border-box;
}
/* Заголовки внутри — editorial serif */
.cgm-product-wrap h1, .cgm-product-wrap h2, .cgm-product-wrap h3,
.cgm-archive-wrap h1, .cgm-archive-wrap h2, .cgm-archive-wrap h3 {
    font-family: var(--font-display, 'Fraunces', Georgia, serif);
    font-weight: 400;
}

/* ── Page wrapper ────────────────────────────────────────────────────────── */
.cgm-product-wrap,
.cgm-archive-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 64px;
    background: transparent;
}

/* body background: задаётся в curly-global.css (--bg-page: #F0F7F4 Mint Mist).
   Не переопределяем здесь — иначе taxonomy-страницы получают белый фон. */

/* ── Top accent bar ──────────────────────────────────────────────────────── */
.cgm-product-wrap::before {
    content: '';
    display: block;
    height: 3px;
    background: var(--brand, #4A7C6F);
    margin: 0 -24px 0;
}

/* ── Section title ───────────────────────────────────────────────────────── */
.cgm-section-title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--cgm-text-light);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin: 48px 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.cgm-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--cgm-border);
}

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.cgm-breadcrumb {
    font-size: .82rem;
    color: var(--cgm-text-light);
    margin: 20px 0 28px;
}
.cgm-breadcrumb a { color: var(--cgm-text-light); text-decoration: none; }
.cgm-breadcrumb a:hover { color: var(--brand, #4A7C6F); }

/* =============================================================================
   SINGLE PRODUCT
   ============================================================================= */

/* Hero grid */
.cgm-product-hero {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 48px;
    align-items: start;
    margin-bottom: 12px;
}
@media (max-width: 800px) {
    .cgm-product-hero { grid-template-columns: 1fr; }
    .cgm-product-image { position: static; }
}

/* Product image */
.cgm-product-image {
    position: sticky;
    top: 24px;
}
.cgm-product-image img {
    width: 100%;
    height: auto;
    border-radius: var(--cgm-r);
    border: 1px solid var(--cgm-border);
    box-shadow: none;
    object-fit: contain;
    background: var(--cgm-white);
    padding: 20px;
    aspect-ratio: 1;
}
.cgm-product-image__placeholder {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    background: var(--cgm-stone);
    border-radius: var(--cgm-r);
    border: 1px solid var(--cgm-border);
}

/* Brand pill */
.cgm-product-brand {
    margin: 0 0 14px;
}
.cgm-product-brand a {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--brand, #4A7C6F);
    text-decoration: none;
    background: var(--cgm-safe-bg);
    padding: 4px 14px;
    border-radius: 999px;
    transition: background .15s;
}
.cgm-product-brand a:hover {
    background: rgba(232,130,107, 0.18);
}

/* Title */
.cgm-product-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--cgm-text);
    margin: 0 0 24px;
    line-height: 1.2;
    letter-spacing: -.02em;
}

/* ── CGM Score Ring ──────────────────────────────────────────────────────── */
.cgm-score-ring {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
}
.cgm-score-svg-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}
.cgm-score-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.cgm-score-track { fill: none; stroke: var(--cgm-stone); stroke-width: 9; }
.cgm-score-fill  {
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
    animation: cgmScoreIn .9s ease forwards;
}
@keyframes cgmScoreIn { from { stroke-dasharray: 0 314; } }

.cgm-score--safe    .cgm-score-fill { stroke: var(--brand, #4A7C6F); }
.cgm-score--caution .cgm-score-fill { stroke: var(--cgm-amber, #D97706); }
.cgm-score--danger  .cgm-score-fill { stroke: var(--cgm-crimson, #DC2626); }

.cgm-score-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.cgm-score-number { font-size: 1.4rem; font-weight: 800; color: var(--cgm-text); line-height: 1; }
.cgm-score-max    { font-size: .55rem; color: var(--cgm-text-light); margin-top: 1px; }

.cgm-score-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cgm-score-title {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--cgm-text-light);
}
.cgm-score-verdict {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none !important;
}
.cgm-score--safe    .cgm-score-verdict { color: var(--brand, #4A7C6F); }
.cgm-score--caution .cgm-score-verdict { color: var(--cgm-amber, #D97706); }
.cgm-score--danger  .cgm-score-verdict { color: var(--cgm-crimson, #DC2626); }

/* ── Status badge ────────────────────────────────────────────────────────── */
.cgm-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--cgm-r);
    padding: 6px 14px;
    font-weight: 700;
    font-size: .88rem;
    margin-bottom: 20px;
}
.cgm-badge--safe    { background: var(--cgm-safe-bg);    color: var(--cgm-safe-text); }
.cgm-badge--caution { background: var(--cgm-caution-bg); color: var(--cgm-caution-text); }
.cgm-badge--danger  { background: var(--cgm-danger-bg);  color: var(--cgm-danger-text); }

/* ── CGM badges row (Sin sulfatos / Sin siliconas / Sin proteínas) ───────── */
.cgm-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}
.cgm-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--cgm-r);
    padding: 9px 14px;
    font-size: .84rem;
    font-weight: 600;
    border: 1px solid transparent;
    flex: 1;
    min-width: 140px;
}
.cgm-badge--yes {
    background: var(--cgm-safe-bg);
    color: var(--cgm-safe-text);
    border-color: rgba(232,130,107, 0.25);
}
.cgm-badge--no {
    background: var(--cgm-caution-bg);
    color: var(--cgm-caution-text);
    border-color: rgba(217,119,6, 0.25);
}
.cgm-badge__icon  { font-size: 1rem; }
.cgm-badge__label { font-weight: 700; }

/* ── Buy box ─────────────────────────────────────────────────────────────── */
.cgm-buy-box {
    background: var(--brand, #4A7C6F);
    border-radius: var(--cgm-r);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: none;
}
.cgm-buy-box__price { display: flex; flex-direction: column; gap: 4px; }

/* Discount badge */
.cgm-discount-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: .75rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 2px;
    letter-spacing: .01em;
    align-self: flex-start;
}
.cgm-discount-badge--sm {
    font-size: .7rem;
    padding: 1px 7px;
    margin-right: 4px;
    vertical-align: middle;
    background: rgba(232,130,107, 0.12);
    color: var(--brand, #4A7C6F);
}

/* Strikethrough original price */
.cgm-price-original {
    font-size: .85rem;
    font-weight: 500;
    color: rgba(255,255,255,.65);
    text-decoration: line-through;
}
.cgm-price-table .cgm-price-original {
    font-size: .8rem;
    color: var(--cgm-text-light);
    text-decoration: line-through;
    margin-right: 4px;
}

.cgm-buy-box__amount {
    font-size: 2rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    letter-spacing: -.03em;
}
.cgm-buy-box__store {
    font-size: .8rem;
    color: rgba(255,255,255,.75);
}

/* "Ver mejor precio →" button */
.cgm-buy-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    color: var(--brand, #4A7C6F);
    font-weight: 700;
    font-size: .9rem;
    padding: 11px 24px;
    border-radius: var(--cgm-r);
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
    transition: background .15s, color .15s;
}
.cgm-buy-btn:hover {
    background: var(--cgm-stone);
    color: var(--brand, #4A7C6F);
}

/* ── Price table ─────────────────────────────────────────────────────────── */
.cgm-prices { margin-bottom: 8px; }

.cgm-price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    border: 1px solid var(--cgm-border);
    border-radius: var(--cgm-r);
    overflow: hidden;
}
.cgm-price-table thead th {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cgm-text-light);
    padding: 10px 16px;
    text-align: left;
    background: var(--cgm-stone);
    border-bottom: 1px solid var(--cgm-border);
}
.cgm-price-table tbody tr {
    background: var(--cgm-white);
    border-bottom: 1px solid var(--cgm-border);
    transition: background .1s;
}
.cgm-price-table tbody tr:last-child { border-bottom: none; }
.cgm-price-table tbody tr:hover { background: var(--cgm-stone); }
.cgm-price-table__best { background: var(--cgm-safe-bg) !important; }

.cgm-price-table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.cgm-price-table__store  { font-weight: 700; color: var(--cgm-text); }
.cgm-price-table__best-badge {
    display: inline-block;
    background: var(--brand, #4A7C6F);
    color: #ffffff;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
}
.cgm-price-table__price { font-weight: 800; font-size: 1.05rem; color: var(--cgm-text); }
.cgm-price-table__best .cgm-price-table__price { color: var(--brand, #4A7C6F); }

.cgm-avail        { font-size: .8rem; font-weight: 600; }
.cgm-avail--in    { color: var(--brand, #4A7C6F); }
.cgm-avail--out   { color: var(--cgm-text-light); }

/* "Ir a tienda" button in table */
.cgm-table-btn {
    display: inline-block;
    padding: 6px 16px;
    background: var(--brand, #4A7C6F);
    color: #ffffff;
    font-weight: 700;
    font-size: .8rem;
    border-radius: var(--cgm-r);
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.cgm-table-btn:hover {
    background: var(--brand-hover, #3a6560);
    color: #ffffff;
}

.cgm-prices__updated {
    font-size: .72rem;
    color: var(--cgm-text-light);
    text-align: right;
    margin-top: 6px;
}

/* ── CGM Analysis grid ───────────────────────────────────────────────────── */
.cgm-analysis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (max-width: 640px) { .cgm-analysis-grid { grid-template-columns: 1fr; } }

.cgm-analysis-card {
    background: var(--cgm-white);
    border-radius: var(--cgm-r);
    padding: 20px 18px;
    box-shadow: none;
    border: 1px solid var(--cgm-border);
    transition: border-color .2s;
}
.cgm-analysis-card:hover { border-color: var(--brand, #4A7C6F); }

.cgm-analysis-card__icon  { font-size: 1.8rem; margin-bottom: 10px; display: block; }
.cgm-analysis-card__title { font-weight: 700; font-size: .92rem; margin-bottom: 8px; color: var(--cgm-text); }
.cgm-analysis-card__desc  { font-size: .8rem; color: var(--cgm-text-mid); line-height: 1.55; }

.cgm-analysis-reason {
    background: var(--cgm-caution-bg);
    border: 1px solid rgba(217,119,6,.25);
    border-radius: var(--cgm-r);
    padding: 12px 16px;
    font-size: .875rem;
    color: #92400e;
    margin-bottom: 16px;
}

.cgm-bad-ingredients {
    background: var(--cgm-danger-bg);
    border: 1px solid rgba(220,38,38,.2);
    border-radius: var(--cgm-r);
    padding: 16px 20px;
    margin-bottom: 8px;
}
.cgm-bad-ingredients__title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--cgm-crimson, #DC2626);
    margin: 0 0 10px;
}
.cgm-bad-ingredients__list { margin: 0; padding-left: 18px; }
.cgm-bad-ingredients__list li { margin-bottom: 4px; font-size: .84rem; color: var(--cgm-text); }

/* ── Pending badge ───────────────────────────────────────────────────────── */
.cgm-badge--pending {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

/* ── Product Description ─────────────────────────────────────────────────── */
.cgm-description {
    background: var(--cgm-white);
    border-radius: var(--cgm-r);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: none;
    border: 1px solid var(--cgm-border);
}
.cgm-description__content {
    font-size: .92rem;
    color: var(--cgm-text);
    line-height: 1.7;
}
.cgm-description__content p { margin: 0 0 12px; }
.cgm-description__content p:last-child { margin-bottom: 0; }
.cgm-description__content ul,
.cgm-description__content ol { padding-left: 20px; margin-bottom: 12px; }
.cgm-description__content li { margin-bottom: 4px; }
.cgm-description__content a { color: var(--brand, #4A7C6F); text-decoration: underline; }

/* Заголовки внутри описания товара (контент the_content() — h2/h3/h4) */
.cgm-description__content h2,
.cgm-description__content h3,
.cgm-description__content h4 {
    font-weight: 600;
    line-height: 1.3;
    margin: 18px 0 8px;
}
.cgm-description__content h2 { font-size: 1.15rem; }
.cgm-description__content h3 { font-size: 1.02rem; }
.cgm-description__content h4 { font-size: .95rem; }
.cgm-description__content > :first-child { margin-top: 0; }

/* ── Ingredients ─────────────────────────────────────────────────────────── */
.cgm-ingredients__parsed {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 18px;
    background: var(--cgm-white);
    border-radius: var(--cgm-r);
    border: 1px solid var(--cgm-border);
    box-shadow: none;
    margin-bottom: 10px;
}
.cgm-ing {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 2px;
    font-size: .76rem;
    font-weight: 500;
    background: #f0f0f0;
    color: #888;
    border: 1px solid #ddd;
    transition: opacity .1s;
    cursor: default;
}
.cgm-ing:hover { opacity: .8; }
.cgm-ing--bad     { background: #fce8ea !important; color: #b91c1c !important; border-color: #f5a3aa !important; font-weight: 700; }
.cgm-ing--caution { background: #fff0db !important; color: #b45309 !important; border-color: #fbbf5a !important; font-weight: 700; }
.cgm-ing--ok      { background: var(--cgm-safe-bg) !important; color: var(--cgm-safe-text) !important; border-color: rgba(92,138,106,.3) !important; font-weight: 700; }

.cgm-ingredients__raw {
    font-size: .84rem;
    line-height: 1.7;
    color: var(--cgm-text-mid);
    background: var(--cgm-white);
    border-radius: var(--cgm-r);
    padding: 14px 18px;
    border: 1px solid var(--cgm-border);
}

/* Legend */
.cgm-ingredients__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--cgm-stone);
    border-radius: var(--cgm-r);
    border: 1px solid var(--cgm-border);
}
.cgm-ingredients__legend-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cgm-text-light);
    margin-right: 4px;
    flex-basis: 100%;
}
.cgm-ingredients__legend .cgm-ing {
    cursor: default;
    font-size: .7rem;
    padding: 3px 8px;
    pointer-events: none;
}
.cgm-ingredients__legend-desc {
    font-size: .7rem;
    color: var(--cgm-text-mid);
    margin-right: 12px;
}

/* ── Product details table ───────────────────────────────────────────────── */
.cgm-details-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--cgm-white);
    border-radius: var(--cgm-r);
    overflow: hidden;
    box-shadow: none;
    border: 1px solid var(--cgm-border);
}
.cgm-details-table th {
    padding: 12px 18px;
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--cgm-text-light);
    background: var(--cgm-stone);
    width: 180px;
    border-bottom: 1px solid var(--cgm-border);
}
.cgm-details-table td {
    padding: 12px 18px;
    font-size: .9rem;
    color: var(--cgm-text);
    border-bottom: 1px solid var(--cgm-border);
}
.cgm-details-table tr:last-child th,
.cgm-details-table tr:last-child td { border-bottom: none; }
.cgm-details-table code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--cgm-stone);
    padding: 2px 6px;
    border-radius: 2px;
    font-size: .8rem;
    color: var(--cgm-text-mid);
}

/* =============================================================================
   ARCHIVE / CATALOG — перенесено в cgm-card.css + cgm-archive.css (Sprint 24)
   ============================================================================= */
/* → карточки: cgm-card.css §2–9
   → грид, фильтры, пагинация: cgm-archive.css */

/* =============================================================================
   RESPONSIVE — только single-product специфика
   ============================================================================= */
@media (max-width: 480px) {
    .cgm-product-title { font-size: 1.3rem; }
    .cgm-buy-box { flex-direction: column; align-items: flex-start; }
    .cgm-buy-box__amount { font-size: 1.7rem; }
    .cgm-price-table thead { display: none; }
    .cgm-price-table td { display: block; padding: 5px 12px; }
    .cgm-price-table td:first-child { padding-top: 12px; }
    .cgm-price-table td:last-child  { padding-bottom: 12px; }
    .cgm-analysis-grid { grid-template-columns: 1fr; }
    .cgm-badges-row { flex-direction: column; }
    .cgm-badge { min-width: unset; }
}