/* ============================================
   VISUAL POLISH ENHANCEMENTS
============================================ */

/* Particle Background Enhancement */
.particles-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity var(--transition-base);
}

@media (prefers-reduced-motion: reduce) {
  .particles-bg {
    opacity: 0.1;
  }
}

@media (max-width: 768px) {
  .particles-bg {
    opacity: 0.2;
  }
}

/* Hero Gradient Enhancement */
.hero-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  animation: gradient-shift 15s ease-in-out infinite alternate;
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .hero-gradient {
    animation: none;
  }
}

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

/* Enhanced Role Rotator */
.role-rotating {
  position: relative;
  display: inline-block;
  min-height: 1.2em;
}

.role-rotating::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.2em;
  background: var(--primary);
  animation: cursor-blink 1s infinite;
  border-radius: var(--radius-full);
}

@media (prefers-reduced-motion: reduce) {
  .role-rotating::after {
    animation: none;
    opacity: 0.7;
  }
}

@media (max-width: 768px) {
  .role-rotating::after {
    display: none;
  }
}

@keyframes cursor-blink {
  0%, 100% { 
    opacity: 1; 
  }
  50% { 
    opacity: 0; 
  }
}

/* Enhanced Tech Stack Responsive Fixes */
@media (max-width: 768px) {
  .tech-stack-showcase {
    padding: var(--space-md);
  }
  
  .tech-tags {
    justify-content: center;
  }
}

/* Highlight Word Animation Enhancement */
.highlight-word {
  position: relative;
  display: inline-block;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-weight: 500;
}

.highlight-word:hover {
  color: var(--primary);
  transform: translateY(-2px);
}

.highlight-word::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--transition-fast);
  border-radius: var(--radius-full);
}

.highlight-word:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Scroll Indicator Enhancement */
.scroll-indicator {
  position: absolute;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  animation: bounce 2s infinite;
  opacity: 0;
  animation: fade-in 0.8s ease-out 2.2s forwards, bounce 2s infinite 2.2s;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-indicator {
    animation: fade-in 0.8s ease-out 2.2s forwards;
  }
}

@media (max-width: 768px) {
  .scroll-indicator {
    display: none;
  }
}

.mouse {
  width: 30px;
  height: 50px;
  border: 2px solid var(--text-secondary);
  border-radius: 15px;
  position: relative;
}

.wheel {
  width: 4px;
  height: 10px;
  background: var(--primary);
  border-radius: var(--radius-full);
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  animation: scroll-wheel 2s infinite;
}

.arrow {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  animation: arrow-bounce 2s infinite;
}

@keyframes scroll-wheel {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

@keyframes arrow-bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-10px);
  }
  60% {
    transform: translateX(-50%) translateY(-5px);
  }
}

/* Enhanced Profile Image Loading States */
.profile-3d {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  background-size: 200% 200%;
  position: relative;
  transition: opacity var(--transition-base);
}

.profile-3d.loading {
  animation: skeleton-loading 1.5s infinite;
}

.profile-3d.loaded {
  animation: fade-in-scale 0.6s ease-out;
}

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

@keyframes fade-in-scale {
  from {
    opacity: 0;
    transform: translateZ(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateZ(20px) scale(1);
  }
}

/* Fallback for missing profile image */
.profile-3d:not([src]), 
.profile-3d[src=""] {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-4xl);
  font-weight: bold;
  overflow: hidden;
}

.profile-3d:not([src])::before, 
.profile-3d[src=""]::before {
  content: 'PK';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-family: var(--font-sans);
  font-weight: 800;
}

/* Enhanced Card Hover Effects */
.principle-card,
.project-card,
.contact-card,
.proof-card {
  transition: all var(--transition-base);
  will-change: transform;
}

.principle-card:hover,
.project-card:hover,
.contact-card:hover,
.proof-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  .principle-card:hover,
  .project-card:hover,
  .contact-card:hover,
  .proof-card:hover {
    transform: translateY(-4px) scale(1.01);
  }
}

/* Button Press Effects */
.cta-button:active {
  transform: scale(0.98);
}

.submit-button:active {
  transform: translateY(0) scale(0.98);
}

/* Card Click Effects */
.principle-card:active,
.project-card:active,
.contact-card:active {
  transform: translateY(-2px) scale(0.99);
}

/* Tech Tag Active States */
.tech-tag:focus-visible,
.metric:focus-visible,
.project-stack span:focus-visible,
.timeline-tech span:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================
   MOBILE-SPECIFIC ENHANCEMENTS
============================================ */
@media (max-width: 768px) {
  /* Hero Layout Fix */
  .hero-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    text-align: center;
  }
  
  .hero-visual {
    order: -1;
    margin-bottom: var(--space-xl);
    width: 100%;
    display: flex;
    justify-content: center;
  }
  
  /* Name Display Fix */
  .hero-name {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  
  .name-part-1, .name-part-2 {
    font-size: var(--text-4xl);
    line-height: 1.1;
  }
  
  /* Role Text Fix */
  .role-rotating-container {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  
  .role-rotating {
    min-width: 180px;
    text-align: center;
  }
  
  /* Profile Card Fix */
  .profile-3d-container {
    max-width: 280px;
  }
  
  .profile-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
  }
  
  .profile-stat {
    padding: var(--space-xs);
    text-align: center;
    flex-direction: column;
    gap: var(--space-2xs);
    align-items: center;
  }
  
  .profile-stat div {
    align-items: center;
  }
  
  /* Proof Cards Fix */
  .social-proof-live {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  /* Section Spacing */
  .section-header {
    margin-bottom: var(--space-2xl);
  }
  
  /* Timeline Fix */
  .timeline-item {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .timeline-item::before {
    display: none;
  }
  
  .timeline-date {
    text-align: center;
    width: 100%;
    margin-bottom: var(--space-sm);
  }
  
  /* Principle Cards */
  .principle-card {
    text-align: center;
    padding: var(--space-lg);
  }
  
  .principle-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .principle-metrics, 
  .principle-tech, 
  .principle-results {
    justify-content: center;
  }
  
  .principle-results {
    flex-direction: column;
    gap: var(--space-md);
  }
}

@media (max-width: 480px) {
  /* Extra Small Screen Fixes */
  .hero-greeting {
    font-size: var(--text-lg);
  }
  
  .role-rotating-container {
    gap: 0.25rem;
  }
  
  .role-prefix,
  .role-rotating,
  .role-suffix {
    font-size: var(--text-xl);
  }
  
  .hero-description {
    font-size: var(--text-base);
    padding: 0 var(--space-xs);
  }
  
  /* CTA Buttons */
  .cta-button {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-sm);
  }
  
  /* Contact Cards */
  .contact-card {
    flex-direction: column;
    text-align: center;
    align-items: center;
    padding: var(--space-lg);
  }
  
  .contact-icon {
    margin-bottom: var(--space-md);
  }
  
  /* Profile Stats */
  .profile-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2xs);
  }
  
  .profile-stat {
    padding: var(--space-2xs);
    font-size: var(--text-xs);
  }
  
  .stat-value {
    font-size: var(--text-xs);
  }
  
  .stat-label {
    font-size: 0.625rem;
  }
}

/* ============================================
   LIGHT MODE ENHANCEMENTS
============================================ */
.light-mode .proof-card,
.light-mode .principle-card,
.light-mode .project-card,
.light-mode .contact-card {
  background: white;
  border-color: var(--neutral-200);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.light-mode .tech-stack-showcase,
.light-mode .project-impact {
  background: var(--neutral-50);
  border-color: var(--neutral-200);
}

.light-mode .proof-bar,
.light-mode .tech-tag,
.light-mode .metric,
.light-mode .project-stack span,
.light-mode .timeline-tech span {
  background: var(--neutral-100);
}

.light-mode .role-rotating::after {
  background: var(--primary-dark);
}

.light-mode .hero-gradient {
  opacity: 0.5;
}

.light-mode .particles-bg {
  opacity: 0.3;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
============================================ */

/* Optimize animations for low-power devices */
@media (prefers-reduced-data: reduce) {
  .hero-gradient,
  .particles-bg {
    display: none;
  }
  
  .profile-3d-card {
    box-shadow: var(--shadow-lg);
  }
}

/* Optimize for mobile performance */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .principle-card,
  .project-card,
  .contact-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
}

/* ============================================
   SMOOTH TRANSITIONS
============================================ */
body,
.navbar,
.hero,
.about,
.projects,
.contact,
.footer {
  transition: 
    background-color var(--transition-slow) ease,
    color var(--transition-slow) ease,
    border-color var(--transition-slow) ease;
}

img {
  transition: 
    opacity var(--transition-base) ease,
    transform var(--transition-slow) ease;
}

.principle-card,
.project-card,
.contact-card,
.proof-card {
  transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   VISUAL EFFECTS
============================================ */

/* Subtle shadow on hover */
.tech-tag:hover,
.metric:hover,
.project-stack span:hover,
.timeline-tech span:hover {
  box-shadow: var(--shadow-sm);
}

/* Glow effect for active elements */
.tech-tag.active {
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

/* Subtle text shadow for better readability */
.section-title,
.hero-name,
.role-rotating {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .section-title,
  .hero-name,
  .role-rotating {
    text-shadow: none;
  }
}

/* Gradient border accents */
.principle-card::before {
  background: linear-gradient(
    to bottom,
    var(--primary),
    var(--primary-light),
    var(--primary-dark)
  );
}

/* Enhanced focus states for accessibility */
.tech-tag:focus,
.cta-button:focus,
.project-link:focus,
.social-link:focus,
.footer-link:focus {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  .tech-tag:focus,
  .cta-button:focus,
  .project-link:focus,
  .social-link:focus,
  .footer-link:focus {
    outline-offset: 2px;
  }
}

/* ============================================
   SCROLLBAR STYLES (Webkit browsers)
============================================ */
@media (min-width: 768px) {
  ::-webkit-scrollbar {
    width: 12px;
  }
  
  ::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: var(--radius-full);
  }
  
  ::-webkit-scrollbar-thumb {
    background: linear-gradient(
      to bottom,
      var(--primary),
      var(--primary-light)
    );
    border-radius: var(--radius-full);
    border: 3px solid var(--bg-primary);
  }
  
  ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
      to bottom,
      var(--primary-light),
      var(--primary)
    );
  }
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bg-primary);
}

/* ============================================
   PRINT STYLES ENHANCEMENT
============================================ */
@media print {
  .code-preview,
  .scroll-indicator,
  .social-proof-live,
  .tech-stack-showcase,
  .project-impact,
  .form-trust,
  .form-microcopy,
  .particles-bg,
  .hero-gradient,
  .profile-glare,
  .profile-badge,
  .animated-badge {
    display: none !important;
  }
  
  .proof-card,
  .principle-card,
  .project-card,
  .contact-card {
    break-inside: avoid;
    border: 1px solid #000 !important;
    box-shadow: none !important;
    margin-bottom: 1rem;
  }
  
  .proof-number,
  .impact-value,
  .result-value,
  .stat-value {
    -webkit-text-fill-color: black !important;
    color: black !important;
  }
  
  .animated-badge {
    border: 1px solid #000 !important;
    background: none !important;
    color: #000 !important;
  }
  
  .profile-3d {
    filter: grayscale(100%) contrast(120%);
  }
  
  a {
    color: black !important;
    text-decoration: underline !important;
  }
  
  .contact-link::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    opacity: 0.8;
  }
}

/* ============================================
   RESPONSIVE TYPOGRAPHY ENHANCEMENTS
============================================ */
@media (max-width: 768px) {
  /* Heading adjustments */
  .section-title {
    font-size: var(--text-3xl);
    line-height: var(--leading-tight);
  }
  
  .hero-name {
    font-size: var(--text-4xl);
  }
  
  .role-rotating {
    font-size: var(--text-2xl);
  }
  
  /* Paragraph adjustments */
  .hero-description,
  .section-description {
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
  }
  
  /* Card text adjustments */
  .principle-title,
  .project-header h3 {
    font-size: var(--text-xl);
  }
  
  .timeline-company {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  /* Further adjustments for very small screens */
  .section-title {
    font-size: var(--text-2xl);
  }
  
  .hero-name {
    font-size: var(--text-3xl);
  }
  
  .role-rotating {
    font-size: var(--text-xl);
  }
  
  .hero-description,
  .section-description {
    font-size: var(--text-base);
  }
  
  .principle-title,
  .project-header h3 {
    font-size: var(--text-lg);
  }
  
  .proof-number {
    font-size: var(--text-2xl);
  }
}

/* ============================================
   ERROR STATE STYLES
============================================ */
.error-input {
  border-color: var(--accent-error) !important;
  background: rgba(239, 68, 68, 0.05) !important;
}

.error-input:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* ============================================
   LOADING ANIMATIONS
============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-secondary) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* Image loading states */
img:not(.loaded) {
  opacity: 0;
}

img.loaded {
  opacity: 1;
  animation: fade-in 0.3s ease-out;
}

/* ============================================
   UTILITY CLASSES
============================================ */
.glass-effect {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glow-text {
  text-shadow: 0 0 20px rgba(99, 102, 241, 0.3),
               0 0 40px rgba(99, 102, 241, 0.2),
               0 0 60px rgba(99, 102, 241, 0.1);
}

.shadow-soft {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ============================================
   ANIMATION PERFORMANCE FIXES
============================================ */
/* Hardware acceleration for smooth animations */
.hero-container,
.profile-3d-card,
.principle-card,
.project-card,
.contact-card {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000;
}

/* Prevent animation on scroll when not in view */
@media (prefers-reduced-motion: no-preference) {
  .hero-container,
  .profile-3d-card {
    will-change: transform;
  }
}

/* ============================================
   FINAL TOUCHES
============================================ */
/* Ensure images don't overflow */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Smooth transitions for theme changes */
* {
  transition: background-color var(--transition-slow) ease,
              color var(--transition-slow) ease,
              border-color var(--transition-slow) ease;
}

/* Performance optimization */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Enhanced focus for keyboard navigation */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip link visible when focused */
.skip-link:focus {
  top: 0.5rem;
  left: 0.5rem;
  z-index: 9999;
}