:root {
    /* Theme variables for index page */
    --bg-primary: #ffffff;
    --bg-overlay: #1e1e1e;
    --fg-primary: #1e1e1e;
    --fg-accent: #ffffd2; /* alias source */
    --fg-nav: var(--fg-accent);
    --border-primary: #1e1e1e;
    --footer-bg: #1e1e1e;
    --footer-fg: #ecf0f1;
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-overlay: #1e1e1e;
    --fg-primary: #e8e8e8;
    --fg-accent: #fffbd2;
    --fg-nav: var(--fg-accent);
    --border-primary: #1e1e1e; /* decorative border stays dark */
    --footer-bg: #1e1e1e;
    --footer-fg: #ecf0f1;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #121212;
        --bg-overlay: #1e1e1e;
        --fg-primary: #e8e8e8;
        --fg-accent: #fffbd2;
        --fg-nav: var(--fg-accent);
        --border-primary: #1e1e1e;
        --footer-bg: #1e1e1e;
        --footer-fg: #ecf0f1;
    }
}

html {
    box-sizing: border-box;
    /* Remove border from HTML as we'll create an overlay */
}

/* Common styles for html and body */
html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Border overlay that sits above content */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 0.5vw solid var(--border-primary);
    pointer-events: none; /* Allow clicking through the border */
    z-index: 1002; /* Above everything else */
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Responsive border adjustments */
@media (max-width: 768px) {
    body::after {
        border-width: 1vw;
    }
}

/* loading overlay, interplay with JS*/
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Standard background styling for all background elements */
.background-1, .background-0, .background--1 {
    width: 100%;
    height: 100vh;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}

/* Individual background settings */
.background-1 {
    /* PNG only to avoid 404s for AVIF/WEBP */
    background-image: url('../images/index_background_1.png');
}

.background-0 {
    background-image: url('../images/index_background_0.png');
}

.background--1 {
    background-image: url('../images/index_background_-1.png');
    background-position: top center;
}

/* Mobile Portrait Background Responsiveness */
@media (max-width: 768px) and (orientation: portrait) {
    .background-1 {
        /* Use desktop image; cropped variant not present */
        background-image: url('../images/index_background_1.png');
    }
    
    .background-0 {
        background-image: url('../images/index_background_0_cropped.png');
    }
    
    .background--1 {
        background-image: url('../images/index_background_-1_cropped.png');
        background-size: contain;
    }
}

/* Mobile Landscape Background Responsiveness */
@media (max-width: 768px) and (orientation: landscape) {
    /* Background images remain the same as desktop */
}

/* Footer */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-fg);
    text-align: center;
    padding: 15px 0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Nav bars*/
.top-nav,
.bottom-nav {
    position: fixed;
    width: 100%; /* Changed from calc(100% - 0.86vw) for full width */
    left: 0; /* Explicitly set left position */
    display: grid;
    grid-template-columns: max-content auto max-content;
    align-items: center;
    z-index: 1003; /* Increased from 1000 to be higher than the border overlay (1002) */
    transition: top 0.3s ease, bottom 0.3s ease;
    overflow: visible;
    padding: 0 0.5vw; /* Add padding to account for the border */
    box-sizing: border-box; /* Ensure padding is included in width calculation */
    isolation: isolate; /* create a new stacking context for overlay layering */
}

/* Offset top-nav links upward slightly to compensate for translucent art */
.top-nav a {
    position: relative;
    top: -2.0vw; /* adjust as needed; negative moves text up */
}

.top-nav .nav-left a,
.top-nav .nav-right a,
.bottom-nav .nav-left a,
.bottom-nav .nav-right a {
    font-family: Vendetta, sans-serif;
    color: var(--fg-nav);
    text-decoration: none;
    font-size: 2.0em;
    padding: 0 6vw;
    margin: 0;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 2em;
}

.nav-left {
    justify-content: flex-start;
}

.nav-right {
    justify-content: flex-end;
}

.top-nav {
    height: 11.3vw;
    background-image: url('../images/top_nav.png');
    background-repeat: no-repeat;
    background-position: top center;
    background-size: contain;
}

.bottom-nav {
    height: 6.9vw;
    background-image: url('../images/bottom_nav.png');
    background-repeat: no-repeat;
    background-position: bottom center;
    background-size: contain;
}

/* Dev-only Concord link styling */
.dev-only-link {
    display: none;
    color: var(--fg-nav);
    position: relative;
}
.dev-only-link::after {
    content: '🔒';
    font-size: 0.75em;
    margin-left: 4px;
    opacity: 0.7;
}
body.dev-authenticated .dev-only-link {
    display: inline-block;
}
.dev-only-link:hover {
    color: var(--fg-nav);
    opacity: 0.8;
}

/* Contrast overlays behind nav content */
.top-nav::before,
.bottom-nav::before {
    content: none;
    position: absolute;
        inset: 25% 0;
    background: none; /* remove contrast overlay */
    pointer-events: none;
    z-index: 0;
}
.top-nav > *,
.bottom-nav > * { position: relative; z-index: 1; }

/* Improve readability of nav links across images */
.top-nav .nav-left a,
.top-nav .nav-right a,
.bottom-nav .nav-left a,
.bottom-nav .nav-right a {
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Theme toggle button for index navs */
.theme-toggle-btn {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--fg-nav);
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
    visibility: hidden; /* avoid icon mismatch pre-JS */
}
.theme-toggle-btn:hover,
.theme-toggle-btn:focus { filter: brightness(1.1); }
.theme-toggle-btn .theme-icon { font-size: 1.2em; line-height: 1; }

/* Focus outlines for accessibility */
.top-nav .nav-left a:focus,
.top-nav .nav-right a:focus,
.bottom-nav .nav-left a:focus,
.bottom-nav .nav-right a:focus,
.theme-toggle-btn:focus {
    outline: 2px solid var(--border-primary);
    outline-offset: 3px;
}

/* Mobile Portrait Nav Responsiveness*/
@media (max-width: 768px) and (orientation: portrait) {
    .top-nav {
        height: 11.5vh;
        width: 100%; /* Changed to full width */
        background-size: cover;
        padding: 0 1vw; /* Adjust padding for mobile */
    }

    .bottom-nav {
        height: 6.5vh;
        width: 100%; /* Changed to full width */
        background-size: cover;
        padding: 0 1vw; /* Adjust padding for mobile */
    }

    .top-nav .nav-left a,
    .top-nav .nav-right a,
    .bottom-nav .nav-left a,
    .bottom-nav .nav-right a {
    font-family: Vendetta, sans-serif;
    color: var(--fg-nav);
    text-decoration: none;
    font-size: 0.8em;
    padding: 0 5px;
}
    
}

/* Mobile Landscape Nav Responsiveness*/
@media (max-width: 768px) and (orientation: landscape) {
    .top-nav {
        height: 20vh;
        width: 100%; /* Changed to full width */
        padding: 0 1vw; /* Adjust padding for mobile */
    }

    .bottom-nav {
        height: 13vh;
        width: 100%; /* Changed to full width */
        padding: 0 1vw; /* Adjust padding for mobile */
    }
    
    .top-nav .nav-left a,
    .top-nav .nav-right a,
    .bottom-nav .nav-left a,
    .bottom-nav .nav-right a {
    font-family: Vendetta, sans-serif;
    color: var(--fg-nav);
    text-decoration: none;
    font-size: 1em;
    padding: 0 10px;
    }
}

