/*
 * Compare tool (inc/compare.php, js/compare.js).
 *
 * On /compare/: a Compare toggle on every firm and program card, drawn like the
 * card's .firm-badge, and the compare bar, drawn like the firm profile's phone
 * trade bar. These use the plain values of css/spf-style.css, because the UI
 * kit tokens do not load on that page.
 *
 * On /compare/side-by-side/: the firm profile's parts (css/firm-profile.css)
 * with a few additions for the comparison tables. Classes are prefixed cmp-.
 */

/* ---------- Compare toggle on each card ---------- */
.cmp-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmp-add {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 8px 10px; border: 0; border-radius: 8px; background-color: #e3e3e3; color: #333333; cursor: pointer;
  font-family: "Neue Montreal", Helvetica, sans-serif; font-size: 12px; font-weight: 700; line-height: 1.2;
  transition: background-color .2s ease, color .2s ease;
}
.cmp-add:hover { background-color: #d6d6d6; }
.cmp-add:focus-visible { outline: 2px solid #ff6b00; outline-offset: 2px; }
.cmp-add__box { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border: 1px solid #d4d6d9; border-radius: 4px; background: #ffffff; }
.cmp-add__box svg { width: 10px; height: 10px; opacity: 0; }
.cmp-add[aria-pressed="true"] { background-color: #333333; color: #ffffff; }
.cmp-add[aria-pressed="true"] .cmp-add__box { border-color: #ff6b00; background: #ff6b00; }
.cmp-add[aria-pressed="true"] .cmp-add__box svg { opacity: 1; }
.cmp-add[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.firm-detail-card.cmp-picked { box-shadow: inset 0 0 0 2px #ff6b00; }

/* ---------- Compare bar ---------- */
.cmp-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
  background: #ffffff; border-top: 1px solid #00000026; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(110%); transition: transform .25s ease;
}
.cmp-bar.is-visible { transform: translateY(0); }
.cmp-bar__in { max-width: 1360px; margin: 0 auto; padding: 14px 40px; display: flex; align-items: center; gap: 16px; }
.cmp-bar__title { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.cmp-bar__title strong { font-family: "Neue Montreal Display", "Neue Montreal", Helvetica, sans-serif; font-size: 22px; line-height: 26px; font-weight: 700; color: #333333; }
.cmp-bar__title span { font-size: 13px; line-height: 16px; color: #555555; }
.cmp-bar__slots { display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.cmp-chip { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 6px 8px 6px 6px; border-radius: 8px; background-color: #f4f4f4; font-size: 14px; line-height: 18px; font-weight: 700; color: #333333; }
.cmp-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: #ffffff; }
.cmp-chip > span { min-width: 0; max-width: 220px; }
.cmp-chip > span, .cmp-chip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-chip small { display: block; font-size: 12px; font-weight: 500; color: #555555; }
.cmp-chip button { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 1px solid #d4d6d9; border-radius: 50%; background: #ffffff; color: #333333; font-size: 14px; line-height: 1; cursor: pointer; }
.cmp-chip button:hover { border-color: #ff6b00; color: #ff6b00; }
.cmp-chip--empty { padding: 6px 14px; min-height: 40px; background: transparent; box-shadow: inset 0 0 0 1px #d4d6d9; color: #91959d; font-weight: 500; }
.cmp-bar .btn-trade { width: auto; flex-shrink: 0; padding: 12px 28px; }
.cmp-bar .btn-trade[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.cmp-bar__clear { flex-shrink: 0; border: 0; background: none; padding: 0; font-size: 14px; font-weight: 500; color: #555555; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cmp-bar__clear:hover { color: #ff6b00; }
/* Room for the bar under the footer while it is open. */
body.cmp-bar-open { padding-bottom: 76px; }

/* ---------- Side-by-side page ---------- */
.cmp-page [hidden] { display: none !important; }
.cmp-page { padding-bottom: 40px; }
.cmp-hero { display: flex; flex-direction: column; gap: 22px; padding: 8px 0 40px; }
.cmp-logos { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Logos sit whole inside a white tile with room around them (BugHerd #256),
   instead of filling it edge to edge and losing their corners. */
.cmp-logos .pf-logo { box-sizing: border-box; width: 72px; height: 72px; padding: 12px; border: 1px solid var(--line, #d4d6d9); border-radius: var(--radius-16); background: var(--white, #fff); object-fit: contain; object-position: center; }
.cmp-logos__vs { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--grey-400); }
.cmp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cmp-facts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cmp-facts--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cmp-facts--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cmp-facts--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cmp-facts--1 { grid-template-columns: minmax(0, 1fr); }

.cmp-nav { position: relative; }
.cmp-nav .pf-nav { padding-right: 260px; }
.cmp-diff { position: absolute; right: 0; top: 0; height: 44px; font-size: 16px; gap: 10px; }

.cmp-matrix { table-layout: fixed; min-width: 820px; }
.cmp-matrix--4 { min-width: 1080px; }
.cmp-matrix thead th { text-align: left; vertical-align: top; padding: 16px; white-space: normal; }
.cmp-matrix thead th:first-child { width: 240px; vertical-align: bottom; }
.cmp-matrix th[scope="row"] { width: 240px; vertical-align: top; }
.cmp-matrix td { white-space: normal; text-align: left; vertical-align: top; padding: 16px; font-size: 16px; line-height: 23px; color: var(--ink-2); overflow-wrap: anywhere; }
.cmp-matrix td + td { box-shadow: inset 1px 0 0 var(--rule-soft); }
.cmp-matrix td.is-num b { display: block; font-size: 17px; line-height: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cmp-matrix td.is-num .cmp-sub { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-3); }
.cmp-matrix td .spf-label { margin-top: 8px; display: flex; width: fit-content; }
.cmp-matrix td .spf-rating { font-size: 14px; }
.cmp-matrix td .pf-platforms { gap: 6px; }
.cmp-matrix td .pf-platform { font-size: 13px; padding: 6px 10px 6px 6px; }
.cmp-matrix tr.is-same td { color: var(--ink-3); }
.cmp-hide-same .cmp-matrix tr.is-same { display: none; }
.cmp-country { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; }
.cmp-country img { width: 20px; height: 13px; border-radius: 2px; object-fit: cover; }

.cmp-th { display: flex; flex-direction: column; gap: 12px; }
.cmp-th__firm { display: flex; align-items: center; gap: 10px; }
.cmp-th__firm img { width: 40px; height: 40px; border-radius: var(--radius-8); object-fit: cover; background: var(--white); flex-shrink: 0; }
.cmp-th__name { flex: 1; min-width: 0; font-size: 16px; line-height: 20px; font-weight: 700; color: var(--white); }
.cmp-th__name a { color: inherit; text-decoration: none; }
.cmp-th__name a:hover { color: var(--orange); }
.cmp-th__name span { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; font-weight: 500; color: rgba(255, 255, 255, .7); }
.cmp-th__x { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 1px solid rgba(255, 255, 255, .3); border-radius: 50%; background: transparent; color: var(--white); font-size: 14px; line-height: 1; text-decoration: none; cursor: pointer; flex-shrink: 0; }
.cmp-th__x:hover { border-color: var(--orange); color: var(--orange); }
.cmp-th .spf-btn { padding: 10px 16px; font-size: 14px; }

.cmp-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
tr.is-open .cmp-clamp { display: block; -webkit-line-clamp: unset; }
.cmp-more { margin-top: 6px; padding: 0; border: 0; background: none; font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 700; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cmp-more:hover { color: var(--orange); }
.cmp-note { max-width: 760px; }

@media (max-width: 1279px) {
  .cmp-facts, .cmp-facts--4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .cmp-bar__in { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .cmp-bar__title { display: none; }
  /* The picks get a row of their own, so more than one shows on a phone. */
  .cmp-bar__slots { flex-basis: 100%; }
  .cmp-chip--empty { display: none; }
  .cmp-bar .btn-trade { flex: 1; }
  body.cmp-bar-open { padding-bottom: 128px; }
  .cmp-logos .pf-logo { width: 52px; height: 52px; padding: 8px; border-radius: var(--radius-12); }
  .cmp-facts, .cmp-facts--4, .cmp-facts--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp-nav .pf-nav { padding-right: 0; margin-bottom: 16px; }
  .cmp-diff { position: static; height: auto; margin-bottom: 28px; }
  .cmp-matrix, .cmp-matrix--4 { min-width: 640px; }
  .cmp-matrix--4 { min-width: 820px; }
  .cmp-matrix thead th:first-child, .cmp-matrix th[scope="row"] { width: 130px; }
  .cmp-matrix td, .cmp-matrix thead th { padding: 12px 10px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .cmp-bar { transition: none; } }
