/* ============================================================
   CLARA KHOO — RESEARCH PAGE STYLES
   ResearchwithCK: Interactive map + topic explorer
   ============================================================ */

/* ---- Hero -------------------------------------------------- */
.research-hero {
  text-align: center;
  padding: 56px 24px 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.research-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--heading);
  margin-bottom: 12px;
}
.research-hero-tagline {
  font-size: 1rem;
  font-style: italic;
  color: var(--text);
  margin-bottom: 16px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
.research-hero-desc {
  font-size: 0.9375rem;
  color: var(--text);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.75;
}

/* ---- View Toggle ------------------------------------------- */
.view-toggle-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 24px 24px 0;
}
.view-toggle-btn {
  padding: 9px 24px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.view-toggle-btn:first-child {
  border-radius: 6px 0 0 6px;
  border-right: none;
}
.view-toggle-btn:last-child {
  border-radius: 0 6px 6px 0;
}
.view-toggle-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.view-toggle-btn:hover:not(.active) {
  background: var(--light);
  color: var(--heading);
}

/* ---- Main research area ------------------------------------ */
.research-main {
  position: relative;
  padding: 32px 0 0;
}

/* ---- Map View --------------------------------------------- */
.map-view {
  display: block;
}
.map-view.hidden,
.topic-view.hidden {
  display: none;
}

.map-container-wrap {
  position: relative;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 24px;
}

#research-map {
  width: 100%;
  height: 520px;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 1;
}

.map-reset-btn {
  position: absolute;
  top: 12px;
  left: 36px;
  z-index: 10;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.map-reset-btn:hover {
  background: var(--light);
  color: var(--heading);
}

.map-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 16px auto 0;
  max-width: var(--max-wide);
  padding: 0 24px;
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
}
.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Leaflet popup customisation */
.leaflet-popup-content-wrapper {
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-family: var(--font);
}
.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}
.popup-name {
  font-weight: 700;
  color: var(--heading);
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.popup-loc {
  font-size: 0.8rem;
  color: var(--placeholder-text);
  margin-bottom: 8px;
}
.popup-open-btn {
  display: inline-block;
  padding: 5px 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.popup-open-btn:hover {
  background: #3D6B4A;
  opacity: 1;
  color: #fff;
}

/* ---- Topic Explorer --------------------------------------- */
.topic-view {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 24px 0;
}

.theme-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

.theme-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}
.theme-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.09);
  transform: translateY(-2px);
}
.theme-card.expanded {
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.theme-card-header {
  padding: 20px 22px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}
.theme-card-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.3;
  margin-bottom: 4px;
}
.theme-card-count {
  font-size: 0.78rem;
  color: var(--placeholder-text);
  font-weight: 500;
}
.theme-card-chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--placeholder-text);
  transition: transform 0.25s ease;
  margin-top: 2px;
}
.theme-card.expanded .theme-card-chevron {
  transform: rotate(180deg);
}

/* Expanding body */
.theme-card-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
  border-top: 0px solid var(--border);
}
.theme-card.expanded .theme-card-body {
  grid-template-rows: 1fr;
  border-top-width: 1px;
}
.theme-card-body-inner {
  overflow: hidden;
}

.theme-direct-sites {
  padding: 10px 22px 4px;
  border-bottom: 1px solid var(--border);
}

/* Subtopic level (The Holocaust, The Atomic Bomb, etc.) */
.subtopic-section {
  padding: 12px 22px 6px;
  border-bottom: 1px dashed var(--border);
}
.region-section .subtopic-section:last-child,
.subtopic-section:last-child {
  border-bottom: none;
  padding-bottom: 14px;
}
.subtopic-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--placeholder-text);
  margin-bottom: 10px;
}
.site-link-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.site-link-list li {
  margin-bottom: 0;
  border-bottom: 1px solid transparent;
}
.site-link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--heading);
  font-weight: 500;
  transition: color 0.15s;
  border-bottom: 1px solid var(--border);
}
.site-link-btn:last-child {
  border-bottom: none;
}
.site-link-btn::before {
  content: '→';
  color: var(--accent);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.site-link-btn:hover {
  color: var(--accent);
}

/* Holocaust external resources */
.holocaust-resources {
  margin-top: 14px;
  padding: 14px 0 0;
  border-top: 1px dashed var(--border);
}
.holocaust-resources-heading {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--placeholder-text);
  margin-bottom: 8px;
}
.holocaust-resource-link {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.holocaust-resource-link:last-child {
  border-bottom: none;
}
.holocaust-resource-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 1px;
  transition: color 0.15s;
}
.holocaust-resource-loc {
  font-size: 0.75rem;
  color: var(--placeholder-text);
}
.holocaust-resource-link:hover .holocaust-resource-name {
  color: var(--accent);
}

/* ---- Detail Panel ----------------------------------------- */
.research-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.research-panel-overlay.active {
  opacity: 1;
  visibility: visible;
}

.research-panel {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 1200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.research-panel.active {
  transform: translateX(0);
}

.panel-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 1;
}
.panel-header-text {
  flex: 1;
  min-width: 0;
}
.panel-site-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.3;
  margin-bottom: 2px;
}
.panel-site-loc {
  font-size: 0.8rem;
  color: var(--placeholder-text);
}
.panel-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.panel-close-btn:hover {
  background: var(--border);
  color: var(--heading);
}

.panel-body {
  padding: 20px;
  flex: 1;
}

.panel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-theme-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.panel-date-badge {
  font-size: 0.78rem;
  color: var(--placeholder-text);
  font-weight: 500;
}

/* Photo area */
.panel-photos {
  width: 100%;
  border-radius: 6px;
  overflow: visible;
  margin-bottom: 18px;
}
.panel-photo-placeholder {
  background: var(--placeholder-bg);
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.panel-photo-placeholder {
  text-align: center;
  color: var(--placeholder-text);
  font-size: 0.8rem;
  padding: 12px;
  line-height: 1.5;
}
.panel-photo-placeholder svg {
  display: block;
  margin: 0 auto 8px;
  width: 32px;
  height: 32px;
  opacity: 0.4;
}

/* Description */
.panel-desc {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.75;
  margin-bottom: 24px;
}

/* Readings */
.panel-readings-heading {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--placeholder-text);
  margin-bottom: 10px;
}
.reading-card {
  display: block;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.reading-card:last-child {
  margin-bottom: 0;
}
.reading-card:hover {
  border-color: var(--accent);
  background: #E8F0E8;
}
.reading-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 2px;
  line-height: 1.4;
}
.reading-card-source {
  font-size: 0.775rem;
  color: var(--accent);
}

/* ---- Panel Carousel --------------------------------------- */
.panel-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  touch-action: pan-y;
  background: var(--placeholder-bg);
}
.panel-carousel-track {
  display: flex;
  transition: transform 0.3s ease;
}
.panel-carousel-slide {
  min-width: 100%;
  flex-shrink: 0;
}
.panel-carousel-slide img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* Counter + Dots */
.panel-carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}
.panel-carousel-counter {
  font-size: 0.75rem;
  color: var(--placeholder-text);
  font-weight: 500;
  min-width: 40px;
  text-align: center;
  padding: 4px 0 2px;
}
.panel-carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 2px;
}
.panel-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.panel-carousel-dot.active {
  background: var(--accent);
  transform: scale(1.2);
}

/* Arrow buttons */
.panel-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  color: var(--heading);
  font-size: 0.9rem;
  transition: background 0.15s, opacity 0.15s;
  opacity: 0;
}
.panel-carousel:hover .panel-carousel-arrow {
  opacity: 1;
}
.panel-carousel-arrow--prev { left: 8px; }
.panel-carousel-arrow--next { right: 8px; }
.panel-carousel-arrow:hover {
  background: #fff;
}

/* ---- Photo Groups ----------------------------------------- */
.panel-photo-groups {
  margin-top: 24px;
}
.panel-photo-group {
  margin-bottom: 24px;
}
.panel-photo-group:last-child {
  margin-bottom: 0;
}
.panel-photo-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--placeholder-text);
  margin-bottom: 10px;
}

/* ---- Research Lightbox ------------------------------------ */
.research-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.research-lightbox.active {
  opacity: 1;
  visibility: visible;
}
.research-lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
}
.research-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.research-lightbox-close:hover {
  color: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .theme-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #research-map {
    height: 400px;
  }
}

@media (max-width: 640px) {
  .research-hero {
    padding: 40px 20px 36px;
  }
  #research-map {
    height: 320px;
  }
  .map-legend {
    gap: 12px;
  }
  /* Panel becomes bottom sheet on mobile */
  .research-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .research-panel.active {
    transform: translateY(0);
  }
  .view-toggle-bar {
    padding: 20px 16px 0;
  }
  .topic-view {
    padding: 0 16px 0;
  }
  .map-container-wrap {
    padding: 0 16px;
  }
  .panel-carousel-arrow { display: none; }
  .panel-carousel-dot { width: 7px; height: 7px; }
  .panel-photo-group { margin-bottom: 20px; }
}
