/* Reset & Base */
:root {
    --bg-color: #f0f4f7; /* Cool, institutional blue-grey */
    --text-color: #1a202c; /* Deep slate, not pure black */
    --accent-color: #2b6cb0;
    --up-color: #2e7d32;   /* Deep Green */
    --down-color: #c62828; /* Deep Red */
    --font-main: "Inter", Helvetica, Arial, sans-serif;
    --grid-gap: 2rem;
    --h1-blend-mode: multiply;
}

[data-theme="dark"] {
    --bg-color: #0f172a; /* Deep Navy/Slate */
    --text-color: #f1f5f9;
    --accent-color: #3b82f6;
    --up-color: #4ade80;   /* Vibrant Mint Green */
    --down-color: #f87171; /* Vibrant Coral Red */
    --h1-blend-mode: screen;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent scroll, this is a viewport */
    background-color: var(--bg-color);
    font-family: var(--font-main);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Canvas Layer - Fixed Background */
#network-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.9; /* Default light mode blend */
    transition: opacity 0.3s ease;
}

[data-theme="dark"] #network-canvas {
    opacity: 1.0; /* Full opacity in dark mode for better contrast */
}

/* UI Layer - Interaction */
.ui-layer {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    pointer-events: none; /* Let clicks pass through to canvas where empty */
}

/* Swiss Grid System */
.grid-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gap);
    width: 100%;
    pointer-events: auto;
}

/* Header Sections */
.brand-block {
    grid-column: 1 / 4;
}

h1 {
    font-size: 4.5rem;
    line-height: 0.9;
    letter-spacing: -0.04em;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    mix-blend-mode: var(--h1-blend-mode); /* Blends text into the graph slightly */
}

h1 .line1, h1 .line2 {
    display: block;
    min-height: 0.9em; /* Matches line-height to prevent vertical collapse */
}

.scramble-char {
    opacity: 0.4;
}

.subtitle {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-top: 1px solid var(--text-color);
    padding-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    max-width: 200px;
}

/* Theme Toggle */
.theme-toggle {
    grid-column: 12 / 13;
    justify-self: end;
    background: none;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 0.5rem;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
    height: fit-content;
}

.theme-toggle:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

.info-block {
    grid-column: 6 / 9;
    font-size: 0.875rem;
    font-family: "Courier New", monospace; /* Data aesthetic */
    opacity: 0.7;
    margin-top: 0.5rem;
}

.nav-block {
    grid-column: 10 / 13;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    opacity: 0.6;
}

.nav-link.active::before {
    content: "→";
    position: absolute;
    left: -1.5rem;
}

/* Footer */
.footer-layout {
    align-items: end;
}

.ticker-carousel {
    grid-column: 1 / 11;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.carousel-nav {
    display: none; /* Hidden on desktop */
}

.ticker {
    display: flex;
    flex-direction: row;
    gap: 4rem;
    font-family: var(--font-main);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ticker-item {
    display: flex; /* Always show on desktop */
    flex-direction: column;
    gap: 0.25rem;
}

.ticker-item .symbol-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.ticker-item .symbol {
    font-weight: 600;
    opacity: 0.5;
}

.ticker-item .price {
    min-width: 100px;
    font-weight: 400;
}

.stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.6rem;
    opacity: 0.8;
}

.stat {
    white-space: nowrap;
}

.stat.up {
    color: var(--up-color);
}

.stat.down {
    color: var(--down-color);
}

.copyright {
    grid-column: 10 / 13;
    text-align: right;
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.5;
}

/* Utility indicators */
.up {
    color: #2e7d32;
}
.down {
    color: #c62828;
}
.neutral {
    color: #78909c;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body, html {
        overflow: auto;
        height: auto;
    }

    #network-canvas {
        position: absolute; /* Moves with page content on mobile */
    }

    .ui-layer {
        padding: 1.5rem;
        height: auto;
        min-height: 100svh; /* Small Viewport Height - mobile friendly */
        pointer-events: auto; /* Required for touch scrolling to work */
        -webkit-overflow-scrolling: touch; /* Smooth momentum scroll on iOS */
    }
    h1 {
        font-size: 3rem;
    }
    .grid-container {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    .theme-toggle {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        z-index: 100;
    }
    .nav-block {
        align-items: flex-start;
        margin-top: 2rem;
    }
    .footer-layout {
        flex-direction: column;
        gap: 2.5rem;
        align-items: flex-start;
    }
    .ticker-carousel {
        width: 100%;
        position: relative;
    }

    .carousel-nav {
        display: flex;
        gap: 1rem;
        margin-top: 1rem;
    }

    .carousel-nav button {
        background: none;
        border: 1px solid var(--text-color);
        color: var(--text-color);
        padding: 0.25rem 0.75rem;
        cursor: pointer;
        font-family: var(--font-main);
        font-size: 0.8rem;
        opacity: 0.5;
        transition: opacity 0.2s;
    }

    .carousel-nav button:hover {
        opacity: 1;
    }

    .ticker {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    .ticker-item {
        display: none; /* Hide all by default on mobile */
        width: 100%;
    }

    .ticker-item.active {
        display: flex; /* Show only active on mobile */
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(5px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .copyright {
        text-align: left;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
