/* ===== 变量与基础 ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #dc2626;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== 头部 ===== */
.site-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #dc2626 100%);
  color: #fff;
  padding: 32px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-emoji {
  font-size: 48px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.brand h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 14px;
  opacity: 0.85;
  margin-top: 2px;
}

.stats {
  display: flex;
  gap: 24px;
}

.header-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.header-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  transition: var(--transition);
  white-space: nowrap;
}

.header-nav a:hover {
  background: rgba(255, 255, 255, 0.28);
}

.header-nav a.active {
  background: #fff;
  color: #1e3a8a;
  font-weight: 700;
  border-color: #fff;
}

.stat {
  text-align: center;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: var(--radius);
  min-width: 90px;
}

.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  opacity: 0.9;
}

/* ===== 地图区域 ===== */
.map-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
  box-shadow: var(--shadow);
}

.map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.map-title-block {
  flex: 1;
  text-align: center;
  min-width: 220px;
}

.map-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.map-hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.map-style-group select {
  min-width: 180px;
}

.map-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  background: linear-gradient(180deg, #e0f2fe 0%, #f0f9ff 100%);
  border-radius: 12px;
  overflow: hidden;
}

#usMap {
  width: 100%;
  height: auto;
  display: block;
}

#usMap .state-path {
  fill: #cbd5e1;
  stroke: #fff;
  stroke-width: 1.2;
  cursor: pointer;
  transition: fill 0.2s ease, stroke 0.2s ease, filter 0.2s ease;
}

#usMap .state-path:hover {
  filter: brightness(1.15);
  stroke: #1e293b;
  stroke-width: 2;
}

#usMap .state-path.active {
  filter: brightness(1.25);
  stroke: #1e293b;
  stroke-width: 2.5;
}

#usMap .state-label {
  font-size: 12px;
  font-weight: 700;
  fill: #1f2937;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 2.5px;
  paint-order: stroke;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.map-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
}

.legend-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

/* 地图 tooltip */
.map-tooltip {
  position: fixed;
  background: rgba(31, 41, 55, 0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.map-tooltip.show {
  opacity: 1;
}

/* ===== 工具栏 ===== */
.toolbar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: -20px;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-light);
  padding: 4px 8px;
  border-radius: 4px;
}

.clear-btn:hover {
  background: var(--border);
}

.controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.control-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  transition: var(--transition);
}

.control-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  padding: 10px 14px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
}

.view-btn:hover:not(.active) {
  background: var(--primary-light);
}

/* ===== 结果计数 ===== */
.result-count {
  margin: 20px 0 16px;
  font-size: 14px;
  color: var(--text-light);
}

.result-count strong {
  color: var(--text);
  font-size: 16px;
}

.filter-hint {
  margin-left: 8px;
  color: var(--primary);
}

/* ===== 卡片网格 ===== */
.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
  align-items: start;
}

.states-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 40px;
}

.state-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

/* 折叠态：仅显示州名，点击展开详情 */
.state-card:not(.expanded) .card-body,
.state-card:not(.expanded) .card-footer,
.state-card:not(.expanded) .region-badge,
.state-card:not(.expanded) .state-abbr {
  display: none;
}

.card-toggle {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.state-card.expanded .card-toggle {
  transform: rotate(180deg);
}

.states-list .state-card:not(.expanded) .card-header {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
}

.state-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.state-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.state-card:hover::before {
  transform: scaleX(1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.state-flag {
  font-size: 32px;
  line-height: 1;
}

.state-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.state-name-en {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 1px;
}

.state-abbr {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 2px;
}

.region-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f3f4f6;
  color: var(--text-light);
  white-space: nowrap;
}

.card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.info-value-en {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-light);
  margin-top: 1px;
}

.card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light);
}

/* 列表视图 */
.states-list .state-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 16px 20px;
}

.states-list .card-header {
  margin-bottom: 0;
  flex-direction: column;
  gap: 4px;
}

.states-list .card-body {
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.states-list .card-footer {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  text-align: right;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 20px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s ease;
}

/* 内容独立滚动，关闭按钮固定在弹窗右上角 */
#modalBody {
  overflow-y: auto;
  min-height: 0;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  z-index: 10;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
  transform: rotate(90deg);
}

.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 32px;
  border-radius: 16px 16px 0 0;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.modal-flag {
  font-size: 56px;
}

.modal-title {
  font-size: 28px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin-top: 4px;
}

.modal-body {
  padding: 24px 32px 32px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-item {
  background: var(--bg);
  padding: 14px;
  border-radius: 8px;
}

.detail-item .info-label {
  margin-bottom: 4px;
}

.detail-item .info-value {
  font-size: 16px;
}

.detail-section h4 {
  font-size: 14px;
  color: var(--primary-dark);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-light);
}

.detail-section ul {
  list-style: none;
  padding: 0;
}

.detail-section li {
  padding: 6px 0 6px 14px;
  font-size: 14px;
  position: relative;
}

.detail-section li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  position: absolute;
  left: 0;
  top: 6px;
}

.fact-en {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ===== 页脚 ===== */
.site-footer {
  background: #1f2937;
  color: #9ca3af;
  text-align: center;
  padding: 20px 0;
  font-size: 13px;
  margin-top: 40px;
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.state-card {
  animation: fadeIn 0.3s ease;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .header-inner {
    flex-direction: column;
    text-align: center;
  }

  .brand {
    flex-wrap: wrap;
    justify-content: center;
  }

  .header-nav {
    justify-content: center;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .stat {
    min-width: 0;
    padding: 10px 8px;
  }

  .stat-label {
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .map-section {
    padding: 16px;
  }

  .map-header h2 {
    font-size: 18px;
  }

  #usMap .state-label {
    font-size: 8px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    justify-content: space-between;
  }

  .states-list .state-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .states-list .card-body {
    grid-template-columns: 1fr 1fr;
  }

  .states-list .card-footer {
    text-align: left;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand h1 {
    font-size: 22px;
  }

  .stats {
    gap: 12px;
  }

  .stat {
    min-width: 70px;
    padding: 8px 12px;
  }

  .stat-num {
    font-size: 18px;
  }
}
