/* =============================================================================
   PROJECTS MAP  —  css/projects-map.css
   All rules namespaced to .projects-map-section / #projects-map / .pm-*
   Inherits CSS custom properties from styles.css
   ============================================================================= */

/* ── Section ─────────────────────────────────────────────────────────────── */

.projects-map-section {
  background: var(--bg-alt);
  padding: 100px 0 0;
}

/* ── Inner container — 15 % side margins (scales down responsively) ───────── */

.pm-section-inner {
  padding: 0 15%;
}

/* ── Section header ──────────────────────────────────────────────────────── */

.pm-header {
  text-align: center;
  padding-bottom: 52px;
}

.pm-header-tag {
  display: inline-block;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: 100px;
  padding: 5px 14px;
  margin-bottom: 18px;
}

.pm-header-title {
  font-family: 'Fraunces', serif;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 600;
  color: var(--dark);
  margin: 0 0 14px;
  line-height: 1.1;
}

.pm-header-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Map wrapper — flex container for split layout ───────────────────────── */

.pm-map-wrapper {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 600px;
  border-radius: 16px;
  box-shadow: 0 4px 40px rgba(45, 37, 34, 0.12);
  /* overflow:hidden clips both children to the rounded box and hides the
     panel while its width is 0 — does NOT block inner scroll of .pm-panel-content */
  overflow: hidden;
}

/* ── Map canvas area — flex child that fills remaining width ──────────────── */

.pm-map-area {
  flex: 1 1 auto;
  min-width: 0;       /* allow shrink past intrinsic size */
  position: relative;
  overflow: hidden;
}

/* ── Leaflet map canvas ──────────────────────────────────────────────────── */

#pm-map {
  width: 100%;
  height: 100%;       /* fills .pm-map-area, which is sized by the wrapper */
  display: block;
  background: #e8dfd8;
  /* isolation: isolate prevents Leaflet's internal z-indexes (400–700)
     from escaping into the wrapper's stacking context */
  isolation: isolate;
}

/* ── Custom pin marker ───────────────────────────────────────────────────── */

.pm-marker-icon {
  background: transparent !important;
  border: none !important;
  filter: drop-shadow(0 3px 8px rgba(45, 37, 34, 0.30));
  cursor: pointer;
  transition: filter 0.15s ease;
}

.pm-marker-icon:hover,
.pm-marker-icon:focus-visible {
  filter: drop-shadow(0 4px 14px rgba(45, 37, 34, 0.46));
  outline: none;
}

/* ── Cluster icon ────────────────────────────────────────────────────────── */

.pm-cluster {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(212, 100, 78, 0.45);
}

/* ── Detail panel — flex sibling of .pm-map-area ─────────────────────────── */
/*
 * Desktop: panel lives in normal flex flow, not position:absolute.
 * width: 0 (closed) → width: 50% (open).  The map area has flex:1 so it
 * automatically fills the remaining 50%.  transition: width animates the split.
 *
 * Mobile (≤768px): overridden to position:fixed bottom sheet (see @media below).
 */

.pm-panel {
  position: relative;   /* gives .pm-close (position:absolute) a correct origin */
  flex: 0 0 auto;       /* do not grow/shrink via flex; width drives the size  */
  width: 0;
  min-width: 0;
  overflow: hidden;     /* hides content while width is 0; inner scroll still works */
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transition: width 0.34s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}

.pm-panel--open {
  width: 50%;
  box-shadow: -6px 0 28px rgba(45, 37, 34, 0.12);
}

/* ── Close button ────────────────────────────────────────────────────────── */

.pm-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.pm-close:hover,
.pm-close:focus-visible {
  background: var(--tag-bg);
  border-color: var(--primary);
  color: var(--primary);
  outline: none;
}

/* ── Panel scrollable content ────────────────────────────────────────────── */

.pm-panel-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* ── Panel sticky header ─────────────────────────────────────────────────── */

.pm-panel-hdr {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  padding: 18px 20px 14px;
  padding-right: 52px; /* room for close button */
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pm-panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.pm-panel-tag {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: 100px;
  padding: 3px 9px;
}

.pm-panel-title {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.25;
  margin: 0 0 8px;
}

.pm-panel-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Content sections ────────────────────────────────────────────────────── */

.pm-panel-body {
  flex: 1;
}

.pm-sec {
  padding: 16px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.pm-sec:last-child {
  border-bottom: none;
}

.pm-sec-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}

.pm-sec-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.pm-sec-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--primary);
}

.pm-sec-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.72;
  color: var(--text);
  margin: 0;
}

.pm-sec-location {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pm-sec-location svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--primary);
}

/* ── Bullet list ─────────────────────────────────────────────────────────── */

.pm-bullet-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pm-bullet-list li {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.pm-bullet-list li::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

/* ── Image grid ──────────────────────────────────────────────────────────── */

.pm-img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.pm-img-btn {
  display: block;
  border: none;
  padding: 0;
  cursor: zoom-in;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--bg-alt);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pm-img-btn:hover,
.pm-img-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(45, 37, 34, 0.16);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.pm-img-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── View-link footer (bottom of panel body) ─────────────────────────────── */

.pm-panel-footer {
  padding: 14px 20px 18px;
}

.pm-view-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.18s;
}

.pm-view-link:hover,
.pm-view-link:focus-visible {
  border-bottom-color: var(--primary);
  outline: none;
}

/* ── Mobile overlay (backdrop) ───────────────────────────────────────────── */

.pm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45, 37, 34, 0.52);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.pm-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Error message ───────────────────────────────────────────────────────── */

.pm-error {
  padding: 20px 24px;
  margin: 12px 20px;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--primary);
  line-height: 1.6;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */

.pm-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 14, 0.94);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.pm-lightbox--open {
  opacity: 1;
  pointer-events: auto;
}

.pm-lb-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(92vw, 1100px);
}

.pm-lb-figure img {
  max-width: min(92vw, 1100px);
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.pm-lb-caption {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 12px;
  letter-spacing: 0.05em;
}

.pm-lb-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  z-index: 1;
}

.pm-lb-close:hover,
.pm-lb-close:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.pm-lb-prev,
.pm-lb-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  z-index: 1;
}

.pm-lb-prev { left: 20px; }
.pm-lb-next { right: 20px; }

.pm-lb-prev:hover,
.pm-lb-next:hover,
.pm-lb-prev:focus-visible,
.pm-lb-next:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.pm-lb-prev:disabled,
.pm-lb-next:disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* ── Leaflet control overrides (theme-match) ─────────────────────────────── */

.pm-map-wrapper .leaflet-control-attribution {
  font-family: 'DM Sans', sans-serif !important;
  font-size: 10px !important;
  background: rgba(255, 251, 247, 0.88) !important;
}

.pm-map-wrapper .leaflet-control-zoom a {
  color: var(--dark) !important;
  border-color: var(--border) !important;
  background: var(--bg) !important;
  font-family: 'DM Sans', sans-serif;
}

.pm-map-wrapper .leaflet-control-zoom a:hover {
  background: var(--tag-bg) !important;
  color: var(--primary) !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* Large desktops: keep 15% */
@media (max-width: 1400px) {
  .pm-section-inner { padding: 0 10%; }
}

/* Laptop / small desktop — panel uses 50% width (percentage, no px override) */
@media (max-width: 1200px) {
  .pm-section-inner { padding: 0 7%; }
}

/* Tablet landscape */
@media (max-width: 1024px) {
  .pm-section-inner { padding: 0 5%; }
}

/* Tablet portrait & large mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .projects-map-section { padding: 70px 0 0; }

  .pm-section-inner { padding: 0 4%; }

  .pm-header { padding-bottom: 36px; }

  /* On mobile the wrapper stays single-column — no flex split */
  .pm-map-wrapper {
    height: 460px;
    border-radius: 10px;
    display: block; /* override flex — panel uses position:fixed below */
  }

  /* #pm-map fills .pm-map-area which fills the wrapper block */
  .pm-map-area {
    height: 100%;
  }

  /* Switch panel to fixed bottom sheet ─────────────────────────────────── */
  .pm-panel {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important; /* override desktop 50% */
    height: 78vh;
    max-height: 78vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -6px 36px rgba(45, 37, 34, 0.18);
    transform: translateY(110%);
    transition: transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
  }

  .pm-panel--open {
    transform: translateY(0);
    box-shadow: 0 -6px 36px rgba(45, 37, 34, 0.18);
  }

  .pm-overlay { display: block; }

  .pm-lb-prev { left: 8px; }
  .pm-lb-next { right: 8px; }
}

/* Small mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .pm-section-inner { padding: 0; }

  .pm-map-wrapper {
    height: 360px;
    border-radius: 0;
  }

  .pm-panel {
    height: 84vh;
    max-height: 84vh;
  }

  .pm-img-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

/* ── Suburb Legend (Leaflet control) ─────────────────────────────────────── */

.pm-suburb-legend {
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  font-size: 12px;
  line-height: 1.5;
  max-width: 180px;
  margin-bottom: 8px;
}

.pm-legend-title {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin-bottom: 6px;
}

.pm-legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pm-legend-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  color: #333;
}

.pm-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid currentColor;
  opacity: 0.85;
}

/* Suburb polygon tooltip */
.pm-suburb-tooltip {
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  color: #333;
}
