/* ==========================================================================
   Components CSS - Buttons, Cards, Tables, Utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary Button */
.btn--primary {
  background-color: var(--color-accent-dark);
  color: var(--color-surface);
  border-color: var(--color-accent-dark);
}

.btn--primary:hover {
  background-color: var(--color-accent-text);
  border-color: var(--color-accent-text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Secondary Button */
.btn--secondary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn--secondary:hover {
  background-color: var(--color-primary);
  color: var(--color-surface);
}

/* Ghost Button */
.btn--ghost {
  background-color: transparent;
  color: var(--color-text);
  border-color: transparent;
}

.btn--ghost:hover {
  background-color: var(--color-background-alt);
}

/* Outline button for dark backgrounds (hero) */
.btn--on-dark {
  background-color: transparent;
  color: var(--color-background);
  border-color: rgba(245, 242, 235, 0.7);
}

.btn--on-dark:hover {
  background-color: var(--color-background);
  border-color: var(--color-background);
  color: var(--color-primary);
  text-decoration: none;
}

/* Button Sizes */
.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

/* Button with Icon */
.btn__icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.card--elevated {
  box-shadow: var(--shadow-lg);
  border: none;
}

.card--bordered {
  box-shadow: none;
  border: 2px solid var(--color-border);
}

.card__header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
  margin: 0;
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.card__body {
  color: var(--color-text-light);
}

.card__footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  margin: var(--space-6) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  /* Opaque, so a sticky first column can cover the cells scrolling under it */
  background-color: var(--color-surface);
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  background-color: var(--color-primary);
  color: var(--color-background);
}

th {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  text-align: left;
  padding: var(--space-4) var(--space-5);
  text-wrap: balance;
}

td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background-color: var(--color-background);
}

tbody tr:hover {
  background-color: var(--color-background-alt);
}

/* Responsive table highlight */
td[data-highlight] {
  background-color: rgba(196, 112, 60, 0.1);
  font-weight: var(--weight-medium);
}

/* Row headers can be long ("Easton hunting chart, traditional recurve column"):
   let them wrap, and give them the same divider as the cells beside them.
   The body face keeps their numbers level: the display face uses old-style figures. */
tbody th {
  white-space: normal;
  font-family: var(--font-body);
  border-bottom: 1px solid var(--color-border-light);
  /* Row headers carry their own opaque stripe (see the sticky column below) */
  background-color: var(--color-surface);
}

tbody tr:nth-child(even) th {
  background-color: var(--color-background);
}

tbody tr:hover th {
  background-color: var(--color-background-alt);
}

tbody tr:last-child th {
  border-bottom: none;
}

/* The worked example's row: the attribute sits on the <tr>. The tint is an
   image layer so the row header stays opaque. */
tr[data-highlight] > td {
  background-color: rgba(196, 112, 60, 0.1);
  font-weight: var(--weight-medium);
}

tr[data-highlight] > th {
  background-image: linear-gradient(rgba(196, 112, 60, 0.1), rgba(196, 112, 60, 0.1));
}

/* Values like 800-700 or RX7-21 never break at their hyphen, and a number
   never breaks from its unit (.qty is added by js/translate-guard.js) */
.nowrap,
.qty {
  white-space: nowrap;
}

/* Phones: tighter cells, and the row header stays in view while the table
   scrolls sideways */
@media (max-width: 768px) {
  th,
  td {
    padding: var(--space-3) var(--space-4);
  }

  .table-wrapper tbody th,
  .table-wrapper thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: inset -1px 0 0 var(--color-border-light);
  }

  .table-wrapper thead th:first-child {
    background-color: var(--color-primary);
  }
}

/* Table caption */
caption {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  caption-side: bottom;
  background-color: var(--color-background);
  border-top: 1px solid var(--color-border-light);
}

/* --------------------------------------------------------------------------
   Badges & Tags
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--primary {
  background-color: var(--color-primary);
  color: var(--color-background);
}

.badge--accent {
  background-color: var(--color-accent-dark);
  color: var(--color-surface);
}

.badge--muted {
  background-color: var(--color-background-alt);
  color: var(--color-text-light);
}

/* --------------------------------------------------------------------------
   Form Elements
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--color-text-muted);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(196, 112, 60, 0.15);
  outline: none;
}

/* Range Slider */
.form-range {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.form-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--color-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.form-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Radio/Checkbox Cards */
.option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-6);
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.option-card:hover {
  border-color: var(--color-accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option-card--selected {
  border-color: var(--color-accent);
  background-color: rgba(196, 112, 60, 0.05);
}

.option-card__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-card__icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-3);
  color: var(--color-primary);
}

.option-card--selected .option-card__icon {
  color: var(--color-accent);
}

.option-card__label {
  font-weight: var(--weight-medium);
  color: var(--color-primary);
}

.option-card__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   Tooltip
   -------------------------------------------------------------------------- */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-bottom: 1px dashed var(--color-text-muted);
}

.tooltip__content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-primary);
  color: var(--color-background);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-out),
              visibility var(--duration-fast) var(--ease-out);
  z-index: var(--z-tooltip);
}

.tooltip__content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-primary);
}

.tooltip:hover .tooltip__content,
.tooltip:focus-within .tooltip__content {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   Progress Indicators
   -------------------------------------------------------------------------- */
.progress-bar {
  width: 100%;
  height: 4px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background-color: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

/* Step Progress */
.step-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.step-dot {
  width: 10px;
  height: 10px;
  background-color: var(--color-border);
  border-radius: 50%;
  transition: all var(--duration-normal) var(--ease-out);
}

.step-dot--active {
  background-color: var(--color-accent);
  transform: scale(1.2);
}

.step-dot--completed {
  background-color: var(--color-primary);
}

.step-line {
  width: 24px;
  height: 2px;
  background-color: var(--color-border);
  transition: background-color var(--duration-normal) var(--ease-out);
}

.step-line--completed {
  background-color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Colors */
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-muted { color: var(--color-text-muted); }
.text-light { color: var(--color-text-light); }

/* Font Families */
.font-display { font-family: var(--font-display); }
.font-body { font-family: var(--font-body); }

/* Font Weights */
.font-normal { font-weight: var(--weight-normal); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); } /* used by the markup but was never defined */
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flexbox */
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Width */
.w-full { width: 100%; }
.max-w-none { max-width: none; }

/* Decorative Elements */
.decorative-line {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.decorative-line::before,
.decorative-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

/* Arrow decoration */
.arrow-decoration {
  display: inline-block;
  width: 40px;
  height: 2px;
  background-color: var(--color-accent);
  position: relative;
}

.arrow-decoration::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: var(--color-accent);
}

/* Highlight box */
.highlight-box {
  background: linear-gradient(135deg, rgba(196, 112, 60, 0.1), rgba(196, 112, 60, 0.05));
  border-left: 3px solid var(--color-accent);
  padding: var(--space-4) var(--space-6);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: var(--space-4) 0;
}

.highlight-box__title {
  font-weight: var(--weight-semibold);
  color: var(--color-accent-dark);
  margin-bottom: var(--space-2);
}

/* Animated number counter */
.counter {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  display: inline-block;
}

.counter__unit {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin-left: var(--space-1);
}

/* --------------------------------------------------------------------------
   Citations and Sources
   -------------------------------------------------------------------------- */
/* Raised without stretching the line they sit in */
sup.cite {
  position: relative;
  top: -0.45em;
  vertical-align: baseline;
  line-height: 0;
  margin-left: 0.08em;
  font-family: var(--font-body);
  font-size: 0.72em;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

/* A word joiner keeps the marker on the line of the word it cites */
sup.cite::before {
  content: "\2060";
}

sup.cite a {
  color: var(--color-primary-light);
  text-decoration: none;
  border-radius: 2px;
}

sup.cite a:hover {
  text-decoration: underline;
}

sup.cite a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* On dark ground: table heads and dark sections */
thead sup.cite a,
.scroll-section--dark sup.cite a {
  color: var(--color-background);
}

/* ...but light panels inside a dark section are light again */
.scroll-section--dark .split-comparison__side--light sup.cite a,
.scroll-section--dark .feature-card sup.cite a {
  color: var(--color-primary-light);
}

.scroll-container > footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* The site-wide hover turns links the footer's own green; the button orange is
   too dark on it for small text (3.9:1), its lighter step passes (5.0:1) */
.scroll-container > footer a:hover {
  color: var(--color-accent-light);
}

.sources-list {
  margin-top: var(--space-8);
  padding-left: 2.25em;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-light);
}

.sources-list li {
  margin-bottom: var(--space-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  break-inside: avoid;
  scroll-margin-top: 6rem;
}

.sources-list li::marker {
  color: var(--color-text-light);
  font-variant-numeric: tabular-nums;
}

.sources-list a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

/* Landing here from a citation marks the source you came for */
.sources-list li:target {
  background-color: rgba(196, 112, 60, 0.14);
}

@media (min-width: 900px) {
  .sources-list {
    columns: 2;
    column-gap: var(--space-12);
  }
}
