/* --- Fonts --- */
@font-face {
    font-family: 'Rubik';
    src: url('rubik.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}
@font-face {
    font-family: 'Amiri';
    src: url('amiri.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}
@font-face {
    font-family: 'NotoSerif';
    src: url('notoserif.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}

/* --- Global Variables --- */
:root {
    --bg-color: #0f0f0f;
    --card-bg: #181818;
    --text-primary: #f0f0f0;
    --text-muted: #888;
    --accent-red: #8b0000;
    --accent-red-bright: #e53935;
    --border-color: #2a2a2a;
    
    /* Default Fonts (Persian) */
    --font-ui: 'Rubik', sans-serif;
    --font-styled: 'Amiri', serif;
    
    --radius-lg: 16px;
    --radius-md: 12px;
}

/* English Override */
html[lang="en"] :root {
    --font-ui: 'NotoSerif', sans-serif;
    --font-styled: 'NotoSerif', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden; 
    height: 100vh; width: 100vw;
}

/* --- INTRO OVERLAY --- */
#intro-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 30px; text-align: center;
    transition: opacity 1s ease-out;
}
.intro-content { max-width: 600px; }
.intro-logo { width: 80px; height: auto; margin-bottom: 20px; opacity: 0; animation: fadeIn 1s forwards; }
#intro-title { font-family: 'Amiri', serif; font-size: 1.8rem; color: #fff; margin-bottom: 15px; min-height: 1.8rem; }
#intro-subtitle { font-family: 'Rubik', sans-serif; font-size: 1rem; color: #aaa; min-height: 1rem; line-height: 1.6; }

@keyframes fadeIn { to { opacity: 1; } }

/* --- UI Header --- */
#ui-header {
    position: fixed; top: 0; left: 0; width: 100%; z-index: 100;
    padding: 15px; pointer-events: none;
    display: flex; flex-direction: column; gap: 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
}
.search-wrapper, .controls-wrapper { pointer-events: auto; }

.search-wrapper { width: 100%; display: flex; justify-content: center; }
#search-input {
    width: 100%; max-width: 500px; padding: 14px 24px;
    border-radius: 50px; border: 1px solid #333;
    background: rgba(20, 20, 20, 0.95); color: white;
    font-family: var(--font-ui); backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4); font-size: 16px;
}
#search-input:focus { border-color: var(--accent-red); outline: none; }

.controls-wrapper { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.control-btn {
    background: rgba(30, 30, 30, 0.9); color: #aaa;
    border: 1px solid #333; padding: 8px 16px;
    border-radius: 50px; font-family: var(--font-ui); backdrop-filter: blur(4px);
    font-size: 0.85rem; cursor: pointer; transition: 0.2s;
}
.control-btn.active { background: var(--accent-red); color: white; border-color: var(--accent-red); box-shadow: 0 0 10px rgba(139,0,0,0.4); }

@media (min-width: 768px) {
    #ui-header { flex-direction: row; justify-content: space-between; align-items: flex-start; padding: 25px; }
    .search-wrapper { position: absolute; left: 50%; transform: translateX(-50%); width: auto; min-width: 400px; }
    .controls-wrapper { justify-content: flex-start; }
}

/* --- Views --- */
#map { height: 100vh; width: 100vw; z-index: 1; background: #0a0a0a; }
.hidden { display: none !important; }

/* --- GRID VIEW --- */
.grid-view {
    height: 100vh; width: 100vw; background: var(--bg-color);
    overflow-y: auto; z-index: 5;
    padding: 160px 20px 100px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    align-content: start;
}
.grid-view::-webkit-scrollbar { width: 6px; }
.grid-view::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* --- CARD --- */
.martyr-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    position: relative;
}
.martyr-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    border-color: #444;
}
.card-image-box {
    width: 100%; aspect-ratio: 1 / 1.1;
    background: #202020; position: relative;
}
.card-image-box img { width: 100%; height: 100%; object-fit: cover; transition: opacity 0.3s; filter: saturate(0) contrast(1.1);}
.card-placeholder {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #444; background: #1a1a1a;
}
.card-placeholder span { font-size: 2rem; margin-bottom: 5px; }
.card-info { padding: 12px; text-align: center; }
.card-name {
    font-size: 1rem; font-weight: 700; color: #fff; margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: var(--font-styled); /* Using styled font for names */
}
.card-location {
    font-size: 0.8rem; color: var(--text-muted);
    background: #222; padding: 2px 8px; border-radius: 4px;
    display: inline-block; font-family: var(--font-ui);
}

/* --- Floating Button --- */
.floating-btn {
    position: fixed; z-index: 200; bottom: 30px; right: 30px;
    width: 60px; height: 60px; border-radius: 50%;
    font-size: 32px; background: var(--accent-red); color: white;
    border: none; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.4); 
    transition: transform 0.2s; cursor: pointer;
}
.floating-btn:hover { background: var(--accent-red-bright); transform: scale(1.1); }

/* --- MODALS --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 1000;
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; 
    padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #181818;
    border: 1px solid #333;
    border-radius: var(--radius-lg);
    width: 100%; max-width: 420px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    transform: translateY(20px); transition: transform 0.3s;
    overflow: hidden;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.close-modal {
    position: absolute; top: 15px; left: 15px; 
    font-size: 28px; color: #fff; cursor: pointer; z-index: 10;
    background: rgba(0,0,0,0.5); width: 32px; height: 32px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* --- PROFILE DETAIL --- */
.profile-header { width: 100%; height: 300px; background: #111; position: relative; }
.profile-header img { width: 100%; height: 100%; object-fit: cover; }
.profile-body { padding: 25px; text-align: center; }

.profile-name { font-family: var(--font-styled); font-size: 1.5rem; font-weight: 800; color: white; margin-bottom: 8px; }
.profile-meta { 
    display: flex; justify-content: center; gap: 15px; 
    margin-bottom: 20px; color: var(--text-muted); font-size: 0.95rem; font-family: var(--font-ui);
}
.profile-meta span { display: flex; align-items: center; gap: 5px; }
.profile-date { 
    background: rgba(139, 0, 0, 0.2); color: #ffcccc; 
    padding: 8px 16px; border-radius: 50px; font-size: 0.9rem; display: inline-block;
    font-family: var(--font-ui);
}

/* --- FORMS --- */
.form-scroll-area { padding: 30px; max-height: 80vh; overflow-y: auto; }
.form-title { font-size: 1.2rem; margin-bottom: 5px; color: white; text-align: center; font-family: var(--font-styled); }
.form-subtitle { text-align: center; color: #777; font-size: 0.8rem; margin-bottom: 25px; font-family: var(--font-ui); }

.form-group { margin-bottom: 18px; }
label { display: block; margin-bottom: 8px; color: #aaa; font-size: 0.85rem; font-family: var(--font-ui); }
input[type="text"], input[type="number"] {
    width: 100%; padding: 12px; background: #222; border: 1px solid #333;
    color: white; border-radius: 8px; outline: none; transition: 0.3s;
    font-family: var(--font-ui);
}
input:focus { border-color: var(--accent-red); background: #2a2a2a; }

.checkbox-row {
    display: flex; align-items: center; gap: 10px;
    background: #222; padding: 12px; border-radius: 8px; cursor: pointer; margin-top: 5px;
}
.checkbox-row input { accent-color: var(--accent-red); width: 18px; height: 18px; }
.checkbox-row label { margin: 0; cursor: pointer; color: #ddd; font-family: var(--font-ui); }

#submit-btn {
    width: 100%; padding: 14px; margin-top: 10px;
    background: white; color: black; font-weight: 800;
    border: none; border-radius: 8px; cursor: pointer;
    font-family: var(--font-ui);
}
#submit-btn:hover { background: #ddd; }
.warning { color: #e53935; font-size: 0.8rem; margin-top: 5px; font-family: var(--font-ui); }

/* Filter for Map */
.dark-tiles-filter { filter: invert(100%) hue-rotate(180deg) brightness(80%) contrast(90%) grayscale(80%) !important; }

/* --- POPUPS --- */
.leaflet-popup-content-wrapper {
    background: #181818 !important; border: 1px solid var(--accent-red);
    border-radius: 8px !important; color: white !important; padding: 0 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8) !important;
}
.leaflet-popup-tip { background: #181818 !important; border: 1px solid var(--accent-red); box-shadow: none !important; }
.leaflet-popup-content { margin: 0 !important; width: 200px !important; cursor: pointer; }

.map-popup-card { display: flex; align-items: center; gap: 10px; padding: 10px; }
.map-popup-img {
    width: 45px; height: 45px; border-radius: 50%; object-fit: cover;
    border: 2px solid #333; background: #222; flex-shrink: 0;
}
.map-popup-info { display: flex; flex-direction: column; overflow: hidden; }
.map-popup-name {
    font-family: var(--font-styled); font-weight: bold; font-size: 0.9rem;
    color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-popup-city { font-family: var(--font-ui); font-size: 0.75rem; color: var(--text-muted); }

[src="unknown.png"] {
    scale: 0.5;
}