/* Common/Shared Component Styles */

/* Common styles */
.section-padding { 
    background-color: var(--bg-color);
    padding: var(--section-padding);
    width: 100%;
}

.container { 
    max-width: var(--container-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--container-padding, 2rem);
}

/* Component-specific Variables */
:root {
    /* Hero Section */
    --hero-grid-opacity: 0.05;
    --hero-gradient-opacity: 0.1;
    
    /* Card Properties */
    --card-hover-opacity: 0.2;
    --card-border-opacity: 0.1;
    
    /* Carousel */
    --carousel-inactive-opacity: 0.8;
    --carousel-active-opacity: 1;
    
    /* Timeline */
    --timeline-border-opacity: 0.1;
    --timeline-dot-size: 0.8rem;
}

/* Core Components */
.text-accent { color: var(--accent-color); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.bg-primary { background: var(--primary-color); }
.bg-secondary { background: var(--secondary-color); }
.border-accent { border-color: var(--accent-color); }

/* Common effects */
.hover-translate:hover { transform: translateY(-5px); }
.hover-scale:hover { transform: scale(1.05); }
.hover-glow:hover {
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.3);
}

/* Performance-optimized Animations */
@keyframes orbit {
    from { transform: rotate3d(0, 0, 1, 0deg); }
    to { transform: rotate3d(0, 0, 1, 360deg); }
}

@keyframes pulse {
    0%, 100% { 
        transform: scale3d(1, 1, 1);
        opacity: 0.5;
    }
    50% { 
        transform: scale3d(1.2, 1.2, 1.2);
        opacity: 1;
    }
}

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

@keyframes slowRotate {
    from { transform: rotate3d(0, 0, 1, 0deg); }
    to { transform: rotate3d(0, 0, 1, 360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-20px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

@keyframes pulseGrid {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.5; 
    }
    50% { 
        transform: scale(1.5); 
        opacity: 0.8; 
    }
}

@keyframes typedjsBlink {
    50% { opacity: 0.0; }
}

/* Add will-change hints for animated elements */
.orbit,
.floating-card,
.tech-item,
.project-card,
.skill-item {
    will-change: transform;
    transform: translateZ(0);
}

.fade-up,
.fade-in {
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Section layouts */
section {
    padding: 4rem 0;
    position: relative;
}

section > h2 {
    text-align: center;
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 3rem;
    color: var(--text-primary);
    position: relative;
}

section > h2::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 3px;
}

/* Focus states */
.nav-links a:focus-visible,
.project-links a:focus-visible,
.social-links a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Utilities */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== TRANSITIONS & ANIMATIONS ===== */

/* Premium Transitions */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Premium Section Transitions */
.section-transition {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-transition.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Premium Light Theme Transition Adjustments */
body.light-theme .section-transition {
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.7s cubic-bezier(0.5, 0, 0, 1), 
              opacity 0.7s cubic-bezier(0.5, 0, 0, 1);
}

body.light-theme .section-transition:not(.visible) {
  transform: translateY(30px);
  opacity: 0;
}

/* Staggered children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.stagger-children.visible > * {
    opacity: 1;
    transform: translateY(0);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.5s; }

/* Section reveal animations */
.reveal-up {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-up.visible {
    clip-path: inset(0 0 0 0);
}

.reveal-scale {
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-scale.visible {
    transform: scale(1);
    opacity: 1;
}

/* Refined glow effects for terracotta theme */
body.light-theme .glow-on-hover:hover {
  box-shadow: 0 5px 15px rgba(201, 100, 66, 0.2);
}

body.light-theme .button-glow:hover {
  box-shadow: 0 0 15px rgba(201, 100, 66, 0.5);
}

/* Performance-optimized Animations */
@keyframes orbit {
    from { transform: rotate3d(0, 0, 1, 0deg); }
    to { transform: rotate3d(0, 0, 1, 360deg); }
}

@keyframes pulse {
    0%, 100% { 
        transform: scale3d(1, 1, 1);
        opacity: 0.5;
    }
    50% { 
        transform: scale3d(1.2, 1.2, 1.2);
        opacity: 1;
    }
}

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

@keyframes slowRotate {
    from { transform: rotate3d(0, 0, 1, 0deg); }
    to { transform: rotate3d(0, 0, 1, 360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-20px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

@keyframes pulseGrid {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.5; 
    }
    50% { 
        transform: scale(1.5); 
        opacity: 0.8; 
    }
}

@keyframes typedjsBlink {
    50% { opacity: 0.0; }
}

/* Add will-change hints for animated elements */
.orbit,
.floating-card,
.tech-item,
.project-card,
.skill-item {
    will-change: transform;
    transform: translateZ(0);
}

.fade-up,
.fade-in {
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Section layouts */
section {
    padding: 4rem 0;
    position: relative;
}

section > h2 {
    text-align: center;
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 3rem;
    color: var(--text-primary);
    position: relative;
}

section > h2::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 3px;
}

/* Focus states */
.nav-links a:focus-visible,
.project-links a:focus-visible,
.social-links a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Utilities */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Loading States */
.loading-state {
    position: relative;
    overflow: hidden;
}

.loading-state::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent,
        rgba(100, 255, 218, 0.1),
        transparent
    );
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

/* Hardware acceleration for smooth animations */
.hardware-accelerated {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

/* Enhanced image loading */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

img.loaded {
    opacity: 1;
}

/* Print styles */
@media print {
    .navbar,
    .carousel-btn,
    #back-to-top,
    .social-links {
        display: none !important;
    }
    
    .hero,
    .projects,
    .contact {
        break-inside: avoid;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* 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) {
    .project-card,
    .skill-category,
    .certificate-card {
        border: 2px solid var(--accent-color);
    }
}

/* Reduce motion preferences */
@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .section-transition,
    .stagger-children > *,
    .reveal-up,
    .reveal-scale,
    .hero-content,
    .spline-container {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
        clip-path: none !important;
        animation: none !important;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .hover-translate:hover,
    .hover-scale:hover,
    .hover-glow:hover {
        transform: none;
        box-shadow: none;
    }
    
    .project-card:hover,
    .skill-item:hover,
    .certificate-card:hover {
        transform: none;
    }
}

/* Light theme adjustments for common components */
body.light-theme section > h2::after {
    background: var(--light-accent);
}

body.light-theme .text-accent {
    color: var(--light-accent);
}

body.light-theme .text-primary {
    color: var(--light-text-primary);
}

body.light-theme .text-secondary {
    color: var(--light-text-secondary);
}

body.light-theme .bg-primary {
    background: var(--light-primary);
}

body.light-theme .bg-secondary {
    background: var(--light-secondary);
}

body.light-theme .border-accent {
    border-color: var(--light-accent);
}

body.light-theme .hover-glow:hover {
    box-shadow: 0 0 20px rgba(201, 100, 66, 0.3);
}

body.light-theme .loading-state::after {
    background: linear-gradient(90deg, 
        transparent,
        rgba(201, 100, 66, 0.1),
        transparent
    );
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-color);
    color: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(100, 255, 218, 0.3);
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 25px rgba(100, 255, 218, 0.4);
    background: var(--highlight-color);
}

#back-to-top:active {
    transform: translateY(-1px) scale(1.05);
}

/* Mobile optimizations for back-to-top */
@media (max-width: 768px) {
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #back-to-top {
        bottom: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
    }
}
