/* Prevent FOUC and improve page load experience */
html {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease;
}

html.loading {
    visibility: hidden;
    opacity: 0;
}

/* Optimized rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Content visibility optimization */
section:not(:first-child) {
    content-visibility: auto;
    contain-intrinsic-size: 1px 500px;
}

/* Reduce CLS (Cumulative Layout Shift) */
img {
    aspect-ratio: attr(width) / attr(height);
}

/* Reset and minimal base styles */
:root {
  /* Light mode colors - simplified palette */
  --primary-color: #2d2d6e;
  --secondary-color: #5353c6;
  --accent-color: #00b4ff;
  --text-color: #333333;
  --bg-color: #f9f9fb;
  --card-bg: #ffffff;
  --sidebar-bg: rgba(255, 255, 255, 0.85);
  --sidebar-bg-rgb: 255, 255, 255;
  --sidebar-text: #333333;
  --sidebar-active: #00b4ff;
  --border-color: #eaeaea;
  --border-color-rgb: 234, 234, 234;
  --shadow-color: rgba(0, 0, 0, 0.08);
  --transition-speed: 0.3s;
  --card-bg-rgb: 255, 255, 255;
  --accent-color-rgb: 0, 180, 255;
}

/* Dark mode variables - simplified */
body.dark-mode {
  --primary-color: #5353c6;
  --secondary-color: #7676e2;
  --accent-color: #00b4ff;
  --text-color: #f5f5f5;
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --card-bg-rgb: 30, 30, 30;
  --sidebar-bg: rgba(30, 30, 30, 0.85);
  --sidebar-bg-rgb: 30, 30, 30;
  --sidebar-text: #f9f9fb;
  --border-color: #333333;
  --border-color-rgb: 51, 51, 51;
  --shadow-color: rgba(0, 0, 0, 0.2);
  --accent-color-rgb: 0, 180, 255;
}

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

::-webkit-scrollbar {
    width: 5px;
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}

body {
    background: var(--bg-color);
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    font-size: 16px;
    transition: all 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition-speed);
}

/* Clean section styles */
section {
    padding: 80px 0;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    transition: all 0.3s ease;
}

/* Minimalist header styles */
.section-header {
    text-align: center;
    margin-bottom: 50px;
}

.section-title {
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    position: relative;
    display: inline-block;
}

.section-title span {
    color: var(--accent-color);
}

.section-subtitle {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 1.1rem;
}

/* Clean button styles */
.btn {
    display: inline-block;
    padding: 10px 25px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(var(--accent-color-rgb), 0.25);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(var(--accent-color-rgb), 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1.5px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-outline:hover {
    background-color: var(--accent-color);
    color: white;
}

.btn-sm {
    padding: 7px 18px;
    font-size: 0.85rem;
}

/* Subtle card styles */
.card {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--shadow-color);
    padding: 25px;
    transition: all 0.3s ease;
}

/* Minimal Sidebar Styles */
.sidebar {
    position: fixed;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    width: 55px;
    height: 75vh;
    background-color: var(--sidebar-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 5px 15px var(--shadow-color);
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar:hover {
    background-color: var(--card-bg);
    box-shadow: 0 8px 20px var(--shadow-color);
}

.sidebar-header {
    margin-bottom: 15px;
}

.profile-icon {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.sidebar-nav li {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.sidebar-nav .nav-link span {
    position: absolute;
    right: 100%;
    background: var(--accent-color);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    white-space: nowrap;
    pointer-events: none;
    margin-right: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.sidebar-nav .nav-link span:after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid var(--accent-color);
}

.sidebar-nav .nav-link:hover {
    color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb), 0.1);
}

.sidebar-nav .nav-link:hover span {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-nav .nav-link.active {
    color: var(--accent-color);
}

.sidebar-nav .nav-link.active:after {
    content: '';
    position: absolute;
    left: -12px;
    height: 5px;
    width: 5px;
    background: var(--accent-color);
    border-radius: 50%;
}

.sidebar-footer {
    margin-top: 15px;
}

.sidebar-footer button {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar-footer button:hover {
    color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb), 0.1);
}

/* Minimal Footer Styles */
.footer {
    background-color: var(--card-bg);
    padding: 30px 0;
    text-align: center;
    border-top: 1px solid rgba(var(--border-color-rgb), 0.5);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    border: none;
    outline: none;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s ease, background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.mobile-menu-btn.active {
    background-color: var(--primary-color);
    transform: rotate(180deg);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.social-links a {
    color: var(--text-color);
    opacity: 0.7;
    transition: all 0.3s ease;
}

.social-links a:hover {
    color: var(--accent-color);
    opacity: 1;
    transform: translateY(-3px);
}

.copy {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .container {
        margin-right: 0;
        padding: 0 20px;
    }
    
    .sidebar {
        top: 0;
        right: 0;
        width: 250px;
        height: 100%;
        flex-direction: column;
        padding: 20px 0;
        transform: translateX(100%);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 1001; /* Must be higher than overlay */
        border-radius: 0; /* Remove border radius on mobile */
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px 15px;
        position: relative;
    }
    
    .sidebar-header:after {
        content: "×";
        font-size: 28px;
        cursor: pointer;
        color: var(--text-color);
        opacity: 0.7;
        position: absolute;
        right: 20px;
        top: 5px;
    }
    
    .sidebar-footer {
        display: flex;
        justify-content: space-between;
        padding: 15px 20px 0;
    }
    
    .sidebar-nav {
        width: 100%;
    }
    
    .sidebar-nav ul {
        flex-direction: column;
    }
    
    .sidebar-nav li {
        margin: 5px 0;
    }
    
    .sidebar-nav .nav-link {
        padding: 12px 25px;
        justify-content: flex-start;
    }
    
    .sidebar-nav .nav-link span {
        display: inline-block;
        margin-left: 15px;
        opacity: 1;
        transform: translateX(0);
    }
    
    .sidebar-nav .nav-link.active:after {
        left: 0;
        top: 0;
        height: 100%;
        width: 3px;
        transform: none;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Mobile overlay to capture clicks outside sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999; /* Below sidebar but above content */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        pointer-events: none;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    /* Adjust sections for mobile view */
    section {
        padding: 60px 0;
        min-height: calc(100vh - 60px);
    }
    
    /* Make cards more readable on mobile */
    .project-card,
    .skill-card,
    .certification-card,
    .volunteer-card,
    .blog-card {
        padding: 20px;
    }
    
    /* Fix contact form layout */
    .contact-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    /* Optimize text sizes for mobile */
    h1 {
        font-size: 2.2rem;
    }
    
    h2 {
        font-size: 1.8rem;
    }
    
    h3 {
        font-size: 1.4rem;
    }
    
    /* Improve spacing in mobile view */
    .section-header {
        margin-bottom: 30px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    /* Further optimize for very small screens */
    .project-card,
    .skill-card,
    .certification-card,
    .volunteer-card,
    .blog-card {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.6rem;
    }
    
    /* Optimize buttons and links */
    .btn, .btn-sm {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    /* Make form elements easier to tap */
    input, textarea, button {
        padding: 12px;
    }
}

/* Hide overlay on larger screens */
@media (min-width: 769px) {
    .sidebar-overlay {
        display: none;
    }
}
