/* ═══════════════════════════════════════════════════════════════════════
   PRODUCT COMPARISON — page-scoped rules for Pages/Compare.cshtml only.
   Loaded LAST via that page's own Styles section, after the 5 shared
   layers — composes tokens.css/theme.css/components.css (reuses .btn,
   .badge, .price*, .empty-state, .alert as-is) and never redeclares them.
   The floating "N منتجات للمقارنة" bar is styled separately, INSIDE
   wwwroot/js/compare.js (injected once at runtime) — it must render
   correctly on any page a data-compare-add button appears on, most of
   which never load this stylesheet at all. See that file's header comment.
   ═══════════════════════════════════════════════════════════════════════ */

.cmp { padding-block: var(--space-2) var(--space-16); }

.cmp__title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--ink);
    margin-block: var(--space-2) var(--space-6);
}

.cmp__notice { margin-block-end: var(--space-6); }

.cmp-visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Guidance state — fewer than two products (mission: never an empty grid) ── */
.cmp-guidance p { max-width: 52ch; }

/* ── Comparison strip — one card per requested id, including failed ones,
   so a removed/unavailable product still occupies its own column instead
   of silently vanishing (Q42). Column count is set inline per-page via
   --cmp-cols (2–4), so this file encodes no product-count assumption. ── */
.cmp-strip {
    display: grid;
    grid-template-columns: repeat(var(--cmp-cols, 2), minmax(200px, 1fr));
    gap: var(--space-5);
    margin-block-end: var(--space-8);
}
@media (max-width: 768px) { /* --bp-md */
    .cmp-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) { /* --bp-xs */
    .cmp-strip { grid-template-columns: 1fr; }
}

.cmp-col {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: var(--card-border, 1px solid var(--line));
    border-radius: var(--card-radius, var(--radius-md));
    overflow: hidden;
}

.cmp-col__remove {
    position: absolute;
    top: var(--space-2); inset-inline-end: var(--space-2);
    z-index: 2;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full);
    background: var(--paper);
    box-shadow: var(--shadow-sm);
    color: var(--ink-soft);
}
.cmp-col__remove:hover { color: var(--danger-base); background: var(--danger-tint); }

.cmp-col__media {
    display: block;
    aspect-ratio: var(--ratio-square);
    background: var(--tray);
}
.cmp-col__media img { width: 100%; height: 100%; object-fit: contain; padding: var(--space-6); }

.cmp-col__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.cmp-col__brand { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--brand); margin: 0; }
.cmp-col__title {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--ink);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}
.cmp-col__price { margin-block: var(--space-1); }
.cmp-col__availability { margin-block-end: var(--space-1); }
.cmp-col__actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: auto; }
.cmp-col__actions .btn { width: 100%; }

.cmp-col__state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--ink-soft);
    min-height: 220px;
}
.cmp-col__state--error { color: var(--danger-base); }

/* ── Specification table — the reason this screen exists. Differing rows
   are highlighted with the warning tint (an attention colour, not an error
   one — a difference is information, not a problem). ─────────────────── */
.cmp-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }

.cmp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}
.cmp-table th, .cmp-table td {
    padding: var(--space-3) var(--space-4);
    text-align: start;
    border-block-end: 1px solid var(--line);
    white-space: normal;
}
.cmp-table thead th {
    background: var(--paper-muted);
    font-weight: var(--weight-bold);
    color: var(--ink);
    position: sticky;
    top: 0;
}
.cmp-table__label-col {
    font-weight: var(--weight-semibold);
    color: var(--ink-soft);
    white-space: nowrap;
    background: var(--paper-muted);
}
.cmp-table tbody tr:last-child th,
.cmp-table tbody tr:last-child td { border-block-end: 0; }

.cmp-table tr.is-diff td,
.cmp-table tr.is-diff th.cmp-table__label-col {
    background: var(--warning-tint);
}
.cmp-table tr.is-diff td { color: var(--warning-base); font-weight: var(--weight-semibold); }
