/* Viewer styles for dating-buildings map */

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

/* Fix Leaflet drawing a focus rectangle around clicked polygons */
.leaflet-interactive:focus { outline: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

#map {
  flex: 1;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */

.sidebar {
  width: 360px;
  height: 100vh;
  background: #16213e;
  border-left: 1px solid #0f3460;
  overflow-y: auto;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.sidebar.hidden,
.hidden {
  display: none !important;
}

.sidebar-handle {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #16213e;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 8px;
  cursor: pointer;
  border-bottom: 1px solid #1e3a5f;
  flex-shrink: 0;
}
.sidebar-handle:hover { background: #1a2a50; }

.sidebar-grip {
  display: block;
  width: 40px;
  height: 4px;
  background: #334155;
  border-radius: 999px;
}
.sidebar-handle:hover .sidebar-grip { background: #475569; }

#sidebar-content {
  padding: 16px;
}

.aerial-block {
  margin-top: 10px;
  margin-bottom: 4px;
}
.aerial-wrap {
  position: relative;
  display: block;
}
.aerial-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Street view image */
.sv-image {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 12px;
  display: block;
  background: #0f3460;
}

/* Address header */
.bldg-address {
  font-size: 16px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 12px;
  padding-right: 28px;
}
.bldg-address-also {
  font-size: 13px;
  font-weight: 400;
  color: #64748b;
}

/* Year badge */
.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.year-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
}
.source-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
}

.year-badge .uncertain-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25em;
  height: 1.25em;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

/* Info table */
.info-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}
.info-table td {
  padding: 4px 0;
  vertical-align: top;
}
.info-table td:first-child {
  color: #94a3b8;
  white-space: nowrap;
  padding-right: 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 5px;
}
.info-table td:last-child {
  color: #e2e8f0;
}

/* Cues list */
.cues-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.cues-list li {
  padding: 2px 0 2px 14px;
  position: relative;
  color: #cbd5e1;
  font-size: 13px;
}
.cues-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #64748b;
}

/* Reasoning block */
.reasoning {
  background: #0f2b4d;
  border-left: 3px solid #334155;
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}

/* Links */
.sv-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  padding: 7px 14px;
  background: #1e3a5f;
  border: 1px solid #2563eb;
  border-radius: 6px;
  color: #60a5fa;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}
.sv-link:hover {
  background: #2563eb;
  color: #fff;
}


/* ── Image carousel ──────────────────────────────────────────────────────────── */

.carousel {
  position: relative;
  margin-bottom: 12px;
}
.carousel .sv-image {
  margin-bottom: 0;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 48px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}
.carousel-btn:hover { background: rgba(0,0,0,0.75); }
.carousel-btn-prev { left: 6px; }
.carousel-btn-next { right: 6px; }
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 2px;
}
.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #334155;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}
.carousel-dot.active { background: #60a5fa; }
.carousel-dot:hover { background: #475569; }

/* Block stats section inside sidebar (mobile) */
.sidebar-block-stats {
  padding: 14px 16px 20px;
  border-top: 1px solid #1e3a5f;
}
.sidebar-block-stats.hidden { display: none !important; }

/* ── Legend ──────────────────────────────────────────────────────────────────── */

/* ── Left-panel: stacks block-stats above the legend, bottom-left ────────────── */

.left-panel {
  position: absolute;
  bottom: 28px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

#legend {
  position: relative;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: auto;
  min-width: 180px;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.legend-header .legend-title { margin-bottom: 0; }

.info-btn {
  pointer-events: auto;
  background: none;
  border: 1.5px solid #334155;
  border-radius: 50%;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.info-btn:hover { color: #94a3b8; border-color: #475569; }

.legend-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 7px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0.85;
}
.swatch.unknown {
  background: #22d3ee;
}
.swatch.processing {
  background: #1e293b;
  border: 1px dashed #475569;
}
/* Heritage: era-coloured fill with gold dashed border — matches the map polygon style */
.swatch.heritage-swatch {
  background: #8e44ad;   /* purple = ~1880 Historicism, a representative era colour */
  border: 2px dashed #f59e0b;
  opacity: 0.85;
}

.legend-divider {
  border-top: 1px solid #1e3a5f;
  margin: 7px 0;
}

.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.source-dot.lookup { background: #22c55e; }
.source-dot.llm    { background: #f59e0b; }

/* ── Queue panel ─────────────────────────────────────────────────────────────── */

#queue-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 220px;
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.queue-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.queue-count {
  background: #1e3a5f;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f2b4d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: #cbd5e1;
}

.queue-item-id {
  font-family: monospace;
  color: #38bdf8;
}

.queue-remove {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.queue-remove:hover { color: #f87171; }

.queue-hint {
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
}

.submit-status {
  font-size: 12px;
  color: #22c55e;
  min-height: 16px;
}

.pipeline-status {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px solid #1e3a5f;
}

.ps-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}
.ps-row b {
  color: #cbd5e1;
  font-weight: 600;
}
.ps-row.ps-error b { color: #f87171; }
.ps-row.ps-flight b { color: #fbbf24; }

.ps-batches {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #1e3a5f;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ps-batch {
  font-size: 10px;
  color: #64748b;
  font-family: ui-monospace, monospace;
  display: flex;
  justify-content: space-between;
}
.ps-batch code { color: #94a3b8; }

.submit-btn {
  width: 100%;
  padding: 8px;
  background: #1d4ed8;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.submit-btn:hover:not(:disabled) { background: #2563eb; }
.submit-btn:disabled {
  background: #1e3a5f;
  color: #475569;
  cursor: default;
}

/* Queue toggle button — shown when panel is hidden */
.queue-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #60a5fa;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.queue-toggle:hover { background: #1e3a5f; }

/* ── Block stats panel ───────────────────────────────────────────────────────── */

.block-stats {
  position: relative;
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 10px 16px;
  pointer-events: auto;
  min-width: 180px;
}

.stats-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 8px;
}

.block-stats-highlight-trigger {
  cursor: pointer;
  transition: color 0.12s ease;
}
.block-stats-highlight-trigger:hover {
  color: #cbd5e1;
}

.stats-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  margin: 8px 0 4px;
}
.stats-section-title:first-of-type { margin-top: 0; }
.stat-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: #475569; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 2px 0;
}

.stat-label {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}

.stat-value {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
}

.stats-empty {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

.legend-bottom-row {
  display: flex;
  gap: 6px;
}

.legend-game-link,
.legend-beauty-btn {
  flex: 1;
  display: block;
  padding: 6px 8px;
  background: #1e3a5f;
  border: 1px solid #2563eb;
  border-radius: 6px;
  color: #60a5fa;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s;
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
}
.legend-game-link:hover { background: #2563eb; color: #fff; }
.legend-beauty-btn:disabled {
  border-color: #1e3a5f;
  color: #475569;
  cursor: default;
  background: #0f1f3d;
}

/* ── Legend era rows with counts + hover filter ───────────────────────────────── */

.era-count {
  margin-left: auto;
  background: #1e3a5f;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
}

.legend-era {
  border-radius: 4px;
  padding: 2px 4px;
  margin: 0 -4px;
  transition: background 0.1s;
}
.legend-era:hover,
.legend-era.era-active {
  background: rgba(255,255,255,0.07);
}

/* ── Leaflet overrides ───────────────────────────────────────────────────────── */

.leaflet-container {
  background: #0d1117;
}

.leaflet-popup-content-wrapper {
  background: #16213e;
  color: #e0e0e0;
  border-radius: 6px;
  border: 1px solid #0f3460;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: #16213e; }
.leaflet-popup-content { margin: 8px 12px; font-size: 13px; }

/* ── Info modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 28px 28px 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #fff; }

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 18px;
}

.modal-body {
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.6;
  margin-bottom: 12px;
}
.modal-body a { color: #60a5fa; text-decoration: none; }
.modal-body a:hover { text-decoration: underline; }

.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  margin: 14px 0 6px;
}

.modal-list {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 4px 16px;
  padding: 0;
}
.modal-list li { margin-bottom: 3px; }
.modal-list a { color: #60a5fa; text-decoration: none; }
.modal-list a:hover { text-decoration: underline; }

.modal-footer-text {
  margin-top: 16px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #64748b;
}

.modal-btn {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  background: #1d4ed8;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-btn:hover { background: #2563eb; }
.modal-btn:disabled { background: #334155; color: #64748b; cursor: default; }

/* ── Correction form ─────────────────────────────────────────────────────────── */

.correction-btn {
  padding: 6px 12px;
  background: none;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  display: inline-block;
}
.correction-btn:hover { border-color: #60a5fa; color: #60a5fa; }

.correction-submitted {
  font-size: 12px;
  color: #4ade80;
}

.correction-field {
  margin-bottom: 14px;
}
.correction-label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.correction-input {
  width: 100%;
  padding: 8px 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
}
.correction-input:focus { outline: none; border-color: #3b82f6; }
.correction-hint {
  font-size: 11px;
  color: #475569;
  margin-top: 4px;
}
.correction-error {
  color: #f87171;
  font-size: 13px;
  margin-bottom: 10px;
}

/* ── Mobile responsive ───────────────────────────────────────────────────────── */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 640px) {
  body { flex-direction: column; }

  #map { height: 100vh; width: 100%; }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 62vh;
    border-left: none;
    border-top: 1px solid #0f3460;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s ease;
    z-index: 2000;
    overflow-y: auto;
  }
  .sidebar:not(.hidden) {
    transform: translateY(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1999;
  }
  .sidebar-backdrop.hidden { display: none !important; }

  #queue-panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 50vh;
  }
  .queue-toggle {
    top: auto;
    bottom: 12px;
    left: 12px;
  }

  .left-panel {
    bottom: auto;
    top: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    gap: 0;
    align-items: stretch;
  }

  #legend {
    flex: 1;
    min-width: 0;
    max-width: none;
    border-radius: 0 0 10px 10px;
    border-top: none;
    border-left: none;
    border-right: none;
  }

  .block-stats {
    display: none;
  }

  .modal-box {
    padding: 20px 18px 18px;
  }
}
