body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
}

.font-display {
  font-family: 'Söhne', 'Inter', 'Avenir Next', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.font-mono {
  font-feature-settings: "tnum" 1, "cv01" 1;
}

*:focus-visible {
  outline: 2px solid #0891b2;
  outline-offset: 2px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.prose h2 {
  font-family: 'Söhne', 'Inter', 'Avenir Next', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: #0f172a;
  scroll-margin-top: 6rem;
}

.prose h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #0f172a;
  scroll-margin-top: 6rem;
}

.prose p {
  line-height: 1.75;
  margin-bottom: 1rem;
  color: #334155;
}

.prose ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose ol {
  list-style: decimal;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose li {
  line-height: 1.75;
  color: #334155;
  margin-bottom: 0.25rem;
}

.prose a {
  color: #0891b2;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: #155e75;
}

.glossary-term {
  border-bottom: 1px dotted #22d3ee;
  cursor: help;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ------------------------------------------------------------------ *
 * Responsive comparison table (.cmp-table)
 *
 * Wide data tables would otherwise force horizontal scrolling on small
 * screens. Instead, below the `md` breakpoint each <tr> collapses into a
 * stacked card and each <td> becomes a label/value row driven by the
 * cell's data-label attribute. No overflow-x, no frozen columns, no fixed
 * min-widths - nothing ever exceeds the viewport width.
 * ------------------------------------------------------------------ */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
}

.cmp-table th,
.cmp-table td {
  text-align: left;
}

.cmp-table th[scope="col"].text-center,
.cmp-table td[data-cell="go"] {
  text-align: center;
}

/* Mobile: cards. Default state, overridden at >=768px below. */
@media (max-width: 767px) {
  .cmp-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .cmp-table,
  .cmp-table tbody,
  .cmp-table tr,
  .cmp-table td {
    display: block;
    width: 100%;
  }

  .cmp-table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    padding: 0.875rem 1rem 1rem;
    margin-bottom: 0.75rem;
  }

  .cmp-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0;
    border: 0;
    text-align: right;
    min-width: 0;
  }

  .cmp-table td > * {
    min-width: 0;
  }

  .cmp-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    text-align: left;
  }

  /* Cells without a label (or that should fill the row) span full width. */
  .cmp-table td[data-label=""]::before,
  .cmp-table td:not([data-label])::before {
    content: "";
  }

  /* Lift the price to the top of the card as the headline figure. */
  .cmp-table td[data-cell="price"] {
    order: -1;
    padding-bottom: 0.6rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-light);
    align-items: baseline;
  }

  .cmp-table td[data-cell="price"]::before {
    align-self: center;
  }

  .cmp-table td[data-cell="provider"] {
    align-items: center;
  }

  /* The "Go"/visit action stretches full width as a tappable button row. */
  .cmp-table td[data-cell="go"] {
    justify-content: stretch;
    padding-top: 0.7rem;
    margin-top: 0.4rem;
    border-top: 1px solid var(--color-border-light);
  }

  .cmp-table td[data-cell="go"]::before {
    content: "";
  }

  .cmp-table td[data-cell="go"] a {
    width: 100%;
    justify-content: center;
  }

  /* Let multi-value cells (specs) wrap to the right column without overflow. */
  .cmp-table td[data-cell="specs"] {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  /* The comparison "dimension" name leads each card as a full-width heading. */
  .cmp-table td[data-cell="dimension"] {
    order: -1;
    justify-content: flex-start;
    text-align: left;
    padding-bottom: 0.5rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
  }

  .cmp-table td[data-cell="dimension"]::before {
    content: "";
  }
}

/* Desktop: normal table cells. */
@media (min-width: 768px) {
  .cmp-table thead tr {
    border-bottom: 1px solid var(--color-border);
  }

  .cmp-table tbody tr {
    border-top: 1px solid var(--color-border-light);
  }

  .cmp-table tbody tr:first-child {
    border-top: 0;
  }

  .cmp-table td::before {
    display: none;
  }
}

/* ------------------------------------------------------------------ *
 * Price chart polish
 * ------------------------------------------------------------------ */
.price-chart-line {
  stroke: #0891b2;
}

.price-chart-area {
  fill: url(#priceChartFill);
}

.price-chart-grid {
  stroke: var(--color-border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.price-chart-dot {
  fill: #0891b2;
}

/* ------------------------------------------------------------------ *
 * Filter bar disclosure - collapses on mobile, always open on md+
 * ------------------------------------------------------------------ */
.filter-disclosure > summary::-webkit-details-marker {
  display: none;
}

@media (min-width: 768px) {
  /* Force the controls visible on desktop even if the user collapsed them
     on a narrow viewport before resizing. */
  .filter-disclosure > div {
    display: grid !important;
  }
}

/* ------------------------------------------------------------------ *
 * Touch targets - on coarse pointers (touch), small inline controls get
 * a >=44px hit area so they meet WCAG 2.5.5 without inflating desktop
 * density. Applied via the .touch-target class on compact table buttons
 * and filter chips.
 * ------------------------------------------------------------------ */
@media (pointer: coarse) {
  .touch-target {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ------------------------------------------------------------------ *
 * Respect a user's reduced-motion preference - disable smooth scroll,
 * transitions, and animations (spinners, scroll-smooth, smooth scrollTo).
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
