/* ============================================================
   Design Tokens
   ============================================================ */

:root {
  --color-bg: #faf8f5;
  --color-surface: #f3f0ec;
  --color-text: #1a1a1a;
  --color-muted: #6b6560;
  --color-accent: #1b3a5c;
  --color-accent-light: #e8eef4;
  --color-border: #d4d0cc;

  --color-party-dem: #3868a8;
  --color-party-dem-bg: #e8eef6;
  --color-party-rep: #b03030;
  --color-party-rep-bg: #f6e8e8;
  --color-party-ind: #5a6a50;
  --color-party-ind-bg: #eef2eb;
  --color-party-other: #6b6560;
  --color-party-other-bg: #f0eeec;

  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  --max-width: 740px;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-full: 9999px;
}

/* ============================================================
   Reset & Base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   Layout
   ============================================================ */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Accessibility
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ============================================================
   Header
   ============================================================ */

.site-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.header-icon {
  display: block;
  margin: 0 auto var(--space-md);
}

.site-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 var(--space-sm);
  color: var(--color-accent);
}

.subtitle {
  font-size: 1.05rem;
  color: var(--color-muted);
  margin: 0 0 var(--space-xs);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.privacy-note {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: var(--space-sm) 0 0;
  font-style: italic;
}

/* ============================================================
   Address Form
   ============================================================ */

.address-form {
  margin-bottom: var(--space-lg);
}

#address-input {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: white;
  color: var(--color-text);
  transition: border-color 0.15s ease;
}

#address-input::placeholder {
  color: #a09a94;
}

#address-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.hint-text {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin: var(--space-xs) 0 var(--space-md);
}

#submit-btn {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--color-accent);
  color: white;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#submit-btn:hover {
  background-color: #15304d;
}

#submit-btn:active {
  background-color: #0f2540;
}

#submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   Status Messages
   ============================================================ */

.status {
  text-align: center;
  min-height: 1.6em;
  margin-bottom: var(--space-md);
}

.status:empty {
  display: none;
}

.status--loading {
  color: var(--color-muted);
}

.status--error {
  color: var(--color-party-rep);
  background: var(--color-party-rep-bg);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: left;
}

/* ============================================================
   Results
   ============================================================ */

.results:empty {
  display: none;
}

.location-echo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--color-text);
  margin: 0 0 var(--space-xs);
}

.location-message {
  font-size: 0.85rem;
  margin: 0 0 var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  line-height: 1.5;
}

.location-message--positive {
  color: #1a5632;
  background: #edf7f0;
  border-left: 3px solid #2a7d4f;
}

.location-message--caution {
  color: #6b5a00;
  background: #fdf8e8;
  border-left: 3px solid #c4a600;
}

.location-message--warning {
  color: var(--color-muted);
  background: var(--color-surface);
  border-left: 3px solid var(--color-border);
  font-style: italic;
}

/* ============================================================
   Level Groups
   ============================================================ */

.level-group {
  margin-bottom: var(--space-xl);
}

.level-heading {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

/* ============================================================
   Representative Cards
   ============================================================ */

.rep-card {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  animation: fadeInUp 0.3s ease both;
  animation-delay: var(--delay, 0s);
}

.rep-card + .rep-card {
  border-top: 1px solid var(--color-border);
}

/* Photo / Initial */

.rep-photo-container {
  flex-shrink: 0;
}

.rep-photo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-surface);
}

.rep-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

/* Info */

.rep-info {
  flex: 1;
  min-width: 0;
}

.rep-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 var(--space-xs);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.rep-title {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin: 0 0 var(--space-sm);
}

/* Party Badge */

.party-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-full);
  vertical-align: baseline;
  white-space: nowrap;
}

.party-badge--dem {
  color: var(--color-party-dem);
  background: var(--color-party-dem-bg);
}

.party-badge--rep {
  color: var(--color-party-rep);
  background: var(--color-party-rep-bg);
}

.party-badge--ind {
  color: var(--color-party-ind);
  background: var(--color-party-ind-bg);
}

.party-badge--other {
  color: var(--color-party-other);
  background: var(--color-party-other-bg);
}

/* ============================================================
   Contact & Social Icons
   ============================================================ */

.rep-contacts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.chip-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: currentColor;
}

.social-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.social-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.social-icon-btn:hover:not(.social-icon-btn--disabled) {
  background: var(--color-border);
  color: var(--color-accent);
}

.social-icon-btn--disabled {
  opacity: 0.22;
  cursor: default;
  pointer-events: none;
}

.social-icon-btn.copied {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.icon-separator {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 3px;
}

.social-icon-btn .chip-icon {
  width: 14px;
  height: 14px;
}

/* Social popover */

.social-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  min-width: 160px;
  padding: var(--space-sm) var(--space-md);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  animation: fadeInUp 0.12s ease;
}

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

.social-popover::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--color-border);
}

.popover-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 2px;
}

.popover-handle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.popover-actions {
  display: flex;
  gap: var(--space-sm);
}

.popover-copy,
.popover-visit {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4em 0.6em;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.1s ease;
}

.popover-copy {
  background: var(--color-accent);
  color: white;
  border: none;
}

.popover-copy:hover {
  background: #15304d;
}

.popover-copy.popover-copied {
  background: #2a7d4f;
}

.popover-visit {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.popover-visit:hover {
  background: var(--color-border);
  text-decoration: none;
}

/* ============================================================
   Field Offices
   ============================================================ */

.field-offices {
  margin-top: var(--space-sm);
}

.field-offices summary {
  font-size: 0.8rem;
  color: var(--color-muted);
  cursor: pointer;
}

.field-offices summary:hover {
  color: var(--color-text);
}

.field-office-list {
  list-style: none;
  padding: var(--space-xs) 0 0;
  margin: 0;
}

.field-office-item {
  font-size: 0.8rem;
  color: var(--color-muted);
  padding: var(--space-xs) 0;
}

.field-office-item a {
  color: var(--color-text);
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  margin-top: auto;
  padding-top: var(--space-2xl);
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.site-footer p {
  margin: 0 0 var(--space-xs);
}

.site-footer a {
  color: var(--color-muted);
}

/* ============================================================
   Animation
   ============================================================ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rep-card {
    animation: none;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 480px) {
  .container {
    padding: var(--space-lg) var(--space-md);
  }

  .rep-photo,
  .rep-initial {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }

  .rep-name {
    font-size: 1.05rem;
  }
}
