@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;0,800;1,700&display=swap');
@import url('https://unpkg.com/leaflet@1.9.4/dist/leaflet.css');

/* Cô lập toàn bộ CSS vào ID cha để không ảnh hưởng bên ngoài */
#cafef-interactive-wrapper {
    position: relative;
    width: 100%;
    clip-path: inset(0 0 0 0); /* Dùng clip-path thay cho overflow:hidden để không làm hỏng tính năng sticky của bản đồ */
    font-family: 'Inter', sans-serif;
    background-color: #0f172a !important;
    color: #f8fafc;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;

    /* Variables */
    --bg-dark: #0f172a; 
    --bg-card: rgba(15, 23, 42, 0.75); 
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Hyper-Vibrant Neon Palette cho 10 dự án */
    --c1: #ff0055; /* Sông Hồng */
    --c2: #00d2ff; /* Olympic */
    --c3: #00ff88; /* Bắc Thăng Long */
    --c4: #ffaa00; /* Thư Lâm */
    --c5: #ff00ea; /* Tiến Xuân */
    --c6: #00f0ff; /* Ocean Park */
    --c7: #ffe600; /* Thanh Hà */
    --c8: #00ffcc; /* Global Gate */
    --c9: #9d00ff; /* Ciputra */
    --c10: #ff3300; /* Smart City */
}

#cafef-interactive-wrapper *, 
#cafef-interactive-wrapper *::before, 
#cafef-interactive-wrapper *::after {
    box-sizing: inherit;
}

/* Phục hồi một số reset cơ bản riêng cho vùng bài viết do đã tắt Tailwind preflight */
#cafef-interactive-wrapper h1, 
#cafef-interactive-wrapper h2, 
#cafef-interactive-wrapper h3, 
#cafef-interactive-wrapper .serif-font {
    font-family: 'Playfair Display', serif !important; 
    margin: 0;
    padding: 0;
}
#cafef-interactive-wrapper p {
    margin: 0 0 1.5rem 0;
}
#cafef-interactive-wrapper img {
    max-width: 100%;
    display: block;
}

/* Ambient Background Neon Blur - Đổi sang absolute để không tràn ra ngoài màn hình */
#cafef-interactive-wrapper .ambient-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
#cafef-interactive-wrapper .ambient-blob {
    position: absolute;
    filter: blur(150px);
    opacity: 0.3;
    border-radius: 50%;
    animation: float 15s infinite alternate ease-in-out;
}
#cafef-interactive-wrapper .blob-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: #0ea5e9; } 
#cafef-interactive-wrapper .blob-2 { top: 40%; right: -10%; width: 40vw; height: 40vw; background: #d946ef; animation-delay: -5s; } 
#cafef-interactive-wrapper .blob-3 { bottom: -20%; left: 20%; width: 60vw; height: 60vw; background: #f59e0b; animation-delay: -2s; } 

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 60px) scale(1.15); }
}

#cafef-interactive-wrapper #scrolly {
    position: relative;
    display: flex;
    align-items: flex-start; /* Bắt buộc để sticky hoạt động đúng trong flexbox */
    padding: 0;
    max-width: 1600px;
    margin: 0 auto;
    z-index: 2;
}

#cafef-interactive-wrapper #article-content {
    position: relative;
    width: 50%; 
    padding: 0 3rem 0 2rem;
    z-index: 10;
}

#cafef-interactive-wrapper #map-container {
    position: sticky;
    top: 5vh; /* Thay đổi nhỏ để không bị lẹm vào menu header của báo */
    height: 90vh;
    width: 50%;
    z-index: 1;
    align-self: flex-start; /* Bắt buộc để map không bị kéo dãn bằng thẻ cha, giúp sticky hoạt động */
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
}

#cafef-interactive-wrapper #map {
    width: 100%;
    height: 100%;
    background: #020617; 
}

#cafef-interactive-wrapper .step {
    margin: 0 auto 50vh auto;
    opacity: 0.25;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    transform: translateY(40px) scale(0.95);
    
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
    border-left-width: 6px;
    border-left-style: solid;
    border-left-color: transparent;
}

#cafef-interactive-wrapper .step.is-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 
        0 20px 40px -10px var(--step-glow),
        inset 0 1px 0 rgba(255,255,255,0.1);
    border-left-color: var(--step-color);
    border-right: 1px solid rgba(255,255,255,0.05);
    border-top: 1px solid rgba(255,255,255,0.05);
}

#cafef-interactive-wrapper .step-num {
    background: linear-gradient(135deg, var(--step-color), #000);
    color: white;
    box-shadow: 0 0 20px var(--step-glow);
}

#cafef-interactive-wrapper .step-image-container {
    overflow: hidden;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    aspect-ratio: 16/9;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    background: #1e293b;
}

#cafef-interactive-wrapper .step-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.05);
    transition: transform 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#cafef-interactive-wrapper .step.is-active .step-image {
    transform: scale(1);
}

#cafef-interactive-wrapper .metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#cafef-interactive-wrapper .metric-card {
    background: rgba(0,0,0,0.4);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#cafef-interactive-wrapper .step.is-active .metric-card {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255,255,255,0.15);
}

#cafef-interactive-wrapper .step.is-active .metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--step-color);
}

#cafef-interactive-wrapper .metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

#cafef-interactive-wrapper .metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    line-height: 1.3;
}

/* Marker CSS */
.custom-div-icon { background: transparent; border: none; }

.marker-wrapper {
    position: relative;
    width: 36px; height: 48px;
    transform-origin: bottom center; 
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.marker-pin {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.95);
    border: 3px solid var(--pin-color);
    box-shadow: 0 0 10px rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 800; font-size: 15px;
    position: relative; z-index: 2;
    transition: background 0.3s, box-shadow 0.3s;
}

.marker-pointer {
    position: absolute; bottom: 0; left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent; border-right: 8px solid transparent;
    border-top: 14px solid var(--pin-color);
    z-index: 1;
}

.marker-wrapper.active {
    transform: scale(1.5);
    z-index: 1000 !important;
}

.marker-wrapper.active .marker-pin {
    background: var(--pin-color);
    box-shadow: 0 0 25px var(--pin-glow), inset 0 0 10px rgba(0,0,0,0.3);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.marker-pulse {
    position: absolute; bottom: -6px; left: 50%;
    width: 24px; height: 24px;
    transform: translateX(-50%);
    background: var(--pin-color); border-radius: 50%;
    z-index: 0; opacity: 0;
}
.marker-wrapper.active .marker-pulse {
    animation: pulse-neon 2s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Popup CSS */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px !important; padding: 0 !important; overflow: hidden;
    box-shadow: 0 15px 30px rgba(0,0,0,0.6) !important;
}
.leaflet-popup-tip { background: rgba(15, 23, 42, 0.95) !important; border: 1px solid rgba(255,255,255,0.1); }
.leaflet-popup-content { margin: 0 !important; width: 280px !important; }
.leaflet-container a.leaflet-popup-close-button { color: white; background: rgba(0,0,0,0.5); border-radius: 50%; margin: 8px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; transition: background 0.3s;}
.leaflet-container a.leaflet-popup-close-button:hover { background: rgba(255,255,255,0.2); }
.popup-custom .popup-img { width: 100%; height: 160px; object-fit: cover; border-bottom: 3px solid var(--popup-color); }
.popup-custom .popup-body { padding: 1rem; color: white; }
.popup-custom .popup-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 16px; color: var(--popup-color); margin-bottom: 6px; line-height: 1.3;}

/* Hero Section */
#cafef-interactive-wrapper .hero-section {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 10vh auto;
    padding: 12vh 2rem 0 2rem;
}

#cafef-interactive-wrapper .hero-title-box {
    text-align: center;
    margin-bottom: 3rem;
    width: 100%;
}

#cafef-interactive-wrapper .hero-title {
    font-size: clamp(1.2rem, 2.5vw, 3.2rem); 
    font-weight: 800;
    line-height: 1.4; 
    font-family: 'Playfair Display', serif !important;
    display: inline-block; 
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #ffffff 0%, #38bdf8 50%, #d946ef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(56, 189, 248, 0.3);
    white-space: normal; 
}

#cafef-interactive-wrapper .hero-content {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.1);
    border-top: 1px solid rgba(255,255,255,0.2);
    border-radius: 1.5rem;
    padding: 3.5rem;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
    color: #e2e8f0;
    font-size: 1.2rem;
    line-height: 1.85;
    text-align: justify;
    max-width: 1000px;
    margin: 0 auto;
}

#cafef-interactive-wrapper .drop-cap {
    float: left;
    font-size: 5.5rem;
    line-height: 0.8;
    padding-top: 8px;
    padding-right: 16px;
    font-family: 'Playfair Display', serif !important;
    font-weight: 800;
    background: linear-gradient(135deg, #38bdf8, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#cafef-interactive-wrapper .chart-container {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 1.5rem;
    padding: 3rem;
    margin-top: 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

#cafef-interactive-wrapper #d3-pie-chart {
    position: relative;
    width: 100%;
    max-width: 450px;
    height: 450px;
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#cafef-interactive-wrapper .slice { transition: opacity 0.3s ease, filter 0.3s ease; cursor: pointer; }
#cafef-interactive-wrapper .slice:hover { filter: brightness(1.2); }

#cafef-interactive-wrapper .chart-tooltip {
    pointer-events: none;
    position: absolute;
    text-align: center;
    background: transparent;
    width: 100%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#cafef-interactive-wrapper .chart-legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    width: 100%;
    margin-top: 1rem;
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

#cafef-interactive-wrapper .legend-item {
    display: flex;
    align-items: flex-start;
    font-size: 0.95rem;
    color: #cbd5e1;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}
#cafef-interactive-wrapper .legend-item:hover { background: rgba(255,255,255,0.1); color: white; transform: translateX(5px); }

#cafef-interactive-wrapper .legend-color {
    width: 16px; height: 16px;
    border-radius: 50%;
    margin-right: 12px;
    margin-top: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 10px currentColor;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    #cafef-interactive-wrapper .hero-title { white-space: normal; }
    #cafef-interactive-wrapper #scrolly { flex-direction: column; }
    #cafef-interactive-wrapper #article-content { width: 100%; padding: 1rem; margin-top: 50vh; }
    #cafef-interactive-wrapper #map-container { width: 100%; height: 50vh; position: fixed; top: 0; left: 0; z-index: 0; border-radius: 0; }
    #cafef-interactive-wrapper .step { margin: 0 auto 30vh auto; padding: 1.5rem; }
    #cafef-interactive-wrapper .hero-content { padding: 2rem; }
    #cafef-interactive-wrapper .hero-title { font-size: 2.2rem; }
}