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

/* ========================================
   8-BIT ANIMATED BACKGROUND
   ======================================== */
@keyframes pixelFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(5deg); }
    50% { transform: translateY(-10px) rotate(-3deg); }
    75% { transform: translateY(-25px) rotate(2deg); }
}

@keyframes pixelPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

.pixel-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Animated gradient base layer */
.pixel-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        #ff6b9d 0%,
        #c44dff 15%,
        #6b5bff 30%,
        #00d4aa 45%,
        #7fff6b 60%,
        #ffeb3b 75%,
        #ff6b9d 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    opacity: 0.15;
}

/* Pixel grid overlay */
.pixel-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 8px 8px;
    pointer-events: none;
}

/* Floating pixel blocks */
.pixel-block {
    position: absolute;
    background: linear-gradient(135deg, var(--pixel-color-1) 50%, var(--pixel-color-2) 50%);
    animation: pixelFloat 6s ease-in-out infinite;
    box-shadow:
        4px 4px 0 var(--pixel-shadow),
        inset -2px -2px 0 rgba(0,0,0,0.2),
        inset 2px 2px 0 rgba(255,255,255,0.2);
}

.pixel-block:nth-child(1) {
    width: 24px;
    height: 24px;
    top: 10%;
    left: 5%;
    animation-delay: 0s;
    animation-duration: 7s;
}

.pixel-block:nth-child(2) {
    width: 16px;
    height: 16px;
    top: 20%;
    right: 10%;
    animation-delay: 1s;
    animation-duration: 5s;
}

.pixel-block:nth-child(3) {
    width: 32px;
    height: 32px;
    bottom: 25%;
    left: 8%;
    animation-delay: 2s;
    animation-duration: 8s;
}

.pixel-block:nth-child(4) {
    width: 20px;
    height: 20px;
    bottom: 15%;
    right: 15%;
    animation-delay: 0.5s;
    animation-duration: 6s;
}

.pixel-block:nth-child(5) {
    width: 12px;
    height: 12px;
    top: 50%;
    left: 3%;
    animation-delay: 3s;
    animation-duration: 9s;
}

.pixel-block:nth-child(6) {
    width: 28px;
    height: 28px;
    top: 70%;
    right: 5%;
    animation-delay: 1.5s;
    animation-duration: 7s;
}

.pixel-block:nth-child(7) {
    width: 18px;
    height: 18px;
    top: 35%;
    right: 25%;
    animation-delay: 2.5s;
    animation-duration: 5.5s;
}

.pixel-block:nth-child(8) {
    width: 14px;
    height: 14px;
    bottom: 40%;
    left: 20%;
    animation-delay: 4s;
    animation-duration: 6.5s;
}

/* Pixel stars */
.pixel-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--star-color);
    animation: pixelPulse 2s ease-in-out infinite;
    box-shadow:
        4px 0 0 var(--star-color),
        -4px 0 0 var(--star-color),
        0 4px 0 var(--star-color),
        0 -4px 0 var(--star-color);
}

.pixel-star:nth-child(9) { top: 15%; left: 25%; animation-delay: 0s; }
.pixel-star:nth-child(10) { top: 45%; right: 30%; animation-delay: 0.4s; }
.pixel-star:nth-child(11) { bottom: 35%; left: 40%; animation-delay: 0.8s; }
.pixel-star:nth-child(12) { top: 75%; left: 60%; animation-delay: 1.2s; }
.pixel-star:nth-child(13) { top: 25%; right: 45%; animation-delay: 1.6s; }
.pixel-star:nth-child(14) { bottom: 20%; right: 35%; animation-delay: 0.2s; }
.pixel-star:nth-child(15) { top: 60%; left: 15%; animation-delay: 0.6s; }
.pixel-star:nth-child(16) { bottom: 55%; right: 20%; animation-delay: 1s; }

/* ========================================
   THEME VARIABLES
   ======================================== */
:root {
    --bg-body: #ffffff;
    --bg-card: rgba(250, 250, 250, 0.95);
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --link-color: #2563eb;
    --link-hover: #1d4ed8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    /* 8-bit pixel colors - light theme */
    --pixel-color-1: #ff6b9d;
    --pixel-color-2: #c44dff;
    --pixel-shadow: rgba(106, 91, 255, 0.4);
    --star-color: #6b5bff;
}

[data-theme="dark"] {
    --bg-body: #0a0a0f;
    --bg-card: rgba(30, 30, 40, 0.95);
    --text-primary: #f5f5f5;
    --text-secondary: #9ca3af;
    --border-color: #404040;
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    /* 8-bit pixel colors - dark theme */
    --pixel-color-1: #00ffcc;
    --pixel-color-2: #ff00aa;
    --pixel-shadow: rgba(0, 255, 204, 0.4);
    --star-color: #ffff00;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-body: #0a0a0f;
        --bg-card: rgba(30, 30, 40, 0.95);
        --text-primary: #f5f5f5;
        --text-secondary: #9ca3af;
        --border-color: #404040;
        --link-color: #60a5fa;
        --link-hover: #93c5fd;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        /* 8-bit pixel colors - dark theme (system) */
        --pixel-color-1: #00ffcc;
        --pixel-color-2: #ff00aa;
        --pixel-shadow: rgba(0, 255, 204, 0.4);
        --star-color: #ffff00;
    }
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

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

/* ========================================
   HOMEPAGE LAYOUT
   ======================================== */
.homepage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.homepage-content {
    text-align: center;
    max-width: 600px;
}

.site-title {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.tagline {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.main-nav {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: center;
}

.nav-link {
    font-size: 1rem;
    font-weight: 500;
}

/* ========================================
   ABOUT PAGE LAYOUT
   ======================================== */
.page-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.home-link {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.home-link:hover {
    color: var(--link-hover);
    text-decoration: none;
}

.about-page {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 2rem;
    width: 100%;
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

/* ========================================
   BIOGRAPHY SECTION
   ======================================== */
.bio {
    margin-bottom: 2rem;
}

.bio p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

/* ========================================
   FOOTER
   ======================================== */
.site-footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.site-footer p {
    margin: 0;
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: var(--transition), transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    transition: var(--transition);
}

.theme-toggle .moon-icon {
    fill: var(--text-primary);
}

.theme-toggle .sun-icon {
    fill: var(--text-primary);
    stroke: var(--text-primary);
    stroke-width: 2;
    stroke-linecap: round;
}

/* Hide icons based on theme */
[data-theme="light"] .theme-toggle .moon-icon,
:root:not([data-theme]) .theme-toggle .moon-icon {
    display: block;
}

[data-theme="light"] .theme-toggle .sun-icon,
:root:not([data-theme]) .theme-toggle .sun-icon {
    display: none;
}

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

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .moon-icon {
        display: none;
    }

    :root:not([data-theme]) .theme-toggle .sun-icon {
        display: block;
    }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .site-title {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .main-nav {
        gap: 1.5rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

    .about-page {
        padding: 2rem 1.5rem;
    }

    .theme-toggle {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
    }

    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.9375rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .about-page {
        padding: 1.5rem 1rem;
    }

    .main-nav {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* ========================================
   8-BIT DUTY GAME STYLES
   ======================================== */

/* Game mode body */
body.game-mode {
    overflow: hidden;
    cursor: none;
}

body.game-mode .pixel-background {
    opacity: 0.3;
}

/* Game Container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: none;
}

/* Game Controls Help */
.game-controls {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 20px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ff00;
    border-radius: 8px;
    font-family: monospace;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.control-item .key {
    background: #333;
    color: #00ff00;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #00ff00;
    text-shadow: 0 0 5px #00ff00;
}

.control-item .action {
    color: #fff;
    font-size: 10px;
    text-transform: uppercase;
}

/* Game Navigation */
.game-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.game-nav .nav-link {
    color: #00ff00;
    font-family: monospace;
    font-size: 14px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ff00;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.game-nav .nav-link:hover {
    background: #00ff00;
    color: #000;
    text-decoration: none;
    box-shadow: 0 0 20px #00ff00;
}

/* Game Footer */
.game-footer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    font-family: monospace;
    font-size: 12px;
    color: #666;
}

.game-footer p {
    margin: 0;
}

/* Mobile Responsiveness for Game */
@media (max-width: 768px) {
    .game-controls {
        flex-wrap: wrap;
        justify-content: center;
        padding: 8px 16px;
        gap: 10px;
        bottom: 80px;
    }

    .control-item .key {
        font-size: 10px;
        padding: 3px 6px;
    }

    .control-item .action {
        font-size: 8px;
    }

    .game-nav {
        bottom: 40px;
    }

    .game-footer {
        bottom: 10px;
        right: 10px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .game-controls {
        display: none; /* Hide on very small screens - mobile uses touch */
    }

    .game-nav .nav-link {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Scanline effect for retro feel */
body.game-mode::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
    opacity: 0.3;
}

/* CRT flicker effect */
@keyframes flicker {
    0% { opacity: 0.97; }
    5% { opacity: 0.95; }
    10% { opacity: 0.97; }
    15% { opacity: 0.94; }
    20% { opacity: 0.98; }
    25% { opacity: 0.96; }
    30% { opacity: 0.97; }
    35% { opacity: 0.95; }
    40% { opacity: 0.98; }
    45% { opacity: 0.96; }
    50% { opacity: 0.97; }
    55% { opacity: 0.95; }
    60% { opacity: 0.98; }
    65% { opacity: 0.94; }
    70% { opacity: 0.97; }
    75% { opacity: 0.96; }
    80% { opacity: 0.98; }
    85% { opacity: 0.95; }
    90% { opacity: 0.97; }
    95% { opacity: 0.96; }
    100% { opacity: 0.98; }
}

body.game-mode #game-canvas {
    animation: flicker 0.15s infinite;
}

/* Disable CRT effects for reduced motion */
@media (prefers-reduced-motion: reduce) {
    body.game-mode::after {
        display: none;
    }

    body.game-mode #game-canvas {
        animation: none;
    }
}
