@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

/* Default Themes - Grid Power (Palette 0) */
:root {
    --surface-dim: 11 19 38;
    --background: 11 19 38;
    --surface-container: 23 31 51;
    --surface-container-low: 19 27 46;
    --surface-container-lowest: 6 14 32;
    --surface-container-high: 34 42 61;
    --surface-container-highest: 45 52 73;
    --surface-bright: 49 57 77;
    --primary: 142 213 255;
    --primary-container: 56 189 248; /* Electric Blue */
    --secondary: 255 198 64; /* Caution Yellow */
    --border-utility: 51 65 85;
    --text-primary: 248 250 252;
    --text-muted: 148 163 184;
    --on-surface: 218 226 253;
    --on-primary: 0 53 74;
    --grid-color: 51 65 85;
    --grid-opacity: 0.12;
    --shadow-color: 56, 189, 248;
}

/* Base Light theme overrides for default */
:root.light-theme {
    --surface-dim: 248 250 252;
    --background: 248 250 252;
    --surface-container: 255 255 255;
    --surface-container-low: 241 245 249;
    --surface-container-lowest: 226 232 240;
    --surface-container-high: 248 250 252;
    --surface-container-highest: 203 213 225;
    --surface-bright: 255 255 255;
    --primary: 2 132 199;
    --primary-container: 14 165 233;
    --secondary: 217 119 6;
    --border-utility: 203 213 225;
    --text-primary: 15 23 42;
    --text-muted: 71 85 105;
    --on-surface: 30 41 59;
    --on-primary: 255 255 255;
    --grid-color: 148 163 184;
    --grid-opacity: 0.18;
    --shadow-color: 14, 165, 233;
}

/* Palette 0: Grid Power (Default Dark & Light) */
[data-palette="0"] {
    --surface-dim: 11 19 38;
    --background: 11 19 38;
    --surface-container: 23 31 51;
    --surface-container-low: 19 27 46;
    --surface-container-lowest: 6 14 32;
    --surface-container-high: 34 42 61;
    --surface-container-highest: 45 52 73;
    --surface-bright: 49 57 77;
    --primary: 142 213 255;
    --primary-container: 56 189 248;
    --secondary: 255 198 64;
    --border-utility: 51 65 85;
    --text-primary: 248 250 252;
    --text-muted: 148 163 184;
    --on-surface: 218 226 253;
    --on-primary: 0 53 74;
    --grid-color: 51 65 85;
    --grid-opacity: 0.12;
    --shadow-color: 56, 189, 248;
}
[data-palette="0"].light-theme {
    --surface-dim: 248 250 252;
    --background: 248 250 252;
    --surface-container: 255 255 255;
    --surface-container-low: 241 245 249;
    --surface-container-lowest: 226 232 240;
    --surface-container-high: 248 250 252;
    --surface-container-highest: 203 213 225;
    --surface-bright: 255 255 255;
    --primary: 2 132 199;
    --primary-container: 14 165 233;
    --secondary: 217 119 6;
    --border-utility: 203 213 225;
    --text-primary: 15 23 42;
    --text-muted: 71 85 105;
    --on-surface: 30 41 59;
    --on-primary: 255 255 255;
    --grid-color: 148 163 184;
    --grid-opacity: 0.18;
    --shadow-color: 14, 165, 233;
}

/* Palette 1: Classic Blueprint (Classic dark blue paper, white grid-lines) */
[data-palette="1"] {
    --surface-dim: 8 30 63;
    --background: 8 30 63;
    --surface-container: 12 43 84;
    --surface-container-low: 10 37 73;
    --surface-container-lowest: 5 22 46;
    --surface-container-high: 18 55 102;
    --surface-container-highest: 25 68 119;
    --surface-bright: 31 79 137;
    --primary: 255 255 255;
    --primary-container: 56 189 248;
    --secondary: 251 191 36;
    --border-utility: 37 75 125;
    --text-primary: 255 255 255;
    --text-muted: 147 197 253;
    --on-surface: 224 242 254;
    --on-primary: 12 43 84;
    --grid-color: 255 255 255;
    --grid-opacity: 0.08;
    --shadow-color: 56, 189, 248;
}
[data-palette="1"].light-theme {
    --surface-dim: 240 247 255;
    --background: 240 247 255;
    --surface-container: 255 255 255;
    --surface-container-low: 224 242 254;
    --surface-container-lowest: 186 230 253;
    --surface-container-high: 248 250 252;
    --surface-container-highest: 125 211 252;
    --surface-bright: 255 255 255;
    --primary: 3 105 161;
    --primary-container: 2 132 199;
    --secondary: 180 83 9;
    --border-utility: 186 230 253;
    --text-primary: 12 74 110;
    --text-muted: 3 105 161;
    --on-surface: 15 23 42;
    --on-primary: 255 255 255;
    --grid-color: 2 132 199;
    --grid-opacity: 0.14;
    --shadow-color: 2, 132, 199;
}

/* Palette 2: High-Voltage Amber */
[data-palette="2"] {
    --surface-dim: 10 10 12;
    --background: 10 10 12;
    --surface-container: 20 20 22;
    --surface-container-low: 14 14 16;
    --surface-container-lowest: 5 5 6;
    --surface-container-high: 28 28 31;
    --surface-container-highest: 37 37 41;
    --surface-bright: 48 48 53;
    --primary: 251 146 60;
    --primary-container: 249 115 22;
    --secondary: 251 191 36;
    --border-utility: 45 45 48;
    --text-primary: 250 250 250;
    --text-muted: 161 161 170;
    --on-surface: 244 244 245;
    --on-primary: 10 10 12;
    --grid-color: 249 115 22;
    --grid-opacity: 0.08;
    --shadow-color: 249, 115, 22;
}
[data-palette="2"].light-theme {
    --surface-dim: 250 250 250;
    --background: 250 250 250;
    --surface-container: 255 255 255;
    --surface-container-low: 244 244 245;
    --surface-container-lowest: 228 228 231;
    --surface-container-high: 255 255 255;
    --surface-container-highest: 212 212 216;
    --surface-bright: 255 255 255;
    --primary: 194 65 12;
    --primary-container: 234 88 12;
    --secondary: 180 83 9;
    --border-utility: 228 228 231;
    --text-primary: 24 24 27;
    --text-muted: 113 113 122;
    --on-surface: 39 39 42;
    --on-primary: 255 255 255;
    --grid-color: 234 88 12;
    --grid-opacity: 0.12;
    --shadow-color: 234, 88, 12;
}

/* Palette 3: Automation Terminal (Laser Green) */
[data-palette="3"] {
    --surface-dim: 5 5 5;
    --background: 5 5 5;
    --surface-container: 14 18 15;
    --surface-container-low: 8 10 8;
    --surface-container-lowest: 0 0 0;
    --surface-container-high: 20 26 21;
    --surface-container-highest: 26 34 28;
    --surface-bright: 34 46 37;
    --primary: 74 222 128;
    --primary-container: 34 197 94;
    --secondary: 163 230 53;
    --border-utility: 21 41 27;
    --text-primary: 236 253 245;
    --text-muted: 107 114 128;
    --on-surface: 209 250 229;
    --on-primary: 2 44 34;
    --grid-color: 34 197 94;
    --grid-opacity: 0.07;
    --shadow-color: 34, 197, 94;
}
[data-palette="3"].light-theme {
    --surface-dim: 240 253 244;
    --background: 240 253 244;
    --surface-container: 255 255 255;
    --surface-container-low: 220 252 231;
    --surface-container-lowest: 187 247 208;
    --surface-container-high: 249 251 249;
    --surface-container-highest: 134 239 172;
    --surface-bright: 255 255 255;
    --primary: 21 128 61;
    --primary-container: 22 163 74;
    --secondary: 77 124 15;
    --border-utility: 187 247 208;
    --text-primary: 6 78 59;
    --text-muted: 21 128 61;
    --on-surface: 31 41 55;
    --on-primary: 255 255 255;
    --grid-color: 22 163 74;
    --grid-opacity: 0.12;
    --shadow-color: 22, 163, 74;
}

/* Base HTML + Body Styles — fix mobile viewport width gap */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background-color: rgb(var(--surface-dim));
    color: rgb(var(--on-surface));
    font-family: 'IBM Plex Sans', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Custom Typography bindings */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
    color: rgb(var(--text-primary));
}

.font-mono-labels {
    font-family: 'IBM Plex Mono', monospace;
}

/* Grid Overlay Background */
.grid-bg {
    background-image: 
        linear-gradient(to right, rgb(var(--grid-color)) 1px, transparent 1px),
        linear-gradient(to bottom, rgb(var(--grid-color)) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: var(--grid-opacity);
    transition: background-image 0.3s ease, opacity 0.3s ease;
}

/* Navigation System Styles */
.nav-bg {
    background-color: rgb(var(--surface-dim));
    border-bottom: 1px solid rgb(var(--border-utility));
    backdrop-filter: blur(12px);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-link {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    color: rgb(var(--text-muted)) !important;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.nav-link:hover {
    color: rgb(var(--text-primary)) !important;
    background-color: rgb(var(--surface-container-low));
    border-color: rgb(var(--border-utility));
    transform: translateY(-1px);
}

.nav-link.active {
    color: rgb(var(--primary-container)) !important;
    background-color: rgb(var(--surface-container-high));
    border-color: rgb(var(--primary-container));
}

/* Interactive Elements */
.btn-primary {
    background-color: rgb(var(--primary-container));
    color: rgb(var(--on-primary));
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    border: 1px solid rgb(var(--primary-container));
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: rgb(var(--primary));
    border-color: rgb(var(--primary));
    box-shadow: 0 0 15px rgba(var(--shadow-color), 0.35);
    transform: translateY(-1.5px);
}

.btn-secondary {
    background-color: rgb(var(--surface-container));
    color: rgb(var(--primary-container));
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    border: 1px solid rgb(var(--border-utility));
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background-color: rgb(var(--surface-container-high));
    border-color: rgb(var(--primary-container));
    color: rgb(var(--text-primary));
    transform: translateY(-1.5px);
}

/* Technical Timeline Node Pulse */
.pulse-node {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--shadow-color), 0.55); }
    70% { box-shadow: 0 0 0 10px rgba(var(--shadow-color), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--shadow-color), 0); }
}

/* Technical Card Hover Effects */
.glow-card {
    background-color: rgb(var(--surface-container));
    border: 1px solid rgb(var(--border-utility));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glow-card:hover {
    box-shadow: 0 0 20px 0 rgba(var(--shadow-color), 0.22);
    border-color: rgb(var(--primary-container)) !important;
    transform: translateY(-3px);
}

/* Premium Themed Project Images to Make Diverse Content Harmonious */
.project-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: rgb(var(--surface-container-lowest));
    overflow: hidden;
}

.project-image-themed {
    filter: grayscale(100%) contrast(1.1) brightness(0.85);
    mix-blend-mode: luminosity;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-image-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(11, 19, 38, 0.75));
    mix-blend-mode: color;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glow-card:hover .project-image-themed {
    filter: grayscale(20%) contrast(1.15) brightness(0.95);
    mix-blend-mode: normal;
}

.glow-card:hover .project-image-container::after {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.05), rgba(11, 19, 38, 0.35));
}

/* Glassmorphism Styles */
.glass {
    background-color: rgba(var(--shadow-color), 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgb(var(--border-utility));
}

/* Form Styles — !important overrides Tailwind forms plugin white-background reset */
.form-input {
    background-color: rgb(var(--surface-container-low)) !important;
    border: 1px solid rgb(var(--border-utility)) !important;
    color: rgb(var(--text-primary)) !important;
    transition: all 0.25s ease;
    font-family: 'IBM Plex Sans', sans-serif;
    caret-color: rgb(var(--primary-container));
}

.form-input::placeholder {
    color: rgb(var(--text-muted));
    opacity: 0.55;
}

/* Prevent browser autofill from forcing white bg / black text in dark mode */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus,
.form-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgb(var(--surface-container-low)) inset !important;
    -webkit-text-fill-color: rgb(var(--text-primary)) !important;
    caret-color: rgb(var(--primary-container)) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-input:focus {
    border-color: rgb(var(--primary-container)) !important;
    box-shadow: 0 0 10px 0 rgba(var(--shadow-color), 0.2);
    background-color: rgb(var(--surface-container-high)) !important;
    color: rgb(var(--text-primary)) !important;
    outline: none;
}

/* Theme Button Toggles */
#theme-toggle, #palette-toggle, #mobile-menu-button {
    background-color: rgb(var(--surface-container-low)) !important;
    border: 1px solid rgb(var(--border-utility)) !important;
    color: rgb(var(--primary-container)) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

#theme-toggle:hover, #palette-toggle:hover, #mobile-menu-button:hover {
    background-color: rgb(var(--surface-container-high)) !important;
    border-color: rgb(var(--primary-container)) !important;
    color: rgb(var(--text-primary)) !important;
    transform: translateY(-1px);
}

/* Palette selector drop-down and details */
.palette-selector {
    position: relative;
}

.palette-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgb(var(--surface-container-high));
    border: 1px solid rgb(var(--border-utility));
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 8px;
    z-index: 1000;
    min-width: 210px;
}

.palette-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: rgb(var(--text-muted));
}

.palette-option:hover {
    background: rgb(var(--surface-container));
    color: rgb(var(--text-primary));
}

.palette-option.active {
    background: rgba(var(--shadow-color), 0.1);
    border: 1px solid rgb(var(--primary-container));
    color: rgb(var(--primary-container));
}

.palette-colors {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Progress bar to ASCII terminal-bar transformation */
.progress-bar-container {
    width: 100%;
    background-color: rgb(var(--surface-container-lowest));
    border: 1px solid rgb(var(--border-utility));
    border-radius: 3px;
    padding: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 12px;
    background: linear-gradient(90deg, rgb(var(--primary-container)), rgb(var(--primary)));
    border-radius: 1.5px;
    transition: width 1.2s cubic-bezier(0.1, 0.8, 0.25, 1);
    width: 0%; /* Initial state for scroll animation */
}

/* Mobile responsive menu */
#mobile-menu {
    background-color: rgb(var(--surface-dim)) !important;
    border: 1px solid rgb(var(--border-utility));
}

#mobile-menu a {
    color: rgb(var(--text-muted)) !important;
    font-family: 'IBM Plex Mono', monospace;
    display: block;
    margin: 0.25rem 0;
    padding: 12px 16px;
    border-radius: 4px;
    transition: all 0.25s ease;
}

#mobile-menu a:hover {
    background-color: rgb(var(--surface-container-low));
    color: rgb(var(--text-primary)) !important;
    transform: translateX(4px);
}

#mobile-menu a.active {
    background-color: rgb(var(--surface-container-high));
    color: rgb(var(--primary-container)) !important;
    border-left: 3px solid rgb(var(--primary-container));
}

/* Back to Top button styles */
#back-to-top {
    position: fixed !important;
    bottom: 24px;
    right: 24px;
    z-index: 99998 !important;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    border: 1px solid rgb(var(--border-utility));
    background-color: rgb(var(--surface-container));
    color: rgb(var(--primary-container));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

#back-to-top:hover {
    background-color: rgb(var(--surface-container-high));
    border-color: rgb(var(--primary-container));
    color: rgb(var(--text-primary));
    transform: translateY(-2px);
    box-shadow: 0 0 10px rgba(var(--shadow-color), 0.2);
}

/* Floating Elements / Technical orbits */
.orbiting-ring {
    border: 1px dashed rgb(var(--border-utility));
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom technical warning badge */
.warning-badge {
    border: 1px solid rgb(var(--secondary));
    background-color: rgba(255, 198, 64, 0.06);
    color: rgb(var(--secondary));
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
}

/* Utilities for grid sections */
.grid-gap {
    gap: 1.5rem;
}

/* Stacking and layout guards */
section[id] {
    position: relative;
    z-index: 10;
}

#persistent-nav {
    position: sticky !important;
    top: 0 !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

/* Blinking terminal cursor */
.terminal-cursor {
    animation: terminal-blink 1s step-end infinite;
    color: rgb(var(--primary-container));
}

@keyframes terminal-blink {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}

/* Terminal nav button active state */
#nav-contact-terminal.terminal-active {
    background-color: rgb(var(--surface-container-high)) !important;
    border-color: rgb(var(--primary-container)) !important;
    color: rgb(var(--text-primary)) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

