/* Iran Map – WordPress Plugin Styles  v1.2 */

/* ── Kamand font (plugin folder) ────────────────────────────────────────── */
@font-face {
  font-family: 'Kamand';
  src: url('../Kamand-Regular.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
/* Map the bold weight and the "Kamand-Bold" family name (used by irannew.svg
   internal styles) both to the same regular file — no separate bold file. */
@font-face {
  font-family: 'Kamand';
  src: url('../Kamand-Regular.woff') format('woff');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Kamand';
  src: url('../Kamand-Regular.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── Container: map RIGHT, table LEFT, 50px padding from edge ────────────── */
.iran-map-container {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 50px !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 20px !important;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif !important;
}
@media (min-width: 900px) {
  .iran-map-container { min-width: 700px !important; }
}

/* ── Map area: ~60% (right side in RTL) ──── */
.iran-map-wrapper {
  flex: 0 0 60% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  position: relative !important;
  background: transparent !important;
  border-radius: 0 !important;
  overflow: visible !important;
  box-shadow: none !important;
}
@media (min-width: 900px) {
  .iran-map-wrapper { min-width: 400px !important; max-width: 800px !important; }
  .iran-map-wrapper svg { min-height: 430px !important; }
}

.iran-map-wrapper.iran-map-zoomed {
  overflow: visible;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.iran-map-zoom-out {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  padding: 7px 16px;
  font-size: 13px;
  font-family: inherit;
  background: #c41e3a;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(196,30,58,0.3);
  transition: background 0.2s, transform 0.2s;
}
.iran-map-zoom-out:hover { background: #8b0000; transform: translateY(-1px); }

/* Main SVG — floating 3-D feel */
.iran-map-wrapper svg {
  width: 100% !important;
  height: auto !important;
  min-height: 280px !important;
  max-width: 100% !important;
  display: block !important;
  overflow: visible !important;
  filter:
    drop-shadow(0 28px 48px rgba(0,20,70,0.22))
    drop-shadow(0 10px 20px rgba(0,15,55,0.16))
    drop-shadow(0  3px  6px rgba(0,10,40,0.12));
}

/* ── Sea / water paths on base map ──────────────────────────────────────── */
.iran-map-wrapper path[id="caspian-sea"],
.iran-map-wrapper path[id="persian-gulf_3_"],
.iran-map-wrapper path[id*="sea"],
.iran-map-wrapper path[id*="gulf"],
.iran-map-wrapper path[id*="island"],
.iran-map-wrapper path[id*="lake"] {
  fill: #a8d8ea !important;
  stroke: #6bb5cc !important;
  stroke-width: 0.8 !important;
  cursor: default !important;
  pointer-events: none !important;
}

/* Baked-in labels from irannew.svg
   - Must not intercept pointer events on province paths underneath.
   - Force direction: ltr so text-anchor "start" stays at the LEFT edge,
     matching Illustrator's layout (parent container is dir="rtl").
   - Apply Kamand font so base-map labels use the same typeface as the table.  */
.iran-map-wrapper svg text,
.iran-map-wrapper svg tspan {
  pointer-events: none !important;
  cursor: default !important;
  direction: ltr !important;
  unicode-bidi: embed !important;
  font-family: 'Kamand', 'Kamand-Bold', 'Vazirmatn', Tahoma, sans-serif !important;
}

/* Province paths – no shops */
.iran-map-wrapper path[id^="IR-"] {
  cursor: pointer;
  fill: #b0bec8 !important;
  stroke: rgba(80,90,110,0.85);
  stroke-width: 1.2;
  stroke-linejoin: round;
  transition: fill 0.2s ease;
}
.iran-map-wrapper path[id^="IR-"]:hover {
  fill: #cdd8e0 !important;
}

/* Province paths – no animation */
.iran-map-wrapper path[id^="IR-"].has-shops {
  fill: #5aaad6 !important;
}
.iran-map-wrapper path[id^="IR-"].has-shops:hover {
  fill: #7fc4e8 !important;
}
.iran-map-wrapper path[id^="IR-"].has-shops.active {
  fill: #9dd4f0 !important;
  animation: iran-map-province-active-blink 2s ease-in-out infinite;
}
.iran-map-wrapper path[id^="IR-"]:not(.has-shops).active {
  animation: iran-map-province-active-blink 2s ease-in-out infinite;
}
@keyframes iran-map-province-active-blink {
  0%, 100% { filter: brightness(1); opacity: 1; }
  50% { filter: brightness(1.25); opacity: 0.92; }
}

/* Zoomed province on base (fallback mode) */
.iran-map-wrapper.iran-map-zoomed path.iran-map-province-zoomed {
  stroke: rgba(255,255,255,0.6);
  stroke-width: 1.5;
}

.iran-map-wrapper.iran-map-cities-shown path.iran-map-province-zoomed {
  fill: #eef2f6 !important;
  filter: none;
  stroke: rgba(0,0,0,0.12);
  stroke-width: 1.5;
}

/* ── Province name labels on base map ───────────────────────────────────── */
.iran-map-province-labels-layer text.iran-map-province-label {
  font-size: 11px;
  fill: #1a2640;
  font-weight: 700;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  text-rendering: geometricPrecision;
  paint-order: stroke fill;
  stroke: rgba(255,255,255,0.75);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.iran-map-province-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 5px 14px;
  font-size: 15px;
  font-family: inherit;
  background: rgba(255,255,255,0.92);
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  pointer-events: none;
  font-weight: 600;
  display: none;
}

/* ── City hotspot ────────────────────────────────────────────────────────── */
/* Legacy hotspot pulse — removed (demarcation regions used instead) */
.iran-map-hotspot-pulse-legacy {
  fill: rgba(255,80,80,0.18);
  stroke: rgba(255,80,80,0.55);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: iran-hotspot-pulse 2.2s ease-out infinite;
}
@keyframes iran-hotspot-pulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  100% { transform: scale(2.8); opacity: 0;   }
}

/* City pins — clean design, labels never overlap */
.iran-map-city-pin {
  fill: #c41e3a;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: fill 0.2s ease, transform 0.2s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.iran-map-city-pin-group {
  cursor: pointer;
  pointer-events: all;
}
.iran-map-city-pin-group:hover .iran-map-city-pin {
  fill: #e63950;
  transform: scale(1.15);
}
.iran-map-city-label {
  fill: #1a237e;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif;
  font-weight: 600;
  font-size: 7px;
  text-anchor: middle;
  dominant-baseline: middle;
  text-rendering: geometricPrecision;
  paint-order: stroke fill;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 2px;
  stroke-linejoin: round;
  pointer-events: none;
}
.iran-map-city-pin-group:hover .iran-map-city-label { fill: #0d47a1; }
.iran-map-city-pin-group.selected .iran-map-city-pin {
  fill: #c41e3a;
  stroke: #ffffff;
  stroke-width: 1.2;
}
.iran-map-city-pin-group.selected .iran-map-city-label {
  fill: #c41e3a;
  font-weight: 700;
}

/* ── Tooltip — province name only (minimal floating label) ──────────────── */
.iran-map-tooltip {
  position: fixed;
  z-index: 999999;
  background: rgba(15, 30, 60, 0.88);
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.iran-map-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.iran-map-tooltip-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif;
  text-align: right;
  direction: rtl;
}
/* Legacy elements — hidden in new simplified tooltip */
.iran-map-tooltip-cities { display: none; }

/* ── Shops section: ~40% width (left side in RTL) ─ */
.iran-map-shops-section {
  flex: 1 1 40% !important;
  min-width: 0 !important;
  padding: 20px !important;
  background: #fff !important;
  border-radius: 10px !important;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08) !important;
  border: 1px solid #e8edf2 !important;
  direction: rtl !important;
}
@media (min-width: 900px) {
  .iran-map-shops-section { min-width: 280px !important; }
}

/* Usage note above the table – blinks 3 times on page load */
.iran-map-usage-note {
  background: #eef6fb;
  border-right: 4px solid #5aaad6;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #2c5f82;
  line-height: 1.7;
  direction: rtl;
  text-align: right;
  animation: iran-map-usage-blink 2.4s ease-in-out 3;
}
@keyframes iran-map-usage-blink {
  0%, 33.33%, 66.66%, 100% { opacity: 1; box-shadow: none; }
  16.66%, 50%, 83.33% { opacity: 0.6; box-shadow: 0 0 12px rgba(90,170,214,0.4); }
}
.iran-map-usage-note strong {
  color: #1a3f5c;
}

/* Cities bar — above table, clickable chips */
.iran-map-cities-bar {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 16px 22px !important;
  margin-bottom: 14px !important;
  padding: 10px 0 !important;
  border-bottom: 1px solid #e8edf2 !important;
}
.iran-map-city-chip {
  margin: 2px 4px !important;
  padding: 6px 14px !important;
  font-size: 12px !important;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif !important;
  background: #f0f4f8 !important;
  border: 1px solid #d0d8e0 !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s !important;
  color: #2c3e50 !important;
  box-sizing: border-box !important;
  display: inline-block !important;
}
.iran-map-city-chip:hover {
  background: #e3eaf2;
  border-color: #b8c4d0;
}
.iran-map-city-chip.selected {
  background: #c41e3a;
  border-color: #c41e3a;
  color: #fff;
}
.iran-map-city-chip.selected.iran-map-city-has-data {
  animation: none;
}
/* City chips blink only when bar is visible (province selected) */
.iran-map-cities-bar[data-province-id] .iran-map-city-chip.iran-map-city-has-data {
  --im-blink: #c41e3a;
  animation: iran-map-blink 2.5s ease-in-out infinite;
}
@keyframes iran-map-blink {
  0%, 100% { background-color: #f0f4f8 !important; color: #2c3e50 !important; box-shadow: none; }
  20% { background-color: var(--im-blink) !important; color: #fff !important; box-shadow: 0 0 12px var(--im-blink); }
  50% { background-color: var(--im-blink) !important; color: #fff !important; box-shadow: 0 0 12px var(--im-blink); }
  80% { background-color: var(--im-blink) !important; color: #fff !important; box-shadow: 0 0 12px var(--im-blink); }
}

.iran-map-shops-title {
  font-size: 13px !important;
  font-weight: 700 !important;
  margin: 0 0 14px 0 !important;
  text-align: right !important;
  color: #1a2640 !important;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif !important;
  direction: rtl !important;
}
.iran-map-shops-title span { color: #c41e3a; font-weight: 700; }

.iran-map-shops-table-wrap {
  overflow-x: auto !important;
  width: 100% !important;
  -webkit-overflow-scrolling: touch;
}

.iran-map-shops-table {
  width: 100% !important;
  border-collapse: collapse !important;
  text-align: right !important;
  direction: rtl !important;
  font-size: 11px !important;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif !important;
  table-layout: fixed !important;
}

/* Column widths: name 22%, phone 22%, fax 16%, address 40% — align under headers */
.iran-map-shops-table th:nth-child(1),
.iran-map-shops-table td:nth-child(1) { width: 22% !important; text-align: right !important; }
.iran-map-shops-table th:nth-child(2),
.iran-map-shops-table td:nth-child(2) { width: 22% !important; text-align: right !important; }
.iran-map-shops-table th:nth-child(3),
.iran-map-shops-table td:nth-child(3) { width: 16% !important; text-align: right !important; }
.iran-map-shops-table th:nth-child(4),
.iran-map-shops-table td:nth-child(4) { width: 40% !important; text-align: right !important; }

.iran-map-shops-table th,
.iran-map-shops-table td {
  padding: 8px 10px !important;
  border-bottom: 1px solid #eee !important;
  vertical-align: top !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}
.iran-map-shops-table th {
  background: #f4f7fa;
  font-weight: 700;
  color: #334;
  font-size: 13px;
  font-family: 'Kamand', 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif;
}
.iran-map-shops-table tbody tr:hover { background: #fafcff; }

/* ── Province popup (full-page overlay) ─────────────────────────────────── */
.iran-map-province-popup {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iran-map-province-popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.40);
  cursor: pointer;
  animation: iran-page-dim-in 0.3s ease forwards;
}
@keyframes iran-page-dim-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Transparent floating panel — square, ~70% of the smaller viewport side */
.iran-map-province-popup-panel {
  position: relative;
  z-index: 100001;
  /* Max size: 72% of the smaller viewport dimension, capped at 720px.
     The SVG inside uses preserveAspectRatio="xMidYMid meet", so provinces
     fill this box at their natural shape without empty forced-square space. */
  width:  min(72vw, 72vh, 720px);
  height: min(72vw, 72vh, 720px);
  display: flex;
  flex-direction: column;
  background: none;
  overflow: visible;
  animation: iran-popup-in 0.22s ease;
}
@keyframes iran-popup-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.iran-map-province-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 10px;
  direction: rtl;
  background: none;
  border: none;
}
.iran-map-province-popup-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Vazirmatn', 'B Nazanin', Tahoma, sans-serif;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
.iran-map-province-popup-close {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 11px;
  border-radius: 6px;
  transition: background 0.15s;
}
.iran-map-province-popup-close:hover { background: rgba(255,255,255,0.28); }

/* SVG wrap — fills remaining panel space; SVG scales via preserveAspectRatio */
.iran-map-province-popup-svg-wrap {
  flex: 1 1 0;
  min-height: 0;        /* critical: lets flex child shrink to fit parent */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.iran-map-province-popup-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Province shape: 3-D elevated — fill set by JS gradient */
.iran-map-province-popup-svg-wrap .iran-map-city-label {
  font-size: 7px !important;
}
/* Only province path (IR-XX) — city regions must stay clickable */
.iran-map-province-popup-svg-wrap path[id^="IR-"] {
  stroke: rgba(255,255,255,0.65) !important;
  stroke-width: 1.8 !important;
  pointer-events: none !important;
  cursor: default !important;
  filter:
    drop-shadow(0 18px 36px rgba(0,0,0,0.55))
    drop-shadow(0  6px 12px rgba(0,0,0,0.38))
    drop-shadow(0  1px  3px rgba(0,0,0,0.25)) !important;
}
/* City pin groups — clickable */
.iran-map-province-popup-svg-wrap .iran-map-city-pin-group {
  pointer-events: all !important;
  cursor: pointer !important;
}

/* ── Responsive: stack vertically on narrow screens ─────────────────────── */
@media (max-width: 899px) {
  .iran-map-container {
    flex-direction: column !important;
    padding: 0 16px !important;
  }
  .iran-map-wrapper {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .iran-map-wrapper svg {
    min-height: 280px !important;
  }
  .iran-map-shops-section {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 16px !important;
  }
  .iran-map-province-popup-panel {
    width: min(94vw, 94vh) !important;
    height: min(94vw, 94vh) !important;
  }
}
@media (max-width: 480px) {
  .iran-map-container { padding: 0 10px !important; }
  .iran-map-wrapper svg { min-height: 220px !important; }
  .iran-map-shops-section { padding: 12px !important; }
  .iran-map-shops-table th,
  .iran-map-shops-table td { padding: 6px 4px !important; font-size: 10px !important; }
}
