/* ============================================================
   home.css — Anasayfa harita ekranı (yalnız index.html'de kullanılır)
   ------------------------------------------------------------
   Strateji: header `position: fixed` (header.js scroll-hide için
   gerekli). Map-wrapper, JS-set --header-height değişkenine göre
   konumlanır. CSS per-breakpoint sensible default verir → JS
   ölçümü tamamlandığında layout shift minimal olur.
   ------------------------------------------------------------
   Breakpoints (JS MOBILE_BREAKPOINT=1024 ile uyumlu):
     mobile:  ≤ 640px
     tablet:  641 – 1024px
     desktop: ≥ 1025px
   ============================================================ */

/* ============================================================
   Anasayfa SSR Freshness Block (Türkiye geneli son 5 deprem)
   AI crawler'lar için statik LiveBlogPosting içeriği.
   ============================================================ */
.ssr-homepage-freshness {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d1b1b 100%);
    color: #fff;
    padding: 24px 0;
    border-top: 3px solid #d32f2f;
}

.hp-fresh__title {
    margin: 0 0 16px;
    font-size: 1.4rem;
    color: #fff;
    line-height: 1.3;
}

.hp-fresh__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.hp-fresh__item {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    border-left: 3px solid #d32f2f;
    font-size: 0.95rem;
    color: #fff;
    line-height: 1.5;
}

.hp-fresh__item a {
    color: #fff;
    text-decoration: none;
}

.hp-fresh__item a:hover {
    color: #fca5a5;
    text-decoration: underline;
}

.hp-fresh__mag {
    display: inline-block;
    background: #d32f2f;
    color: #fff;
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.82rem;
}

.hp-fresh__depth {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.hp-fresh__updated {
    margin: 14px 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    text-align: right;
}

@media (max-width: 640px) {
    .hp-fresh__title { font-size: 1.15rem; }
    .hp-fresh__item { font-size: 0.88rem; padding: 8px 12px; }
}

/* ---------- Header height fallback (JS measure'ı ezecek) ---------- */
:root {
    --header-height: 64px;   /* desktop default — gerçek render ~62-66px */
    --hm-gap: 10px;
}

@media (max-width: 1024px) {
    :root {
        --header-height: 68px;
        --hm-gap: 8px;
    }
}

@media (max-width: 640px) {
    :root {
        --header-height: 62px;
        --hm-gap: 8px;
    }
}

/* ---------- Map wrapper ---------- */
/* main.map-wrapper: tag+class kombinasyonu (specificity 0,0,1,1)
   Bilinmeyen cascade kuralının üzerine geçer. */
main.map-wrapper {
    position: relative;
    width: 100%;
    margin-top: calc(var(--header-height) + var(--hm-gap));
}

main.map-wrapper #map {
    width: 100%;
    /* Desktop: viewport yüksekliğinin ~78'i — header + ekstra boşluk çıkartılır */
    height: calc((100vh - var(--header-height)) * 0.78);
    border-radius: 0;
    z-index: 1;
}

/* Tablet ve mobilde harita 65vh ile sınırlandı — eskiden ekranı doldurup
   altındaki "Son depremler" panelini görmek için scroll gerekiyordu. */
@media (max-width: 1024px) {
    main.map-wrapper #map {
        height: 65vh;
        min-height: 360px;
    }
}

@media (max-width: 640px) {
    main.map-wrapper #map {
        height: 60vh;
        min-height: 320px;
    }
}

.map-h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.map-wrapper .leaflet-top {
    top: 8px;
}

/* ---------- Magnitude legend (sol, dikey) ---------- */
.map-wrapper .magnitude-legend {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    width: 130px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 0.9;
    z-index: 1000;
    max-height: calc(100vh - var(--header-height) - 60px);
    overflow-y: auto;
    scrollbar-width: none;
}

.map-wrapper .magnitude-legend::-webkit-scrollbar { display: none; }

.magnitude-legend .legend-title {
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.magnitude-legend .legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.magnitude-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.magnitude-legend .color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.magnitude-legend .legend-label {
    font-size: 11px;
    color: #111827;
}

.magnitude-legend .legend-short {
    display: none;
}

/* ---------- Türkiye + Konumum butonları ---------- */
.magnitude-legend .turkey-btn,
.magnitude-legend .my-location-btn {
    width: 100%;
    margin-top: 8px;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.magnitude-legend .turkey-btn {
    background: linear-gradient(135deg, #E30A17, #C41E3A);
}

.magnitude-legend .my-location-btn {
    background: linear-gradient(135deg, #4285f4, #1a73e8);
}

.magnitude-legend .turkey-btn:hover,
.magnitude-legend .my-location-btn:hover:not(.is-loading) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.magnitude-legend .my-location-btn.is-loading {
    opacity: 0.75;
    cursor: wait;
}

.magnitude-legend .my-location-btn.is-loading i {
    animation: spin 1s linear infinite;
}

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

/* ---------- Earthquake list (sağ) ---------- */
.map-wrapper .earthquake-list {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    width: 240px;
    /* Harita yüksekliğinin yaklaşık yarısı — gereksiz dikey alan kaplamasın. */
    max-height: calc((100vh - var(--header-height)) * 0.4);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    opacity: 0.92;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.earthquake-list .list-header {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.earthquake-list .list-header h2 {
    font-size: 15px;
    color: #1f2937;
    margin: 0;
    flex: 1 0 100%;
}

.earthquake-list #push-subscribe-btn {
    margin: 0;
    padding: 3px 6px;
    border: 1px solid #d32f2f;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #d32f2f;
    font-size: 0.65rem;
    cursor: pointer;
}

.earthquake-list .filter-controls {
    margin-left: auto;
}

.earthquake-list .filter-controls select {
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 10px;
    cursor: pointer;
}

.earthquake-list .earthquake-items {
    flex: 1 1 auto;
    min-height: 0;          /* flex child scroll için kritik */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.earthquake-list .earthquake-items::-webkit-scrollbar { width: 4px; }
.earthquake-list .earthquake-items::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.earthquake-list .earthquake-item {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.earthquake-list .earthquake-item:hover {
    background: #f9f9f9;
}

.earthquake-list .magnitude {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    margin-right: 8px;
    border-radius: 5px;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.earthquake-list .details {
    min-width: 0;
    flex: 1;
}

.earthquake-list .details h3 {
    font-size: 12px;
    color: #1f2937;
    margin: 0 0 1px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.earthquake-list .details .time {
    font-size: 10.5px;
    color: #666;
    margin-bottom: 0;
    line-height: 1.15;
}

.earthquake-list .details .depth {
    font-size: 10px;
    color: #888;
    line-height: 1.15;
}

.earthquake-list .loading {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* ---------- Update info (alt-orta) ---------- */
.map-wrapper .update-info {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 0.9;
    z-index: 1000;
    max-width: calc(100% - 32px);
}

.update-info #last-update {
    font-size: 10.5px;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-info .btn-refresh {
    width: 24px;
    height: 24px;
    padding: 4px;
    border: none;
    background: none;
    color: #d32f2f;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.update-info .btn-refresh:hover {
    background: rgba(211, 47, 47, 0.1);
}

.update-info .btn-refresh i {
    font-size: 12px;
    animation: spin 1s linear infinite;
}

/* ---------- Leaflet popup ---------- */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #fff;
    color: #1f2937;
}

.leaflet-popup-content p { color: #1f2937; margin: 6px 0; }
.leaflet-popup-content p strong { color: #111827; font-weight: 700; }

.earthquake-popup { text-align: left; min-width: 220px; }
.earthquake-popup__title { margin: 0 0 8px; color: #d32f2f; font-weight: 700; font-size: 16px; }
.earthquake-popup__details p { margin: 6px 0; font-size: 14px; }
.earthquake-popup__source { margin-top: 6px; font-size: 12px; color: #374151; }
.earthquake-popup__actions { margin-top: 10px; display: flex; gap: 8px; }
.earthquake-popup__action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #d32f2f;
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.earthquake-popup__action-btn:hover { background: #b71c1c; }

/* ============================================================
   TABLET (641 – 1024px)
   - Earthquake list mobil dropdown'a taşınıyor (JS) → haritada gizle
   - Legend altta yatay/merkez (kompakt)
   ============================================================ */
@media (max-width: 1024px) {
    .map-wrapper .earthquake-list {
        display: none;
    }

    .map-wrapper .magnitude-legend {
        top: auto !important;
        bottom: 16px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: auto !important;
        max-width: calc(100% - 24px) !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 12px 14px 10px !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        opacity: 0.97 !important;
        backdrop-filter: blur(6px);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18) !important;
    }

    .magnitude-legend .legend-title { display: none; }

    .magnitude-legend .legend-items {
        position: relative;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        width: 100%;
        padding-top: 22px;
    }

    .magnitude-legend .legend-items::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 16px;
        border-radius: 999px;
        background: linear-gradient(90deg,
            #4caf50 0%, #ffc107 20%, #ff9800 38%,
            #ff5722 52%, #f44336 70%, #d32f2f 85%, #7b1fa2 100%);
        border: 1px solid rgba(0, 0, 0, 0.15);
    }

    .magnitude-legend .legend-item {
        display: none;
        justify-content: center;
        gap: 0;
        padding: 2px 0;
    }

    .magnitude-legend .legend-item[data-short] {
        display: flex;
    }

    .magnitude-legend .color-box,
    .magnitude-legend .legend-label {
        display: none;
    }

    .magnitude-legend .legend-short {
        display: inline-block;
        font-size: 14px;
        font-weight: 700;
        color: #111827;
        letter-spacing: 0.01em;
    }

    /* Türkiye + Konumum dropdown'a taşınıyor */
    .magnitude-legend .turkey-btn,
    .magnitude-legend .my-location-btn {
        display: none;
    }

    .mobile-legend-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .mobile-legend-actions .turkey-btn,
    .mobile-legend-actions .my-location-btn {
        display: flex;
        margin-top: 0;
        padding: 8px 10px;
        font-size: 12px;
    }

    .mobile-info-content .earthquake-list {
        display: flex;
        position: static;
        transform: none;
        width: 100%;
        max-height: none;
        opacity: 1;
        box-shadow: none;
    }

    .mobile-info-content .earthquake-list .earthquake-items {
        max-height: none;
    }

    .map-wrapper .update-info {
        bottom: 12px;
        padding: 5px 9px;
        gap: 6px;
        max-width: calc(100% - 24px);
    }

    .update-info #last-update { font-size: 10px; }
    .update-info .btn-refresh { width: 22px; height: 22px; padding: 3px; }
    .update-info .btn-refresh i { font-size: 11px; }
}

/* ============================================================
   MOBILE (≤ 640px)
   - Legend tepeye sabitle
   ============================================================ */
@media (max-width: 640px) {
    .map-wrapper .magnitude-legend {
        top: 8px;
        bottom: auto;
        max-width: 96%;
    }

    .map-wrapper .leaflet-top {
        top: 60px;
    }
}

/* ============================================================
   Touch target accessibility (≥44px Google önerisi)
   ============================================================ */
.earthquake-list .magnitude {
    min-width: 44px;
    min-height: 44px;
}

.earthquake-list .earthquake-item {
    min-height: 48px;
    padding: 8px 12px;
}

.cat-btn,
.page-btn {
    min-height: 44px;
}

.btn-refresh,
.update-info .btn-refresh {
    min-width: 36px;
    min-height: 36px;
}
