/* ============================================
   نُزه - أنماط الخريطة التفاعلية
   map.css
   ============================================ */

.main-content:has(.map-container) { padding: 0; }

.map-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;               /* فوق الزخرفة، تحت شريط التنقل */
}

.map-header {
    position: absolute;
    /* تُحسب من الارتفاع الفعلي للترويسة، فلا تنزل تحت الشعار عند أي مقاس */
    top: calc(var(--header-height) + var(--spacing-md));
    left: 50%;
    transform: translateX(-50%);
    width: min(90%, 400px);
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.map-title {
    color: #111;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 5px;
}

.map-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: #444;
    font-weight: 700;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 8px;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-color { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.color-green  { background: #2ecc71; }
.color-red    { background: #e74c3c; }
.color-yellow { background: #f1c40f; }
.color-blue   { background: #3498db; }

.header-toggle-btn {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #888;
    padding: 4px 0 0;
}
.header-toggle-btn svg { transition: transform 0.3s ease; }
.header-toggle-btn.open svg { transform: rotate(180deg); }

.collapsible-status {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    text-align: right;
}
.collapsible-status.open { max-height: 220px; padding: 8px 4px 4px; }

.status-box {
    background: #f9f9f9;
    border-right: 4px solid #ccc;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.7;
}
.status-box.safe    { border-right-color: #2ecc71; background: rgba(46, 204, 113, 0.07); }
.status-box.warning { border-right-color: #f1c40f; background: rgba(241, 196, 15, 0.07); }
.status-box.danger  { border-right-color: #e74c3c; background: rgba(231, 76, 60, 0.07); }

.status-label { display: block; margin-bottom: 4px; color: #222; }
.status-text  { color: #555; }

#realMap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* خلفية بلون التطبيق: إن تأخّرت البلاطات لا يظهر رمادي المتصفح */
    background: var(--color-bg-darker);
    /* تلاشٍ علوي وسفلي لدمج الخريطة مع خلفية التطبيق،
       مقيس على الارتفاع الفعلي للترويسة لا على رقم ثابت */
    -webkit-mask-image: linear-gradient(to bottom,
        transparent 0, transparent var(--header-height),
        black calc(var(--header-height) + 120px),
        black calc(100% - 140px), transparent calc(100% - 40px));
    mask-image: linear-gradient(to bottom,
        transparent 0, transparent var(--header-height),
        black calc(var(--header-height) + 120px),
        black calc(100% - 140px), transparent calc(100% - 40px));
}

/* نوافذ Leaflet المنبثقة */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.96);
    color: #333;
    border-radius: 12px;
    font-family: var(--font-family);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    direction: rtl;
    text-align: right;
}
.leaflet-popup-tip { background: rgba(255, 255, 255, 0.96); }
.popup-title {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 5px;
}
.popup-desc { font-size: 12px; color: #666; line-height: 1.7; }

.popup-animals {
    margin-top: 6px; padding-top: 6px;
    border-top: 1px solid rgba(0,0,0,.06);
    font-size: 11px; color: #555;
}

/* --- مبدّل نمط الخريطة (ثلاثة تصنيفات) --- */
.map-styles {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.map-style {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.04);
    color: #555;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.map-style:hover { background: rgba(0, 0, 0, 0.08); }
.map-style--on {
    background: #1e3d2d;
    color: var(--color-gold);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.popup-link {
    display: inline-block;
    margin-top: 8px;
    color: #a88a3a;
    font-weight: 700;
    font-size: 12px;
}
.trip-pin { filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }

/* أزرار التكبير: بهوية نُزه لا بالنمط الافتراضي لليفلت */
.leaflet-control-zoom {
    border: 1px solid var(--color-gold-border) !important;
    border-radius: var(--border-radius-md) !important;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    margin-block-end: calc(var(--navbar-height) + 16px) !important;
    margin-inline-start: var(--spacing-lg) !important;
}
.leaflet-control-zoom a {
    background: var(--scrim-92);
    color: var(--color-gold);
    border-bottom-color: var(--color-gold-border);
    font-weight: 700;
}
.leaflet-control-zoom a:hover { background: rgba(201, 168, 76, 0.9); color: #111; }
.leaflet-control-zoom a.leaflet-disabled { opacity: 0.4; }


/* زرّ الجهة الرسمية في بطاقة المحمية.

   يُميَّز عن بقيّة البطاقة ليُقرأ خروجاً لا تكملةً للنصّ، ويقول
   «يفتح في تبويب جديد» قبل الضغط لا بعده: من انتقل فجأةً إلى موقعٍ
   آخر يظنّها خطأً فيعود بزرّ الرجوع، وقد يفقد ما كان يقرأ. */
.popup-partner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid var(--color-gold-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-gold-bg);
    color: var(--color-gold);
    font-size: var(--font-size-sm);
    font-weight: 700;
    text-align: center;
}
.popup-partner:hover { background: var(--tint-010); }
.popup-partner small {
    font-weight: 400;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}
/* السهم يُرسم بضلعين لا حرفاً: محارف الزوايا تنقلب في الفقرة
   اليمينية، وقد كلّفنا ذلك سهماً معكوساً في كل صفٍّ يُضغط. */
.popup-partner span::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-inline-start: 6px;
    border-top: 2px solid currentColor;
    border-left: 2px solid currentColor;
    transform: rotate(-45deg);
    vertical-align: middle;
}
