:root {
    /* Base Variables (Default to Obsidian if no scheme set) */
    --bg-body: #18181B;
    --primary: #FBBF24;
    --text-main: #ffffff;
    --text-muted: #A1A1AA;
    --glass-bg: rgba(24, 24, 27, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #FBBF24;
    --card-hover: rgba(251, 191, 36, 0.05);
}

/* =========================================
   COLOR SCHEMES
   ========================================= */

/* 1. Obsidian & Gold (Default) */
[data-scheme="obsidian"] {
    --bg-body: #18181B;
    --primary: #FBBF24;
    --text-main: #ffffff;
    --text-muted: #A1A1AA;
    --glass-bg: rgba(24, 24, 27, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #FBBF24;
    --card-hover: rgba(251, 191, 36, 0.05);
}

[data-scheme="obsidian"][data-theme="light"] {
    --bg-body: #FFFBEB;
    /* Amber 50 */
    --primary: #D97706;
    /* Amber 600 */
    --text-main: #27272A;
    --text-muted: #52525B;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(217, 119, 6, 0.15);
    --particle-color: #D97706;
    --card-hover: rgba(217, 119, 6, 0.05);
}

/* 2. Crimson & Slate (Ivy League) */
[data-scheme="crimson"] {
    --bg-body: #020617;
    /* Slate 950 */
    --primary: #FB7185;
    /* Rose 400 */
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --glass-bg: rgba(2, 6, 23, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #FB7185;
    --card-hover: rgba(251, 113, 133, 0.05);
}

[data-scheme="crimson"][data-theme="light"] {
    --bg-body: #FFF1F2;
    /* Rose 50 */
    --primary: #BE123C;
    /* Rose 700 */
    --text-main: #0F172A;
    /* Slate 900 */
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(190, 18, 60, 0.15);
    --particle-color: #BE123C;
    --card-hover: rgba(190, 18, 60, 0.05);
}

/* 3. Oxford Blue (Navy & Blue) */
[data-scheme="oxford"] {
    --bg-body: #0B1120;
    /* Deep Navy */
    --primary: #60A5FA;
    /* Blue 400 */
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --glass-bg: rgba(11, 17, 32, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #60A5FA;
    --card-hover: rgba(96, 165, 250, 0.05);
}

[data-scheme="oxford"][data-theme="light"] {
    --bg-body: #F0F9FF;
    /* Sky 50 */
    --primary: #0369A1;
    /* Sky 700 */
    --text-main: #0F172A;
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(3, 105, 161, 0.15);
    --particle-color: #0369A1;
    --card-hover: rgba(3, 105, 161, 0.05);
}

/* 4. Sage & Stone (Scientific/Natural) */
[data-scheme="sage"] {
    --bg-body: #0C0A09;
    /* Stone 950 */
    --primary: #86EFAC;
    /* Green 300 */
    --text-main: #ffffff;
    --text-muted: #A8A29E;
    --glass-bg: rgba(12, 10, 9, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #86EFAC;
    --card-hover: rgba(134, 239, 172, 0.05);
}

[data-scheme="sage"][data-theme="light"] {
    --bg-body: #FAFAF9;
    /* Stone 50 */
    --primary: #15803D;
    /* Green 700 */
    --text-main: #1C1917;
    --text-muted: #57534E;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(21, 128, 61, 0.15);
    --particle-color: #15803D;
    --card-hover: rgba(21, 128, 61, 0.05);
}

/* 5. Royal & Silver (Humanities) */
[data-scheme="royal"] {
    --bg-body: #0A0A0A;
    /* Neutral 950 */
    --primary: #C084FC;
    /* Purple 400 */
    --text-main: #ffffff;
    --text-muted: #A3A3A3;
    --glass-bg: rgba(10, 10, 10, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --particle-color: #C084FC;
    --card-hover: rgba(192, 132, 252, 0.05);
}

[data-scheme="royal"][data-theme="light"] {
    --bg-body: #FAF5FF;
    /* Purple 50 */
    --primary: #7E22CE;
    /* Purple 700 */
    --text-main: #171717;
    --text-muted: #525252;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(126, 34, 206, 0.15);
    --particle-color: #7E22CE;
    --card-hover: rgba(126, 34, 206, 0.05);
}

/* Theme Selector Styles */
.theme-selector-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 50;
    /* Removed absolute positioning to fit in flow */
}

@media (min-width: 768px) {
    .theme-selector-container {
        left: 1.5rem;
        right: auto;
    }
}

.scheme-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.scheme-btn:hover {
    transform: scale(1.1);
}

.scheme-btn.active {
    border-color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--primary);
}

.scheme-dropdown {
    position: relative;
    display: inline-block;
    padding-bottom: 10px;
    /* Invisible bridge for hover */
    margin-bottom: -10px;
}

.scheme-dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    /* Open upwards */
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    /* Space from button */
    flex-direction: column;
    gap: 0.5rem;
    min-width: 40px;
    align-items: center;

    /* Animation */
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.scheme-dropdown:hover .scheme-dropdown-content {
    display: flex;
    opacity: 1;
}

/* Add a pseudo-element to bridge the gap */
.scheme-dropdown-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 20px;
    /* Bridge gap */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    opacity: 0.2;
    border-radius: 4px;
}

/* Glassmorphism Card Effect */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, border-color 0.3s;
}

.glass-panel:hover {
    background-color: var(--card-hover);
    /* Subtle highlight on hover */
}

/* Typography */
.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out forwards;
}

.slide-in-left {
    animation: slideInLeft 0.4s ease-out forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Interactive Elements */
.nav-item {
    transition: all 0.3s ease;
    position: relative;
    color: var(--text-muted);
}

.nav-item:hover {
    color: var(--text-main);
}

.nav-item::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

.nav-item:hover::after,
.nav-item.active::after {
    width: 100%;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

/* Canvas Background */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* Toast Notification */
#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--bg-body);
    color: var(--text-main);
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 50;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    border: 1px solid var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    aspect-ratio: 1;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

/* AI Loading State */
.animate-pulse-fast {
    animation: pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Lightbox */
#lightbox {
    position: fixed;
    z-index: 100;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

#lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#lightbox.active img {
    transform: scale(1);
}

/* Accessibility & Focus */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Mobile Touch Targets */
@media (max-width: 768px) {
    .nav-item {
        padding: 12px 16px;
        /* Larger touch target */
    }
}

/* Theme Toggle Switch - Day/Night Effect */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 70px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1e293b;
    /* Dark Night Sky */
    transition: .4s;
    border-radius: 34px;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* The Knob (Moon/Sun) */
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: #fbbf24;
    /* Moon Color */
    transition: .4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    /* Bouncy effect */
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

/* Light Mode (Checked) State */
input:checked+.slider {
    background-color: #60a5fa;
    /* Day Sky Blue */
}

input:checked+.slider:before {
    transform: translateX(36px);
    background-color: #fcd34d;
    /* Sun Color */
    box-shadow: 0 0 15px rgba(252, 211, 77, 0.8);
}

/* Stars (Visible in Dark Mode) */
.star {
    position: absolute;
    background-color: white;
    border-radius: 50%;
    transition: all 0.4s ease;
    opacity: 1;
    z-index: 1;
}

.star-1 {
    top: 7px;
    left: 42px;
    width: 2px;
    height: 2px;
}

.star-2 {
    top: 16px;
    left: 52px;
    width: 1px;
    height: 1px;
}

.star-3 {
    top: 8px;
    left: 58px;
    width: 2px;
    height: 2px;
}

.star-4 {
    top: 22px;
    left: 38px;
    width: 1px;
    height: 1px;
}

.star-5 {
    top: 15px;
    left: 32px;
    width: 2px;
    height: 2px;
    opacity: 0.7;
}

input:checked+.slider .star {
    transform: translateY(20px);
    opacity: 0;
}

/* Clouds (Visible in Light Mode) */
.cloud {
    position: absolute;
    background-color: #ffffff;
    border-radius: 10px;
    transition: all 0.4s ease;
    opacity: 0;
    z-index: 1;
}

.cloud-1 {
    top: 10px;
    left: 12px;
    width: 18px;
    height: 8px;
}

.cloud-2 {
    top: 20px;
    left: 22px;
    width: 12px;
    height: 6px;
}

/* Cloud Shapes */
.cloud:before,
.cloud:after {
    content: '';
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
}

.cloud-1:before {
    width: 10px;
    height: 10px;
    top: -5px;
    left: 2px;
}

.cloud-1:after {
    width: 8px;
    height: 8px;
    top: -3px;
    left: 8px;
}

.cloud-2:before {
    width: 6px;
    height: 6px;
    top: -3px;
    left: 2px;
}

.cloud-2:after {
    width: 5px;
    height: 5px;
    top: -2px;
    left: 6px;
}

input:checked+.slider .cloud {
    opacity: 0.9;
}

input:checked+.slider .cloud-1 {
    transform: translateX(0);
    transition-delay: 0.1s;
}

input:checked+.slider .cloud-2 {
    transform: translateX(0);
    transition-delay: 0.2s;
}

/* =========================================
   FORM INPUT STYLES - CONTRAST FIX
   ========================================= */

/* Ensure input text is always visible with proper contrast */
input[type="text"],
input[type="email"],
textarea {
    color: var(--text-main) !important;
}

/* Dark mode - ensure light text on dark background */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] textarea,
:root:not([data-theme="light"]) input[type="text"],
:root:not([data-theme="light"]) input[type="email"],
:root:not([data-theme="light"]) textarea {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Light mode - ensure dark text on light background */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] textarea {
    color: #000000 !important;
    background-color: rgba(0, 0, 0, 0.03) !important;
}

/* Placeholder text styling */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.6;
}

/* Focus state enhancements */
input:focus,
textarea:focus {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus {
    background-color: rgba(0, 0, 0, 0.05) !important;
}
