:root {
    /* ==== DARK MODE (Default) ==== */
    --bg-color: #0f172a;
    /* Deep blue-gray */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    /* Blue Accent Colors */
    --accent-blue: #3b82f6;
    /* Tailwind Blue 500 */
    --accent-blue-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.5);

    /* Glassmorphism settings */
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Background blobs */
    --blob-1: rgba(59, 130, 246, 0.2);
    --blob-2: rgba(147, 51, 234, 0.15);
    /* Subtle purple for depth */

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

[data-theme="light"] {
    /* ==== LIGHT MODE ==== */
    --bg-color: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;

    /* Blue Accent remains similar for brand consistency */
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.3);

    /* Glassmorphism settings for light mode */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    /* Background blobs adjust for light mode */
    --blob-1: rgba(59, 130, 246, 0.15);
    --blob-2: rgba(147, 51, 234, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    line-height: 1.6;
}

main {
    flex: 1 0 auto;
    width: 100%;
    display: block;
}

body.loading {
    overflow: hidden;
}

.skip-preloader #preloader {
    display: none !important;
}

/* ===== Preloader ===== */
#preloader {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

#preloader.fade-out {
    transform: translateY(-100%);
}

.loader-logo {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -2px;
    animation: pulse 1.5s ease-in-out infinite;
}

.loader-logo span {
    color: var(--accent-blue);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

/* ===== Reveal Animations ===== */
.reveal-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.loaded .reveal-item {
    opacity: 1;
    transform: translateY(0);
}

.loaded .glass-nav.reveal-item {
    transition-delay: 0.1s;
}

.loaded .hero-content.reveal-item {
    transition-delay: 0.3s;
}

.loaded .hero-image-container.reveal-item {
    transition-delay: 0.5s;
}

.loaded .page-title.reveal-item {
    transition-delay: 0.2s;
}

/* Staggered Delay for lists (Links, Cards, etc.) */
.reveal-item:nth-child(1) {
    transition-delay: 0.1s;
}

.reveal-item:nth-child(2) {
    transition-delay: 0.2s;
}

.reveal-item:nth-child(3) {
    transition-delay: 0.3s;
}

.reveal-item:nth-child(4) {
    transition-delay: 0.4s;
}

.reveal-item:nth-child(5) {
    transition-delay: 0.5s;
}

.loaded .reveal-item:nth-child(6) {
    transition-delay: 0.6s;
}

.loaded .reveal-item:nth-child(7) {
    transition-delay: 0.7s;
}

.loaded .reveal-item:nth-child(8) {
    transition-delay: 0.8s;
}

.loaded .reveal-item:nth-child(9) {
    transition-delay: 0.9s;
}

.loaded .reveal-item:nth-child(10) {
    transition-delay: 1.0s;
}

/* Background Blobs for depth */
.blob-bg {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--blob-1) 0%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    z-index: -1;
    filter: blur(60px);
    animation: float 20s ease-in-out infinite alternate;
}

.blob-2 {
    top: 50%;
    left: 50%;
    background: radial-gradient(circle, var(--blob-2) 0%, rgba(0, 0, 0, 0) 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(10%, 15%) scale(1.1);
    }
}

/* Typography Utilities */
h1,
h2,
h3,
h4,
.logo {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* ===== Navigation ===== */
.glass-nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -1px;
}

.logo span {
    color: var(--accent-blue);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
    font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-blue);
}

#theme-toggle {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#theme-toggle:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* ===== Common Layouts ===== */
.page-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8rem 2rem 4rem;
    /* Top padding accounts for fixed nav */
}

.page-title {
    font-size: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 50%;
    height: 4px;
    background: var(--accent-blue);
    border-radius: 2px;
}

/* Glass Card Component */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-blue);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 0 20px var(--accent-glow);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-family: var(--font-heading);
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: none;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ===== Index (Hero) ===== */
.hero {
    max-width: 900px;
    margin: 10rem auto 4rem;
    padding: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4rem;
}

.hero-content {
    flex: 1;
}

.glitch-text {
    font-size: 5rem;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px var(--accent-glow);
}

.subtitle {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-blue);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.hero-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.social-links-hero {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

.minecraft-btn {
    position: relative;
    cursor: help;
}

.minecraft-id {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--accent-blue);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.minecraft-id::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--accent-blue);
}

.minecraft-btn:hover .minecraft-id,
.minecraft-btn:active .minecraft-id {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.social-tag {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hero-image-container {
    width: 250px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px var(--accent-glow);
    position: relative;
    overflow: visible;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    z-index: 2;
}

.profile-avatar::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, var(--accent-blue), transparent 40%);
    animation: rotate 4s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.avatar-letter {
    display: none;
    /* No longer needed */
}

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

/* ===== Common Grid (Projects & Services) ===== */
.common-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    width: 100%;
}

.project-card {
    display: flex;
    flex-direction: column;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.project-icon {
    font-size: 2rem;
    color: var(--accent-blue);
}

.project-header h3 {
    font-size: 1.4rem;
}

.project-body {
    flex: 1;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.project-footer {
    display: flex;
    gap: 1rem;
}

.project-card.dashed {
    border-style: dashed;
    border-width: 2px;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: transparent;
    box-shadow: none;
}

.project-card.dashed:hover {
    box-shadow: none;
    background: var(--glass-bg);
}

/* ===== Devices Grid ===== */
.devices-container {
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.device-category h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.device-category h3 i {
    color: var(--accent-blue);
}

/* Specialized Device Grids (No Orphans) */
.device-grid-3, .device-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* 3 Items: PC & Gadgets (1 to 3 cols jump) */
@media (min-width: 950px) {
    .device-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 2 Items: Servers (1 to 2 cols jump) */
@media (min-width: 700px) {
    .device-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 8 Items: Gadgets (1 -> 2 -> 4 cols jump, avoids orphans) */
.device-grid-8 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 650px) {
    .device-grid-8 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1050px) {
    .device-grid-8 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.device-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pc-card { min-width: 290px; }
.server-card { min-width: 270px; }
.gadget-card { min-width: 250px; }

.device-card h4 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--accent-blue);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.device-specs {
    list-style: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.device-specs li {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.device-specs strong {
    color: var(--text-primary);
    font-weight: 600;
}

.device-desc {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Responsive Design ===== */
/* ===== Link Tree Layout ===== */
.link-tree-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 8rem 1rem 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.profile-header {
    text-align: center;
    margin-bottom: 2rem;
}

.profile-header .profile-avatar {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
}

.profile-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.link-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.link-item:hover {
    transform: scale(1.03);
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px var(--accent-glow);
}

.link-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.link-info i,
.link-info svg {
    font-size: 1.5rem;
    color: var(--accent-blue);
    width: 24px;
    text-align: center;
}

.link-label {
    font-weight: 700;
    font-family: var(--font-heading);
}

.link-id {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.link-item i.fa-chevron-right {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .hero {
        flex-direction: column-reverse;
        padding: 2rem;
        margin-top: 8rem;
        text-align: center;
    }

    .social-links-hero {
        justify-content: center;
    }

    .link-item {
        padding: 1rem 1.5rem;
    }
}

/* ===== Footer & Mode Switcher ===== */
.glass-footer {
    margin-top: 4rem;
    padding: 2rem;
    padding-bottom: 4rem;
    background: var(--glass-bg);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.mode-switcher {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.mode-switcher span {
    font-weight: 600;
    color: var(--text-main);
}

.mode-switcher a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.mode-switcher a:hover {
    color: var(--accent-blue);
}

.mode-switcher a.active {
    color: var(--accent-blue);
    font-weight: bold;
    pointer-events: none;
}

@media (max-width: 768px) {
    .mode-switcher {
        flex-direction: column;
        gap: 0.5rem;
    }
}