/* The breed comparison tool on /compare and the picker on each
 * /compare/<a>-vs-<b> page (src/assets/compare.js). Page specific rules
 * only, every colour and font from the site's custom properties. The first
 * breed is drawn in --brand, the second in --amber. */

.cmp-tool { margin: 0.4rem 0 1.6rem; --cmp-a: var(--brand); --cmp-b: var(--amber); }
/* In dark mode the rebrand made --brand biscuit, the same family as --amber,
 * so the second breed takes sky to stay told apart. */
@media (prefers-color-scheme: dark) {
  .cmp-tool { --cmp-b: var(--sky); }
}
.cmp-tool .field > label { font-family: var(--font-display); }

.cmp-pick {
  display: grid; gap: 0.6rem; align-items: end;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.cmp-field { min-width: 0; }
.cmp-swap {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-soft); cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-2) var(--ease);
}
.cmp-swap svg { width: 20px; height: 20px; }
.cmp-swap:hover { border-color: var(--brand); color: var(--brand-ink); }
.cmp-swap:active { transform: rotate(180deg); }
@media (max-width: 639px) {
  .cmp-pick { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "a swap" "b swap"; align-items: center; }
  .cmp-pick > .cmp-field:first-child { grid-area: a; }
  .cmp-pick > .cmp-field:last-child { grid-area: b; }
  .cmp-swap { grid-area: swap; transform: rotate(90deg); }
  .cmp-swap:active { transform: rotate(270deg); }
}

.cmp-quick { margin-top: 0.9rem; }
.cmp-quick-label { display: block; font-size: 0.82rem; font-weight: 650; color: var(--ink-soft); }
.cmp-quick .chip-row { margin: 0.4rem 0 0; }
.cmp-quick .chip { text-decoration: none; }
.cmp-status { margin: 0.9rem 0 0; }
.cmp-status[hidden] { display: none; }

/* Result */
.cmp-result { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1.1rem; }
.cmp-result[hidden], .cmp-result:empty { display: none; }
.cmp-result h3 { font-size: 1.08rem; margin: 1.5rem 0 0.6rem; }
.cmp-title { font-size: 1.3rem; margin: 0 0 0.8rem; overflow-wrap: anywhere; }

.cmp-heads {
  display: grid; gap: 0.5rem; align-items: start;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.cmp-head { margin: 0; min-width: 0; }
.cmp-photo {
  display: block; aspect-ratio: 3 / 2; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-alt); border: 3px solid var(--cmp-a);
}
.cmp-b .cmp-photo { border-color: var(--cmp-b); }
.cmp-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cmp-photo-none { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; color: var(--ink-faint); }
.cmp-photo-none svg { width: 40%; height: 40%; }
.cmp-head figcaption { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.45rem; min-width: 0; }
.cmp-name { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.cmp-sub { font-size: 0.82rem; color: var(--ink-soft); line-height: 1.35; }
.cmp-credit { font-size: 0.72rem; color: var(--ink-faint); line-height: 1.35; overflow-wrap: anywhere; }
.cmp-credit a { color: inherit; }
.cmp-vs {
  align-self: center; margin-top: -2.2rem; font-family: var(--font-display); font-weight: 800;
  font-size: 0.85rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em;
}

.cmp-summary {
  margin-top: 1.1rem; padding: 0.9rem 1rem; border-radius: var(--radius-sm);
  background: var(--brand-soft); border: 1px solid var(--brand-line);
}
.cmp-result .cmp-summary h3 { margin: 0 0 0.35rem; font-size: 0.98rem; }
.cmp-summary p { margin: 0 0 0.45rem; }
.cmp-summary p:last-child { margin-bottom: 0; }
.cmp-full a { font-weight: 700; }

/* Bars: one row per measure or trait, one line per breed. */
.cmp-rows { display: grid; gap: 0.35rem; }
.cmp-row { padding: 0.55rem 0; border-bottom: 1px solid var(--line); min-width: 0; }
.cmp-row:last-child { border-bottom: 0; }
.cmp-row-name { font-weight: 700; font-size: 0.92rem; margin-bottom: 0.3rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; }
.cmp-diff-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem; border-radius: var(--radius-pill);
  background: var(--brand-soft); color: var(--brand-ink); border: 1px solid var(--brand-line);
}
.cmp-bar {
  display: grid; align-items: center; gap: 0.25rem 0.6rem; min-width: 0; padding: 0.12rem 0;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) minmax(4.6rem, auto);
}
.cmp-range .cmp-bar { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) minmax(7.5rem, auto); }
.cmp-who {
  display: flex; align-items: center; gap: 0.4rem; min-width: 0;
  font-size: 0.82rem; color: var(--ink-soft);
}
.cmp-bar .cmp-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cmp-dot {
  display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; flex: none;
  background: var(--cmp-a); vertical-align: -0.05rem; margin-right: 0.35rem;
}
.cmp-dot-b { background: var(--cmp-b); border-radius: 50%; }
.cmp-val { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cmp-unrated .cmp-val { font-weight: 500; color: var(--ink-faint); font-style: italic; }

.cmp-pips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; min-width: 0; }
.cmp-pips i { display: block; height: 12px; border-radius: 3px; background: var(--line); }
.cmp-a .cmp-pips i.on { background: var(--cmp-a); }
.cmp-b .cmp-pips i.on { background: var(--cmp-b); }
.cmp-b .cmp-pips i { border-radius: var(--radius-pill); }
.cmp-unrated .cmp-pips i { background: transparent; border: 1px dashed var(--line-strong); }

.cmp-track {
  position: relative; display: block; height: 12px; border-radius: var(--radius-pill);
  background: var(--line); min-width: 0;
}
.cmp-span { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-pill); background: var(--cmp-a); }
.cmp-b .cmp-span { background: var(--cmp-b); }
.cmp-unrated .cmp-track { background: transparent; border: 1px dashed var(--line-strong); }

@media (max-width: 639px) {
  /* Traits keep one line per breed: name, pips, score. Measures put the
   * longer value beside the name and the bar under them. */
  .cmp-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 7.5rem) 3.6rem; gap: 0.5rem; padding: 0.15rem 0; }
  .cmp-unrated { grid-template-columns: minmax(0, 1fr) minmax(0, 6rem) 4.6rem; }
  .cmp-range .cmp-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who val" "bar bar";
    gap: 0.15rem 0.5rem; padding: 0.2rem 0;
  }
  .cmp-range .cmp-bar .cmp-who { grid-area: who; }
  .cmp-range .cmp-bar .cmp-val { grid-area: val; }
  .cmp-range .cmp-bar .cmp-track { grid-area: bar; }
  .cmp-row { padding: 0.45rem 0; }
  .cmp-pips { gap: 3px; }
  .cmp-quick .chip-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.35rem; scrollbar-width: thin; }
  .cmp-quick .chip { flex: none; }
  .cmp-heads { gap: 0.35rem; }
  .cmp-vs { font-size: 0.72rem; }
  .cmp-name { font-size: 0.95rem; }
}

.cmp-group { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 1.1rem 0 0.1rem; }
.cmp-scale { margin-top: -0.2rem; }
.cmp-facts { margin: 1rem 0 0.2rem; }
.cmp-facts table { width: 100%; table-layout: fixed; }
.cmp-facts th, .cmp-facts td { overflow-wrap: break-word; padding: 0.6rem 0.65rem; font-size: 0.92rem; }
.cmp-facts thead th { font-weight: 700; text-transform: none; letter-spacing: normal; white-space: normal; vertical-align: bottom; }
.cmp-facts th[scope="row"] { width: 30%; }
.cmp-facts thead th:first-child { width: 30%; }
.cmp-facts thead .cmp-who { display: inline; font-size: 0.85rem; color: var(--ink); }
.cmp-sources { margin-top: 1rem; }
.cmp-guides { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-weight: 650; }
.cmp-share { margin-top: 1rem; }

/* The picker on each comparison page */
.cmp-jump { padding-top: 0.9rem; padding-bottom: 0.9rem; }
.cmp-jump-title { font-family: var(--font-display); font-weight: 800; margin: 0 0 0.6rem; }
.cmp-jump-go { margin-top: 0.8rem; display: flex; justify-content: flex-end; }
@media (max-width: 639px) { .cmp-jump-go .btn { width: 100%; } }

/* Popular comparisons grid on /compare */
.cmp-pop-grid {
  list-style: none; padding: 0; margin: 0.8rem 0 1.6rem;
  display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14.5rem), 1fr));
}
.cmp-pop-grid li { margin: 0; min-width: 0; }
.cmp-pop {
  display: flex; align-items: center; gap: 0.65rem; height: 100%; min-width: 0;
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); text-decoration: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.cmp-pop:hover { border-color: var(--brand-line); box-shadow: var(--shadow-sm); color: var(--ink); }
.cmp-pop-imgs { display: flex; flex: none; }
.cmp-pop-imgs img, .cmp-pop-none {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block;
  border: 2px solid var(--surface); background: var(--surface-alt);
}
.cmp-pop-imgs > :last-child { margin-left: -10px; }
.cmp-pop-txt { min-width: 0; font-size: 0.9rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.cmp-pop-vs { color: var(--ink-faint); font-weight: 500; }
/* The pair already names both breeds, so the jump picker's labels are for
 * screen readers only and the panel stays short above the write up. */
.cmp-jump .cmp-field > label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.cmp-jump .cmp-pick { align-items: center; }

/* Nothing picked yet is an empty state, so Pip sits on it (brand rule:
 * Pip on marketing pages and empty states, calm cards inside tools). */
.cmp-status.is-empty { text-align: center; }
.cmp-status.is-empty::before {
  content: ""; display: block; width: 56px; height: 54px; margin: 0 auto 0.4rem;
  background: url("/art/pip-happy.svg") center / contain no-repeat;
}
