/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-alt: #f1f5f9;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-neon: 0 0 20px rgba(37, 99, 235, 0.3);
    --transition: all 0.3s ease;
    --transition-slow: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto !important;
    }
}

/* Optimizaciones para dispositivos de bajos recursos */
.low-end-device .floating,
.low-end-device .parallax,
.low-end-device .morphing {
    animation: none !important;
    transform: none !important;
}

.low-end-device::before,
.low-end-device::after {
    display: none !important;
}

.reduced-motion .floating,
.reduced-motion .parallax,
.reduced-motion .fade-in-up,
.reduced-motion .fade-in-left,
.reduced-motion .fade-in-right {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Focus visible para mejor accesibilidad */
.focus-visible:focus {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
}

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    border-radius: 4px;
    text-decoration: none;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 6px;
}

/* Focus visible para accesibilidad */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link para accesibilidad */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    z-index: 9999;
    text-decoration: none;
    border-radius: 4px;
}

.skip-link:focus {
    top: 6px;
}

/* Header y Navegación */
.header {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

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

.nav-brand h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.nav-menu a:hover {
    color: var(--primary-color);
    background-color: var(--bg-alt);
}

/* Hero Section */
.hero {
    background: var(--gradient-1);
    color: white;
    padding: 8rem 2rem 4rem;
    text-align: center;
    margin-top: 70px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 400;
    opacity: 0.9;
}

.location {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.8;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    border: 2px solid transparent;
}

.btn-primary {
    background-color: white;
    color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--bg-alt);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    color: white;
    border-color: white;
}

.btn-secondary:hover {
    background-color: white;
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Secciones */
.section {
    padding: 4rem 2rem;
}

.bg-alt {
    background-color: var(--bg-alt);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
    text-align: center;
}

.section p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Grid de Habilidades */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.skill-category {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.skill-category:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.skill-category h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.skill-category ul {
    list-style: none;
}

.skill-category ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.skill-category ul li:last-child {
    border-bottom: none;
}

/* Experiencia */
.experience-item {
    background: var(--bg-primary);
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.experience-item h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.period {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
}

.experience-item ul {
    margin-left: 1.5rem;
}

.experience-item ul li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Educación */
.education-item {
    background: var(--bg-primary);
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.education-item h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.certifications {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.certifications h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.certifications ul {
    margin-left: 1.5rem;
}

.certifications ul li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Contacto */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.contact-info, .portfolio-links {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.contact-info h3, .portfolio-links h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.contact-info ul, .portfolio-links ul {
    list-style: none;
}

.contact-info ul li, .portfolio-links ul li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portfolio-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portfolio-links a:hover {
    color: var(--primary-color);
}

/* Quote */
.quote {
    text-align: center;
    background: var(--bg-primary);
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.quote blockquote {
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.8;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 2rem;
}

.footer p {
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

/* Nuevas Animaciones y Efectos */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
    }
}

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

/* Nuevas animaciones mejoradas */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(0);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-200deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.3); }
    70% { transform: scale(1); }
}

@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary-color);
    }
}

@keyframes glow {
    0%, 100% {
        text-shadow: 0 0 5px var(--primary-color), 
                     0 0 10px var(--primary-color), 
                     0 0 15px var(--primary-color);
    }
    50% {
        text-shadow: 0 0 10px var(--primary-color), 
                     0 0 20px var(--primary-color), 
                     0 0 30px var(--primary-color);
    }
}

@keyframes wiggle {
    0%, 7% {
        transform: rotateZ(0);
    }
    15% {
        transform: rotateZ(-15deg);
    }
    20% {
        transform: rotateZ(10deg);
    }
    25% {
        transform: rotateZ(-10deg);
    }
    30% {
        transform: rotateZ(6deg);
    }
    35% {
        transform: rotateZ(-4deg);
    }
    40%, 100% {
        transform: rotateZ(0);
    }
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes morphing {
    0%, 100% {
        border-radius: 40% 50% 30% 70%;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 20% 60% 40% 80%;
        transform: rotate(90deg);
    }
    50% {
        border-radius: 80% 20% 60% 40%;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 50% 70% 20% 30%;
        transform: rotate(270deg);
    }
}

/* Efectos de hover mejorados */
.skill-category {
    position: relative;
    overflow: hidden;
}

.skill-category::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.skill-category:hover::before {
    left: 100%;
}

.skill-category:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-neon);
    transition: var(--transition-slow);
}

.skill-category:nth-child(1) {
    animation: slideInLeft 0.8s ease forwards;
}

.skill-category:nth-child(2) {
    animation: bounceIn 1s ease forwards 0.2s;
    opacity: 0;
}

.skill-category:nth-child(3) {
    animation: slideInRight 0.8s ease forwards 0.4s;
    opacity: 0;
}

.experience-item {
    position: relative;
    overflow: hidden;
}

.experience-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-3);
    opacity: 0;
    transition: all 0.6s ease;
    z-index: -1;
}

.experience-item:hover::after {
    left: 0;
    opacity: 0.9;
}

.experience-item:hover {
    transform: translateX(10px);
    box-shadow: var(--shadow-neon);
    color: white;
    transition: var(--transition-slow);
}

.experience-item:hover h3,
.experience-item:hover .period,
.experience-item:hover ul li {
    color: white;
    z-index: 2;
    position: relative;
}

/* Animaciones para diferentes elementos */
.hero-content h1 {
    animation: glow 2s ease-in-out infinite alternate;
}

.hero-buttons .btn:first-child {
    animation: heartbeat 2s ease-in-out infinite;
}

.hero-buttons .btn:nth-child(2) {
    animation: pulse 2s infinite;
}

.hero-buttons .btn:last-child {
    animation: wiggle 3s ease-in-out infinite;
}

/* Efectos de partículas CSS */
.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 40% 20%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 60% 80%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 80% 40%, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 300px 300px, 200px 200px, 250px 250px, 350px 350px;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

/* Gradientes de texto */
.gradient-text {
    background: var(--gradient-2);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 3s ease infinite;
}

.hero-content h1 {
    background: linear-gradient(45deg, #fff, #e0e7ff, #fff);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 2s ease infinite;
}

/* Parallax scrolling effect */
.parallax {
    transform: translateZ(0);
    will-change: transform;
}

/* Loading animations */
.fade-in-up {
    animation: slideInUp 0.6s ease forwards;
}

.fade-in-left {
    animation: slideInLeft 0.6s ease forwards;
}

.fade-in-right {
    animation: slideInRight 0.6s ease forwards;
}

/* Floating elements */
.floating {
    animation: float 6s ease-in-out infinite;
}

.floating:nth-child(2) {
    animation-delay: -2s;
}

.floating:nth-child(3) {
    animation-delay: -4s;
}

/* Pulse effect for buttons */
.btn-primary {
    animation: pulse 2s infinite;
}

.btn-primary:hover {
    animation: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-neon);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-alt);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.project-card {
    background: var(--bg-primary);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition-slow);
    border: 1px solid var(--border-color);
    position: relative;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(37, 99, 235, 0.1) 0%, 
        rgba(124, 58, 237, 0.1) 50%, 
        rgba(59, 130, 246, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.project-card:hover::before {
    opacity: 1;
}

.project-card:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: var(--shadow-neon);
}

.project-image {
    background: var(--gradient-2);
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.project-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.8s ease;
}

.project-card:hover .project-image::after {
    left: 100%;
}

.project-icon {
    font-size: 3rem;
    color: white;
    opacity: 0.9;
    transition: transform 0.3s ease;
}

.project-card:hover .project-icon {
    transform: scale(1.1) rotate(5deg);
}

.project-content {
    padding: 1.5rem;
}

.project-content h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.project-card:hover .project-content h3 {
    color: var(--accent-color);
}

.project-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tech-tag {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.project-card:hover .tech-tag {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.project-features {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-alt);
    border-radius: 0.5rem;
    border-left: 3px solid var(--primary-color);
}

.project-features h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-features ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.project-features li {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-features li::before {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    flex-shrink: 0;
}

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

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: 0.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.project-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    transition: left 0.3s ease;
    z-index: -1;
}

.project-link:hover::before {
    left: 0;
}

.project-link:hover {
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.project-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

.project-link.disabled:hover {
    background: none;
    color: var(--text-secondary);
    transform: none;
    box-shadow: none;
}

.project-link.disabled::before {
    display: none;
}

/* Animaciones específicas para las tarjetas de proyectos */
.project-card:nth-child(1) {
    animation: slideInLeft 0.8s ease forwards;
}

.project-card:nth-child(2) {
    animation: slideInUp 0.8s ease forwards 0.2s;
    opacity: 0;
}

.project-card:nth-child(3) {
    animation: slideInRight 0.8s ease forwards 0.4s;
    opacity: 0;
}

.project-card:nth-child(4) {
    animation: bounceIn 1s ease forwards 0.6s;
    opacity: 0;
}

.project-card:nth-child(5) {
    animation: zoomIn 0.8s ease forwards 0.8s;
    opacity: 0;
}

.project-card:nth-child(6) {
    animation: rotateIn 1s ease forwards 1s;
    opacity: 0;
}

/* Modo oscuro */
[data-theme="dark"] {
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-alt: #334155;
    --border-color: #475569;
}

[data-theme="dark"] .project-card {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Performance optimizations */
.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.loaded {
    opacity: 1;
}

/* Critical CSS optimizations */
.above-fold {
    will-change: auto;
}

/* Reduce layout shift */
img {
    aspect-ratio: attr(width) / attr(height);
}

/* Improve scrolling performance */
* {
    scroll-behavior: smooth;
}

/* PWA Install Button */
.install-prompt {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gradient-2);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    box-shadow: var(--shadow-neon);
    transform: translateX(200px);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.install-prompt.show {
    transform: translateX(0);
}

.install-prompt:hover {
    transform: translateY(-2px) translateX(0);
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.5);
}

/* Loading states */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Dark theme skeleton */
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 10000;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.show {
    transform: translateX(0);
}

/* Improved focus states for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --text-primary: #000000;
        --text-secondary: #333333;
        --bg-primary: #ffffff;
        --border-color: #000000;
    }
    
    .btn {
        border: 2px solid #000000;
    }
    
    .project-card {
        border: 2px solid #000000;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .floating,
    .parallax,
    .fade-in-up,
    .fade-in-left,
    .fade-in-right {
        animation: none !important;
        transform: none !important;
    }
    
    .skill-category:hover,
    .experience-item:hover,
    .project-card:hover {
        transform: none !important;
    }
}

/* Focus management for keyboard navigation */
.nav-menu a:focus,
.hero-buttons a:focus,
.project-link:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
    background-color: var(--bg-alt);
}

/* Color contrast improvements */
.text-contrast-high {
    color: #000000;
    background-color: #ffffff;
}

[data-theme="dark"] .text-contrast-high {
    color: #ffffff;
    background-color: #000000;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .hero {
        background: white !important;
        color: black !important;
    }
    
    .project-card,
    .skill-category,
    .experience-item {
        border: 1px solid #000000 !important;
        box-shadow: none !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .hero {
        padding: 6rem 1rem 3rem;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-content h2 {
        font-size: 1.2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .section {
        padding: 3rem 1rem;
    }
    
    .section h2 {
        font-size: 2rem;
    }
    
    .skills-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.5rem;
    }
    
    .hero-content h2 {
        font-size: 1rem;
    }
    
    .section h2 {
        font-size: 1.5rem;
    }
}