:root {
  color-scheme: dark;
  --bg: #050606;
  --surface: #090c0d;
  --surface-soft: rgba(255, 255, 255, 0.045);
  --surface-strong: #0f1415;
  --text: #f7faf3;
  --muted: #aab6b0;
  --dim: #718079;
  --line: rgba(226, 255, 244, 0.14);
  --line-strong: rgba(187, 255, 42, 0.56);
  --green: #bbff2a;
  --cyan: #38dff1;
  --amber: #ffbe4d;
  --coral: #ff6b5f;
  --pink: #ff4fa3;
  --violet: #c29bff;
  --gap: rgba(255, 255, 255, 0.09);
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.44);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(56, 223, 241, 0.06), transparent 340px),
    radial-gradient(circle at 18% 0, rgba(187, 255, 42, 0.08), transparent 340px),
    var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

.affordability-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  padding: 10px max(14px, calc((100vw - 1180px) / 2));
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: rgba(187, 255, 42, 0.08);
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 950;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 950;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-copy small,
.toolkit-menu summary,
.toolkit-menu nav a,
.mode-switch button,
.affordability-controls label,
.map-toolbar,
.legend-chip,
.map-popout > span,
.map-popout dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.toolkit-menu {
  position: relative;
  z-index: 50;
  display: grid;
  justify-items: end;
}

.toolkit-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.toolkit-menu summary::-webkit-details-marker {
  display: none;
}

.toolkit-menu summary::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--green);
  transition: transform 160ms ease;
}

.toolkit-menu[open] summary,
.toolkit-menu summary:hover,
.toolkit-menu summary:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.toolkit-menu[open] summary::after {
  transform: rotate(180deg);
}

.toolkit-menu nav {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  gap: 2px;
  width: 306px;
  max-width: calc(100vw - 20px);
  border: 1px solid var(--line);
  padding: 8px;
  background: rgba(5, 6, 6, 0.98);
  box-shadow: var(--shadow);
}

.toolkit-menu nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  text-decoration: none;
}

.toolkit-menu nav a:hover,
.toolkit-menu nav a:focus-visible {
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

.affordability-app,
.site-legal-footer {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.affordability-hero {
  display: grid;
  gap: 14px;
  padding: clamp(18px, 3vw, 34px) 0 0;
}

.hero-copy {
  display: grid;
  gap: 12px;
}

.hero-copy h1 {
  max-width: 900px;
  font-size: clamp(38px, 5.6vw, 72px);
  line-height: 0.94;
  text-transform: uppercase;
}

.hero-copy p {
  max-width: 780px;
  color: var(--muted);
  font-size: clamp(14px, 1.45vw, 18px);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hero-stats div,
.detail-metrics div {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.hero-stats dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-stats dd {
  overflow-wrap: anywhere;
  color: var(--green);
  font-size: clamp(16px, 2vw, 23px);
  font-weight: 900;
  line-height: 1.05;
}

.affordability-controls {
  display: grid;
  width: min(430px, 100%);
  margin-top: 16px;
  border: 1px solid var(--line);
  padding: 8px;
  background: rgba(9, 12, 13, 0.82);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 46px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.mode-switch button {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-switch button:last-child {
  border-right: 0;
}

.mode-switch button:hover,
.mode-switch button:focus-visible,
.mode-switch button[aria-selected="true"] {
  background: var(--green);
  color: #071004;
  outline: none;
}

.map-shell {
  display: grid;
  margin-top: 12px;
}

.map-stage {
  min-width: 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(56, 223, 241, 0.08), transparent 34%),
    var(--surface);
}

.map-stage {
  display: grid;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.map-toolbar span:first-child {
  color: var(--cyan);
}

.map-viewport {
  position: relative;
  min-height: 0;
}

.affordability-map {
  width: 100%;
  height: clamp(420px, 52vw, 690px);
  min-height: 0;
}

.affordability-map.is-unavailable {
  min-height: 260px;
}

.us-tile-map {
  display: grid;
  grid-template-columns: repeat(11, minmax(54px, 1fr));
  grid-auto-rows: minmax(54px, 1fr);
  gap: 6px;
  align-content: center;
  min-height: clamp(420px, 52vw, 690px);
  padding: clamp(12px, 2vw, 22px);
  overflow: auto;
}

.state-tile {
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  min-height: 54px;
  border: 1px solid rgba(247, 250, 243, 0.5);
  border-radius: 5px;
  padding: 6px 4px;
  color: #050606;
  cursor: pointer;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.state-tile:hover,
.state-tile:focus-visible,
.state-tile.is-selected {
  border-color: #f7faf3;
  outline: none;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.28),
    0 0 0 2px rgba(247, 250, 243, 0.3);
}

.state-tile strong,
.state-tile span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
}

.state-tile strong {
  font-size: clamp(12px, 1.25vw, 16px);
}

.state-tile span {
  margin-top: 4px;
  font-size: clamp(10px, 1vw, 13px);
}

.map-fallback {
  border-top: 1px solid var(--line);
  padding: 12px;
  color: var(--amber);
  font-size: 0.9rem;
}

.detail-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.detail-head {
  display: grid;
  gap: 8px;
}

.detail-head span {
  color: var(--green);
}

.detail-head h2 {
  overflow-wrap: anywhere;
  font-size: clamp(28px, 4vw, 50px);
  line-height: 0.96;
  text-transform: uppercase;
}

.detail-head p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.38;
}

.detail-metrics {
  display: grid;
  gap: 8px;
}

.detail-metrics dt {
  color: var(--muted);
}

.detail-metrics dd {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.16;
}

#detail-hours {
  color: var(--green);
  font-size: 2.15rem;
  line-height: 0.95;
}

.legend-section {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  padding: 7px 9px;
  background: var(--surface-soft);
}

.legend-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  background: var(--legend-fill, currentColor);
}

.legend-short {
  display: none;
}

.legend-chip.is-fast {
  --legend-fill: linear-gradient(135deg, #59f1ff, #27bfd1);
  border-color: rgba(56, 223, 241, 0.58);
  color: var(--cyan);
}

.legend-chip.is-good {
  --legend-fill: linear-gradient(135deg, #d8ff56, #9df418);
  border-color: rgba(187, 255, 42, 0.56);
  color: var(--green);
}

.legend-chip.is-mid {
  --legend-fill: linear-gradient(135deg, #ffe06b, #ff9f38);
  border-color: rgba(255, 190, 77, 0.62);
  color: var(--amber);
}

.legend-chip.is-high {
  --legend-fill: linear-gradient(135deg, #ff9a56, #ff5f6d);
  border-color: rgba(255, 107, 95, 0.62);
  color: var(--coral);
}

.legend-chip.is-severe {
  --legend-fill: linear-gradient(135deg, #ff65b7, #b96dff);
  border-color: rgba(255, 79, 163, 0.66);
  color: var(--pink);
}

.legend-chip.is-extreme {
  --legend-fill: linear-gradient(135deg, #a974ff, #5f6bff);
  border-color: rgba(138, 115, 255, 0.7);
  color: var(--violet);
}

.legend-chip.is-estimate {
  --legend-fill:
    repeating-linear-gradient(
      135deg,
      rgba(247, 250, 243, 0.92) 0 2px,
      rgba(247, 250, 243, 0.22) 2px 4px
    );
  border-color: rgba(247, 250, 243, 0.32);
  color: var(--muted);
}

[data-gta-affordability-mode="us"] .legend-chip.is-estimate {
  display: none;
}

.map-popout {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100% - 24px));
  border: 1px solid rgba(247, 250, 243, 0.26);
  padding: 14px;
  background: rgba(5, 6, 6, 0.96);
  box-shadow: var(--shadow);
}

.map-popout.is-dragging {
  cursor: grabbing;
}

.map-popout::before {
  display: none;
}

.popout-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.popout-close:hover,
.popout-close:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.map-popout > span {
  color: var(--green);
  cursor: grab;
  padding-right: 32px;
  touch-action: none;
  user-select: none;
}

.map-popout h2 {
  overflow-wrap: anywhere;
  cursor: grab;
  padding-right: 32px;
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 0.96;
  touch-action: none;
  text-transform: uppercase;
  user-select: none;
}

.map-popout p {
  color: var(--muted);
  cursor: grab;
  font-size: 0.92rem;
  line-height: 1.34;
  touch-action: none;
  user-select: none;
}

.map-popout dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.map-popout dl div {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.map-popout dt {
  color: var(--muted);
}

.map-popout dd {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 850;
  line-height: 1.16;
}

#popout-hours {
  color: var(--green);
  font-size: 1.62rem;
  line-height: 0.95;
}

.table-section,
.method-section {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2 {
  font-size: clamp(24px, 3.2vw, 44px);
  line-height: 1;
  text-transform: uppercase;
}

.section-heading p,
.method-section p {
  max-width: 900px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.method-section {
  border-top: 1px solid var(--line);
  padding: 18px 0 26px;
}

.method-section strong {
  color: var(--text);
}

.method-section a {
  color: var(--cyan);
  text-decoration: none;
}

.method-section a:hover,
.method-section a:focus-visible {
  color: var(--green);
  outline: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: rgba(9, 12, 13, 0.82);
}

.affordability-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.affordability-table th,
.affordability-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.affordability-table tbody tr {
  cursor: pointer;
}

.affordability-table tbody tr:hover,
.affordability-table tbody tr:focus-within,
.affordability-table tbody tr.is-selected {
  background: rgba(187, 255, 42, 0.08);
}

.affordability-table tbody tr:last-child td {
  border-bottom: 0;
}

.affordability-table td {
  color: var(--muted);
  font-size: 0.9rem;
}

.affordability-table td:first-child {
  color: var(--text);
  font-weight: 850;
}

.affordability-table .hours-cell {
  color: var(--green);
  font-size: 1.08rem;
  font-weight: 950;
}

.site-legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  justify-content: center;
  border-top: 1px solid var(--line);
  padding: 20px 0 28px;
}

.site-legal-footer a {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.site-legal-footer a:hover,
.site-legal-footer a:focus-visible {
  color: var(--green);
  outline: none;
}

@media (max-width: 900px) {
  .affordability-hero {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .affordability-topbar {
    min-height: 58px;
    padding: 8px 16px;
  }

  .brand-copy small {
    display: none;
  }

  .brand-copy strong {
    max-width: 170px;
    font-size: 12px;
  }

  .toolkit-menu nav {
    width: min(284px, calc(100vw - 32px));
  }

  .affordability-app,
  .site-legal-footer {
    width: min(100% - 20px, 1180px);
  }

  .affordability-hero {
    gap: 7px;
    padding-top: 10px;
  }

  .hero-copy {
    gap: 7px;
  }

  .hero-copy h1 {
    font-size: clamp(29px, 8.2vw, 35px);
    line-height: 0.98;
  }

  .hero-copy p {
    max-width: 31ch;
    font-size: 0.82rem;
    line-height: 1.34;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .affordability-controls {
    width: 100%;
    margin-top: 8px;
    padding: 6px;
  }

  .mode-switch {
    min-height: 40px;
  }

  .mode-switch button {
    padding-inline: 7px;
    font-size: 10px;
    letter-spacing: 0.05em;
  }

  .map-toolbar {
    display: grid;
    gap: 4px;
    justify-content: stretch;
    padding: 9px 10px;
    font-size: 10px;
  }

  .map-toolbar span:last-child {
    text-align: left;
  }

  .affordability-map {
    height: clamp(360px, 96vw, 450px);
  }

  .us-tile-map {
    grid-template-columns: repeat(11, minmax(0, 1fr));
    grid-auto-rows: minmax(42px, 1fr);
    gap: 3px;
    min-height: auto;
    padding: 8px;
    overflow: visible;
  }

  .state-tile {
    min-height: 42px;
    border-radius: 4px;
    padding: 3px 1px;
  }

  .state-tile strong {
    font-size: 10.5px;
  }

  .state-tile span {
    margin-top: 2px;
    font-size: 8.5px;
  }

  .legend-chip {
    justify-content: flex-start;
    min-height: 27px;
    padding: 5px 7px;
    font-size: 9px;
    letter-spacing: 0.04em;
    text-align: left;
  }

  .legend-chip::before {
    width: 8px;
    height: 8px;
  }

  .legend-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
  }

  .legend-full {
    display: none;
  }

  .legend-short {
    display: inline;
  }

  .map-popout {
    position: fixed;
    right: 10px;
    bottom: 10px;
    top: auto;
    left: 10px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 16px);
    max-height: min(34vh, 300px);
    overflow: auto;
    gap: 6px;
    padding: 10px;
    transform: none;
  }

  .map-popout::before {
    display: none;
  }

  .map-popout dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .map-popout dl div {
    padding: 6px;
  }

  .map-popout h2 {
    font-size: 23px;
  }

  .map-popout p {
    display: none;
  }

  .map-popout dt {
    font-size: 9px;
  }

  .map-popout dd {
    font-size: 0.78rem;
  }

  #popout-hours {
    font-size: 1.32rem;
  }
}

@media (max-width: 360px) {
  .us-tile-map {
    gap: 2px;
    grid-auto-rows: minmax(40px, 1fr);
    padding: 6px;
  }

  .state-tile {
    min-height: 40px;
    padding: 2px 0;
  }

  .state-tile strong {
    font-size: 9.5px;
  }

  .state-tile span {
    margin-top: 1px;
    font-size: 7.2px;
    line-height: 0.95;
  }
}
