/*
KRIZDINGUS.com Styles
Theme: Retro OS interface with CRT effects
Features:
  - OS window styling with title bar and controls
  - CRT scan lines and static effects
  - Glitch animations and transitions
  - Responsive design with mobile optimizations
  - Dark/light theme support
  - Reduced motion preferences
  - Menu system with dropdowns
  - Window control button states

Breakpoints:
  - Mobile: < 480px
  - Tablet: < 768px
  - Desktop: > 768px

Notes:
- Uses CSS variables for easy theme switching
- Window controls styled like classic OS buttons
- Retro effects respect reduced motion preferences
*/

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    /* Light Theme Colors (Game Boy inspired) */
    --bg-primary: #c4bebb;
    --bg-secondary: #d4d0cb;
    --bg-tertiary: #e4e0db;
    --text-primary: #272929;
    --text-secondary: #404242;
    --accent-primary: #9a2257;    /* Magenta headers */
    --accent-secondary: #494786;  /* Purple nav */
    --accent-tertiary: #494786;   /* Brand purple (was pixel green) */
    --border-color: #94908b;
    --shadow-color: rgba(39, 41, 41, 0.1);
    
    /* Dark Theme Colors */
    --dark-bg-primary: #1a1c1c;
    --dark-bg-secondary: #242727;
    --dark-bg-tertiary: #2e3131;
    --dark-text-primary: #c4bebb;
    --dark-text-secondary: #a4a0a0;
    --dark-accent-primary: #ff6b9d;
    --dark-accent-secondary: #7b7bc9;
    --dark-accent-tertiary: #a4f09d;
    --dark-border-color: #404242;
    --dark-shadow-color: rgba(0, 0, 0, 0.3);
    
    /* Typography */
    --font-pixel: 'Silkscreen', 'Courier New', monospace;
    --font-mono: 'Courier New', 'Monaco', monospace;
    
    /* Spacing & Layout */
    --container-width: 1200px;
    --container-narrow: 576px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Borders & Effects */
    --border-width: 2px;
    --border-radius: 4px;
    --transition: all 0.2s ease;
    --scan-line-height: 2px;
    --static-intensity: 0.5; /* Dynamic static opacity control */
    --error-color: #b8002f;    /* Deep red for light mode */
    --warning-color: #b86b00;  /* Deep orange for light mode */
}

/* Dark Theme Custom Properties */
[data-theme="dark"] {
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --bg-tertiary: var(--dark-bg-tertiary);
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --accent-primary: var(--dark-accent-primary);
    --accent-secondary: var(--dark-accent-secondary);
    --accent-tertiary: var(--dark-accent-tertiary);
    --border-color: var(--dark-border-color);
    --shadow-color: var(--dark-shadow-color);
    --error-color: #ff4444;    /* Bright red for dark mode */
    --warning-color: #ffaa00;  /* Bright orange for dark mode */
}

/* ===== RESET & BASE STYLES ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* ===== TYPOGRAPHY ===== */
.pixel-text, h1, h2, h3 {
    font-family: var(--font-pixel);
    font-weight: 400;
    letter-spacing: 0.05em;
}

h1 { 
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--accent-primary);
    margin-bottom: var(--spacing-md);
}

h2 { 
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--accent-secondary);
    margin-bottom: var(--spacing-md);
}

h3 { 
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: var(--accent-primary);
    margin-bottom: var(--spacing-sm);
}

p {
    margin-bottom: var(--spacing-md);
    max-width: 70ch;
}

/* ===== LAYOUT CONTAINERS ===== */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ===== SKIP LINK ===== */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 0;
    background: var(--accent-primary);
    color: white;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: var(--border-radius);
    z-index: 1000;
    transition: var(--transition);
}
[data-theme="dark"] .skip-link {
    color: var(--dark-bg-primary);
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--accent-tertiary);
    outline-offset: 2px;
}

/* ===== HEADER ===== */
.site-header {
    background: var(--bg-secondary);
    border-bottom: var(--border-width) solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.site-header .container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.site-title {
    margin: 0;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.site-title a {
    color: var(--accent-primary);
    text-decoration: none;
    font-family: var(--font-pixel);
    font-weight: 400;
    letter-spacing: 0.05em;
    font-size: inherit;
    transition: var(--transition);
}

.site-title a:hover,
.site-title a:focus {
    color: var(--accent-secondary);
    outline: none;
    text-decoration: none;
}

[data-theme="dark"] .site-title a {
    color: var(--accent-primary);
}
[data-theme="dark"] .site-title a:hover,
[data-theme="dark"] .site-title a:focus {
    color: var(--accent-tertiary);
}

/* Navigation */
.nav-list {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-md);
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-list li {
    display: flex;
    align-items: center;
}

.nav-list a {
    color: var(--accent-secondary);
    text-decoration: none;
    font-weight: bold;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: var(--border-width) solid transparent;
    transition: var(--transition);
    position: relative;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.nav-list a:hover,
.nav-list a:focus {
    color: var(--bg-tertiary);
    background: var(--accent-tertiary);
    border-color: var(--accent-secondary);
    transform: translateY(-1px);
    outline: none;
}

/* Dark Theme Navigation  */
[data-theme="dark"] .nav-list a {
    color: var(--text-primary);
}

/* Dark Theme Navigation Hover */
[data-theme="dark"] .nav-list a:hover,
[data-theme="dark"] .nav-list a:focus {
    color: var(--dark-bg-primary);
    background: var(--dark-accent-tertiary);
    border-color: var(--dark-accent-secondary);
}

.nav-list a[aria-current="page"] {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--accent-secondary);
    border: var(--border-width) solid transparent;
    border-radius: var(--border-radius);
    color: white;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.theme-toggle:hover,
.theme-toggle:focus {
    background: #b6e6b0;
    color: #272929;
    border-color: var(--accent-secondary);
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #b6e6b0;
}

.theme-toggle:active {
    background: #b6e6b0;
    color: #272929;
    border-color: var(--accent-primary);
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

[data-theme="dark"] .theme-toggle:hover,
[data-theme="dark"] .theme-toggle:focus {
    background: var(--dark-accent-tertiary);
    color: var(--dark-bg-primary);
    border-color: var(--dark-accent-secondary);
    outline: 2px solid var(--dark-accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--dark-accent-tertiary);
}

[data-theme="dark"] .theme-toggle:active {
    background: var(--dark-accent-tertiary);
    color: var(--dark-bg-primary);
    border-color: var(--dark-accent-primary);
    outline: 2px solid var(--dark-accent-primary);
    outline-offset: 2px;
}

.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    width: 20px;
    height: 20px;
}

.theme-toggle .sun-icon {
    opacity: 1;
}

.theme-toggle .moon-icon {
    opacity: 0;
    position: absolute;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 0;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 1;
}

/* ===== HERO SECTION ===== */
.hero {
    position: relative;
    background: linear-gradient(135deg, #242727 0%, #2e3131 100%);
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: var(--border-width) solid var(--border-color);
    animation: occasionalGlitch 10s infinite;
    will-change: transform, filter;
    transform: translateZ(0);
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
    animation: staticBars 0.2s infinite steps(3);
}

.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='5' stitchTiles='stitch'/%3E%3CcolorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.5;
    mix-blend-mode: overlay;
    animation: dramaticStatic 0.08s steps(8) infinite;
    pointer-events: none;
    z-index: 2;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes staticBars {
    0% { transform: translateY(0); }
    25% { transform: translateY(-1px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(1px); }
    100% { transform: translateY(0); }
}

@keyframes dramaticStatic {
    0% { 
        transform: translate(0, 0) scale(1) rotate(0deg); 
        opacity: 0.5;
    }
    12.5% { 
        transform: translate(-3px, 2px) scale(1.02) rotate(0.5deg); 
        opacity: 0.6;
    }
    25% { 
        transform: translate(2px, -3px) scale(0.98) rotate(-0.5deg); 
        opacity: 0.4;
    }
    37.5% { 
        transform: translate(-2px, -2px) scale(1.03) rotate(0.3deg); 
        opacity: 0.55;
    }
    50% { 
        transform: translate(3px, 3px) scale(0.97) rotate(-0.3deg); 
        opacity: 0.65;
    }
    62.5% { 
        transform: translate(-1px, 2px) scale(1.01) rotate(0.2deg); 
        opacity: 0.45;
    }
    75% { 
        transform: translate(2px, -1px) scale(0.99) rotate(-0.2deg); 
        opacity: 0.58;
    }
    87.5% { 
        transform: translate(-3px, -1px) scale(1.02) rotate(0.4deg); 
        opacity: 0.62;
    }
    100% { 
        transform: translate(1px, -2px) scale(1) rotate(0deg); 
        opacity: 0.5;
    }
}

.hero.glitch-burst {
    animation: glitchBurst 0.3s ease-out;
}

@keyframes glitchBurst {
    0% { filter: none; transform: none; }
    10% { filter: hue-rotate(360deg) saturate(5) contrast(3); transform: translate(5px, 0) skewX(5deg); }
    20% { filter: invert(1) hue-rotate(180deg) saturate(2); transform: translate(-5px, 2px) skewX(-3deg); }
    30% { filter: sepia(1) saturate(8) hue-rotate(120deg); transform: translate(3px, -3px) skewY(2deg); }
    40% { filter: contrast(5) brightness(3) saturate(0); transform: translate(-2px, 1px) scale(1.02); }
    50% { filter: hue-rotate(-360deg) saturate(3) invert(0.5); transform: translate(2px, -1px) scale(0.98); }
    100% { filter: none; transform: none; }
}

@keyframes occasionalGlitch {
    0%, 95%, 100% { 
        filter: none;
        transform: none;
    }
    96% { 
        filter: hue-rotate(90deg) saturate(1.5);
        transform: translate(1px, 0);
    }
    97% { 
        filter: hue-rotate(-90deg) saturate(0.8);
        transform: translate(-1px, 0);
    }
    98% { 
        filter: none;
        transform: translate(0, 0);
    }
}

/* ===== SECTIONS ===== */
section {
    padding: var(--spacing-xl) 0;
}

.featured-project {
    background: var(--bg-secondary);
    border-bottom: var(--border-width) solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.featured-project.glitch-burst {
    animation: glitch-burst 0.3s ease-in-out;
}

@keyframes glitch-burst {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(2px, -2px); }
    60% { transform: translate(-2px, -2px); }
    80% { transform: translate(2px, 2px); }
    100% { transform: translate(0); }
}

/* ===== PROJECT CARDS ===== */
.project-card {
    background: var(--bg-tertiary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
    border-color: var(--accent-tertiary);
}

.project-card.featured {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--spacing-lg);
    align-items: center;
}

.project-image img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: var(--border-width) solid var(--border-color);
}

.project-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.project-card h3 {
    margin-bottom: var(--spacing-sm);
}

.project-hook {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.project-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.project-link:hover,
.project-link:focus {
    border-bottom-color: var(--accent-primary);
    outline: none;
}

/* Tech Tags */
.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    list-style: none;
    margin-bottom: var(--spacing-sm);
}

.tech-tags li,
.tech-tags span {
    background: #b6e6b0;
    color: #272929;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: bold;
    border: 1px solid var(--border-color);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

[data-theme="dark"] .tech-tags li,
[data-theme="dark"] .tech-tags span {
    background: var(--dark-bg-secondary);
    color: var(--dark-text-primary);
    border-color: var(--dark-border-color);
}

/* ===== PROJECTS GRID ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

/* ===== ABOUT SECTION ===== */
.about-section {
    background: var(--bg-secondary);
}

.about-content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--spacing-xl);
    align-items: start;
}

.about-portrait {
    margin: 0;
    position: relative;
    transition: var(--transition);
}

.about-portrait:hover {
    transform: translateY(-4px);
}

.about-portrait img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: var(--border-width) solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: var(--transition);
}

.about-portrait:hover img {
    box-shadow: 0 8px 24px var(--shadow-color);
    border-color: var(--accent-tertiary);
}

.about-text {
    max-width: 70ch;
}

.about-text p {
    margin-bottom: var(--spacing-md);
}

.about-text a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.about-text a:hover,
.about-text a:focus {
    border-bottom-color: var(--accent-primary);
    outline: none;
}

/* ===== FOOTER ===== */
.site-footer {
    background: var(--bg-tertiary);
    border-top: var(--border-width) solid var(--border-color);
    text-align: center;
    padding: var(--spacing-xl) 0;
}

.social-nav {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.social-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-primary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: var(--transition);
    color: var(--accent-secondary); /* Set default SVG color */
}

.social-nav a:hover,
.social-nav a:focus {
    background: #b6e6b0;
    color: #272929;
    border-color: #94908b;
    outline: 2px solid #b6e6b0;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #b6e6b0;
}

.social-nav a svg {
    /* fill: currentColor; */
}

.social-nav a svg.filled-icon {
    fill: currentColor;
}

.social-icon {
    font-size: 1.2rem;
}

.footer-text {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    max-width: none;
}

.copyright {
    font-size: 0.9rem;
    max-width: none;
}

.copyright a {
    color: var(--accent-primary);
    text-decoration: none;
}

.copyright a:hover,
.copyright a:focus {
    text-decoration: underline;
}

/* ===== ANIMATIONS & KEYFRAMES ===== */
@keyframes glitch {
    0%, 90%, 100% { transform: translate(0); }
    91% { transform: translate(-1px, -1px); }
    92% { transform: translate(1px, 1px); }
    93% { transform: translate(-1px, 1px); }
    94% { transform: translate(1px, -1px); }
    95% { transform: translate(0); }
}

@keyframes scanlines {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* ===== FOCUS STYLES ===== */
*:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus,
a:focus {
    outline-offset: 4px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .nav-list {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: var(--spacing-md);
        margin-top: var(--spacing-sm);
    }
    .nav-list li {
        width: auto;
        justify-content: center;
    }
    .theme-toggle {
        width: 32px;
        height: 32px;
    }
    .theme-toggle .sun-icon,
    .theme-toggle .moon-icon {
        width: 16px;
        height: 16px;
    }
    
    .hero {
        min-height: 50vh;
    }
    
    .project-card.featured {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .social-nav {
        flex-wrap: wrap;
    }
    
    .about-content-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .about-portrait {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .console-hero {
        height: 50vh;
        min-height: 350px;
        padding: var(--spacing-md);
        margin: 0;
    }
    
    .boot-sequence {
        padding-bottom: 2.5rem;
    }
}

@media (max-width: 480px) {
    :root {
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .hero-content {
        padding: var(--spacing-lg);
    }
    
    .nav-list {
        gap: var(--spacing-sm);
    }
    
    .nav-list a {
        padding: var(--spacing-xs);
        font-size: 0.8rem;
    }
    
    .about-portrait {
        max-width: 100%;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scan-lines {
        animation: none;
    }
    
    .hero-title {
        animation: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .theme-toggle,
    .scan-lines,
    .social-nav {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .project-card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

[data-theme="dark"] .social-nav a:hover,
[data-theme="dark"] .social-nav a:focus {
    background: var(--dark-accent-tertiary);
    color: var(--dark-bg-primary);
    border-color: var(--dark-accent-secondary);
    outline: 2px solid var(--dark-accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--dark-accent-tertiary);
}

/* Glitch warning popup */
.glitch-warning {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: var(--accent-primary);
    color: white;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    text-align: center;
    z-index: 1000;
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    animation: glitch 0.4s infinite;
    border: 2px solid var(--accent-tertiary);
    box-shadow: 0 0 20px var(--accent-primary);
    pointer-events: none;
}

.glitch-warning .pixel-text {
    font-size: 1rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.glitch-burst {
    animation: glitchBurst 0.3s ease-out;
}

@keyframes glitchBurst {
    0% { filter: none; transform: none; }
    10% { filter: hue-rotate(360deg) saturate(5) contrast(3); transform: translate(5px, 0) skewX(5deg); }
    20% { filter: invert(1) hue-rotate(180deg) saturate(2); transform: translate(-5px, 2px) skewX(-3deg); }
    30% { filter: sepia(1) saturate(8) hue-rotate(120deg); transform: translate(3px, -3px) skewY(2deg); }
    40% { filter: contrast(5) brightness(3) saturate(0); transform: translate(-2px, 1px) scale(1.02); }
    50% { filter: hue-rotate(-360deg) saturate(3) invert(0.5); transform: translate(2px, -1px) scale(0.98); }
    100% { filter: none; transform: none; }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .glitch-warning {
        animation: none;
    }
    
    .glitch-burst {
        animation: none;
    }
}

/* ===== EXTREME GLITCH EFFECTS FOR FEATURED PROJECT TRANSITIONS ===== */

/* Section shake effect for just the featured section */
.section-shake {
    animation: sectionShake 0.8s ease-in-out;
}

@keyframes sectionShake {
    0% { transform: translate(0); }
    10% { transform: translate(-8px, 2px) rotate(0.5deg); }
    20% { transform: translate(6px, -6px) rotate(-0.5deg); }
    30% { transform: translate(-4px, 8px) rotate(0.3deg); }
    40% { transform: translate(8px, -2px) rotate(-0.3deg); }
    50% { transform: translate(-6px, -4px) rotate(0.2deg); }
    60% { transform: translate(4px, 6px) rotate(-0.2deg); }
    70% { transform: translate(-2px, -8px) rotate(0.1deg); }
    80% { transform: translate(2px, 4px) rotate(-0.1deg); }
    90% { transform: translate(-1px, -2px) rotate(0.05deg); }
    100% { transform: translate(0); }
}

/* Extreme glitch effect for featured section */
.featured-project.extreme-glitch {
    animation: extremeGlitch 0.8s ease-in-out;
    position: relative;
    overflow: hidden;
}

.featured-project.extreme-glitch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(255, 0, 255, 0.8) 2px,
        rgba(255, 0, 255, 0.8) 4px,
        transparent 4px,
        transparent 6px,
        rgba(0, 255, 255, 0.8) 6px,
        rgba(0, 255, 255, 0.8) 8px
    );
    animation: scanlineGlitch 0.1s linear infinite;
    z-index: 10;
    pointer-events: none;
}

.featured-project.extreme-glitch::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2.5' numOctaves='8' stitchTiles='stitch'/%3E%3CcolorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.9;
    mix-blend-mode: difference;
    animation: chaosStatic 0.05s steps(10) infinite;
    z-index: 11;
    pointer-events: none;
}

@keyframes extremeGlitch {
    0% { 
        filter: none; 
        transform: none; 
        clip-path: inset(0);
    }
    5% { 
        filter: hue-rotate(90deg) saturate(5) contrast(3) brightness(2);
        transform: translate(15px, -5px) skewX(10deg) scale(1.05);
        clip-path: inset(20% 0 30% 0);
    }
    10% { 
        filter: invert(1) hue-rotate(180deg) saturate(8) contrast(5);
        transform: translate(-12px, 8px) skewX(-8deg) scaleY(0.9);
        clip-path: inset(0 20% 0 15%);
    }
    15% { 
        filter: sepia(1) saturate(10) hue-rotate(270deg) brightness(3);
        transform: translate(8px, -12px) skewY(5deg) scaleX(1.1);
        clip-path: inset(40% 0 10% 0);
    }
    20% { 
        filter: contrast(8) brightness(0.2) saturate(0) invert(0.5);
        transform: translate(-18px, 3px) rotate(2deg) scale(0.95);
        clip-path: inset(0 30% 0 0);
    }
    25% { 
        filter: hue-rotate(-180deg) saturate(6) contrast(4) brightness(4);
        transform: translate(10px, -8px) skewX(15deg) scaleY(1.2);
        clip-path: inset(15% 0 25% 10%);
    }
    30% { 
        filter: invert(0.8) hue-rotate(45deg) saturate(3) contrast(6);
        transform: translate(-6px, 15px) skewY(-10deg) scale(1.08);
        clip-path: inset(0 0 35% 20%);
    }
    35% { 
        filter: sepia(0.8) saturate(12) hue-rotate(120deg) brightness(2.5);
        transform: translate(20px, -10px) rotate(-3deg) scaleX(0.85);
        clip-path: inset(50% 15% 0 0);
    }
    40% { 
        filter: contrast(10) brightness(0.1) saturate(2) hue-rotate(360deg);
        transform: translate(-8px, 12px) skewX(-20deg) scaleY(0.8);
        clip-path: inset(0 10% 20% 30%);
    }
    45% { 
        filter: hue-rotate(270deg) saturate(4) invert(0.3) contrast(7);
        transform: translate(5px, -20px) skewY(8deg) scale(1.15);
        clip-path: inset(25% 0 0 25%);
    }
    50% { 
        filter: invert(1) hue-rotate(-90deg) saturate(9) brightness(5);
        transform: translate(-25px, 6px) rotate(5deg) scaleX(1.2);
        clip-path: inset(0 40% 30% 0);
    }
    60% { 
        filter: sepia(1) saturate(15) hue-rotate(180deg) contrast(3);
        transform: translate(12px, -15px) skewX(12deg) scaleY(1.1);
        clip-path: inset(35% 0 0 15%);
    }
    70% { 
        filter: contrast(5) brightness(3) saturate(1) hue-rotate(45deg);
        transform: translate(-10px, 8px) skewY(-5deg) scale(0.9);
        clip-path: inset(0 20% 40% 0);
    }
    80% { 
        filter: hue-rotate(135deg) saturate(7) invert(0.6) brightness(2);
        transform: translate(8px, -5px) rotate(-1deg) scaleX(1.05);
        clip-path: inset(20% 10% 0 20%);
    }
    90% { 
        filter: invert(0.2) saturate(3) contrast(2) hue-rotate(315deg);
        transform: translate(-3px, 3px) skewX(3deg) scale(1.02);
        clip-path: inset(10% 0 15% 5%);
    }
    100% { 
        filter: none; 
        transform: none; 
        clip-path: inset(0);
    }
}

@keyframes scanlineGlitch {
    0% { 
        transform: translateX(0) scaleY(1);
        opacity: 0.8;
    }
    25% { 
        transform: translateX(-100%) scaleY(2);
        opacity: 0.6;
    }
    50% { 
        transform: translateX(100%) scaleY(0.5);
        opacity: 1;
    }
    75% { 
        transform: translateX(-50%) scaleY(3);
        opacity: 0.4;
    }
    100% { 
        transform: translateX(0) scaleY(1);
        opacity: 0.8;
    }
}

@keyframes chaosStatic {
    0% { 
        transform: translate(0, 0) scale(1) rotate(0deg); 
        opacity: 0.9;
        filter: hue-rotate(0deg);
    }
    10% { 
        transform: translate(-10px, 5px) scale(1.1) rotate(2deg); 
        opacity: 0.7;
        filter: hue-rotate(45deg);
    }
    20% { 
        transform: translate(8px, -8px) scale(0.9) rotate(-3deg); 
        opacity: 1;
        filter: hue-rotate(90deg);
    }
    30% { 
        transform: translate(-5px, -12px) scale(1.2) rotate(1deg); 
        opacity: 0.5;
        filter: hue-rotate(135deg);
    }
    40% { 
        transform: translate(12px, 8px) scale(0.8) rotate(-2deg); 
        opacity: 0.9;
        filter: hue-rotate(180deg);
    }
    50% { 
        transform: translate(-8px, 12px) scale(1.05) rotate(4deg); 
        opacity: 0.6;
        filter: hue-rotate(225deg);
    }
    60% { 
        transform: translate(6px, -6px) scale(0.95) rotate(-1deg); 
        opacity: 0.8;
        filter: hue-rotate(270deg);
    }
    70% { 
        transform: translate(-12px, 3px) scale(1.15) rotate(3deg); 
        opacity: 0.4;
        filter: hue-rotate(315deg);
    }
    80% { 
        transform: translate(4px, -10px) scale(0.85) rotate(-4deg); 
        opacity: 1;
        filter: hue-rotate(360deg);
    }
    90% { 
        transform: translate(-6px, 6px) scale(1.08) rotate(2deg); 
        opacity: 0.7;
        filter: hue-rotate(45deg);
    }
    100% { 
        transform: translate(2px, -4px) scale(1) rotate(0deg); 
        opacity: 0.9;
        filter: hue-rotate(0deg);
    }
}

/* Enhanced glitch warning positioned within project card */
.glitch-warning {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: var(--accent-primary);
    color: white;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    text-align: center;
    z-index: 1000;
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    animation: dramaticGlitchWarning 1.2s ease-out;
    border: 3px solid var(--accent-tertiary);
    box-shadow: 
        0 0 30px var(--accent-primary),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    pointer-events: none;
    backdrop-filter: blur(4px);
    /* Ensure it stays within viewport bounds */
    max-width: 90vw;
    white-space: nowrap;
}

.glitch-warning .pixel-text {
    font-size: 1rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 
        2px 2px 0 var(--accent-secondary),
        -2px -2px 0 var(--accent-tertiary);
    white-space: nowrap;
}

@keyframes dramaticGlitchWarning {
    0% { 
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
        filter: hue-rotate(0deg);
    }
    10% { 
        transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
        opacity: 1;
        filter: hue-rotate(180deg) saturate(3);
    }
    15% { 
        transform: translate(-45%, -55%) scale(0.8) rotate(-3deg);
        filter: invert(1) hue-rotate(90deg);
    }
    20% { 
        transform: translate(-55%, -45%) scale(1.1) rotate(2deg);
        filter: sepia(1) saturate(5) hue-rotate(270deg);
    }
    25% { 
        transform: translate(-50%, -50%) scale(0.9) rotate(-1deg);
        filter: contrast(3) brightness(2);
    }
    30% { 
        transform: translate(-48%, -52%) scale(1.05) rotate(1deg);
        filter: hue-rotate(45deg) saturate(2);
    }
    70% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
        filter: none;
    }
    90% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0.8;
    }
    100% { 
        transform: translate(-50%, -50%) scale(0.95) rotate(0deg);
        opacity: 0;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .section-shake,
    .extreme-glitch {
        animation: none !important;
    }
    
    .featured-project.extreme-glitch::before,
    .featured-project.extreme-glitch::after {
        animation: none !important;
        opacity: 0.1 !important;
    }
    
    .glitch-warning {
        animation: none !important;
        transform: translate(-50%, -50%) !important;
    }
}

/* Make the featured project title larger and more prominent */
#featured .project-info #featured-project-title {
    font-size: clamp(1.7rem, 4vw, 2.5rem);
    color: var(--accent-primary);
    font-family: var(--font-pixel);
    margin-bottom: var(--spacing-xs);
    text-shadow: 2px 2px 0 var(--shadow-color);
    letter-spacing: 0.06em;
}

#featured .project-info .project-hook {
    font-size: clamp(1.1rem, 2.2vw, 1.3rem);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

#featured .project-info .project-link {
    display: inline-block;
    border-bottom: 2px solid var(--accent-primary);
    padding: 0 0.2em;
    margin-top: var(--spacing-xs);
    font-family: var(--font-pixel);
    font-size: 1rem;
    background: none;
    width: auto;
    transition: border-color 0.2s, color 0.2s;
    font-weight: 400;
}

#featured .project-info .project-link:hover,
#featured .project-info .project-link:focus {
    border-bottom-color: var(--accent-tertiary);
    color: var(--accent-tertiary);
    outline: none;
}

/* ===== RANDOM PROJECT CARD EFFECTS ===== */

/* Pixel Corruption Effect */
.pixel-corruption {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='2' height='2' x='0' y='0' fill='%23ff0000'/%3E%3Crect width='2' height='2' x='4' y='4' fill='%2300ff00'/%3E%3Crect width='2' height='2' x='8' y='8' fill='%230000ff'/%3E%3C/svg%3E");
    background-size: 10px 10px;
    opacity: 0.6;
    animation: pixelCorrupt 0.6s steps(8);
    pointer-events: none;
    z-index: 8;
    border-radius: var(--border-radius);
}

.project-card.corrupted {
    animation: cardCorruption 0.6s steps(8);
}

@keyframes pixelCorrupt {
    0% { opacity: 0; background-position: 0 0; }
    12.5% { opacity: 0.8; background-position: -2px 2px; }
    25% { opacity: 0.4; background-position: 2px -2px; }
    37.5% { opacity: 0.9; background-position: -1px -3px; }
    50% { opacity: 0.3; background-position: 3px 1px; }
    62.5% { opacity: 0.7; background-position: -3px 0px; }
    75% { opacity: 0.5; background-position: 1px 3px; }
    87.5% { opacity: 0.8; background-position: 0 -1px; }
    100% { opacity: 0; background-position: 0 0; }
}

@keyframes cardCorruption {
    0% { transform: translate(0); }
    12.5% { transform: translate(1px, 0); }
    25% { transform: translate(-1px, 1px); }
    37.5% { transform: translate(0, -1px); }
    50% { transform: translate(1px, 1px); }
    62.5% { transform: translate(-1px, 0); }
    75% { transform: translate(0, 1px); }
    87.5% { transform: translate(1px, -1px); }
    100% { transform: translate(0); }
}

/* Quick Glitch Effect */
.project-card.quick-glitch {
    animation: quickGlitch 0.3s ease-in-out;
}

@keyframes quickGlitch {
    0% { 
        transform: translate(0); 
        filter: none; 
    }
    20% { 
        transform: translate(2px, -1px) skew(1deg); 
        filter: hue-rotate(90deg) saturate(1.5); 
    }
    40% { 
        transform: translate(-1px, 2px) skew(-0.5deg); 
        filter: invert(0.1) hue-rotate(180deg); 
    }
    60% { 
        transform: translate(1px, 1px) skew(0.5deg); 
        filter: sepia(0.3) saturate(2); 
    }
    80% { 
        transform: translate(-2px, 0) skew(-1deg); 
        filter: contrast(1.2) brightness(1.1); 
    }
    100% { 
        transform: translate(0); 
        filter: none; 
    }
}

/* Chroma Bleed Effect (CRT-style) */
.project-card.chroma-bleed {
    animation: chromaBleed 1.5s ease-in-out;
}

@keyframes chromaBleed {
    0% { 
        text-shadow: none; 
        box-shadow: 0 4px 12px var(--shadow-color); 
    }
    25% { 
        text-shadow: 
            2px 0 0 rgba(255, 0, 0, 0.5),
            -2px 0 0 rgba(0, 255, 255, 0.5);
        box-shadow: 
            2px 0 0 rgba(255, 0, 0, 0.3),
            -2px 0 0 rgba(0, 255, 255, 0.3),
            0 4px 12px var(--shadow-color);
    }
    50% { 
        text-shadow: 
            3px 0 0 rgba(255, 0, 0, 0.7),
            -3px 0 0 rgba(0, 255, 255, 0.7);
        box-shadow: 
            3px 0 0 rgba(255, 0, 0, 0.4),
            -3px 0 0 rgba(0, 255, 255, 0.4),
            0 4px 12px var(--shadow-color);
    }
    75% { 
        text-shadow: 
            1px 0 0 rgba(255, 0, 0, 0.3),
            -1px 0 0 rgba(0, 255, 255, 0.3);
        box-shadow: 
            1px 0 0 rgba(255, 0, 0, 0.2),
            -1px 0 0 rgba(0, 255, 255, 0.2),
            0 4px 12px var(--shadow-color);
    }
    100% { 
        text-shadow: none; 
        box-shadow: 0 4px 12px var(--shadow-color); 
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .pixel-corruption,
    .project-card.corrupted,
    .project-card.quick-glitch,
    .project-card.chroma-bleed {
        animation: none !important;
        transform: none !important;
        filter: none !important;
        text-shadow: none !important;
        box-shadow: 0 4px 12px var(--shadow-color) !important;
    }
    
    .pixel-corruption {
        display: none !important;
    }
}

/* ===== CONSOLE HERO ===== */
.console-hero {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #1a1c1c;  /* --dark-bg-primary */
    padding: var(--spacing-lg);
    overflow: hidden;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.3),  /* --dark-shadow-color */
        inset 0 0 20px rgba(0, 0, 0, 0.2);
    z-index: 2;
    will-change: transform, filter;
}

.console-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.4;
    color: #c4bebb;  /* --dark-text-primary */
}

/* Boot sequence styles */
.boot-sequence {
    display: block;
    height: 100%;
    overflow: hidden;
    user-select: none;
    pointer-events: none;
    padding-bottom: 1.5rem;
}

.boot-line {
    opacity: 0;
    animation: fadeInLine 0.5s ease forwards;
    margin-bottom: 0.2rem;
}

.boot-line.system { color: #a4f09d; }      /* --dark-accent-tertiary */
.boot-line.loading { color: #a4a0a0; }     /* --dark-text-secondary */
.boot-line.success { color: #a4f09d; }     /* --dark-accent-tertiary */
.boot-line.warning { color: #ffaa00; }     /* dark mode --warning-color */
.boot-line.error { color: #ff4444; }       /* dark mode --error-color */

/* Ready state styles */
.ready-state {
    display: none;
    height: 100%;
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.ready-content {
    width: 100%;
}

.console-title {
    font-family: var(--font-pixel);
    font-size: clamp(2rem, 5vw, 3rem);
    color: var(--accent-primary);
    margin-bottom: var(--spacing-md);
    text-shadow: 2px 2px 0 var(--shadow-color);
    letter-spacing: 0.1em;
}

.console-tagline {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-style: italic;
    text-align: center;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* ASCII Art Display */
.ascii-display {
    display: none;
    height: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.ascii-art {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.2;
    color: #a4f09d;  /* --dark-accent-tertiary */
    white-space: pre;
    animation: asciiGlow 2s ease-in-out infinite alternate;
}

.ascii-label {
    margin-top: var(--spacing-md);
    font-size: 0.7rem;
    color: #a4a0a0;  /* --dark-text-secondary */
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ASCII Progress */
.ascii-progress {
    font-family: var(--font-mono, monospace);
    color: #a4f09d;  /* --dark-accent-tertiary */
    margin-left: 8px;
    letter-spacing: 1px;
}

/* Console Hero Animations */
@keyframes fadeInLine {
    to { opacity: 1; }
}

@keyframes asciiGlow {
    0% { opacity: 0.8; }
    100% { opacity: 1; text-shadow: 0 0 5px currentColor; }
}

.console-hero.glitch-burst {
    animation: consoleGlitch 0.3s ease-out;
}

@keyframes consoleGlitch {
    0% { transform: translate(0); filter: none; }
    10% { transform: translate(2px, -1px); filter: hue-rotate(90deg); }
    20% { transform: translate(-1px, 2px); filter: invert(0.1); }
    30% { transform: translate(1px, 1px); filter: sepia(0.3); }
    40% { transform: translate(-2px, 0); filter: contrast(1.2); }
    100% { transform: translate(0); filter: none; }
}

/* ===== CRT POWER-ON EFFECTS ===== */
.crt-power-on {
    position: relative;
    overflow: hidden;
}

.crt-power-on::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--accent-tertiary) 50%, 
        transparent 100%);
    animation: crtScanOpen 0.8s ease-out forwards;
    z-index: 10;
    pointer-events: none;
}

@keyframes crtScanOpen {
    0% {
        height: 2px;
        opacity: 1;
        box-shadow: 0 0 20px var(--accent-tertiary);
    }
    100% {
        height: 100vh;
        opacity: 0;
        box-shadow: 0 0 40px var(--accent-tertiary);
    }
}

/* CRT Flicker Effect */
.crt-flicker {
    animation: crtFlicker 0.4s ease-in-out;
}

@keyframes crtFlicker {
    0%, 100% { 
        filter: brightness(1) contrast(1); 
        opacity: 1; 
    }
    20% { 
        filter: brightness(1.2) contrast(1.5); 
        opacity: 0.9; 
    }
    40% { 
        filter: brightness(0.8) contrast(0.8); 
        opacity: 1.1; 
    }
    60% { 
        filter: brightness(1.1) contrast(1.2); 
        opacity: 0.95; 
    }
    80% { 
        filter: brightness(0.9) contrast(1.1); 
        opacity: 1.05; 
    }
}

/* ===== INITIALIZING OVERLAY ===== */
.init-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.4s ease;
    overflow: hidden;
}

.init-text {
    font-family: var(--font-pixel);
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--accent-tertiary);
    text-align: center;
    letter-spacing: 0.1em;
    animation: initTextPulse 1.5s ease-in-out infinite alternate;
    margin-bottom: var(--spacing-md);
    text-shadow: 0 0 10px currentColor;
}

@keyframes initTextPulse {
    0% { 
        opacity: 0.7; 
        transform: scale(1);
        text-shadow: 0 0 5px currentColor;
    }
    100% { 
        opacity: 1; 
        transform: scale(1.02);
        text-shadow: 0 0 15px currentColor;
    }
}

/* Initializing scanlines effect */
.init-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        0deg,
        var(--accent-tertiary) 0px,
        var(--accent-tertiary) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.1;
    animation: initScanlines 2s linear infinite;
    pointer-events: none;
}

@keyframes initScanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(6px); }
}

/* ===== TITLE MATERIALIZATION EFFECT ===== */
.title-materialize {
    animation: titleMaterialize 0.8s ease-out;
}

@keyframes titleMaterialize {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
        filter: blur(8px) brightness(1.2);
        text-shadow: 
            0 0 15px var(--accent-primary),
            0 0 30px var(--accent-primary);
    }
    30% {
        opacity: 0.6;
        transform: scale(1.1) translateY(-5px);
        filter: blur(4px) brightness(1.1);
        text-shadow: 
            0 0 12px var(--accent-primary),
            0 0 25px var(--accent-primary);
    }
    60% {
        opacity: 0.9;
        transform: scale(0.95) translateY(2px);
        filter: blur(1px) brightness(1.05);
        text-shadow: 
            0 0 8px var(--accent-primary),
            2px 2px 0 var(--shadow-color);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0) brightness(1);
        text-shadow: 2px 2px 0 var(--shadow-color);
    }
}

/* Add specific light theme adjustments */
[data-theme="light"] .title-materialize {
    animation: titleMaterializeLight 0.8s ease-out;
}

@keyframes titleMaterializeLight {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
        filter: blur(8px) brightness(1.1);
        text-shadow: 
            0 0 12px var(--accent-primary),
            0 0 25px var(--accent-primary);
    }
    30% {
        opacity: 0.6;
        transform: scale(1.1) translateY(-5px);
        filter: blur(4px) brightness(1.05);
        text-shadow: 
            0 0 10px var(--accent-primary),
            0 0 20px var(--accent-primary);
    }
    60% {
        opacity: 0.9;
        transform: scale(0.95) translateY(2px);
        filter: blur(1px) brightness(1.02);
        text-shadow: 
            0 0 6px var(--accent-primary),
            2px 2px 0 var(--shadow-color);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0) brightness(1);
        text-shadow: 2px 2px 0 var(--shadow-color);
    }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .init-text {
        font-size: clamp(1rem, 4vw, 1.4rem);
        margin-bottom: var(--spacing-sm);
    }
    
    .crt-power-on::before {
        height: 1px;
    }
    
    @keyframes crtScanOpen {
        0% {
            height: 1px;
            opacity: 1;
        }
        100% {
            height: 50vh;
            opacity: 0;
        }
    }
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
    .crt-power-on::before,
    .crt-flicker,
    .init-text,
    .init-scanlines,
    .title-materialize {
        animation: none !important;
        transition: opacity 0.3s ease !important;
    }
    
    .crt-power-on::before {
        display: none;
    }
    
    .init-text {
        opacity: 1;
        transform: none;
    }
    
    .title-materialize {
        filter: none !important;
        transform: none !important;
        text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3) !important;
    }
}

/* ===== CRT BOOTUP GLITCH EFFECT ===== */
.crt-bootup {
    animation: crtBootup 0.9s ease-out;
    position: relative;
    overflow: hidden;
    height: 100% !important; /* Force height containment */
    min-height: 100% !important;
    max-height: 100% !important;
}

@keyframes crtBootup {
    0% { 
        filter: brightness(1) contrast(1); 
        transform: scaleY(1);
    }
    15% { 
        filter: brightness(0.1) contrast(8) saturate(0);
        transform: scaleY(0.01);
    }
    25% { 
        filter: brightness(3) contrast(2) hue-rotate(180deg);
        transform: scaleY(0.8);
    }
    40% { 
        filter: brightness(0.3) contrast(5) invert(1);
        transform: scaleY(1.1) scaleX(0.98);
    }
    55% { 
        filter: brightness(2) contrast(3) sepia(1) saturate(3);
        transform: scaleY(0.95) scaleX(1.02);
    }
    70% { 
        filter: brightness(0.8) contrast(6) hue-rotate(90deg);
        transform: scaleY(1.05) scaleX(0.99);
    }
    85% { 
        filter: brightness(1.5) contrast(2) invert(0.3);
        transform: scaleY(0.98) scaleX(1.01);
    }
    100% { 
        filter: brightness(1) contrast(1);
        transform: scaleY(1) scaleX(1);
    }
}

/* Add scan line effect during bootup */
.crt-bootup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        rgba(255, 255, 255, 0.1) 1px,
        transparent 2px,
        transparent 4px
    );
    animation: bootupScanlines 0.9s ease-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes bootupScanlines {
    0% { 
        opacity: 0;
        transform: scaleY(0.1);
    }
    30% { 
        opacity: 0.8;
        transform: scaleY(2) translateY(-10px);
    }
    60% { 
        opacity: 0.4;
        transform: scaleY(0.5) translateY(5px);
    }
    80% { 
        opacity: 0.2;
        transform: scaleY(1) translateY(0);
    }
    100% { 
        opacity: 0;
        transform: scaleY(1) translateY(0);
    }
}

/* Ensure the hero container maintains its dimensions during transition */
.console-hero {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #1a1c1c;  /* --dark-bg-primary */
    padding: var(--spacing-lg);
    overflow: hidden;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.3),  /* --dark-shadow-color */
        inset 0 0 20px rgba(0, 0, 0, 0.2);
    z-index: 2;
    will-change: transform, filter;
}

/* Ensure ready state maintains dimensions */
.ready-state {
    display: none;
    height: 100%;
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Title card background for console hero */
.console-title-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.5s cubic-bezier(.4,0,.2,1);
}
.console-hero .ready-state ~ .console-title-bg,
.console-hero .console-title-bg {
    /* Ensure .console-title-bg is always present, but only visible when .ready-state is active */
}
.console-hero.ready-bg-visible .console-title-bg {
    opacity: 1;
}
.console-hero:not(.ready-bg-visible) .console-title-bg {
    opacity: 0;
}

/* Title card background for console hero (now inside .ready-state) */
.ready-state .console-title-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.5s cubic-bezier(.4,0,.2,1);
}
.ready-state[style*="display: flex"] .console-title-bg {
    opacity: 1;
}

.ready-state .ready-content {
    position: relative;
    z-index: 1;
}

.ready-state .console-title {
    text-shadow:
        2px 2px 0 #000,
        -2px 2px 0 #000,
        2px -2px 0 #000,
        -2px -2px 0 #000;
    padding: 0.25em 0.75em;
    border-radius: 4px;
}

.ready-state .console-tagline {
    display: block;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.45);
    padding: 0.25em 0.75em;
    border-radius: 4px;
}

/* ===== RETRO OS WINDOW ===== */
.os-window {
    display: none;
    height: 100%;
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--spacing-lg);
}

.window-chrome {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    border-radius: 0;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.3),
        inset 1px 1px 0 #ffffff,
        inset -1px -1px 0 #808080;
    max-width: 600px;
    width: 100%;
    max-height: 500px;
    height: auto;
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
    font-size: 11px;
    position: relative;
    z-index: 2;
}

/* Title Bar */
.title-bar {
    background: linear-gradient(90deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    color: white;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 11px;
    border-bottom: 1px solid #808080;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.window-controls {
    display: flex;
    gap: 2px;
    margin-right: 8px;
}

.window-btn {
    width: 16px;
    height: 14px;
    border: 1px outset #c0c0c0;
    background: #c0c0c0;
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: var(--font-mono);
    font-weight: bold;
}

.window-btn:hover {
    background: #d4d0c8;
}

.window-btn:active {
    border: 1px inset #c0c0c0;
}

.close-btn::after { content: '×'; color: #000; }
.minimize-btn::after { content: '_'; color: #000; }
.maximize-btn::after { content: '□'; color: #000; }

.window-title {
    flex: 1;
    text-align: center;
    font-family: var(--font-pixel);
    letter-spacing: 1px;
}

/* Menu Bar */
.menu-bar {
    background: #c0c0c0;
    border-bottom: 1px solid #808080;
    padding: 2px 8px;
    display: flex;
    gap: 16px;
    font-size: 11px;
    position: relative; /* For dropdown positioning */
    user-select: none;
}

.menu-item {
    padding: 2px 8px;
    cursor: pointer;
    user-select: none;
    position: relative;
    color: var(--text-primary); /* Use theme-aware text color */
}

.menu-item:hover,
.menu-item.active {
    background: var(--accent-secondary);
    color: white;
}

/* Dropdown Menu Styles */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    min-width: 200px;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.3),
        inset 1px 1px 0 #ffffff,
        inset -1px -1px 0 #808080;
    z-index: 1000;
    display: none;
    font-size: 11px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 4px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    color: var(--text-primary); /* Use theme-aware text color */
}

.dropdown-item:hover:not(.disabled) {
    background: var(--accent-secondary);
    color: white;
}

.dropdown-item.disabled {
    color: #808080;
    cursor: default;
}

.dropdown-item.has-submenu::after {
    content: '▶';
    font-size: 8px;
    margin-left: auto;
}

.dropdown-separator {
    height: 1px;
    background: #808080;
    margin: 2px 0;
}

/* Submenu Styles */
.dropdown-submenu {
    position: absolute;
    top: -2px;
    left: 100%;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    min-width: 180px;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.3),
        inset 1px 1px 0 #ffffff,
        inset -1px -1px 0 #808080;
    display: none;
}

.dropdown-item:hover .dropdown-submenu,
.dropdown-item.active .dropdown-submenu {
    display: block;
}

/* Minimized State */
.window-chrome.minimized {
    position: fixed !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 250px;
    height: auto;
    animation: minimizeWindow 0.1s steps(3) forwards;
    transform-origin: bottom center;
    z-index: 100;
}

.window-chrome.minimized .menu-bar,
.window-chrome.minimized .window-content,
.window-chrome.minimized .status-bar {
    display: none;
}

.window-chrome.minimized .title-bar {
    cursor: pointer;
}

@keyframes minimizeWindow {
    0% { 
        transform: translateX(-50%) scale(1, 1);
        opacity: 1;
    }
    33% { 
        transform: translateX(-50%) scale(0.7, 0.5);
        opacity: 0.9;
    }
    66% { 
        transform: translateX(-50%) scale(0.5, 0.2);
        opacity: 0.8;
    }
    100% { 
        transform: translateX(-50%) scale(1, 1);
        opacity: 1;
    }
}

@keyframes restoreWindow {
    0% {
        transform: translate(-50%, 0) scale(0.3);
        opacity: 0.3;
    }
    33% {
        transform: translate(-50%, -33%) scale(0.6);
        opacity: 0.6;
    }
    66% {
        transform: translate(-50%, -66%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }
}

.window-chrome.restoring {
    animation: restoreWindow 0.1s steps(3) forwards;
}

/* Dark theme adjustments */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .dropdown-submenu {
    background: #404040;
    border-color: #404040;
    color: #fff;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        inset 1px 1px 0 #606060,
        inset -1px -1px 0 #202020;
}

[data-theme="dark"] .dropdown-item:hover:not(.disabled) {
    background: var(--dark-accent-secondary);
    color: var(--dark-bg-primary);
}

[data-theme="dark"] .dropdown-item.disabled {
    color: #606060;
}

[data-theme="dark"] .dropdown-separator {
    background: #202020;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dropdown-menu,
    .dropdown-submenu {
        min-width: 160px;
        font-size: 10px;
    }
    
    .dropdown-item {
        padding: 3px 15px;
    }
}

/* Window Content */
.window-content {
    flex: 1;
    background: #c0c0c0;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px inset #c0c0c0;
    margin: 2px;
}

.os-window .console-title {
    color: var(--accent-primary);
    margin-bottom: var(--spacing-sm);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

.os-window .console-tagline {
    color: #000;
    margin-bottom: var(--spacing-md);
    font-style: italic;
}

.os-window .console-button {
    background: var(--accent-secondary);
    border: 2px outset var(--accent-secondary);
    color: white;
    padding: 4px 16px;
    text-decoration: none;
    font-family: var(--font-pixel);
    font-size: 11px;
    cursor: pointer;
    box-shadow: none;
}

.os-window .console-button:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.os-window .console-button:active {
    border: 2px inset var(--accent-secondary);
}

/* Status Bar */
.status-bar {
    background: #c0c0c0;
    border-top: 1px solid #808080;
    padding: 2px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #000;
    border: 1px inset #c0c0c0;
    margin: 2px;
    margin-top: 0;
}

.status-text {
    font-weight: bold;
}

.status-info {
    font-style: italic;
}

/* Dark Theme Adjustments */
[data-theme="dark"] .window-chrome {
    background: #404040;
    border-color: #404040;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        inset 1px 1px 0 #606060,
        inset -1px -1px 0 #202020;
}

[data-theme="dark"] .window-btn {
    background: #404040;
    border-color: #404040;
    color: #fff;
}

[data-theme="dark"] .window-btn::after {
    color: #fff;
}

[data-theme="dark"] .menu-bar,
[data-theme="dark"] .window-content,
[data-theme="dark"] .status-bar {
    background: #404040;
    color: #fff;
    border-color: #202020;
}

[data-theme="dark"] .os-window .console-tagline,
[data-theme="dark"] .os-window .console-button,
[data-theme="dark"] .status-text,
[data-theme="dark"] .status-info {
    color: #fff;
}

[data-theme="dark"] .os-window .console-button,
[data-theme="dark"] .os-window .console-button:hover {
    background: var(--dark-accent-primary);
    border-color: var(--dark-accent-primary);
    color: var(--dark-bg-primary);
}

[data-theme="dark"] .os-window .console-button:active {
    border: 2px inset var(--dark-accent-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .window-chrome {
        max-width: 90%;
        margin: var(--spacing-sm);
    }
    
    .menu-bar {
        gap: 8px;
        font-size: 10px;
    }
    
    .menu-item {
        padding: 2px 4px;
    }
    
    .window-title {
        font-size: 10px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .window-chrome {
        box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }
}

/* Ensure box-sizing for all relevant elements */
.os-window,
.window-chrome,
.window-content,
.console-title {
  box-sizing: border-box;
}

/* Responsive fixes for faux app window heading on mobile */
@media (max-width: 600px) {
  .os-window .window-content {
    padding: 1.2rem 0.5rem;
  }
  .os-window .console-title {
    font-size: clamp(1.2rem, 7vw, 2.2rem);
    padding: 0.2em 0.1em;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    flex-shrink: 1;
  }
  .boot-sequence .boot-line {
    font-size: clamp(12px, 3vw, 1rem);
    line-height: 1.3;
    padding: 0.1em 0;
  }
}

/* Fix submenu item alignment */
.dropdown-submenu .dropdown-item {
    text-align: left;
    justify-content: flex-start;
}

/* Console reset animation */
@keyframes consoleReset {
    0% {
        opacity: 1;
        filter: brightness(1) contrast(1);
    }
    15% {
        opacity: 0.8;
        filter: brightness(2) contrast(0.5) blur(2px);
        transform: scale(1.02);
    }
    30% {
        opacity: 0.3;
        filter: brightness(0.5) contrast(2) blur(4px);
        transform: scale(0.98);
    }
    45% {
        opacity: 0;
        filter: brightness(0) contrast(1) blur(8px);
        transform: scale(0.95);
    }
    55% {
        opacity: 0;
        filter: brightness(0) contrast(1) blur(8px);
        transform: scale(0.95);
    }
    70% {
        opacity: 0.3;
        filter: brightness(0.5) contrast(2) blur(4px);
        transform: scale(0.98);
    }
    85% {
        opacity: 0.8;
        filter: brightness(2) contrast(0.5) blur(2px);
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        filter: brightness(1) contrast(1);
        transform: scale(1);
    }
}

.console-hero.resetting {
    animation: consoleReset 1.2s ease-in-out;
}

/* Desktop wallpaper change animation */
@keyframes wallpaperChange {
    0% {
        opacity: 1;
        filter: brightness(1);
    }
    25% {
        opacity: 0.8;
        filter: brightness(1.5) saturate(0.5);
    }
    50% {
        opacity: 0;
        filter: brightness(2) saturate(0);
    }
    75% {
        opacity: 0.8;
        filter: brightness(1.5) saturate(0.5);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
    }
}

.console-title-bg.changing {
    animation: wallpaperChange 0.8s ease-in-out;
}

/* Current wallpaper indicator */
.dropdown-item.current-wallpaper {
    position: relative;
    padding-left: 30px;
}

.dropdown-item.current-wallpaper::before {
    content: '✓';
    position: absolute;
    left: 10px;
    font-weight: bold;
}

/* ===== FIXED OS WINDOW ANIMATIONS ===== */

/* Keep window chrome centered when not minimized */
.window-chrome:not(.minimized) {
    position: relative;
    transform: none;
    animation: none;
}

/* Faster, choppier minimize animation */
@keyframes minimizeWindow {
    0% { 
        transform: translateX(-50%) scale(1, 1);
        opacity: 1;
    }
    33% { 
        transform: translateX(-50%) scale(0.7, 0.5);
        opacity: 0.9;
    }
    66% { 
        transform: translateX(-50%) scale(0.5, 0.2);
        opacity: 0.8;
    }
    100% { 
        transform: translateX(-50%) scale(1, 1);
        opacity: 1;
    }
}

/* Faster, choppier restore animation from bottom center */
@keyframes restoreWindow {
    0% {
        transform: translate(-50%, 0) scale(0.3);
        opacity: 0.3;
    }
    33% {
        transform: translate(-50%, -33%) scale(0.6);
        opacity: 0.6;
    }
    66% {
        transform: translate(-50%, -66%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }
}

/* Apply restore animation to the ready state container */
.os-window.restoring {
    animation: restoreWindow 0.1s steps(3) forwards;
}

/* Maximize state */
.window-chrome.maximized {
    transform: scale(1.15) !important;
    transition: transform 0.1s steps(3);
}

/* Disable maximize button visual feedback when already maximized */
.window-chrome.maximized .maximize-btn {
    opacity: 0.6;
    cursor: default;
}

/* Ensure the window controls are always clickable */
.window-chrome.minimized .window-controls {
    pointer-events: auto;
}

/* Responsive maximized state */
@media (max-width: 768px) {
    .window-chrome.maximized {
        transform: scale(1.05) !important;
    }
}

/* ===== CRT POWER OFF ANIMATION ===== */
.crt-poweroff {
    animation: crtPowerOff 0.6s ease-in forwards;
    position: relative;
    overflow: hidden;
    height: 100% !important; /* Force height containment */
    min-height: 100% !important;
    max-height: 100% !important;
    transform-origin: center center; /* Center the transform origin */
}

@keyframes crtPowerOff {
    0% { 
        filter: brightness(1) contrast(1); 
        transform: scale(1);
        opacity: 1;
    }
    10% { 
        filter: brightness(1.5) contrast(2) saturate(0);
        transform: scale(1.02);
    }
    20% { 
        filter: brightness(2) contrast(4) saturate(0);
        transform: scale(1) scaleY(0.98);
    }
    40% { 
        filter: brightness(1.2) contrast(8) saturate(0);
        transform: scaleY(0.3) scaleX(1.1);
        opacity: 1;
    }
    60% { 
        filter: brightness(0.8) contrast(10) saturate(0);
        transform: scaleY(0.1) scaleX(1.2);
        opacity: 0.8;
    }
    80% { 
        filter: brightness(0.4) contrast(15) saturate(0);
        transform: scaleY(0.02) scaleX(0.8);
        opacity: 0.4;
    }
    90% {
        filter: brightness(0.1) contrast(20) saturate(0);
        transform: scaleY(0.001) scaleX(0.5);
        opacity: 0.2;
    }
    100% { 
        filter: brightness(0) contrast(20) saturate(0);
        transform: scaleY(0) scaleX(0);
        opacity: 0;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .crt-poweroff {
        transform-origin: center center;
        will-change: transform, opacity, filter;
    }
    
    @keyframes crtPowerOff {
        0% { 
            filter: brightness(1) contrast(1); 
            transform: scale(1);
            opacity: 1;
        }
        10% { 
            filter: brightness(1.5) contrast(2) saturate(0);
            transform: scale(1.01);
        }
        20% { 
            filter: brightness(2) contrast(4) saturate(0);
            transform: scale(1) scaleY(0.98);
        }
        40% { 
            filter: brightness(1.2) contrast(8) saturate(0);
            transform: scaleY(0.3) scaleX(1.05);
            opacity: 1;
        }
        60% { 
            filter: brightness(0.8) contrast(10) saturate(0);
            transform: scaleY(0.1) scaleX(1.1);
            opacity: 0.8;
        }
        80% { 
            filter: brightness(0.4) contrast(15) saturate(0);
            transform: scaleY(0.02) scaleX(0.9);
            opacity: 0.4;
        }
        90% {
            filter: brightness(0.1) contrast(20) saturate(0);
            transform: scaleY(0.001) scaleX(0.5);
            opacity: 0.2;
        }
        100% { 
            filter: brightness(0) contrast(20) saturate(0);
            transform: scaleY(0) scaleX(0);
            opacity: 0;
        }
    }
}

/* Power off scan line effect */
.crt-poweroff::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(0deg,
        transparent 48%,
        rgba(255, 255, 255, 0.8) 49%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 255, 255, 0.8) 51%,
        transparent 52%
    );
    animation: powerOffScanline 0.6s ease-in forwards;
    pointer-events: none;
    z-index: 100;
    transform: translateY(-50%);
}

@keyframes powerOffScanline {
    0% { 
        height: 100%;
        opacity: 0;
    }
    10% {
        height: 100%;
        opacity: 0.3;
    }
    40% { 
        height: 60%;
        opacity: 0.6;
    }
    60% { 
        height: 20%;
        opacity: 0.8;
    }
    80% { 
        height: 4%;
        opacity: 1;
    }
    90% {
        height: 2px;
        opacity: 1;
        box-shadow: 0 0 20px rgba(255, 255, 255, 1);
    }
    100% { 
        height: 0;
        opacity: 0;
    }
}

/* Static burst during power off */
.crt-poweroff::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3' numOctaves='10' stitchTiles='stitch'/%3E%3CcolorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0;
    mix-blend-mode: screen;
    animation: powerOffStatic 0.6s ease-in;
    pointer-events: none;
    z-index: 99;
}

@keyframes powerOffStatic {
    0%, 10% { opacity: 0; }
    15% { opacity: 0.8; transform: scale(1.05); }
    20% { opacity: 0.4; transform: scale(0.98); }
    30% { opacity: 0.9; transform: scale(1.02); }
    50% { opacity: 0.3; }
    100% { opacity: 0; }
}

/* ===== EXTREME BACKGROUND CHANGE GLITCH ===== */
.console-title-bg.extreme-change {
    animation: extremeBgChange 1.2s ease-in-out;
}

@keyframes extremeBgChange {
    0% {
        opacity: 1;
        filter: none;
        transform: scale(1) rotate(0deg);
    }
    5% {
        opacity: 0.3;
        filter: hue-rotate(180deg) saturate(5) contrast(3) brightness(2);
        transform: scale(1.1) rotate(2deg) translateX(10px);
    }
    10% {
        opacity: 0.8;
        filter: invert(1) sepia(1) saturate(10) hue-rotate(90deg);
        transform: scale(0.9) rotate(-3deg) translateY(-15px);
    }
    15% {
        opacity: 0.2;
        filter: contrast(10) brightness(0.2) saturate(0);
        transform: scale(1.2) rotate(1deg) translate(-20px, 10px);
    }
    20% {
        opacity: 0.9;
        filter: hue-rotate(270deg) saturate(8) invert(0.5) blur(2px);
        transform: scale(0.8) rotate(-2deg) translateX(15px);
    }
    25% {
        opacity: 0.1;
        filter: brightness(3) contrast(0.5) blur(5px);
        transform: scale(1.15) rotate(4deg) translate(10px, -20px);
    }
    30% {
        opacity: 0.6;
        filter: sepia(1) saturate(15) hue-rotate(45deg) brightness(2);
        transform: scale(0.95) rotate(-1deg) translateY(12px);
    }
    35% {
        opacity: 0;
        filter: invert(1) contrast(20) blur(8px);
        transform: scale(1.3) rotate(3deg);
    }
    /* Glitch frames with corrupted image */
    40%, 42%, 44% {
        opacity: 1;
        filter: contrast(30) saturate(0) brightness(2);
        transform: scale(1) skewX(20deg);
        background-size: 50% 100%;
        background-position: -50% 0;
    }
    41%, 43%, 45% {
        opacity: 0;
        filter: invert(1);
        transform: scale(1) skewX(-20deg);
        background-size: 150% 50%;
        background-position: 100% 100%;
    }
    50% {
        opacity: 0;
        filter: brightness(0);
        transform: scale(1) rotate(0deg);
        background-size: cover;
        background-position: center;
    }
    /* New image materializing with corruption */
    55% {
        opacity: 0.2;
        filter: contrast(20) brightness(0.1) saturate(0) blur(10px);
        transform: scale(0.7) rotate(-5deg);
    }
    60% {
        opacity: 0.8;
        filter: hue-rotate(180deg) saturate(10) contrast(5) blur(3px);
        transform: scale(1.1) rotate(2deg) translateX(-10px);
    }
    65% {
        opacity: 0.4;
        filter: invert(0.8) sepia(1) saturate(5) brightness(1.5);
        transform: scale(0.9) rotate(-1deg) translateY(8px);
    }
    70% {
        opacity: 1;
        filter: contrast(8) brightness(2) saturate(0.5) blur(1px);
        transform: scale(1.05) rotate(1deg) translate(5px, -5px);
    }
    75% {
        opacity: 0.7;
        filter: hue-rotate(90deg) saturate(3) invert(0.2);
        transform: scale(0.98) rotate(-0.5deg);
    }
    80% {
        opacity: 0.9;
        filter: brightness(1.5) contrast(2) saturate(1.2);
        transform: scale(1.02) rotate(0.5deg);
    }
    85%, 87%, 89% {
        opacity: 1;
        filter: contrast(1.5) brightness(1.1);
        transform: scale(1) translateX(2px);
    }
    86%, 88% {
        opacity: 0.8;
        filter: invert(0.1);
        transform: scale(1) translateX(-2px);
    }
    90% {
        opacity: 0.95;
        filter: brightness(1.2) contrast(1.2);
        transform: scale(1.01);
    }
    95% {
        opacity: 0.98;
        filter: brightness(1.05) contrast(1.05);
        transform: scale(1.005);
    }
    100% {
        opacity: 1;
        filter: none;
        transform: scale(1) rotate(0deg);
        background-size: cover;
        background-position: center;
    }
}

/* Scanline corruption during background change */
.console-title-bg.extreme-change::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(255, 0, 255, 0.6) 2px,
        rgba(255, 0, 255, 0.6) 4px,
        transparent 4px,
        transparent 6px,
        rgba(0, 255, 255, 0.6) 6px,
        rgba(0, 255, 255, 0.6) 8px
    );
    animation: bgChangeScanlines 1.2s ease-in-out;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: difference;
}

@keyframes bgChangeScanlines {
    0%, 100% { opacity: 0; transform: scaleY(1); }
    10%, 90% { opacity: 0.8; transform: scaleY(2) translateY(-25%); }
    20%, 80% { opacity: 0.4; transform: scaleY(0.5) translateY(50%); }
    30%, 70% { opacity: 0.9; transform: scaleY(3) translateY(0) skewY(5deg); }
    40%, 60% { opacity: 0.6; transform: scaleY(1) translateY(-100%) skewY(-5deg); }
    50% { opacity: 1; transform: scaleY(5) translateY(0) skewY(0); }
}

/* Data corruption effect */
.console-title-bg.extreme-change::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(90deg, 
            transparent 0, 
            rgba(255,0,0,0.5) 20px, 
            transparent 40px),
        repeating-linear-gradient(0deg, 
            transparent 0, 
            rgba(0,255,0,0.5) 20px, 
            transparent 40px),
        repeating-linear-gradient(45deg, 
            transparent 0, 
            rgba(0,0,255,0.5) 20px, 
            transparent 40px);
    animation: dataCorruption 1.2s ease-in-out;
    pointer-events: none;
    z-index: 2;
    mix-blend-mode: multiply;
}

@keyframes dataCorruption {
    0%, 100% { opacity: 0; }
    15%, 25%, 35%, 45%, 55%, 65%, 75%, 85% { 
        opacity: 0.8; 
        background-size: 80px 80px, 60px 60px, 40px 40px;
    }
    20%, 30%, 40%, 50%, 60%, 70%, 80% { 
        opacity: 0; 
        background-size: 20px 20px, 30px 30px, 50px 50px;
    }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .crt-poweroff {
        animation: simplePowerOff 0.3s ease-in forwards;
    }
    
    @keyframes simplePowerOff {
        to { opacity: 0; transform: scale(0.9); }
    }
    
    .crt-poweroff::before,
    .crt-poweroff::after,
    .console-title-bg.extreme-change::before,
    .console-title-bg.extreme-change::after {
        display: none;
    }
    
    .console-title-bg.extreme-change {
        animation: simpleBgChange 0.5s ease-in-out;
    }
    
    @keyframes simpleBgChange {
        0%, 100% { opacity: 1; }
        50% { opacity: 0; }
    }
}