/* Premium Dark Mode UI - Pinterest Fluid Masonry Aesthetic (CSS-FTW Method) */
:root {
    --bg-color: #111111; 
    --panel-bg: #0c0c0c;
    --border-color: #333333;
    --border-light: #222222;
    --text-main: #FFFFFF; 
    --text-muted: #A1A1AA;
    --accent: #D1FF00; 
    --accent-hover: rgba(209, 255, 0, 0.4); 
    --hover-bg: #222222; 
    --badge-bg: #D1FF00;
    --badge-text: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 16px; 
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Header Navbar */
header.top-nav {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    height: 64px; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px; 
    flex: 1;
}

/* --- Hamburger Menu & Overlay Defaults --- */
.hamburger-btn {
    display: none; 
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
    z-index: 1001; 
}
.hamburger-btn .bar {
    width: 22px;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mobile-overlay.active {
    opacity: 1;
}

.logo { font-weight: 800; font-size: 20px; text-decoration: none; color: var(--text-main); letter-spacing: -0.5px; }

.search-bar { 
    padding: 10px 20px; 
    border: none; 
    width: 100%;
    min-width: 300px;
    max-width: 600px; 
    border-radius: 32px; 
    outline: none; 
    background: #222222; 
    color: var(--text-main);
    transition: all 0.2s ease; 
    font-size: 15px; 
}
.search-bar::placeholder { color: var(--text-muted); }
.search-bar:focus { background: #333333; box-shadow: 0 0 0 2px var(--accent); }

/* --- Top Navigation Links & Buttons --- */
.header-right { display: flex; align-items: center; gap: 24px; }
.header-right .desktop-link { 
    text-decoration: none; 
    color: var(--text-main); 
    font-weight: 600; 
    font-size: 15px; 
    transition: color 0.2s; 
}
.header-right .desktop-link:hover { color: var(--accent); }

.action-buttons { display: flex; align-items: center; gap: 12px; }

.header-right .btn-outline {
    display: inline-block !important;
    text-decoration: none !important;
    color: var(--text-main) !important;
    border: 2px solid var(--border-color) !important;
    padding: 8px 24px !important;
    border-radius: 32px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    background: transparent !important;
}
.header-right .btn-outline:hover { border-color: var(--text-main) !important; background: rgba(255, 255, 255, 0.05) !important; }

.header-right .btn-submit { 
    display: inline-block !important;
    text-decoration: none !important;
    background: var(--accent) !important; 
    color: #000000 !important; 
    padding: 8px 24px !important; 
    font-size: 14px !important;
    font-weight: 700 !important; 
    border-radius: 32px !important; 
    transition: all 0.2s ease !important; 
    border: 2px solid var(--accent) !important;
}
.header-right .btn-submit:hover { background: #b8e600 !important; border-color: #b8e600 !important; }

/* --- Fully Fluid Layout Wrapper --- */
.layout-wrapper {
    display: grid;
    grid-template-columns: 240px 1fr 300px;
    gap: 32px;
    padding: 32px;
    flex: 1;
    width: 100%;
    max-width: 100%; 
    margin: 0 auto;
    align-items: start;
}

/* Panels */
aside { 
    padding: 0; 
    height: fit-content; 
    position: sticky; 
    top: 96px; 
    max-height: calc(100vh - 120px); 
    overflow-y: auto; 
    
    /* Hide scrollbar for Firefox */
    scrollbar-width: none; 
    /* Hide scrollbar for IE and Edge */
    -ms-overflow-style: none; 
}

/* Hide scrollbar for Chrome, Safari, and Opera */
aside::-webkit-scrollbar { 
    display: none; 
}
main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

h2, h3 { font-size: 16px; font-weight: 700; color: var(--text-main); margin-bottom: 16px; padding: 0; }

/* Sidebar Left Lists */
.sidebar-left ul { list-style: none; padding: 0; margin: 0; }
.sidebar-left ul li { margin-bottom: 4px; }
.sidebar-left ul li a { text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 15px; display: block; padding: 10px 16px; border-radius: 8px; transition: all 0.2s; }
.sidebar-left ul li a:hover { color: #fff; background: var(--hover-bg); }

/* Sub-Header Section */
.page-header { background: transparent; padding: 0 0 32px 0; text-align: left; width: 100%; margin-bottom: 16px; }
.pill-badge { display: inline-block; background-color: var(--badge-bg); color: var(--badge-text); font-size: 12px; font-weight: 800; letter-spacing: 0.5px; padding: 6px 16px; border-radius: 999px; text-transform: uppercase; margin-bottom: 16px; }
.page-header h1 { font-size: 40px; font-weight: 800; color: var(--text-main); margin-bottom: 12px; letter-spacing: -1px; line-height: 1.1; }
.page-header p { font-size: 16px; color: var(--text-muted); line-height: 1.6; max-width: 600px; margin: 0; }

/* Sidebar Right Boxes */
.sidebar-box { background: var(--panel-bg); border-radius: 16px; margin-bottom: 24px; overflow: hidden; border: 1px solid var(--border-light); }
.sidebar-box-header { padding: 20px 20px 12px 20px; font-weight: 800; font-size: 18px; color: var(--text-main); background: var(--panel-bg); }
.sidebar-box-content { padding: 0 20px 20px 20px; }


/* ========================================================
   CSS-FTW DYNAMIC GRID SYSTEM
   ======================================================== */
.post-grid {
    display: grid;
    /* 250px guarantees exactly 3 columns fit within 1536px screen limits */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 10px; /* Base row height for JS math */
    column-gap: 24px; /* Pure horizontal gap */
    width: 100%;
    align-items: start;
}

.post-card {
    background: transparent; 
    border: none; 
    display: block;
    text-decoration: none;
    color: inherit;
    /* JS adds vertical gap visually via row spanning! */
}

.post-card img { 
    width: 100%; 
    height: auto;
    /* NOTICE: max-height removed! Images now keep natural aspect ratios! */
    border-radius: 16px; 
    display: block;
    transition: filter 0.2s ease;
}

.post-card:hover img { filter: brightness(0.8); }

.post-card-content { 
    padding: 8px 4px 0 4px; 
    display: flex; 
    flex-direction: column; 
}

.post-title { 
    font-size: 14px; 
    font-weight: 500; 
    color: var(--text-main); 
    line-height: 1.3; 
    margin-bottom: 0; 
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;  
    overflow: hidden;
}


/* --- Single Post / Details Page --- */
.cover-image { width: 100%; border-radius: 24px; margin-bottom: 32px; display: block; }
.article-body { padding: 0 16px; max-width: 800px; margin: 0 auto; }
.single-title { font-size: 40px; font-weight: 800; margin-bottom: 16px; color: var(--text-main); letter-spacing: -1px; line-height: 1.2; text-align: left; }
.single-meta-bar { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 24px; margin-bottom: 32px; border-bottom: 1px solid var(--border-light); }

.single-description { font-size: 18px; margin-bottom: 32px; line-height: 1.6; color: var(--text-main); }

/* Prompt Box & Buttons */
.prompt-box { background: #F4F4F5; border-radius: 16px; padding: 24px; font-family: ui-monospace, monospace; font-size: 15px; margin: 16px 0; color: #000000; white-space: pre-wrap; line-height: 1.6; }
.action-bar { display: flex; gap: 12px; margin-top: 16px; }
.btn-action { border: none; background: #222222; padding: 10px 20px; cursor: pointer; font-size: 15px; font-weight: 700; color: var(--text-main); border-radius: 32px; transition: all 0.2s ease; }
.btn-action:hover { background: var(--hover-bg); color: #000000; }
.copy-btn { background: var(--accent); color: #000000; }
.copy-btn:hover { background: #000000; color: var(--accent); }
.btn-like { color: var(--text-main); background: #222222; border: none; }
.btn-like:hover { background: var(--accent); color: #000000; }

/* FAQ Section */
.faq-section { background: var(--panel-bg); border-radius: 16px; padding: 32px; margin-bottom: 24px; border: 1px solid var(--border-light); }
.faq-item { margin-bottom: 24px; }
.faq-question { font-weight: 800; font-size: 18px; margin-bottom: 8px; color: var(--text-main); }
.faq-answer { font-size: 15px; color: var(--text-muted); line-height: 1.6; }

/* Footer */
footer { background: transparent; padding: 64px 32px; margin-top: auto; border-top: 1px solid var(--border-light); }
.footer-links { display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px; text-align: left; width: 100%; margin: 0 auto 32px auto; }
.footer-links strong { color: var(--text-main); font-size: 16px; font-weight: 800; display: block; margin-bottom: 16px; }
.footer-links ul { list-style: none; padding: 0; }
.footer-links ul li { border: none; padding: 6px 0; }
.footer-links ul li a { color: var(--text-muted); font-weight: 600; font-size: 15px; text-decoration: none; transition: color 0.2s; }
.footer-links ul li a:hover { color: var(--accent); }
.copyright { padding-top: 32px; text-align: center; font-size: 14px; color: var(--text-muted); width: 100%; }

/* --- MOBILE & TABLET MEDIA QUERIES --- */
@media (max-width: 1200px) {
    .layout-wrapper { grid-template-columns: 240px 1fr; }
    .sidebar-right { display: none; }
}

@media (max-width: 900px) {
    .layout-wrapper { grid-template-columns: 1fr; padding: 16px; gap: 24px; }
    header.top-nav { height: auto; padding: 16px; flex-wrap: wrap; }
    .header-left { width: 100%; flex-wrap: wrap; gap: 16px; }
    .hamburger-btn { display: flex; }
    .search-wrapper { width: 100%; order: 3; }
    .search-bar { width: 100%; min-width: 100%; }
    .header-right { position: absolute; top: 12px; right: 16px; gap: 8px; }
    .header-right .desktop-link { display: none; }
    .header-right .btn-outline, .header-right .btn-submit { padding: 6px 12px !important; font-size: 13px !important; }

    .sidebar-left { 
        position: fixed; top: 0; left: -320px; width: 280px; height: 100vh; 
        background: var(--bg-color); z-index: 1000; padding: 32px 24px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.8); overflow-y: auto;
    }
    .sidebar-left.open { left: 0; }
}

@media (max-width: 600px) {
    .post-grid { grid-template-columns: 1fr; } /* Force 1 column on tiny screens */
    .footer-links { grid-template-columns: 1fr 1fr; }
    .page-header h1 { font-size: 28px; }
}

/* Right Sidebar List Styles */
.contributor-list { list-style: none; padding: 0; }
.contributor-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #222; border: 1px solid var(--border-light); overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.contributor-name { font-weight: 700; font-size: 14px; color: var(--text-main); }
.contributor-stats { font-size: 12px; color: var(--text-muted); }

.top-prompts-list { list-style: none; padding: 0; }
.top-prompt-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.tiny-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.top-prompt-title { font-weight: 700; font-size: 13px; color: var(--text-main); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.top-prompt-stats { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }