/* CCW Reciprocity Map — Workman Firearms
   Dark theme, mobile-first, no frameworks */

:root {
  --bg-primary:    #1a1a2e;
  --bg-secondary:  #16213e;
  --bg-card:       #0f3460;
  --bg-hover:      #1a4a7a;
  --color-green:   #22c55e;
  --color-red:     #ef4444;
  --color-gold:    #eab308;
  --color-gray:    #4b5563;
  --color-blue:    #3b82f6;
  --text-primary:  #f1f5f9;
  --text-muted:    #94a3b8;
  --border:        #1e40af;
  --accent:        #c9a227;
  --state-default: #2d3f6e;
  --state-border:  #1a1a2e;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --radius:        8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.header-logo {
  font-size: 1.4rem;
  line-height: 1;
}

.header-text h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.header-text p {
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.header-cta {
  background: var(--accent);
  color: #1a1a2e;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.header-cta:hover { background: #e0b520; transform: translateY(-1px); }

/* ── MAIN LAYOUT ── */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* ── STATE SELECTOR ── */
.state-selector-bar {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.state-selector-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.state-selector-bar select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  flex: 1;
  min-width: 160px;
  max-width: 260px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 28px;
}

.state-selector-bar select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Legend */
.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── MAP + PANEL LAYOUT ── */
.map-panel-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .map-panel-layout {
    grid-template-columns: 1fr 320px;
    align-items: start;
  }
}

/* ── SVG MAP ── */
.map-wrapper {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.map-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
}

.state {
  fill: var(--state-default);
  stroke: var(--state-border);
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.25s ease, filter 0.15s;
  vector-effect: non-scaling-stroke;
}

.state:hover {
  filter: brightness(1.3);
  stroke-width: 1.5;
  stroke: #ffffff88;
}

.state.selected {
  fill: #7c3aed !important;
  stroke: #a78bfa;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px #7c3aed88);
}

.state.honored {
  fill: var(--color-green);
}

.state.not-honored {
  fill: var(--color-red);
}

.state.partial {
  fill: var(--color-gold);
}

/* State label tooltip */
.map-tooltip {
  position: absolute;
  background: #000000cc;
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  z-index: 50;
  border: 1px solid var(--accent);
}

/* Map stat bar */
.map-stat-bar {
  background: var(--bg-primary);
  padding: 8px 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.stat-count {
  font-weight: 700;
  font-size: 1rem;
}

.stat-label { color: var(--text-muted); }

/* ── STATE DETAIL PANEL ── */
.state-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  position: sticky;
  top: 72px;
}

.panel-header {
  background: var(--bg-card);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-state-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.panel-permit-type {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.panel-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-green  { background: #16532d; color: var(--color-green); }
.badge-red    { background: #7f1d1d; color: #fca5a5; }
.badge-gold   { background: #713f12; color: var(--color-gold); }
.badge-purple { background: #4c1d95; color: #c4b5fd; }
.badge-blue   { background: #1e3a5f; color: #93c5fd; }

.panel-body {
  padding: 14px 16px;
}

.panel-section {
  margin-bottom: 14px;
}

.panel-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.panel-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 0.82rem;
  padding: 4px 0;
  gap: 8px;
}

.info-label { color: var(--text-muted); flex-shrink: 0; }
.info-value { font-weight: 600; text-align: right; }
.info-value.green { color: var(--color-green); }
.info-value.red   { color: var(--color-red); }
.info-value.gold  { color: var(--color-gold); }

.panel-notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
}

.restricted-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.restricted-list li {
  font-size: 0.68rem;
  background: var(--bg-primary);
  border: 1px solid var(--color-red);
  color: #fca5a5;
  padding: 2px 6px;
  border-radius: 4px;
}

.honored-by-list {
  font-size: 0.78rem;
  color: var(--color-green);
  font-weight: 600;
  line-height: 1.6;
}

.not-honored-note {
  font-size: 0.78rem;
  color: var(--color-red);
  font-weight: 600;
}

/* Panel CTA */
.panel-cta {
  display: block;
  background: var(--accent);
  color: #1a1a2e;
  text-decoration: none;
  text-align: center;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 6px;
  margin: 0 16px 16px;
  transition: background 0.2s, transform 0.1s;
}

.panel-cta:hover { background: #e0b520; transform: translateY(-1px); }

/* Reciprocity count bar */
.reciprocity-bar {
  margin: 8px 0 12px;
}

.recip-bar-track {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.recip-bar-fill {
  height: 100%;
  background: var(--color-green);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.recip-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.recip-bar-label strong { color: var(--color-green); }

/* ── AFFILIATE WIDGETS ── */
.affiliate-section {
  margin-top: 20px;
}

.affiliate-section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 700;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.affiliate-widget {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.affiliate-widget .widget-icon { font-size: 1.5rem; }
.affiliate-widget .widget-label { font-weight: 600; color: var(--text-primary); font-size: 0.8rem; }

/* ── DISCLAIMER / FOOTER ── */
.disclaimer-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
}

.disclaimer-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-gold);
  margin-bottom: 8px;
  font-weight: 700;
}

.disclaimer-section p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 6px;
}

footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  margin-top: 24px;
  text-align: center;
}

footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 600px) {
  header { padding: 10px 14px; }
  .header-text h1 { font-size: 0.85rem; }
  .header-cta { padding: 6px 10px; font-size: 0.7rem; }
  .main-container { padding: 10px; }
  .state-selector-bar { padding: 10px 12px; gap: 8px; }
  .legend { display: none; }
  .map-stat-bar { padding: 6px 12px; gap: 10px; }
  .panel-body { padding: 10px 12px; }
}

/* ── LOADING / TRANSITIONS ── */
.map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.loading-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Small state callout boxes */
.small-states-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
  font-style: italic;
}

/* ── AFFILIATE LINKS ── */
.affiliate-link {
  text-decoration: none;
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
}
.affiliate-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.arsenal-widget {
  border: 1px solid #c8a84b;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(200,168,75,0.08) 100%);
}
.arsenal-widget:hover {
  border-color: #e5c76b;
  transform: translateY(-2px);
}
.widget-cta {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.arsenal-widget .widget-cta { color: #c8a84b; }
.affiliate-disclosure {
  margin-top: 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
}
