/*
 * Hamat International Contracting Company — Interactive Saudi Arabia 23-Project-Sites Map
 * Dark obsidian cartography with subtle CSS-only ambient telemetry (zero SMIL).
 * Paired with js/map-saudi.js hydrating [data-animated-map="saudi"].
 */

.hm-saudi-map {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 714 / 560;
  background: radial-gradient(circle at 38% 54%, #141210 0%, #0B0B0A 72%);
  border: 1px solid var(--hm-line, #2B2A28);
  overflow: hidden;
  isolation: isolate;
}

.hm-map-frame .hm-saudi-map {
  border-color: rgba(242, 238, 230, 0.08);
}

/* Keep SVG coordinate space strictly LTR on RTL Arabic pages so anchors never mirror */
.hm-sa__stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  direction: ltr;
  unicode-bidi: isolate;
}

.hm-sa__svg {
  display: block;
  width: 100%;
  height: 100%;
  direction: ltr;
  font-family: 'Montserrat', 'Lato', system-ui, sans-serif;
}

.hm-saudi-map[data-lang="ar"] .hm-sa__svg {
  font-family: 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, sans-serif;
}

/* Subtle technical cartographic gridlines (~0.04 opacity) */
.hm-sa__grid {
  fill: none;
  stroke: #F2EEE6;
  stroke-opacity: 0.04;
  stroke-width: 0.7;
  pointer-events: none;
}

/* ---------- 13 Saudi Arabia Regions ---------- */
.hm-sa__region {
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: fill 200ms ease, stroke 200ms ease, stroke-width 200ms ease, opacity 200ms ease, filter 200ms ease;
}

.hm-sa__region--inactive {
  fill: #161513;
  stroke: #2B2A28;
  stroke-width: 1;
}

.hm-sa__region--active {
  cursor: pointer;
  fill: #2A1708;
  stroke: #8A3A0B;
  stroke-width: 1.15;
}

/* Subtle amber-bronze concentration scale across the 8 operating regions */
.hm-sa__region--active[data-tier="1"] {
  fill: #2A1708;
  stroke: #8A3A0B;
}

.hm-sa__region--active[data-tier="2"] {
  fill: #301A09;
  stroke: #9D460B;
}

.hm-sa__region--active[data-tier="3"] {
  fill: #351D09;
  stroke: #B4530A;
  stroke-width: 1.2;
}

.hm-sa__region--active[data-tier="4"] {
  fill: #3B200A;
  stroke: #CA6208;
  stroke-width: 1.25;
}

.hm-sa__region--active:focus-visible {
  outline: 2px solid #F07D05;
  outline-offset: 2px;
}

.hm-saudi-map.has-active .hm-sa__region--active:not(.is-active) {
  opacity: 0.62;
}

.hm-sa__region--active:hover,
.hm-sa__region--active.is-active {
  fill: #522B0B;
  stroke: #F07D05;
  stroke-width: 1.8;
  opacity: 1;
}

.hm-sa__focus-outline {
  fill: none;
  stroke: #F07D05;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 0 7px rgba(240, 125, 5, 0.55));
  transition: opacity 180ms ease;
}

.hm-sa__focus-outline.is-visible {
  opacity: 1;
}

/* ---------- Curved Dispatch Corridors from Jeddah HQ ---------- */
.hm-sa__routes {
  pointer-events: none;
}

.hm-sa__routes-base {
  fill: none;
  stroke: #F07D05;
  stroke-opacity: 0.16;
  stroke-width: 1;
  stroke-linecap: round;
}

.hm-sa__route-pulse {
  fill: none;
  stroke: #F07D05;
  stroke-opacity: 0.56;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-dasharray: 16 84;
  stroke-dashoffset: 100;
  animation: hm-sa-dispatch 3.6s linear infinite;
  transition: stroke 200ms ease, stroke-opacity 200ms ease, stroke-width 200ms ease;
}

.hm-sa__route-pulse--d0 { animation-delay: 0s; animation-duration: 3.4s; }
.hm-sa__route-pulse--d1 { animation-delay: -0.45s; animation-duration: 3.2s; }
.hm-sa__route-pulse--d2 { animation-delay: -0.9s; animation-duration: 3.6s; }
.hm-sa__route-pulse--d3 { animation-delay: -1.35s; animation-duration: 3.8s; }
.hm-sa__route-pulse--d4 { animation-delay: -1.8s; animation-duration: 3.9s; }
.hm-sa__route-pulse--d5 { animation-delay: -2.25s; animation-duration: 3.0s; }
.hm-sa__route-pulse--d6 { animation-delay: -2.7s; animation-duration: 3.5s; }
.hm-sa__route-pulse--d7 { animation-delay: -3.15s; animation-duration: 3.7s; }

.hm-saudi-map.has-active .hm-sa__route-pulse:not(.is-active) {
  stroke-opacity: 0.14;
}

.hm-sa__route-pulse.is-active {
  stroke: #FFA033;
  stroke-opacity: 0.96;
  stroke-width: 2;
  stroke-dasharray: 28 72;
  filter: drop-shadow(0 0 4px rgba(240, 125, 5, 0.72));
}

@keyframes hm-sa-dispatch {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* ---------- 23 Project Site Beacons ---------- */
.hm-sa__pin {
  fill: #F2EEE6;
  stroke: #F07D05;
  stroke-width: 2.2;
  stroke-opacity: 0.88;
  cursor: pointer;
  filter: drop-shadow(0 0 3px rgba(240, 125, 5, 0.65));
  animation: hm-sa-pin-breathe 3.6s ease-in-out infinite;
  transition: stroke 180ms ease, stroke-width 180ms ease, opacity 200ms ease, filter 200ms ease;
}

.hm-sa__pin--b0 { animation-delay: 0s; }
.hm-sa__pin--b1 { animation-delay: -0.9s; }
.hm-sa__pin--b2 { animation-delay: -1.8s; }
.hm-sa__pin--b3 { animation-delay: -2.7s; }

.hm-saudi-map.has-active .hm-sa__pin:not(.is-active) {
  opacity: 0.34;
}

.hm-sa__pin.is-active,
.hm-sa__pin:hover {
  fill: #FFFFFF;
  stroke: #FF9E2C;
  stroke-width: 3.1;
  stroke-opacity: 1;
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(240, 125, 5, 0.95));
}

@keyframes hm-sa-pin-breathe {
  0%, 100% {
    stroke-width: 1.95;
    stroke-opacity: 0.72;
  }
  50% {
    stroke-width: 2.75;
    stroke-opacity: 1;
  }
}

/* ---------- 2 Site Offices & Jeddah Head Office ---------- */
.hm-sa__site-office {
  fill: #0B0B0A;
  stroke: #F2EEE6;
  stroke-width: 1.9;
  cursor: pointer;
  transition: stroke 180ms ease, fill 180ms ease, filter 180ms ease;
}

.hm-sa__site-office.is-active,
.hm-sa__site-office:hover {
  fill: #2A1708;
  stroke: #F07D05;
  filter: drop-shadow(0 0 5px rgba(240, 125, 5, 0.85));
}

.hm-sa__hq-pulse {
  fill: none;
  stroke: #F07D05;
  stroke-width: 1.3;
  pointer-events: none;
  transform-origin: 164.9px 378px;
  animation: hm-sa-hq-radar 3.6s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

.hm-sa__hq-pulse--2 {
  animation-delay: -1.8s;
}

.hm-sa__hq-ring {
  fill: none;
  stroke: #F07D05;
  stroke-opacity: 0.58;
  stroke-width: 1.15;
  pointer-events: none;
}

.hm-sa__hq-core {
  fill: #F07D05;
  stroke: #F2EEE6;
  stroke-width: 2;
  cursor: pointer;
  filter: drop-shadow(0 0 5px rgba(240, 125, 5, 0.8));
}

@keyframes hm-sa-hq-radar {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
    stroke-width: 1.6;
  }
  70% {
    opacity: 0.16;
  }
  100% {
    transform: scale(2.15);
    opacity: 0;
    stroke-width: 0.6;
  }
}

/* ---------- Labels & Callout Leader Lines ---------- */
.hm-sa__callouts {
  pointer-events: none;
}

.hm-sa__callout-lines {
  fill: none;
  stroke: #8A3A0B;
  stroke-opacity: 0.82;
  stroke-width: 1;
  stroke-dasharray: 2.5 2.5;
}

.hm-sa__callout-dot {
  fill: #161513;
  stroke: #C45E08;
  stroke-width: 1.15;
}

.hm-sa__labels {
  pointer-events: none;
  user-select: none;
}

.hm-sa__label {
  paint-order: stroke;
  stroke: #0B0B0A;
  stroke-linejoin: round;
  transition: fill 180ms ease, fill-opacity 180ms ease;
}

.hm-sa__label--active {
  fill: #F2EEE6;
  fill-opacity: 0.92;
  font-size: 11.5px;
  font-weight: 600;
  stroke-width: 3px;
}

.hm-saudi-map[data-lang="ar"] .hm-sa__label--active {
  font-size: 12px;
}

.hm-sa__label--active.is-active {
  fill: #FFFFFF;
  fill-opacity: 1;
}

.hm-sa__label--inactive {
  fill: #B0A89D;
  fill-opacity: 0.88;
  font-size: 10.5px;
  font-weight: 500;
  stroke-width: 2.5px;
}

.hm-saudi-map[data-lang="ar"] .hm-sa__label--inactive {
  font-size: 11px;
}

.hm-sa__label--callout {
  fill: #B3ACA1;
  fill-opacity: 0.92;
  font-size: 10.5px;
  font-weight: 600;
  stroke-width: 2.4px;
}

.hm-sa__label--hq {
  fill: #F2EEE6;
  font-size: 12.5px;
  font-weight: 700;
  stroke-width: 3px;
}

.hm-sa__label--hq-sub {
  fill: #F07D05;
  font-size: 10.5px;
  font-weight: 600;
  stroke-width: 2.6px;
}

/* ---------- Inline SVG Legend ---------- */
.hm-sa__legend {
  pointer-events: none;
  user-select: none;
}

.hm-sa__legend-box {
  fill: #121110;
  fill-opacity: 0.92;
  stroke: #2B2A28;
  stroke-width: 1;
}

.hm-sa__legend-text {
  fill: #F2EEE6;
  font-size: 11px;
  font-weight: 600;
}

.hm-saudi-map[data-lang="ar"] .hm-sa__legend-text {
  font-size: 11.5px;
}

/* ---------- Interactive Region Readout Tooltip ---------- */
.hm-sa-tip {
  position: absolute;
  bottom: 12px;
  right: 52px;
  z-index: 5;
  max-width: min(260px, calc(100% - 64px));
  padding: 8px 12px;
  background: rgba(18, 17, 16, 0.96);
  border: 1px solid #F07D05;
  border-inline-start: 3px solid #F07D05;
  color: #F2EEE6;
  font-family: var(--font-text, 'Lato', system-ui, sans-serif);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.hm-saudi-map[data-lang="ar"] .hm-sa-tip {
  direction: rtl;
  text-align: right;
  font-family: var(--font-text, 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, sans-serif);
}

.hm-saudi-map[data-lang="en"] .hm-sa-tip {
  direction: ltr;
  text-align: left;
}

.hm-sa-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hm-sa-tip__name {
  display: block;
  font-family: var(--font-display, 'Montserrat', system-ui, sans-serif);
  font-weight: 700;
  font-size: 13px;
  color: #F2EEE6;
}

.hm-sa-tip__meta {
  display: block;
  margin-top: 2px;
  color: #F07D05;
  font-weight: 600;
  font-size: 11.5px;
}

@media (max-width: 639px) {
  .hm-sa-tip {
    bottom: 10px;
    right: 50px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .hm-sa-tip__name {
    font-size: 12px;
  }
  .hm-sa-tip__meta {
    font-size: 11px;
  }
}

/* ---------- Sidebar Row Sync (#projects .rows > li[data-region]) ---------- */
#projects .rows > li[data-region] {
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

#projects .rows > li[data-region]:hover,
#projects .rows > li[data-region].is-map-active {
  background: rgba(240, 125, 5, 0.08);
  border-bottom-color: rgba(240, 125, 5, 0.55);
}

#projects .rows > li[data-region]:hover .rows__name,
#projects .rows > li[data-region].is-map-active .rows__name {
  color: var(--hm-text, var(--ink, #F2EEE6));
}

#projects .rows > li[data-region]:hover .rows__value,
#projects .rows > li[data-region].is-map-active .rows__value {
  color: #F07D05;
}

/* ---------- Pause Button & Paused State (WCAG 2.2.2 .loop-pause) ---------- */
.hm-saudi-map > .loop-pause {
  background: rgba(18, 17, 16, 0.92);
  color: #F2EEE6;
  border: 1px solid rgba(242, 238, 230, 0.22);
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease;
}

.hm-saudi-map > .loop-pause:hover,
.hm-saudi-map > .loop-pause:focus-visible {
  border-color: #F07D05;
  color: #F07D05;
  background: #1A130D;
}

.hm-saudi-map.is-paused .hm-sa__route-pulse,
.hm-saudi-map.is-paused .hm-sa__pin,
.hm-saudi-map.is-paused .hm-sa__hq-pulse,
.hm-saudi-map.is-offscreen .hm-sa__route-pulse,
.hm-saudi-map.is-offscreen .hm-sa__pin,
.hm-saudi-map.is-offscreen .hm-sa__hq-pulse {
  animation-play-state: paused !important;
}

/* ---------- Reduced Motion: Crisp Calm Static State (0 Movement) ---------- */
@media (prefers-reduced-motion: reduce) {
  .hm-saudi-map,
  .hm-saudi-map *,
  .hm-saudi-map *::before,
  .hm-saudi-map *::after,
  #projects .rows > li[data-region] {
    animation: none !important;
    transition: none !important;
  }

  .hm-sa__route-pulse {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    stroke-opacity: 0.28;
  }

  .hm-sa__hq-pulse {
    transform: scale(1.25);
    opacity: 0.34;
  }

  .hm-sa__hq-pulse--2 {
    display: none;
  }

  .hm-sa__pin {
    stroke-width: 2.3;
    stroke-opacity: 0.92;
  }

  .hm-saudi-map .loop-pause {
    display: none !important;
  }
}
