:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-elevated: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --federal: #1f6feb;
  --states: #238636;
  --territories: #8957e5;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  background-image: url("/images/flag-background.svg");
  background-size: cover;
  background-position: center top;
  /* fixed attachment causes visible “offset” / layer bugs with overlays and some GPUs */
  background-attachment: scroll;
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Ensure content sits above background; scrim subdues stripe pattern */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(13,17,23,0.5) 0%, rgba(13,17,23,0.65) 100%);
  pointer-events: none;
  z-index: 0;
}

body > .site-header,
body > main,
body > .site-footer {
  position: relative;
  z-index: 1;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  box-sizing: border-box;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0 1.1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header subtitle only: sits to the right of the logo (see .site-header__brand) */
.site-header__brand .tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.35;
  flex: 1 1 14rem;
  min-width: min(100%, 11rem);
  max-width: 38ch;
}

main {
  padding: 2rem 0 3rem;
  flex: 1 1 auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 0.5rem 1rem;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.site-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.site-header__brand {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.35rem;
  flex: 1 1 auto;
  min-width: 0;
}

.site-header__brand .site-header__logo-link {
  flex-shrink: 0;
}

.site-header__logo-link {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
  border-radius: 10px;
  outline-offset: 3px;
}

.site-header__logo-link:focus-visible {
  outline: 2px solid var(--federal);
}

/* PNG uses real alpha; keep wrapper transparent (no “white card” behind mark). */
.site-header__logo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 10px;
  padding: 0;
  box-shadow: none;
}

.site-header__logo-img {
  display: block;
  height: clamp(3rem, 7.2vw, 4.6rem);
  width: auto;
  max-width: min(14.5rem, 52vw);
  object-fit: contain;
}

@media (max-width: 520px) {
  .site-header__brand {
    gap: 0.75rem 1rem;
  }

  .site-header__brand .tagline {
    flex: 1 1 100%;
    max-width: none;
  }

  .site-header__logo-img {
    height: clamp(2.65rem, 12vw, 3.5rem);
    max-width: min(12rem, 72vw);
  }
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.site-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.intro {
  margin-bottom: 2rem;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}

.intro p {
  margin: 0;
  color: var(--muted);
  max-width: 56ch;
}

.levels-heading {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.levels-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: stretch;
}

.level-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 280px;
  max-width: 360px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s ease;
}

.level-card:hover {
  border-color: currentColor;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.level-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.level-card p {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  flex: 1;
}

.level-link {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.9;
}

/* Level card accent colors */
.level-federal { color: var(--federal); }
.level-federal .level-graphic { --graphic-color: var(--federal); }
.level-states { color: var(--states); }
.level-states .level-graphic { --graphic-color: var(--states); }
.level-territories { color: var(--territories); }
.level-territories .level-graphic { --graphic-color: var(--territories); }

/* Graphics: simple CSS shapes */
.level-graphic {
  --graphic-color: var(--muted);
  width: 100%;
  height: 120px;
  margin-bottom: 1rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  border-radius: 8px;
}

/* Federal: capitol dome + pillars */
.graphic-dome {
  position: absolute;
  bottom: 28px;
  width: 56px;
  height: 36px;
  border: 3px solid var(--graphic-color);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  opacity: 0.85;
}

.graphic-pillars {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 32px;
  border: 2px solid var(--graphic-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  opacity: 0.7;
}

.graphic-pillars::before,
.graphic-pillars::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 32px;
  background: var(--graphic-color);
  opacity: 0.7;
}

.graphic-pillars::before { left: 12px; }
.graphic-pillars::after { right: 12px; left: auto; }

/* States: outline map + star */
.graphic-map {
  position: absolute;
  width: 70px;
  height: 44px;
  border: 2.5px solid var(--graphic-color);
  border-radius: 50% 50% 45% 48% / 48% 52% 45% 50%;
  opacity: 0.8;
  transform: rotate(-8deg);
}

.graphic-star {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 16px solid var(--graphic-color);
  opacity: 0.9;
  transform: translateY(-4px);
}

.graphic-star::before {
  content: "";
  position: absolute;
  top: 4px;
  left: -10px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 16px solid var(--graphic-color);
}

/* Territories: islands + sun */
.graphic-islands {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 20px;
}

.graphic-islands::before,
.graphic-islands::after {
  content: "";
  position: absolute;
  bottom: 0;
  border: 2px solid var(--graphic-color);
  border-radius: 50%;
  opacity: 0.8;
}

.graphic-islands::before {
  width: 24px;
  height: 20px;
  left: 0;
}

.graphic-islands::after {
  width: 18px;
  height: 16px;
  right: 8px;
  bottom: 2px;
}

.graphic-sun {
  position: absolute;
  top: 16px;
  right: 24px;
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--graphic-color);
  border-radius: 50%;
  opacity: 0.85;
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 2rem;
}

.site-footer p { margin: 0; }
.site-footer small { color: var(--muted); }

/* Sub-pages: breadcrumb + list layout */
.breadcrumb {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { color: var(--muted); }

.page-title {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

.page-subtitle {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.body-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.body-list a {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.body-list a:hover {
  border-color: var(--federal);
  background: var(--surface-elevated);
}

.body-list .body-name { font-weight: 600; }
.body-list .body-desc { font-size: 0.875rem; color: var(--muted); margin-top: 0.2rem; }

.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.states-grid a {
  display: block;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  text-align: center;
  font-size: 0.9rem;
  transition: border-color 0.2s, background 0.2s;
}

.states-grid a:hover {
  border-color: var(--states);
  background: var(--surface-elevated);
}

.states-grid .states-grid__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
}

/* Fixed-height band so every card has the state name in the same vertical slot. */
.states-grid__thumb {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 3rem;
  box-sizing: border-box;
}

.states-grid__flag {
  display: block;
  max-width: 100%;
  max-height: 3rem;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 3px;
}

.states-grid__label {
  display: block;
  width: 100%;
  line-height: 1.25;
  text-align: center;
}

.state-symbols-note {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: -0.25rem 0 1.25rem;
  max-width: 48rem;
}

.state-symbols-note a {
  color: var(--states);
}

.state-hub-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.state-hub-hero__flag {
  display: block;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.state-hub-hero__seal {
  display: block;
  width: 100px;
  height: auto;
  max-height: 120px;
  object-fit: contain;
}

.territories-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.territories-list a {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.territories-list a:hover {
  border-color: var(--territories);
  background: var(--surface-elevated);
}

.territories-list .body-name { font-weight: 600; }
.territories-list .body-desc { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }

/* Counties: dropdown on state page */
.counties-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* State index: county dropdown at top of page */
.county-dropdown-top {
  margin-bottom: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.county-dropdown-top .county-label { font-weight: 600; color: var(--text); }
.county-dropdown-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.county-dropdown-wrap {
  margin-top: 1rem;
}

.county-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.county-select {
  width: 100%;
  max-width: 360px;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.county-select:hover,
.county-select:focus {
  border-color: var(--states);
  outline: none;
}

/* County page: non-link list items */
.body-list-item.placeholder {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.body-list-item .body-name { font-weight: 600; }
.body-list-item .body-desc { font-size: 0.875rem; color: var(--muted); margin-top: 0.2rem; }

.county-officials .levels-heading { margin-top: 1.5rem; }
.county-officials .levels-heading:first-of-type { margin-top: 0; }

/* Federal/state member lists (DB-driven) */
.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.member-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.member-item--empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.member-name {
  font-weight: 600;
  color: inherit;
}

.member-item a.member-name:hover {
  color: var(--federal);
}

.member-meta {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Federal member grid (photo cards linking to profile) */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.member-grid .member-item--empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s ease;
}

.member-card:hover {
  border-color: var(--federal);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

.member-card__photo {
  display: block;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: var(--surface-elevated);
  flex-shrink: 0;
}

.member-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.member-card__img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.75rem;
  color: var(--muted);
}

.member-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.member-card__meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Member profile page (individual) */
.member-profile {
  margin-top: 0.5rem;
}

.member-profile__head {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.member-profile__photo-wrap {
  flex-shrink: 0;
  width: 200px;
  height: 250px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-elevated);
}

.member-profile__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.member-profile__photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 1rem;
}

.member-profile__info {
  flex: 1;
  min-width: 200px;
}

.member-profile__role {
  color: var(--muted);
  margin: 0.25rem 0 0.5rem;
  font-size: 1.05rem;
}

.member-profile__bio {
  margin: 0.5rem 0 0;
  color: var(--text);
  max-width: 56ch;
}

.member-profile section {
  margin-top: 1.5rem;
}

.member-profile section h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.member-profile section p {
  margin: 0;
}

.term-history {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.term-history li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.term-history li:last-child {
  border-bottom: none;
}
