/* ============================================================
   COMPARE — Monitor side-by-side comparison
   3 columns desktop · 2 columns tablet · 1 column + horizontal
   scroll on mobile, with sticky spec-label gutter on the left.
   ============================================================ */

.compare-page {
  padding: 2rem 0 4rem;
}

.compare-page__intro {
  margin-bottom: 1.5rem;
}

.compare-page__intro h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.compare-page__intro p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---- Picker bar (sticky) ---- */

.compare-pickers {
  position: sticky;
  top: var(--header-height);
  z-index: 30;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 0;
}

.compare-pickers__row {
  display: grid;
  grid-template-columns: 220px repeat(3, 1fr);
  gap: 1rem;
  align-items: center;
}

.compare-pickers__label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compare-pickers__select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
}

.compare-pickers__select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---- Comparison grid ---- */

.compare-grid {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}

.compare-grid__scroll {
  overflow-x: auto;
}

.compare-row {
  display: grid;
  grid-template-columns: 220px repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}

.compare-row:last-child {
  border-bottom: none;
}

.compare-row__label,
.compare-row__cell {
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-word;
}

.compare-row__label {
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 1;
}

.compare-row__cell {
  color: var(--text-primary);
  border-right: 1px solid var(--border);
}

.compare-row__cell:last-child {
  border-right: none;
}

.compare-row__cell--empty {
  color: var(--text-muted);
}

/* Format specifics — framerate detail in parens renders small + muted so the
   format names read first. Wraps freely (narrow compare columns). */
.compare-row__cell .fr,
.compare-row__label .fr {
  font-size: 0.82em;
  color: var(--text-muted);
}

/* Section header rows */
.compare-row--section {
  background: var(--bg-elevated);
}

.compare-row--section .compare-row__label,
.compare-row--section .compare-row__cell {
  background: var(--bg-elevated);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  padding: 0.85rem 1rem;
}

/* Header row (model name / price / link) */
.compare-row--header .compare-row__label {
  background: var(--bg-card);
  color: transparent;
}

.compare-row--header .compare-row__cell {
  background: var(--bg-card);
  padding: 1.25rem 1rem;
}

.compare-header__sku {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.compare-header__name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.compare-header__price {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.compare-header__link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
  transition: opacity var(--duration) var(--ease);
}

.compare-header__link:hover {
  opacity: 0.7;
}

/* Yes/No icons */
.compare-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

.compare-icon--yes {
  color: var(--success);
}

.compare-icon--no {
  color: var(--danger);
}

/* No pill styling on .compare-tag — render as plain inline text alongside
   the check/x icons. Class kept on the span in case JS or future styling
   needs a hook, but visually it's just text. */
.compare-tag {
  font-size: inherit;
  color: inherit;
}

/* Empty / no-product state */
.compare-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

/* ---- Mobile differences toggle — desktop hides it ---- */
.compare-switch { display: none; }

.compare-switch__diff {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.compare-switch__diff-input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ---- Responsive ---- */

@media (max-width: 960px) {
  /* Two product columns on tablet, scroll the third */
  .compare-pickers__row,
  .compare-row {
    grid-template-columns: 180px repeat(3, minmax(220px, 1fr));
    min-width: 800px;
  }
  .compare-pickers {
    overflow-x: auto;
  }
}

@media (max-width: 767px) {
  /* Phone: 2 monitors locked on screen at once (or 1 if only one picked),
     NO horizontal scroll. A pill bar switches which two of the three are shown;
     the product header row sticks under the site header as you scroll specs. */
  .compare-page__intro h1 {
    font-size: 1.5rem;
  }

  /* Pickers stack full-width and drop out of the sticky zone — the compact
     product header row does the sticking instead, so it can't fight the picker.
     Only two monitors compare on mobile, so the third picker is hidden. */
  .compare-pickers {
    position: static;
    padding: 0.85rem 0;
  }
  .compare-pickers__row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    min-width: 0;
  }
  .compare-pickers__label {
    display: none;
  }
  .compare-pickers__select[data-slot="2"] {
    display: none;
  }

  /* Differences-only toggle. */
  .compare-switch {
    display: flex;
    align-items: center;
    margin-top: 1rem;
  }

  /* Kill the horizontal scroll container so sticky can reach the viewport
     and columns simply fit the width. */
  .compare-grid {
    margin-top: 0.85rem;
    overflow: visible;
  }
  .compare-grid__scroll {
    overflow-x: visible;
  }

  /* Label gutter + up to 2 equal product tracks, sized to fit. */
  .compare-row {
    grid-template-columns: var(--compare-label-w, 100px) repeat(var(--compare-vis, 2), minmax(0, 1fr));
    min-width: 0;
  }

  /* Hide inactive / empty product columns (compare.js toggles hide-col-N). */
  .compare-grid.hide-col-0 [data-col="0"],
  .compare-grid.hide-col-1 [data-col="1"],
  .compare-grid.hide-col-2 [data-col="2"] {
    display: none;
  }

  /* Differences-only: hide matching rows + sections left empty by the filter. */
  .compare-grid.is-diff-only .compare-row.is-same,
  .compare-grid.is-diff-only .compare-row--section.is-empty-section {
    display: none;
  }

  .compare-row__label,
  .compare-row__cell {
    padding: 0.6rem;
    font-size: 0.84rem;
  }

  /* Section titles span the full width instead of cramming into the narrow
     label gutter (which broke them mid-word, e.g. "SPECIFICATI ONS"). */
  .compare-row--section .compare-row__label {
    grid-column: 1 / -1;
    border-right: none;
    word-break: normal;
    overflow-wrap: normal;
    padding: 0.65rem 0.6rem;
  }
  .compare-row--section .compare-row__cell {
    display: none;
  }

  /* Sticky compact product header. */
  .compare-row--header {
    position: sticky;
    top: var(--header-height);
    z-index: 5;
  }
  .compare-row--header .compare-row__cell {
    padding: 0.8rem 0.6rem;
  }
  .compare-header__name {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
  }
  .compare-header__price {
    margin-bottom: 0.4rem;
  }
  .compare-header__link {
    font-size: 0.8rem;
  }
}
