/* Favourites, the compare bar and the comparison (compare.js, issue #21).
 *
 * z-index map: header 20, #feedbackBtn 25, #planViewer 30, #compareView 50,
 * #cmpViewer 52 (the full-screen image, over the comparison), #enquiryDialog 55
 * (the form can be opened from a comparison column), #feedbackDialog 60.
 * Phone rules live here, not in responsive.css. */

/* ----------------------------------------------- buttons on cards and rows */
.act-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 14px; border: 1px solid rgba(0,0,0,.28); border-radius: 999px;
  background: #fff; color: var(--warm-ink,#000); font-size: 13px; font-weight: 650; cursor: pointer;
}
.act-btn:hover { border-color: #000; }
.act-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.act-btn .ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.act-save[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.act-save[aria-pressed="true"] .ico { fill: var(--accent); }
.act-compare[aria-pressed="true"] { background: var(--warm-ink,#000); border-color: #000; color: #fff; }
.act-btn.compact { width: 44px; min-height: 44px; padding: 0; }
.act-btn.compact .act-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.apt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }

/* A list row: the card, and the two toggles beside it. */
.card-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: stretch; margin-bottom: 8px; }
.card-row > .card { margin: 0; }
.card-row[hidden] { display: none !important; }
.row-actions { display: grid; grid-auto-rows: 1fr; gap: 6px; align-content: center; }
.row-actions .act-btn.compact { width: 40px; min-height: 0; height: 100%; min-height: 40px; border-radius: 12px; }

/* Availability: Saved / Compare shortcuts above the filters. */
.avail-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.avail-tools button { min-height: 40px; padding: 0 14px; border: 1px solid rgba(0,0,0,.28); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 650; cursor: pointer; }
.avail-tools button[aria-pressed="true"] { background: var(--warm-ink,#000); border-color: #000; color: #fff; }
.avail-tools button:hover { border-color: #000; }
.saved-empty { padding: 14px; border: 1px dashed rgba(0,0,0,.3); border-radius: 12px; }

/* ------------------------------------------------------- the selection bar */
.cmp-bar {
  position: fixed; z-index: 27; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  max-width: min(640px, calc(100vw - 24px)); padding: 8px 10px 8px 14px;
  border: 1px solid rgba(0,0,0,.2); border-radius: 18px; background: rgba(255,255,255,.97);
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
.cmp-bar[hidden], .cmp-bar.covered { display: none; }
/* Desktop and a phone on its side: top centre of the scene, under the header.
 * The feedback button is at the bottom there and the viewer draws its camera bar
 * along the bottom edge, so the top is the one strip nothing else uses. */
.cmp-bar[data-mode="top"] { top: calc(var(--header-h, 68px) + 12px); left: calc((100vw - var(--panel-edge, 0px)) / 2); transform: translateX(-50%); }
/* A phone held upright: just above the bottom sheet (compare.js sets `bottom`
 * from the sheet's live height) and clear of #feedbackBtn, which is at the top
 * right of the screen there. Hidden while the sheet is full. */
.cmp-bar[data-mode="sheet"] { left: 8px; right: 8px; max-width: none; z-index: 14; }
.cmp-bar-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 11px; border-radius: 999px; background: var(--warm-paper,#f1f1f1); font-size: 13px; font-weight: 700; }
.cmp-chip button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; font-size: 17px; cursor: pointer; }
.cmp-chip button:hover { background: #ddd; }
.cmp-bar-actions { display: flex; gap: 6px; margin-left: auto; }
.cmp-open { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.cmp-clear { min-height: 40px; padding: 0 12px; border: 0; background: transparent; font-weight: 600; cursor: pointer; text-decoration: underline; }
.cmp-hint, .cmp-notice { font-size: 12.5px; color: var(--warm-muted,#555); }
.cmp-notice:empty { display: none; }
.cmp-bar:has(.cmp-notice:not(:empty)) .cmp-notice { color: #b00020; font-weight: 600; flex-basis: 100%; }

/* --------------------------------------------------------- the comparison */
.cmp-view {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: var(--warm-paper,#f6f6f6); color: var(--warm-ink,#000); --label-w: 150px; --col-min: clamp(300px, 28vw, 420px);
}
.cmp-view[hidden] { display: none; }
html.compare-open { overflow: hidden; }
.cmp-top {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid rgba(0,0,0,.14);
}
.cmp-title { display: flex; align-items: baseline; gap: 10px; }
.cmp-title h2 { margin: 0; font-size: 20px; }
.cmp-title span { color: var(--warm-muted,#666); font-size: 13px; }
.cmp-tabs { display: flex; gap: 4px; padding: 3px; border: 1px solid rgba(0,0,0,.16); border-radius: 999px; }
.cmp-tabs button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 650; cursor: pointer; }
.cmp-tabs button.active { background: var(--warm-ink,#000); color: #fff; }
.cmp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
.cmp-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.cmp-switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.cmp-add select, .cmp-replace select, .cmp-slot select {
  min-height: 40px; max-width: 100%; padding: 0 10px; border: 1px solid rgba(0,0,0,.28); border-radius: 999px; background: #fff; font-size: 13px;
}
.cmp-btn { min-height: 40px; padding: 0 16px; border: 1px solid rgba(0,0,0,.28); border-radius: 999px; background: #fff; font-weight: 650; cursor: pointer; }
.cmp-btn:hover { border-color: #000; }
.cmp-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--warm-paper,#f1f1f1); font-size: 26px; line-height: 1; cursor: pointer; }
.cmp-sharebox { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px; background: #fff; border-bottom: 1px solid rgba(0,0,0,.1); }
.cmp-sharebox input { flex: 1 1 260px; min-width: 0; padding: 9px 12px; border: 1px solid rgba(0,0,0,.25); border-radius: 10px; font-size: 14px; }
.cmp-view > .cmp-notice { flex: none; margin: 0; padding: 8px 24px; background: #fff7e0; font-size: 13px; }
.cmp-view button:focus-visible, .cmp-view select:focus-visible, .cmp-view input:focus-visible, .cmp-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cmp-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.cmp-grid { min-width: calc(var(--label-w) + var(--n) * var(--col-min)); padding-bottom: 40px; }
.cmp-row { display: grid; grid-template-columns: var(--label-w) repeat(var(--n), minmax(var(--col-min), 1fr)); }
.cmp-rowlabel {
  position: sticky; left: 0; z-index: 3; padding: 16px 12px 16px 24px; background: var(--warm-paper,#f6f6f6);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warm-muted,#666);
}
.cmp-heads { position: sticky; top: 0; z-index: 5; background: var(--warm-paper,#f6f6f6); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.cmp-head { padding: 14px 16px 10px; background: #fff; border-left: 1px solid rgba(0,0,0,.1); display: grid; gap: 3px; align-content: start; }
.cmp-id { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmp-num { font-size: 24px; line-height: 1.1; }
.cmp-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--warm-paper,#f1f1f1); font-size: 20px; line-height: 1; cursor: pointer; }
.cmp-x:hover { background: #ddd; }
.cmp-sub { color: var(--warm-muted,#555); font-size: 13px; }
.cmp-price { font-size: 18px; font-weight: 750; }
.cmp-price.sold { color: var(--warm-muted,#5a5a5a); }
.cmp-ref-badge { justify-self: start; padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.cmp-acts { padding: 10px 16px; border-left: 1px solid rgba(0,0,0,.1); background: #fff; display: grid; gap: 8px; align-content: start; }
.cmp-acts-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cmp-acts .act-btn { min-height: 38px; font-size: 13px; }
.act-ask { background: var(--accent); border-color: var(--accent); color: #fff; }
.act-ask:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.act-ref.on { background: var(--warm-ink,#000); border-color: #000; color: #fff; }
.cmp-actions .cmp-rowlabel { background: var(--warm-paper,#f6f6f6); }
.cmp-cell { padding: 18px 16px; border-left: 1px solid rgba(0,0,0,.1); display: grid; gap: 8px; align-content: start; min-width: 0; }
.cmp-cell p { margin: 0; font-size: 14px; line-height: 1.5; }
.cmp-kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--warm-muted,#777); }
.cmp-cell .muted, .cmp-imgkind { font-size: 12.5px; color: var(--warm-muted,#666); }
.cmp-img { display: block; padding: 0; border: 1px solid rgba(0,0,0,.14); border-radius: 12px; overflow: hidden; background: #fff; cursor: zoom-in; }
.cmp-img img { display: block; width: 100%; height: auto; max-height: 56vh; object-fit: cover; }
.cmp-img.plan img { object-fit: contain; background: #fff; }
.cmp-img.schematic svg { display: block; width: 100%; height: auto; }
.cmp-empty { display: grid; place-items: center; min-height: 160px; padding: 16px; border: 1px dashed rgba(0,0,0,.3); border-radius: 12px; color: var(--warm-muted,#666); font-size: 14px; text-align: center; }
.cmp-facts { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.cmp-row.cmp-heads + .cmp-row.cmp-actions { border-bottom: 1px solid rgba(0,0,0,.12); }
/* Key figures: aligned rows, one value per column. */
.cmp-figures .cmp-row { border-bottom: 1px solid rgba(0,0,0,.1); background: #fff; }
.cmp-figures .cmp-row.cmp-heads, .cmp-figures .cmp-row.cmp-actions { background: #fff; }
.cmp-figures .cmp-rowlabel { background: #fff; padding-top: 18px; }
.cmp-fig strong { font-size: 17px; }
.cmp-fig strong.missing { color: var(--warm-muted,#777); font-weight: 500; font-style: italic; }
.cmp-diff { display: inline-block; justify-self: start; padding: 2px 9px; border-radius: 999px; background: #f4e6c8; color: #5b4310; font-size: 12.5px; font-weight: 650; }
.cmp-none { margin: 40px 24px; font-size: 15px; color: var(--warm-muted,#555); }

/* --------------------------------------------------- full-screen image */
.cmpz { position: fixed; inset: 0; z-index: 52; display: flex; flex-direction: column; background: #111; color: #fff; }
.cmpz[hidden] { display: none; }
.cmpz-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(0,0,0,.85); }
.cmpz-bar button { min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: transparent; color: #fff; font-size: 15px; cursor: pointer; }
.cmpz-bar button:hover { background: rgba(255,255,255,.15); }
.cmpz-bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmpz-step { font-size: 26px !important; line-height: 1; }
.cmpz.single .cmpz-step { visibility: hidden; }
.cmpz-id { display: grid; gap: 1px; min-width: 0; flex: 1; }
.cmpz-name { font-size: 20px; }
.cmpz-meta, .cmpz-count { font-size: 12.5px; color: #cfcfcf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmpz-controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cmpz-zoom { min-width: 48px; text-align: center; font-size: 13px; color: #ddd; }
.cmpz-stage { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: grab; }
.cmpz-stage:active { cursor: grabbing; }
.cmpz-canvas { transform-origin: center; max-width: 100%; max-height: 100%; display: grid; place-items: center; will-change: transform; }
.cmpz-canvas img { max-width: 100vw; max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); user-select: none; -webkit-user-drag: none; }
.cmpz-canvas svg { width: min(92vw, 900px); height: auto; background: #fff; border-radius: 8px; }
.cmpz-empty { padding: 40px; border: 1px dashed rgba(255,255,255,.4); border-radius: 12px; color: #ddd; }

/* ------------------------------------------------------------------ phone */
/* Two columns, with a selector over each to swap the other shortlisted homes in
 * (compare.js shows two ids at a time under 721px). No label column: each row
 * carries its own label across the top. */
@media (max-width: 720px) {
  .cmp-view { --label-w: 0px; --col-min: 0px; }
  .cmp-top { padding: 10px 12px; gap: 8px 10px; }
  .cmp-title h2 { font-size: 17px; }
  .cmp-tabs { order: 3; width: 100%; }
  .cmp-tabs button { flex: 1; padding: 0 6px; font-size: 13px; }
  .cmp-tools { margin-left: auto; }
  .cmp-tools .cmp-add select { max-width: 130px; }
  .cmp-sharebox, .cmp-view > .cmp-notice { padding-inline: 12px; }
  .cmp-grid { min-width: 0; padding-bottom: 80px; }
  .cmp-row { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
  .cmp-rowlabel { grid-column: 1 / -1; position: static; padding: 10px 12px 4px; }
  .cmp-heads .cmp-rowlabel, .cmp-actions .cmp-rowlabel { display: none; }
  .cmp-head { padding: 10px 10px 8px; }
  .cmp-num { font-size: 20px; }
  .cmp-price { font-size: 15px; }
  .cmp-acts { padding: 8px 8px; }
  .cmp-acts-row { gap: 6px; }
  .cmp-acts .act-btn { width: 100%; padding: 0 8px; font-size: 12px; }
  .cmp-cell { padding: 12px 10px; }
  .cmp-replace select, .cmp-slot select { width: 100%; }
  .cmp-slot { display: block; }
  .cmp-figures .cmp-rowlabel { background: #fff; }
  .cmpz-bar { padding: 8px 10px; gap: 6px; }
  .cmpz-name { font-size: 17px; }
  .cmpz-bar button { min-width: 40px; padding: 0 9px; }
  .cmp-img img { max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) { .cmp-bar, .cmp-view, .cmpz { transition: none; animation: none; } }
@media print { .cmp-bar, .cmp-view, .cmpz { display: none !important; } }
