/**
 * Sheldon Gates Site Map — Stylesheet
 * Scarlett Homes brand colours:
 *   Primary:   #7D0303
 *   Heading:   #4A4A4A
 *   Text:      #7A7A7A
 *   Accent bg: #F5F5F5
 */

/* ── Reset / Container ────────────────────────────────────────────────────── */
.sgm-container {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: #4A4A4A;
  max-width: 1160px;
  margin: 0 auto 40px;
  position: relative;
}

.sgm-container *,
.sgm-container *::before,
.sgm-container *::after {
  box-sizing: border-box;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
.sgm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #7A7A7A;
}

.sgm-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #E0D8D0;
  border-top-color: #7D0303;
  border-radius: 50%;
  animation: sgm-spin 0.8s linear infinite;
  margin-bottom: 14px;
}

@keyframes sgm-spin {
  to { transform: rotate(360deg); }
}

/* ── Error ────────────────────────────────────────────────────────────────── */
.sgm-error {
  background: #FFF5F5;
  border-left: 4px solid #7D0303;
  border-radius: 0 6px 6px 0;
  padding: 16px 20px;
  color: #4A4A4A;
  margin: 20px 0;
}

.sgm-error a {
  color: #7D0303;
  font-weight: 600;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.sgm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 14px;
  border-bottom: 2px solid #7D0303;
  margin-bottom: 16px;
}

.sgm-title {
  font-size: 22px;
  font-weight: 700;
  color: #4A4A4A;
  margin: 0 0 2px;
  letter-spacing: 0.3px;
}

.sgm-subtitle {
  font-size: 12px;
  color: #7A7A7A;
  margin: 0;
}

.sgm-meta {
  text-align: right;
}

.sgm-last-updated {
  font-size: 11px;
  color: #9A9A9A;
  font-style: italic;
}

/* ── Map Wrapper ──────────────────────────────────────────────────────────── */
.sgm-map-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #F5F2EC;
  border: 1px solid #E0D8CC;
  border-radius: 6px;
  padding: 4px;
  position: relative;
}

.sgm-map-wrap svg {
  display: block;
  width: 100%;
  min-width: 480px;
  height: auto;
}

/* Lot hover / focus styles injected via JS per status colour,
   but provide a base interactive feel here */
.sgm-map-wrap .lot rect {
  transition: filter 0.15s ease, stroke-width 0.15s ease;
  cursor: pointer;
}

.sgm-map-wrap .lot:hover rect,
.sgm-map-wrap .lot:focus rect,
.sgm-map-wrap .lot.sgm-active rect {
  filter: brightness(1.08) drop-shadow(0 0 4px rgba(125,3,3,0.35));
  stroke-width: 2.5px !important;
  stroke: #7D0303 !important;
}

.sgm-map-wrap .lot:focus {
  outline: none;
}

/* ── Legend ───────────────────────────────────────────────────────────────── */
.sgm-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1px solid #E0D8CC;
  border-radius: 6px;
  margin-top: 12px;
  font-size: 12px;
}

.sgm-legend-title {
  font-weight: 700;
  color: #4A4A4A;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-right: 4px;
}

.sgm-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

.sgm-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4A4A4A;
  white-space: nowrap;
}

.sgm-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* ── CTA Bar ──────────────────────────────────────────────────────────────── */
.sgm-cta {
  background: #4A4A4A;
  border-radius: 6px;
  padding: 20px 24px 14px;
  margin-top: 16px;
  color: #F5F5F5;
}

.sgm-cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.sgm-cta-text {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: #F5F5F5;
  flex: 1 1 200px;
}

.sgm-cta-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sgm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 22px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  letter-spacing: 0.3px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.sgm-btn-primary {
  background: #7D0303;
  color: #FFFFFF !important;
  border: 2px solid #7D0303;
}

.sgm-btn-primary:hover {
  background: #9A0404;
  border-color: #9A0404;
}

.sgm-btn-secondary {
  background: transparent;
  color: #F5F5F5 !important;
  border: 2px solid rgba(245,245,245,0.5);
}

.sgm-btn-secondary:hover {
  border-color: #F5F5F5;
  background: rgba(255,255,255,0.08);
}

.sgm-disclaimer {
  font-size: 10px;
  color: rgba(245,245,245,0.55);
  margin: 0;
  line-height: 1.4;
  font-style: italic;
}

/* ── Popup Overlay ────────────────────────────────────────────────────────── */
.sgm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  backdrop-filter: blur(2px);
}

/* ── Lot Detail Popup ─────────────────────────────────────────────────────── */
.sgm-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28);
  z-index: 9999;
  overflow: hidden;
  animation: sgm-popup-in 0.18s ease;
}

@keyframes sgm-popup-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.sgm-popup-status-bar {
  height: 6px;
  background: #7D0303;
  /* background colour overridden by JS to match lot status */
}

.sgm-popup-body {
  padding: 22px 24px 20px;
}

.sgm-popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 22px;
  color: #FFFFFF;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  z-index: 1;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.sgm-popup-close:hover {
  opacity: 1;
}

.sgm-popup-lot-title {
  font-size: 20px;
  font-weight: 700;
  color: #4A4A4A;
  margin: 0 0 2px;
}

.sgm-popup-address {
  font-size: 13px;
  color: #7A7A7A;
  margin: 0 0 14px;
}

.sgm-popup-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.sgm-popup-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: #F5F5F5;
  border-radius: 6px;
}

.sgm-popup-detail-item {
  display: flex;
  flex-direction: column;
}

.sgm-popup-detail-label {
  font-size: 10px;
  color: #9A9A9A;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 1px;
}

.sgm-popup-detail-value {
  font-size: 13px;
  font-weight: 600;
  color: #4A4A4A;
}

.sgm-popup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.sgm-popup-actions .sgm-btn-primary {
  flex: 1 1 auto;
  text-align: center;
}

.sgm-popup-notes {
  font-size: 11.5px;
  color: #7A7A7A;
  margin: 0;
  font-style: italic;
  line-height: 1.45;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .sgm-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .sgm-meta {
    text-align: left;
  }

  .sgm-title {
    font-size: 18px;
  }

  .sgm-cta-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .sgm-cta-buttons {
    width: 100%;
  }

  .sgm-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .sgm-legend {
    flex-direction: column;
    align-items: flex-start;
  }

  .sgm-popup-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sgm-cta {
    padding: 16px;
  }

  .sgm-popup {
    width: 96vw;
    max-height: 88vh;
    overflow-y: auto;
  }
}

/* ── Accessibility ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sgm-spinner,
  .sgm-popup,
  .sgm-map-wrap .lot rect {
    animation: none;
    transition: none;
  }
}
