@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* --- CSS VARIABLES FOR LIGHT & DARK THEMES --- */
:root {
    --font-main: 'Inter', sans-serif;
    
    /* Core Brand Colors */
    --mil-dark: #1a252c;
    --mil-olive: #6b7222;
    --mil-red: #c0392b;
    
    /* Light Theme */
    --bg-main: #f4f7f6;
    --bg-card: #ffffff;
    --bg-card-alt: #f9fafb;
    --text-main: #333333;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --nav-hover: rgba(255, 255, 255, 0.1);
    
    /* Post Content - Light Mode */
    --post-h2: #1a252c;
}

body.dark-mode {
    /* Dark Theme */
    --bg-main: #111827;
    --bg-card: #1f2937;
    --bg-card-alt: #111827;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    
    /* Post Content - Dark Mode */
    --post-h2: #ffffff;
}

/* --- GLOBAL RESETS --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-main); background-color: var(--bg-main); color: var(--text-main); line-height: 1.6; overflow-x: hidden; transition: background-color 0.3s, color 0.3s; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: transparent; transition: all 0.2s ease; }
img { max-width: 100%; display: block; }
        
/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mil-olive); border-radius: 10px; }

/* --- POST CONTENT TYPOGRAPHY --- */
.prose h2 { font-size: 1.5rem; font-weight: 800; margin-top: 1.5rem; margin-bottom: 0.75rem; color: var(--post-h2); transition: color 0.3s; }
@media (min-width: 640px) { .prose h2 { font-size: 1.875rem; margin-top: 2rem; margin-bottom: 1rem; } }
.prose p { margin-bottom: 1.25rem; line-height: 1.75; font-size: 0.95rem; color: var(--text-main); transition: color 0.3s; }
@media (min-width: 640px) { .prose p { font-size: 1rem; } }

/* --- LAYOUT UTILITIES --- */
.container { max-width: 1350px; margin: 0 auto; padding: 0 5%; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }

/* --- HEADER & NAVIGATION --- */
header { background-color: var(--mil-dark); color: white; position: sticky; top: 0; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.4); border-bottom: 1px solid #1f2937; }
.header-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.logo { font-size: 1.5rem; font-weight: 800; cursor: pointer; letter-spacing: -0.5px; margin-left: 20px;}
.logo span { color: var(--mil-red); }
        
/* Desktop Nav */
.desktop-nav { display: none; align-items: center; gap: 35px; }
.nav-btn { color: #9ca3af; font-size: 0.900rem; font-weight: 900; padding: 16px 12px; border-radius: 6px; transition: 0.2s; }
.nav-btn:hover { color: white; }
.nav-btn.active { color: white; }
.nav-btn-tool { display: flex; flex-direction: column; align-items: center; padding: 6px 16px; border-radius: 6px; color: #9ca3af; }
.nav-btn-tool span { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.nav-btn-tool.active { background-color: var(--mil-red); color: white; box-shadow: 0 4px 14px rgba(192,57,43,0.4); }

/* Controls */
.controls { display: flex; align-items: center; gap: 6px;}
.icon-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; }
.icon-btn:hover { background: rgba(255,255,255,0.2); transform: scale(0.95); }

/* Dropdowns */
.dropdown { position: relative; margin-right: 16px; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 8px; width: 180px; background: var(--mil-dark); border-top: 4px solid var(--mil-olive); border-radius: 0 0 8px 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); overflow: hidden; z-index: 2000; }
.dropdown-menu.show { display: block; animation: dropIn 0.2s ease; }
.dropdown-item { display: block; width: 100%; text-align: left; padding: 12px 16px; color: #d1d5db; font-size: 0.875rem; font-weight: 600; border-bottom: 1px solid #374151; text-transform: capitalize; }
.dropdown-item:hover { background: rgba(255,255,255,0.1); color: white; }
@keyframes dropIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Nav */
.mobile-nav-container { display: block; background: #111827; border-top: 1px solid #1f2937; width: 100%; }
.mobile-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 8px 2%; }
.mob-btn { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 8px; background: rgba(255,255,255,0.05); color: #9ca3af; font-size: 9px; font-weight: 800; border-radius: 6px; border: 1px solid rgba(255,255,255,0.05); flex: 1 1 auto; max-width: fit-content; }
.mob-btn.active { background: rgba(255,255,255,0.15); color: white; border-color: rgba(255,255,255,0.3); }
.mob-btn-tool { background: #1f2937; }
.mob-btn-tool.active { background: var(--mil-red); color: white; border-color: var(--mil-red); }

/* --- SECTIONS --- */
main { padding: 2rem 0; min-height: 94vh; }
.page-section { display: none; animation: fadeIn 0.4s ease; margin-bottom: 20px; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section-title { font-size: 1.5rem; font-weight: 800; color: var(--text-main); margin-bottom: 1.5rem; padding-left: 12px; border-left: 4px solid var(--mil-olive); }
.search-bar { position: relative; width: 100%; max-width: 300px; margin-bottom: 1.5rem; }
.search-bar input { width: 100%; padding: 10px 10px 10px 36px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.875rem; outline: none; }
.search-bar input:focus { border-color: var(--mil-olive); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

/* --- GRIDS & CARDS --- */
.grid { display: grid; gap: 1rem; }

/* Base fallback grid (for Tool & Read Next) */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media(min-width: 768px) { .grid-2 { grid-template-columns: repeat(3, 1fr); } }
@media(min-width: 1024px) { .grid-2 { grid-template-columns: repeat(4, 1fr); } }

/* ==============================================================
   MANUAL CARD SIZE CONTROLS (SEPARATED BY SECTION)
   Change the number inside "repeat(X, 1fr)" to change card sizes.
   Higher number = More columns (Smaller Cards)
   Lower number  = Fewer columns (Bigger Cards)
============================================================== */

/* --- 1. HOME: LATEST ANALYSIS --- */
.grid-home-analysis { grid-template-columns: repeat(2, 1fr); } /* Mobile Size */
@media(min-width: 768px) { .grid-home-analysis { grid-template-columns: repeat(3, 1fr); } } /* Tablet Size */
@media(min-width: 1024px) { .grid-home-analysis { grid-template-columns: repeat(4, 1fr); } } /* Desktop Size */

/* --- 2. LATEST COMPARISONS --- */
.grid-latest-comparisons { grid-template-columns: repeat(2, 1fr); } /* Mobile Size */
@media(min-width: 768px) { .grid-latest-comparisons { grid-template-columns: repeat(3, 1fr); } } /* Tablet Size */
@media(min-width: 1024px) { .grid-latest-comparisons { grid-template-columns: repeat(4, 1fr); } } /* Desktop Size */

/* --- 3. TOP 5 MILITARY POWERS --- */
.grid-top5 { grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 20px; } /* Mobile Size */
@media(min-width: 768px) { .grid-top5 { grid-template-columns: repeat(5, 1fr); } } /* Tablet Size */
@media(min-width: 1024px) { .grid-top5 { grid-template-columns: repeat(5, 1fr); } } /* Desktop Size */

/* --- 4. NEW & NEXT-GEN WEAPONS --- */
.grid-new-weapons { grid-template-columns: repeat(2, 1fr); } /* Mobile Size */
@media(min-width: 768px) { .grid-new-weapons { grid-template-columns: repeat(3, 1fr); } } /* Tablet Size */
@media(min-width: 1024px) { .grid-new-weapons { grid-template-columns: repeat(4, 1fr); } } /* Desktop Size */

/* --- 5. GLOBAL COMPARISONS --- */
/* --- 5. GLOBAL COMPARISONS --- */
.grid-global-comparisons { grid-template-columns: repeat(2, 1fr); margin-bottom: 40px; } /* Mobile Size */
@media(min-width: 768px) { .grid-global-comparisons { grid-template-columns: repeat(2, 1fr); } } /* Tablet Size */
@media(min-width: 1024px) { .grid-global-comparisons { grid-template-columns: repeat(2, 1fr); } } /* Desktop Size */

/* 👇 ADD THIS NEW CODE RIGHT HERE 👇 */
/* --- CUSTOM IMAGE SIZE FOR GLOBAL COMPARISONS ONLY --- */
.grid-global-comparisons .card-img-wrap {
    aspect-ratio: 9 / 16; /* Makes the image tall (9:16). Change to 16 / 9 if you want it wide! */
    
    
}
.card-img-wrap { width: 100%; aspect-ratio: 16/9; overflow: hidden; border-bottom: 2px solid var(--mil-olive); position: relative; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.card:hover .card-img-wrap img { transform: scale(1.05); }

/* --- NEW: MAKE GLOBAL COMPARISONS IMAGES TALL (9:16) --- */
/* --- NEW: FORCE GLOBAL COMPARISON IMAGES TO BE 9:11 EVERYWHERE --- */
.card-img-wrap.tall-img {
    aspect-ratio: 9 / 11 !important;
}
.comp-res-img-wrap.tall-img {
    aspect-ratio: 9 / 11 !important;
    max-width: 250px;       /* Force the image to be smaller */
    margin: 0 auto;         /* Keep it centered */
}
/* 👆 ============================= 👆 */

/* ============================================================== */

.card { background: var(--bg-card); border-radius: 8px; border: 1px solid var(--border-color); overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.05); display: flex; flex-direction: column; position: relative; transition: 0.3s; cursor: pointer; }
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 12px rgba(0,0,0,0.1); border-color: var(--border-color); }
.card.selected { border: 2px solid var(--mil-red); }
        
.card-img-wrap { width: 100%; aspect-ratio: 16/9; overflow: hidden; border-bottom: 2px solid var(--mil-olive); position: relative; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.card:hover .card-img-wrap img { transform: scale(1.05); }
 .card-body { padding: 4px; display: flex; flex-direction: column; flex-grow: 1; }
.card-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 2px; line-height: 1.2; color: var(--text-main); }
.card-excerpt { font-size: 0.7rem; color: var(--text-muted); flex-grow: 1; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
        
.card-btn { align-self: flex-start; background: var(--mil-red); color: white; font-size: 0.65rem; font-weight: 700; padding: 4px 10px; border-radius: 4px; letter-spacing: 0.5px; margin-top: auto; }
.card.selected .card-btn { background: var(--mil-dark); }
        
.select-icon { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; z-index: 10; }
.select-icon.unselected { background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.5); }
.select-icon.selected { background: var(--mil-red); }

/* --- TOP 5 POWERS STYLING --- */
.top5-card { background: var(--mil-dark); border-radius: 12px; border: 1px solid #374151; overflow: hidden; text-align: center; position: relative; transition: 0.3s; }
.top5-card:hover { transform: translateY(-4px); }
.top5-img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-bottom: 3px solid var(--mil-red); }
.top5-body { padding: 7px 1px; position: relative; background: #1e293b; }
.top5-rank { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--mil-red); color: white; font-size: 12px; font-weight: 800; padding: 2px 12px; border-radius: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.top5-title { font-size: 1rem; color: white; font-weight: 700; margin-bottom: -1px; }
.top5-stat { font-size: 10px; color: #9ca3af; margin-bottom: 1px; }
.top5-stat span { color: white; font-weight: 600; }

/* --- COMPARE TOOL --- */
.compare-header { background: transparent; margin-bottom: 24px; }
.compare-empty { border: 2px dashed var(--border-color); padding: 40px 20px; text-align: center; border-radius: 12px; background: var(--bg-card-alt); margin-bottom: 40px; }
        
.compare-layout { background: var(--bg-card-alt); border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; margin-bottom: 24px; }
.comp-res-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 40px; }
.comp-res-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; position: relative; display: flex; flex-direction: column; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.compare-remove { position: absolute; top: 12px; right: 12px; background: var(--mil-red); color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; z-index: 10; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); transition: transform 0.2s; }
.compare-remove:hover { transform: scale(1.1); }
.comp-res-img-wrap { width: 100%; aspect-ratio: 16/9; border-bottom: 3px solid var(--mil-olive); }
.comp-res-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
        
.comp-res-body { padding: 16px; display: flex; flex-direction: column; flex-grow: 1; }
.comp-res-title { font-size: 1.1rem; font-weight: 800; color: var(--text-main); margin-bottom: 20px; line-height: 1.2; text-align: center; }
.comp-stat-wrap { display: flex; flex-direction: column; gap: 12px; }
.comp-stat-row { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.comp-stat-bar-bg { width: 100%; height: 6px; background: rgba(156, 163, 175, 0.2); border-radius: 4px; overflow: hidden; }
.comp-stat-bar-fill { height: 100%; border-radius: 4px; transition: width 1s cubic-bezier(0.4, 0, 0.2, 1); }
.comp-stat-row .winner-text { color: #16a34a; font-weight: 800; }
.comp-stat-bar-fill.winner-bg { background-color: #16a34a; }
.comp-stat-bar-fill.loser-bg { background-color: var(--mil-olive); }

/* --- RANKING TABLE --- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border-color); border-radius: 8px; max-height: 60vh; background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; text-align: left; table-layout: auto; }
th { background: var(--mil-dark); color: white; padding: 12px; position: sticky; top: 0; font-size: 0.875rem; z-index: 10; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); font-size: 0.875rem; vertical-align: middle; }
tr:hover { background: var(--bg-card-alt); }
.flag-img { width: 28px; height: 20px; object-fit: cover; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
        
.directory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 24px; border-top: 1px solid var(--border-color); padding-top: 24px; }
.dir-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; text-align: center; }
.dir-img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-bottom: 2px solid var(--mil-olive); }

/* --- POST VIEW --- */
.post-img { 
    width: 100%;       /* Changed from 40% to 100% for mobile-first */
    max-width: 500px;  /* Keeps it from being too huge on desktop */
    aspect-ratio: 16 / 9; 
    object-fit: cover; 
    border-radius: 12px; 
    border-bottom: 6px solid var(--mil-olive); 
    margin-bottom: 24px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}
.post-img.tall-img {
    aspect-ratio: 9 / 11 !important;
    width: 100% !important;
    max-width: 280px; /* Makes the tall image narrower to look correct */
}
.back-btn { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-weight: 700; font-size: 0.875rem; margin-bottom: 24px; }
.back-btn:hover { color: var(--text-main); }
/* --- NEW: FORCE GLOBAL COMPARISON IMAGES TO BE 9:11 EVERYWHERE --- */
.card-img-wrap.tall-img,
.comp-res-img-wrap.tall-img {
    aspect-ratio: 9 / 11 !important;
}
/* --- FOOTER --- */
/* --- FOOTER --- */
footer { background: var(--mil-dark); border-top: 4px solid var(--mil-red); color: white; text-align: center; padding: 20px 10px; margin-top: auto; }

.footer-links { 
    display: flex; 
    justify-content: center; 
    gap: 20px; 
    margin-top: 16px; 
    font-size: 0.85rem; /* Slightly larger for readability */
    font-weight: 700; 
    text-transform: uppercase; 
}

/* This targets the buttons inside the footer links */
.footer-links button { 
    color: #e5e7eb; /* Light gray color (Visible on dark background) */
    cursor: pointer;
    transition: 0.3s;
}

.footer-links button:hover { 
    color: var(--mil-red); /* Changes to your red brand color when hovering */
}
/* --- RESPONSIVE MOBILE --- */
/* --- RESPONSIVE MOBILE --- */
@media(max-width: 767px) {
    th { padding: 8px 4px; font-size: 0.75rem; }
    td { padding: 8px 4px; font-size: 0.75rem; }
    .flag-img { width: 20px; height: 14px; margin-right: 4px; }
    td:nth-child(2) { white-space: normal; word-break: break-word; }
    
    .comp-res-grid { gap: 8px; }
    .comp-res-body { padding: 10px; }
    .comp-res-title { font-size: 0.95rem; margin-bottom: 12px; min-height: 2.2rem; }
    .comp-stat-wrap { gap: 8px; }
    .comp-stat-row { font-size: 0.7rem; margin-bottom: 2px; }
    .compare-remove { width: 24px; height: 24px; top: 8px; right: 8px; }
    .compare-remove svg { width: 12px; height: 12px; }

    /* --- TINY CARDS FOR MOBILE --- */
    .card-body { padding: 6px; }
    .card-title { font-size: 0.7rem; margin-bottom: 2px; line-height: 1.1; }
    .card-excerpt { font-size: 0.6rem; margin-bottom: 4px; line-height: 1.2; }
    .card-btn { font-size: 0.55rem; padding: 3px 6px; letter-spacing: 0px; }

    /* --- TINY TOP 5 CARDS FOR MOBILE --- */
    .top5-body { padding: 8px 2px; }
    .top5-title { font-size: 0.8rem; margin-bottom: 2px; }
    .top5-stat { font-size: 0.55rem; margin-bottom: 2px; letter-spacing: -0.2px; }
    .top5-rank { font-size: 9px; padding: 2px 8px; top: -10px; }

    /* --- NEW: 2 FLAGS PER ROW ON MOBILE --- */
    .directory-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* --- RESPONSIVE DESKTOP --- */
@media(min-width: 768px) {
    .desktop-nav { display: flex; }
    .mobile-nav-container { display: none; }
    .section-title { font-size: 2rem; }
    
    .comp-res-title { font-size: 1.5rem; }
}