/* Added global styles for html and body to remove scrollbars */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

:root {
    /* Core theme colors show clear semantic meaning */
    --fungal-black: #1A1B1C;
    --bio-lavender: #E6D7F3;
    --dark-lavender: #9B87AB;
    --dark-void: #0D0E0E;
    --light-void: #999999;
    --spore-gray: #9BA0A3;
    --dark-spore: #4D5052;
    --shadow-mint: #7A9B89;
    --necrotic-green: #4B9900;
    
    /* Animation colors */
    --animation-wireframe: var(--necrotic-green);
    --animation-wireframe-pulse: var(--shadow-mint);
    --animation-sphere: var(--dark-lavender);
    --animation-sphere-pulse: var(--bio-lavender);
    --animation-opacity: 0.3;
    --animation-pulse-intensity: 0.4;
    
    /* Remove old animation colors */
    --animation-primary: var(--animation-wireframe);
    --animation-primary-pulse: var(--animation-wireframe-pulse);
    --animation-secondary: var(--animation-sphere);
    --animation-secondary-pulse: var(--animation-sphere-pulse);
    
    /* Dynamic spacing */
    --spacing-unit: clamp(0.75rem, 2vw, 1rem);
    --spacing-large: calc(var(--spacing-unit) * 2);
    --spacing-xl: calc(var(--spacing-unit) * 4);
    --header-height: clamp(2rem, 3vh, 2.5rem);
    --footer-height: clamp(3rem, 4vh, 4rem);
    --content-max-width: min(65ch, 100% - 4rem);
    
    /* Theme mappings */
    --bg-color: var(--light-void);
    --text-color: var(--fungal-black);
    --link-color: var(--dark-spore);
    --accent-color: var(--spore-gray);
    --border-color: var(--dark-spore);
    --logo-color: var(--necrotic-green);
}

[data-theme="dark"] {
    --bg-color: var(--dark-void);
    --text-color: var(--dark-lavender);
    --link-color: var(--shadow-mint);
    --accent-color: var(--dark-spore);
    --border-color: var(--dark-spore);
    --logo-color: var(--shadow-mint);
    
    /* Animation colors - dark mode */
    --animation-wireframe: var(--shadow-mint);
    --animation-wireframe-pulse: var(--dark-spore);
    --animation-sphere: var(--dark-lavender);
    --animation-sphere-pulse: var(--dark-spore);
    
    /* Remove old animation colors */
    --animation-primary: var(--animation-wireframe);
    --animation-primary-pulse: var(--animation-wireframe-pulse);
    --animation-secondary: var(--animation-sphere);
    --animation-secondary-pulse: var(--animation-sphere-pulse);
}

/* Base styles */
body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.7;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: var(--spacing-unit);
    box-sizing: border-box;
}

.content {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: calc(var(--spacing-unit) / 2) 0;
}

/* Navigation and Logo */
.nav-header {
    padding: 0;
    margin-bottom: var(--spacing-large);
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.landing .nav-header {
    position: absolute;
    top: var(--spacing-unit);
    right: var(--spacing-unit);
    margin: 0;
    z-index: 10;
}

.site-title {
    margin-right: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: none;
    opacity: 0.85;
    transition: opacity 0.3s ease;
    padding: 0.5rem;
}

.site-title:hover {
    opacity: 1;
    border-bottom: none;
    background: var(--bg-color);
}

.header-animation {
    transition: transform 0.3s ease;
}

.site-title:hover .header-animation {
    transform: scale(1.1);
}

.nav-logo {
    height: var(--header-height);
    width: auto;
    display: block;
}

.nav-title {
    color: inherit;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    font-weight: 400;
    letter-spacing: 0.05em;
    margin: 0;
    line-height: 1;
}

/* Typography */
.prose {
    margin: 0;
    padding: 0;
}

.prose__section {
    margin-bottom: var(--spacing-unit);
}

.prose__section:last-child {
    margin-bottom: calc(var(--spacing-unit) / 2);
}

.prose__section p {
    margin-bottom: var(--spacing-unit);
    color: var(--text-color);
    opacity: 0.98;
    font-weight: 300;
    line-height: 1.6;
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.8;
}

a:hover {
    color: var(--accent-color);
    border-bottom-color: currentColor;
    opacity: 1;
}

/* Terminal */
.terminal-frame {
    position: relative;
    border: 1px solid var(--border-color);
    padding: var(--spacing-unit);
    background: var(--bg-color);
    max-height: none;
    overflow: visible;
}

.terminal-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--border-color);
    pointer-events: none;
}

/* Footer */
footer {
    width: 100%;
    padding: calc(var(--spacing-unit) / 2) 0;
    border-top: 1px solid var(--accent-color);
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--spacing-unit);
}

.footer-legal {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    line-height: 1.8;
    text-align: left;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .container {
        padding: calc(var(--spacing-unit) / 2);
    }
    
    .footer-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .theme-toggle {
        position: absolute;
        right: var(--spacing-unit);
        bottom: var(--spacing-unit);
    }
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 1rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    opacity: 0.85;
    transition: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    margin-left: auto;
    align-self: flex-end;
}

.theme-toggle:hover {
    opacity: 1;
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.theme-toggle:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--bg-color), 0 0 0 2px var(--accent-color);
}

.theme-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--border-color);
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.theme-toggle:hover::before {
    opacity: 0.7;
}

:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Reset container padding for landing page */
.container.landing {
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Landing page specific styles */
.landing {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh, 1vh) * 100);  /* updated to use dynamic viewport height */
    position: relative;
}

.landing-content {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;   /* ensure full height for centering */
    display: grid;
    place-items: center;
}

.branding {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
}

.hero-logo {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

.main-nav ul {
    display: flex;
    gap: var(--spacing-large);
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.main-nav a {
    font-size: 1.1rem;
    padding: 0.4em 0.8em;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    opacity: 0.85;
}

.main-nav a:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .animation-container {
        width: min(90vmin, 512px);
        height: min(90vmin, 512px);
    }
}

@media (max-height: 600px) {
    .animation-container {
        width: min(80vmin, 512px);
        height: min(80vmin, 512px);
    }
}

/* Add these rules to the existing CSS */
.main-nav a.inactive {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border-color);
    pointer-events: none;
}

.main-nav a.inactive:hover {
    background: transparent;
    color: var(--text-color);
}

/* Add this to ensure SVG inherits theme colors properly */
.hero-logo {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
    color: var(--logo-color);
}

.support-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    margin: 1rem 0;
    background: transparent;
    min-height: 50px;
}

.support-container iframe {
    border: none;
    background: transparent !important;
    min-height: 50px;
    min-width: 200px;
}

.animation-container {
    position: relative;
    width: min(75vh, 75vw, 800px);
    height: min(75vh, 75vw, 800px);
    display: grid;
    place-items: center;
    background: transparent;
}

canvas {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    object-fit: contain;
    margin: 0;
    padding: 0;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .landing {
        height: -webkit-fill-available;
    }
    
    .landing-content {
        min-height: -webkit-fill-available;
    }
}

/* Additional Mobile Adjustments for About and other pages */
@media (max-width: 768px) {
    /* Force non-landing containers to fit the viewport */
    .container:not(.landing) {
        height: 100vh;
        overflow: hidden;
    }
    /* Ensure main content area doesn't scroll */
    .content {
        flex: 1;
        overflow: hidden;
    }
    /* Adjust terminal-frame to scale its content and prevent overflow */
    .terminal-frame {
        max-height: calc(100vh - var(--header-height) - var(--footer-height) - 2rem);
        overflow: hidden;
        font-size: 0.9rem;
    }
    /* Adjust support container spacing */
    .support-container {
        padding: 1rem 0;
        margin: 1rem 0;
    }
    /* Adjust main navigation links for mobile */
    .main-nav a {
        padding: 0.3em 0.6em;
        font-size: 0.9rem;
    }
    /* Adjust theme-toggle button size for mobile */
    .theme-toggle {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.9rem;
    }
}