/* ==========================================
   1. CORE THEME & RESET
   ========================================== */
:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f8fafc;
    --accent-color: #38bdf8;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    /* CHANGED: Reverted to standard browser scrolling defaults */
    overflow-x: hidden; 
    overflow-y: auto;   
    min-height: 100vh;
    position: relative; 
}

h1 span, h2 span {
    color: var(--accent-color);
}


/* ==========================================
   2. NAVIGATION (Logo Left, Links Right)
   ========================================== */
.navbar {
    height: 70px;
    background: rgba(30, 41, 59, 0.95); 
    backdrop-filter: blur(8px); 
    border-bottom: 1px solid var(--accent-color);
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    transition: height 0.3s ease; /* Smooth transition if height changes */
}

.nav-container {
    width: 100%;
    max-width: 1400px; /* Matched to your wider split container limit */
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo { 
    color: white; 
    text-decoration: none; 
    font-weight: bold; 
    font-size: 1.5rem;
    white-space: nowrap; /* Prevents Cine and Stat from snapping to two lines */
}

.nav-logo span { color: var(--accent-color); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap; /* Keeps link text like "Download Data" on a single line */
}

.nav-links a:hover, .nav-links a.active { 
    color: var(--accent-color); 
}

/* ==========================================
   MOBILE NAVBAR OVERRIDE (Below 768px)
   ========================================== */
@media (max-width: 768px) {
    .navbar {
        height: auto; /* Allow navbar to grow vertically to hold two rows */
        padding: 1rem 0;
    }

    .nav-container {
        flex-direction: column; /* Stack logo on top, links underneath */
        gap: 1rem;
        padding: 0 1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center; /* Center the links under the logo */
        gap: 1.2rem; /* Tighter gap so everything fits across a phone screen */
        flex-wrap: wrap; /* Allows links to cleanly drop to a second line if a phone is tiny */
    }

    .nav-links a {
        font-size: 0.85rem; /* Marginally smaller text for handheld screens */
    }

    /* Adjust the main page scroll container padding so the taller mobile navbar doesn't cover content */
    .scroll-section {
        padding-top: 110px; 
    }
}

/* ==========================================
   3. THE MAIN CONTAINER & SCROLLING SPLIT LAYOUT
   ========================================== */
body.home-scroll-layout {
    overflow: hidden;
    height: 100vh;
}

.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

.scroll-section {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    position: relative;
    box-sizing: border-box;
    /* INCREASED: Pushes the entire container content down further safely on desktop */
    padding-top: 100px; 
}

/* Background panel accents */
.hero-section { background-color: var(--bg-color); }
.dashboard-section { background-color: var(--card-bg); }
.analyses-section { background-color: var(--bg-color); }
.data-section { background-color: var(--card-bg); }

/* Maximized Flex Box Grid container width */
.section-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px; /* Expanded from 1200px to allow larger visual assets */
    margin: 0 auto;
    padding: 0 5rem;
    gap: 5rem; /* Wide channel spacing between text block and image */
}

.section-split.reverse {
    flex-direction: row-reverse;
}

.section-text {
    flex: 1.1; /* Gives slightly more horizontal weight to text layout */
    text-align: left;
}

.section-text h1 {
    font-size: 3.5rem;
    /* MODIFIED: Changed from 0 to a small top margin to ensure breathing room below the navbar */
    margin: 2rem 0 3rem 0; 
    line-height: 1.2;
}

.section-text h2 {
    font-size: 2.8rem; /* Expanded section titles */
    margin: 0 0 1rem 0;
}

.section-text p {
    font-size: 1.2rem; /* Cleaned typography baseline sizing */
    line-height: 1.6;
    color: #94a3b8; 
    margin-bottom: 2rem;
}

.section-image-wrapper {
    flex: 1.3; /* Allocates extra layout footprint space to images */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Expanded fluid asset styling */
.panel-image {
    width: 100%;
    max-width: 650px; /* Expanded maximum viewport size from 500px */
    height: auto;
    /* Scales dynamically to take up half the available screen height */
    max-height: 52vh; 
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.panel-image:hover {
    transform: scale(1.015);
    border-color: var(--accent-color);
}

/* ==========================================
   RESPONSIVE DESIGN SYSTEM OVERRIDES
   ========================================== */

/* Medium Laptop Screens: Adjust scaling gracefully */
@media (max-height: 800px) and (min-width: 901px) {
    .panel-image {
        max-height: 45vh; /* Shrinks image slightly so elements fit on short laptop displays */
    }
    .section-text h2 {
        font-size: 2.2rem;
    }
}

/* Mobile & Small Tablet Breaks */
@media (max-width: 900px) {
    /* FIX: Force override the specific scroll-layout class on mobile */
    body, body.home-scroll-layout {
        overflow-y: auto !important; 
        height: auto !important;
    }

    .scroll-container {
        height: auto;
        overflow-y: visible;
        scroll-snap-type: none; /* Disables snapping to prevent browser jerking on phones */
    }

    .scroll-section {
        height: auto; /* Lets panels elongate naturally with content demands */
        min-height: 90vh;
        scroll-snap-align: none;
        padding: 5rem 2rem 4rem 2rem; /* Clean vertical spacing padding gaps */
    }

    .section-split, .section-split.reverse {
        flex-direction: column;
        text-align: center;
        gap: 3rem;
        padding: 0;
    }
    
    .section-text {
        text-align: center;
    }

    .section-text h1 { font-size: 2.8rem; }
    .section-text h2 { font-size: 2.2rem; }

    .panel-image {
        max-width: 100%;
        max-height: 300px; /* Controlled phone boundary clamp height limit */
    }
}

/* ==========================================
   4. IFRAME / DASHBOARD STYLES (RESTORED)
   ========================================== */
.container.full-width {
    max-width: 100%; 
    width: 100%;
    padding: 0;     
    margin: 0;
}

.iframe-container {
    width: 100%;
    height: calc(100vh - 150px); 
    min-height: 700px; 
    background-color: #1e293b;
}

.iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================
   5. HOME & ARTICLE STYLES
   ========================================== */
.home-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.hero-image {
    max-width: 100%;
    max-height: 350px; 
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

/* Unified button style using your design rules */
.dashboard-btn, .action-btn, .scroll-down-btn {
    display: inline-block;
    background: var(--accent-color);
    color: var(--bg-color);
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    margin-top: 1rem;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.action-btn:hover, .dashboard-btn:hover, .scroll-down-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* Secondary styled links for internal sections */
.secondary-link {
    color: var(--accent-color);
    display: block;
    margin-top: 1rem;
    text-decoration: none;
    font-weight: bold;
}

.secondary-link:hover {
    text-decoration: underline;
}

.grid {
    display: grid;
    /* CHANGED: Swapped auto-fill to auto-fit so cards expand evenly, or cap them cleanly */
    grid-template-columns: repeat(auto-fit, minmax(300px, 400px));
    gap: 2.5rem;
    width: 100%; 
    max-width: 900px; /* Constraints the grid container so 2 cards don't float apart */
    margin: 3rem auto 0 auto; /* Centering the grid layout box horizontally */
    text-align: left; 
    justify-content: center; /* Forces the internal cards to center if there is leftover space */
}

.card { background: var(--card-bg); border-radius: 12px; overflow: hidden; border: 1px solid #334155; }
.card-content { padding: 1.5rem; }
.card img { width: 100%; height: 180px; object-fit: cover; }

.read-more {
    color: var(--accent-color) !important; 
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.read-more:visited {
    color: var(--accent-color) !important; 
}

.read-more:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ==========================================
   6. FOOTER (Bottom Anchored)
   ========================================== */
footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #64748b;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* ==========================================
   7. FIXED FULL-SCREEN DASHBOARD ENGINE
   ========================================== */

/* Turn the body into a flexbox column that locks exactly to the screen height */
body.dashboard-page-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden; /* Stops the overall browser page from scrolling vertically */
    position: relative;
}

/* Ensure the navbar remains standard at the top of the column */
body.dashboard-page-body .navbar {
    position: static; /* Drops fixed positioning here so it plays nice with the flex layout */
    flex-shrink: 0;   /* Prevents the navbar from compressing */
}

/* The content container expands to claim all empty space between nav and footer */
body.dashboard-page-body .container.full-width {
    flex: 1; 
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* Strip out the hard calc() height and let flexbox handle it dynamically */
body.dashboard-page-body .iframe-container {
    width: 100%;
    height: 100%; /* Automatically fills the container exactly */
    min-height: 0; /* Prevents default iframe blowouts */
    flex: 1;
}

body.dashboard-page-body .iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Unpin the footer from absolute bottom so it doesn't overlap your canvas metrics */
body.dashboard-page-body footer {
    position: static; /* Drops absolute positioning */
    flex-shrink: 0;   /* Prevents the footer from squishing */
    height: 50px;     /* Slid down from 80px to save precious vertical canvas space for data */
    background: var(--bg-color);
}

/* ==========================================
   8. ARTICLE LIST CLEANUP
   ========================================== */
body.analysis-layout {
    padding-top: 100px; /* Safely clears the fixed navbar height */
}

body.analysis-layout h1 {
    margin-bottom: 2rem;
    color: var(--text-color);
}