/* -------------------------------------------
   GLOBAL & ANIMATED BACKGROUND
   ------------------------------------------- */

/* Animated Gradient Background */
body.homepage {
    /* NEW: Dark, subtle animated gradient */
    background: linear-gradient(-45deg, #0b0c10, #1f2833, #021a2c, #1a2a6c);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    
    /* Custom Fonts for Body and Fallback */
    font-family: 'Roboto', sans-serif; 
    color: #ffffff;
}

/* Admin Page Theme */
body.admin-page {
    /* Simple dark background for admin */
    background-color: #1f2833;
    color: #c5c8c6;
}
.admin-page .card {
    background-color: #0b0c10;
    color: #c5c8c6;
    border: 1px solid #45a29e;
}
.admin-page .card-header {
    background-color: #1f2833;
}


@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Fade In Animation for Grid Items */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* -------------------------------------------
   TYPOGRAPHY & HEADER
   ------------------------------------------- */

/* Custom Font Application (Bebas Neue) */
.hero-title, .section-title, .category-title, .grid-item h5 {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 300;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Special Effect: Animated Gradient Hero Title */
.hero-title {
    /* Create a gradient to be the background of the text */
    background: linear-gradient(90deg, #fff, #c0c0c0, #fff);
    background-size: 200% 200%;
    
    /* Clip the background to the text */
    -webkit-background-clip: text;
    background-clip: text;
    
    /* Make the text color transparent so the background shows through */
    -webkit-text-fill-color: transparent;
    text-fill-color: transparent;
    
    /* Add the animation */
    animation: gradient-shine 3s ease-in-out infinite;
}

@keyframes gradient-shine {
    0% { background-position: 200% center; }
    50% { background-position: 0% center; }
    100% { background-position: 200% center; }
}


/* -------------------------------------------
   NAVIGATION (TABS)
   ------------------------------------------- */

.nav-tabs {
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}
.nav-tabs .nav-link {
    /* Glassmorphism Tabs */
    background: rgba(255, 255, 255, 0.05); 
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: none;
    color: #eee;
    margin-right: 5px;
    transition: all 0.3s ease;
}
.nav-tabs .nav-link.active,
.nav-tabs .nav-link:hover {
    background: rgba(255, 255, 255, 0.1); 
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}


/* -------------------------------------------
   THE CSS GRID LAYOUT
   ------------------------------------------- */

.portal-grid {
    display: grid;
    /* Sets up the 3x3 concept */
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

/* The Grid Item Tile (Glassmorphism) */
.grid-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px); 
    border-radius: 8px;
    padding: 20px;
    color: #fff;
    overflow: hidden; /* Important for spanning elements */
    
    /* Apply fade-in animation with staggered delays */
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0; 
}

/* Staggered animation delays for the first 9 tiles */
.grid-item:nth-child(1) { animation-delay: 0.1s; }
.grid-item:nth-child(2) { animation-delay: 0.2s; }
.grid-item:nth-child(3) { animation-delay: 0.3s; }
.grid-item:nth-child(4) { animation-delay: 0.4s; }
.grid-item:nth-child(5) { animation-delay: 0.5s; }
.grid-item:nth-child(6) { animation-delay: 0.6s; }
.grid-item:nth-child(7) { animation-delay: 0.7s; }
.grid-item:nth-child(8) { animation-delay: 0.8s; }
.grid-item:nth-child(9) { animation-delay: 0.9s; }


/* -------------------------------------------
   ITEM TYPE STYLES
   ------------------------------------------- */

/* Video container - Maintains 16:9 aspect ratio regardless of tile size */
.video-container {
    position: relative;
    padding-bottom: 56.25%; 
    height: 0;
    overflow: hidden;
    margin-bottom: 10px;
    border-radius: 4px;
}
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Link-style tile content */
.grid-link-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: #fff;
    transition: transform 0.3s ease;
}
.grid-link-content:hover {
    transform: scale(1.03);
    text-decoration: underline;
}
.grid-link-content p {
    flex-grow: 1; 
    opacity: 0.8;
}
.grid-link-content span {
    font-weight: bold;
    color: #45a29e; /* Custom accent color */
}

.grid-item img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}


/* -------------------------------------------
   RESPONSIVENESS
   ------------------------------------------- */

@media (max-width: 768px) {
    .portal-grid {
        /* On small screens, stack to 1 column */
        grid-template-columns: 1fr;
    }

    .grid-item {
        /* On mobile, ignore all grid and span data and just stack */
        grid-row: auto !important;
        grid-column: auto !important;
    }
}


/* -------------------------------------------
   FOOTER
   ------------------------------------------- */

footer {
    padding: 2rem;
    background: rgba(0, 0, 0, 0.3); 
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}
footer a {
    color: #45a29e;
    font-weight: bold;
}

/* Grid Helper Styles */
.grid-helper {
    display: grid;
    /* 3 columns based on your max column count (3) */
    grid-template-columns: repeat(3, 1fr); 
    /* Max 9 rows based on your max row count (9) */
    grid-template-rows: repeat(9, 30px); 
    gap: 1px;
    background-color: #ccc;
    border: 1px solid #aaa;
    margin-top: 15px;
    position: relative;
    max-height: 271px; /* 9 rows * 30px + 8px gap */
    overflow: hidden; /* Prevent grid overflow */
}
.grid-cell {
    background-color: #f8f9fa; /* Light background for unselected cells */
    border: 1px solid #ddd;
    box-sizing: border-box;
}

.grid-block {
    /* Use grid-area properties for placement via JS */
    grid-area: 1 / 1 / span 1 / span 1; 
    
    position: relative; /* Use relative positioning within the grid flow */
    background-color: rgba(0, 123, 255, 0.6); /* Blue overlay */
    border: 2px solid #007bff;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    pointer-events: none; /* Ignore mouse events */
    transition: all 0.2s ease-out; /* Smooth transition */
    overflow: hidden;
    z-index: 10;
}