/* Taiwan Interactive Map Styles */

/* ─── Map Section Layout ─── */
.map-section {
  text-align: center;
}

.map-container {
  position: relative;
  display: inline-block;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.map-wrapper {
  position: relative;
  width: 100%;
}

/* ─── SVG County Paths ─── */
.map-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
}

.map-wrapper path[data-county] {
  fill: var(--map-fill);
  stroke: var(--map-stroke);
  stroke-width: 1;
  cursor: pointer;
  transition: fill 0.2s ease, stroke-width 0.2s ease;
}

.map-wrapper path[data-county]:hover,
.map-wrapper path[data-county].hovered {
  fill: var(--map-fill-hover);
  stroke-width: 1.8;
}

.map-wrapper path[data-county].active {
  fill: var(--map-fill-hover);
  stroke-width: 2;
}

.map-wrapper path[data-county]:focus-visible {
  outline: none;
  fill: var(--map-fill-hover);
  stroke: var(--brand-dark);
  stroke-width: 2.5;
}

/* ─── Tooltip Card ─── */
.map-tooltip {
  position: absolute;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  min-width: 180px;
  max-width: 260px;
  text-align: left;
}

.map-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.map-tooltip-county {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.map-tooltip-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.map-tooltip-list li {
  margin: 0;
  padding: 0;
}

.map-tooltip-list a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  color: var(--brand);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.map-tooltip-list a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.map-tooltip-list a svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* ─── Tooltip Close Button ─── */
.map-tooltip-close {
  display: none;
}

/* ─── Fallback Library List ─── */
.library-text-list {
  margin-top: 32px;
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.library-text-list summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 8px 0;
}

.library-text-list summary:hover {
  color: var(--brand);
}

.library-text-list ul {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  columns: 2;
  column-gap: 24px;
}

.library-text-list li {
  padding: 4px 0;
  break-inside: avoid;
}

.library-text-list a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
}

.library-text-list a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.library-text-list .lib-city {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 4px;
}

/* ─── ARIA Live Region ─── */
.map-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ─── Color Variables ─── */
:root {
  --map-fill: #bbf7d0;
  --map-fill-hover: #34d399;
  --map-stroke: #059669;
  --border: #e2e8f0;
}

html.dark {
  --map-fill: #064e3b;
  --map-fill-hover: #10b981;
  --map-stroke: #34d399;
  --border: #334155;
}

/* ─── Mobile: Bottom Sheet Tooltip ─── */
@media (max-width: 600px) {
  .map-container {
    max-width: 320px;
  }

  .map-tooltip {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    min-width: 0;
    border-radius: 16px 16px 0 0;
    padding: 20px 24px 28px;
    transform: translateY(100%);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  }

  .map-tooltip.visible {
    transform: translateY(0);
  }

  .map-tooltip-close {
    display: block;
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
  }

  .map-tooltip-close:hover {
    color: var(--text-primary);
  }

  .library-text-list ul {
    columns: 1;
  }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  .map-wrapper path[data-county] {
    transition: none;
  }

  .map-tooltip {
    transition: none;
  }
}
