/* America's Cleanest Homes - Excel Pest Services.
 *
 * Restyled from the Type A T2 sortable-table template to the campaign Figma.
 * Every colour, hero, icon and copy string is driven from theme.json + copy.json
 * at runtime, so the two-state toggle swaps them without touching this file.
 *
 * Layout follows the Figma: a full-width hero, a centred Cleanest/Dirtiest
 * switch, then a card holding a div-based table (house convention - NOT a real
 * <table>). On mobile the City/State columns stay put and the factor columns
 * scroll horizontally inside the card.
 */

:root {
  --primary: #051c34;
  --accent: #e02126;
  --bg: #f2f2f2;
  --text: #1a1a1a;
  --text-muted: #565e6b;
  --brand-blue: #0255a3;
  --surface: #ffffff;
  --surface-alt: #f2efe9;
  --radius: 8px;
  --font: 'Open Sans', sans-serif;
  --heading-font: 'Open Sans Condensed', 'Open Sans', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 989px;
  margin: 0 auto;
  background: var(--bg);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 300px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
}

/* Hero photo layer sits behind the overlay; the CSS background-image is the
   fallback for the (image-swap) state, the <img> is what actually swaps. */
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero-overlay {
  position: relative;
  z-index: 2;
  color: #fff;
  max-width: 640px;
}

/* Soft dark scrim so the title stays legible over any hero photo. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(5, 28, 52, 0.44);
  z-index: 1;
}

.hero .logo { height: 34px; margin-bottom: 14px; }

.hero h1 {
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 64px;
  line-height: 1.02;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  text-transform: uppercase;
  color: #fff;
}

.hero p {
  margin: 0 auto;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
}

/* ---------- toggle ---------- */
.controls {
  display: flex;
  justify-content: center;
  padding: 22px 16px 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.toggle-side {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.25s ease;
}

.toggle-side.is-active { color: var(--text); }
.toggle-side:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: 3px; }

.toggle-icon { width: 22px; height: 22px; object-fit: contain; }

.toggle-switch {
  position: relative;
  width: 66px;
  height: 34px;
  border-radius: 20px;
  border: 3px solid var(--text);
  background: var(--surface, #fff);
  cursor: pointer;
  padding: 0;
  transition: background 0.25s ease;
}

.toggle-switch:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: 3px; }

.toggle-switch .knob {
  position: absolute;
  top: 50%;
  left: 4px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: left 0.25s ease, transform 0.25s ease;
}

body[data-state="dirty"] .toggle-switch .knob {
  left: 31px;
}

/* ---------- table card ---------- */
.table-card {
  background: var(--surface, #fff);
  margin: 18px 0 0;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-content { min-width: 100%; }

.table-header-row,
.table-body-row {
  display: flex;
  align-items: stretch;
  min-width: 720px;
}

.table-header-row {
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.table-body-row { border-top: 1px solid rgba(0, 0, 0, 0.07); }
.table-body-row:nth-child(odd) { background: var(--surface-alt, #f7f7f7); }
.table-body-row:hover { background: rgba(2, 85, 163, 0.06); }

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  text-align: center;
  font-size: 15px;
}

/* Header cells share the body cell's box, so icons/labels sit directly above
   their values. Rank aligns left like the rank ordinal; the rest centre. */
.header-cell { padding: 6px 10px; }

.header-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 6px;
  font: inherit;
}

.header-btn:hover { background: rgba(2, 85, 163, 0.07); }
.header-btn:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: 2px; }
.header-btn.active .sort-arrow { color: var(--accent); }

.sort-arrow { font-size: 10px; line-height: 1; height: 10px; }

.col-rank.header-cell { justify-content: flex-start; padding-left: 14px; }
.col-rank .header-btn { align-items: flex-start; padding-left: 0; }

.col-icon { width: 26px; height: 26px; object-fit: contain; }

.col-label {
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 13px;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}

/* column widths */
.col-rank { flex: 0 0 96px; justify-content: flex-start; padding-left: 14px; }
.col-city { flex: 1.3 1 0; min-width: 150px; justify-content: flex-start; padding-left: 14px;
  font-weight: 600; font-size: 16px; letter-spacing: 0.01em; white-space: nowrap; }
.col-state { flex: 1.1 1 0; min-width: 130px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.col-factor { flex: 1 1 0; min-width: 118px; }

/* rank cell: thin rank-coloured bar flush left + ordinal */
.rank-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
}

.table-body-row { position: relative; }
.table-header-row { position: relative; }

.col-rank .rank-text {
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  white-space: nowrap;
}

/* metric chip, tinted by the active state's scale */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 17px;
  color: #fff;
}

/* ---------- show more ---------- */
.show-more {
  display: block;
  width: 100%;
  border: none;
  background: #18181b;
  color: #fff;
  font-family: var(--heading-font);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 15px 16px;
  cursor: pointer;
}

.show-more:hover { background: #000; }
.show-more:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: -3px; }
.show-more[hidden] { display: none; }

/* ---------- footnote / footer ---------- */
.footnote {
  color: var(--text-muted);
  font-size: 13px;
  margin: 18px 16px 0;
}

footer {
  margin: 22px 16px 0;
  padding: 18px 0 40px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* build-fails-loud: missing source credit */
.missing-credit {
  background: #dc2626;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  padding: 22px;
  border-radius: var(--radius);
  border-top: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- responsive: match the mobile Figma ---------- */
@media (max-width: 700px) {
  .hero { min-height: 262px; padding: 32px 18px; }
  .hero h1 { font-size: 40px; }
  .hero p { font-size: 16px; }

  /* City/State stay visible and must not collide; factor columns scroll
     inside the card (Figma mobile frames). */
  .table-header-row,
  .table-body-row { min-width: 100%; width: max-content; }
  .col-rank { flex: 0 0 74px; padding-left: 12px; }
  .col-city { flex: 0 0 132px; min-width: 132px; padding-left: 12px; font-size: 14px; }
  .col-state { flex: 0 0 132px; min-width: 132px; font-size: 14px; }
  .col-factor { flex: 0 0 104px; min-width: 104px; }
  .col-label { font-size: 12px; }
  .chip { font-size: 15px; min-width: 58px; padding: 7px 8px; }
  .col-rank .rank-text { font-size: 18px; }
}
