/* ---------------------------------------------------------------------- */
/* CSS VARIABLES */
/* ---------------------------------------------------------------------- */
:root {
    /* Color Palette - DARK MODE (DEFAULT) - Mapped to your new dark theme values */
    --bg-primary: #111827; /* Mapped from html.dark:root --bg-default (Gray 900) */
    --bg-content: #1f2937; /* Mapped from html.dark:root --bg-paper (Gray 800) */
    --accent-neon: #3b82f6; /* Mapped from --primary-color (Blue 500) */
    --text-primary: #f3f4f6; /* Mapped from html.dark:root --text-default (Gray 100) */
    --text-secondary: #9ca3af; /* Mapped from html.dark:root --text-secondary (Gray 400) */
    --grid-line: #374151; /* Mapped from html.dark:root --border-color (Gray 700) */
    
    /* NEW: Dark mode heavy overlay for background image */
    --bg-overlay-dark: rgba(0, 0, 0, 0.9); /* Adjust opacity for desired darkness */

    /* Mapped Dark Mode Shadows */
    --glow-shadow: 0 0 15px rgba(59, 130, 246, 0.7); /* Custom glow using Blue 500 */
    --box-shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3); /* Mapped from html.dark:root --shadow-lg */
    
    /* Typography*/
    --font-primary: 'Consolas', 'Courier New', monospace;
    --font-secondary: 'Arial', sans-serif;
    
    /* Spacing*/
    --spacing-lg: 4rem;
    --spacing-md: 2rem;
    --border-radius-card: 16px; /* Mapped from --border-radius */
}

/* Hide scrollbar for Chrome, Safari, and Opera */
::-webkit-scrollbar {
    display: none;
}
/* Hide underline in the url */
a {
    text-decoration: none;
}

/* LIGHT MODE VARIABLES - Mapped to your new light theme values */
body.light-theme {
    --bg-primary: #f3f4f6; /* Mapped from :root --bg-light (Gray 100) */
    --bg-content: #ffffff; /* Mapped from :root --bg-paper (White) */
    --accent-neon: #3b82f6; /* Mapped from :root --primary-color (Blue 500) */
    --text-primary: #1f2937; /* Mapped from :root --text-default (Gray 800) */
    --text-secondary: #6b7280; /* Mapped from :root --secondary-color (Gray 500) */
    --grid-line: #e5e7eb; /* Mapped from :root --border-color (Gray 200) */
    
    /* NEW: Light mode overlay (can be transparent or lighter if desired) */
    --bg-overlay-light: rgba(0, 0, 0, 0.1); /* Lighter or fully transparent for light mode */

    /* Mapped Light Mode Shadows */
    --glow-shadow: 0 0 10px rgba(59, 130, 246, 0.3); /* Custom glow using Blue 500 */
    --box-shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); /* Mapped from :root --shadow-lg */
}

/* ---------------------------------------------------------------------- */
/* GLOBAL BASE STYLES & CONTAINER (.d1) STYLES */
/* ---------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; 
}

body {
    font-family: var(--font-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    
    min-height: 100vh;
    background-color: var(--bg-primary); 
    display: flex;
    flex-direction: column;
    align-items: center; 
    
    background-image: url('img/BG.png'); 
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed; 
    overflow-x: hidden; 
    position: relative; /* Needed for pseudo-element positioning */
}

/* NEW: Heavy shadow overlay for the body background image */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-overlay-dark); /* Dark overlay by default (dark mode) */
    z-index: -1; /* Place it behind the .d1 content but above the background image */
    transition: background-color 0.3s ease; /* Smooth transition for theme change */
}

/* Adjust overlay for light theme */
body.light-theme::before {
    background-color: var(--bg-overlay-light); /* Lighter or transparent for light mode */
}


.d1 {
    width: 100%;
    max-width: 100%;
    padding: 0; 
    height: auto; 
    min-height: 100vh;
    margin: 0 auto;
    flex-grow: 0;

    background-color: transparent; /* Keep this transparent to show the body background/overlay */
    
    box-shadow: var(--box-shadow-card); 
    
    border-left: 1px solid var(--grid-line); 
    border-right: 1px solid var(--grid-line); 
    
    display: grid;
    gap: var(--spacing-lg);
    grid-template-columns: 1fr;
}

/* --- THEME TOGGLE BUTTON STYLES --- */
#theme-toggle {
    position: fixed; 
    top: 10px;
    right: var(--spacing-md);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-neon);
    color: var(--bg-content); 
    border: none;
    cursor: pointer;
    box-shadow: var(--glow-shadow);
    z-index: 100;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
#theme-toggle:hover {
    background-color: #2563eb; /* Mapped from --primary-hover (Blue 600) */
    box-shadow: none;
    transform: scale(1.05);
}

/* ---------------------------------------------------------------------- */
/* CARD STYLES */
/* ---------------------------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    
    gap: var(--spacing-md); 
    padding: var(--spacing-md); 
    
    width: 100%;
    height: auto; 
    justify-content: center;
}

.link-card, .non-clickable-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    
    height: 300px; 
    
    text-decoration: none;
    color: var(--text-primary);
    
    border-radius: var(--border-radius-card); 
    
    background-color: var(--bg-content);
    border: 1px solid var(--grid-line);
    box-shadow: var(--box-shadow-card);
    overflow: hidden;
    
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Hover effects only for clickable cards */
.link-card:hover {
    transform: translateY(-5px); 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5); 
    border-color: var(--accent-neon);
}
/* **ADDITION**: Set light mode hover shadow */
body.light-theme .link-card:hover {
     box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.non-clickable-card {
    cursor: default;
}
.non-clickable-card:hover {
    transform: translateY(-5px); 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 8px, 0, 0.5); 
    border-color: var(--accent-neon);
}
/* **ADDITION**: Set light mode hover shadow */
body.light-theme .non-clickable-card:hover {
     box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}


.link-card img, .non-clickable-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5; 
    transition: opacity 0.3s ease;
}

.overlay {
    position: relative;
    z-index: 10;
    padding: var(--spacing-md);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); 
    color: var(--accent-neon);
    font-family: var(--font-primary);
    font-size: 1.6rem;
    font-weight: 700;
    text-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
    display: flex;
    flex-direction: column;
}

/* --- CARD TAG STYLES (Top Left) --- */
.card-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 15;
    background-color: var(--text-secondary); /* Darker background */
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: bold;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
body.light-theme .card-tag {
    background-color: var(--bg-content); 
    color: var(--accent-neon);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); 
}


/* --- SHOW STORY BUTTON STYLES (Top Right) --- */
.card-button {
    position: absolute;
    top: 10px;
    right: 10px; /* Moved to the top right */
    left: auto; /* Ensure no left positioning interferes */
    z-index: 15;

    background-color: var(--accent-neon);
    color: var(--bg-content); 
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.8rem;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
.card-button:hover {
    background-color: #2563eb; 
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.9);
    transform: scale(1.05);
}


/* ---------------------------------------------------------------------- */
/* MODAL STYLES */
/* ---------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.story-modal {
    background-color: var(--bg-content); 
    border: 1px solid var(--accent-neon);
    border-radius: var(--border-radius-card);
    padding: 10px; /* Reduced padding */
    max-width: 600px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
    color: var(--text-primary);
    box-shadow: var(--glow-shadow);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .story-modal {
    transform: translateY(0);
}

.story-modal h3 {
    color: var(--accent-neon);
    margin-bottom: 15px;
    font-size: 1.5rem;
    font-family: var(--font-primary);
    text-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}

.story-modal p {
    margin-bottom: 10px;
    line-height: 1.7;
    font-size: 1rem;
    color: var(--text-primary);
}
.story-modal p a {
    color: var(--accent-neon);
    word-break: break-all;
}
.story-modal p a:hover {
    color: var(--text-secondary);
}

.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-primary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-button:hover {
    color: var(--accent-neon);
}

/* Light theme adjustments for the modal and button */
body.light-theme .modal-overlay {
    background-color: rgba(0, 0, 0, 0.5);
}
body.light-theme .story-modal {
    border: 1px solid var(--accent-neon);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}
body.light-theme .story-modal h3 {
    text-shadow: none;
}
body.light-theme .card-button {
    background-color: var(--accent-neon);
    color: #fff;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.2);
}
body.light-theme .card-button:hover {
    background-color: #2563eb;
}


/* ---------------------------------------------------------------------- */
/* MOBILE RESPONSIVENESS (Screens 850px and smaller) */
/* ---------------------------------------------------------------------- */
@media (max-width: 850px) {
    .card-grid {
        grid-template-columns: 1fr;
        width: 100%;
        padding: var(--spacing-md) 10px; 
    }
    
    .link-card, .non-clickable-card {
        height: 230px; 
    }
    
    .overlay {
        font-size: 1.4rem;
        padding: 15px;
    }

    #theme-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}
