/* Force Container Constraints */
* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

.max-w-6xl {
  max-width: min(72rem, calc(100vw - 2rem)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

@media (max-width: 640px) {
  .max-w-6xl {
    max-width: 100vw !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(to right, blue, purple);
  width: 0%;
  transition: width 0.1s;
}

body {
  transition: background-color 0.5s ease-in-out,
    color 0.5s ease-in-out;
}

@media (max-width: 768px) {
  header {
    padding: 1.5rem 0;
  }

  .hero-text h1 {
    font-size: 2.2rem;
  }
}

#quoteText,
#quoteAuthor {
  transition: opacity 0.15s ease-in-out;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
    opacity: 0.3;
  }

  33% {
    transform: translateY(-10px) rotate(120deg);
    opacity: 0.7;
  }

  66% {
    transform: translateY(5px) rotate(240deg);
    opacity: 0.5;
  }
}

.profile-image-placeholder {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

.profile-image-placeholder::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.profile-glow {
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.3);
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
    opacity: 0.3;
  }

  33% {
    transform: translateY(-10px) rotate(120deg);
    opacity: 0.7;
  }

  66% {
    transform: translateY(5px) rotate(240deg);
    opacity: 0.5;
  }
}

@keyframes typing {
  from {
    width: 0
  }

  to {
    width: 100%
  }
}

@keyframes blink {
  50% {
    border-color: transparent
  }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}


#cardContent {
  transition: opacity 0.15s ease-in-out;
}

:root {
  animation-duration: 0.3s;
}

/* Enhanced mobile menu animations */
#mobileMenu {
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
}

/* Backdrop blur effect when menu is open */
#mobileMenu::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: -1;
}

#mobileMenu[data-open="true"]::before {
  opacity: 1;
  pointer-events: auto;
}

/* A NOTE AWAY CSS*/

@keyframes float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* Mesh gradients for sections */
section {
  background: radial-gradient(at 50% 0%, rgba(59, 130, 246, 0.1), transparent 50%);
}

/* FOR float animation in CONTACT Section*/
@keyframes float {

  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
    opacity: 0.3;
  }

  33% {
    transform: translateY(-10px) rotate(120deg);
    opacity: 0.7;
  }

  66% {
    transform: translateY(5px) rotate(240deg);
    opacity: 0.5;
  }
}

/* Certificate Modal Animations */
#certModal {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

#certModal.flex {
  opacity: 1;
}

/* Certificate Cards Hover Effects 
#certifications .group:hover {
  animation: subtle-float 2s;
}*/

@keyframes subtle-float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-8px) scale(1.03);
  }
}

/* CHATBOT */
* {
  -webkit-tap-highlight-color: transparent;
}

@keyframes slideUp {
  from {
    transform: translateY(100%) scale(0.8);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  to {
    transform: translateY(100%) scale(0.8);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes typing-dot {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

@keyframes slideInFromBottom {
  from {
    transform: translateY(100px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modalShow {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes voicePulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

.chat-message {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget {
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.closing {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.6, 1);
}

.typing-indicator span {
  animation: typing-dot 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

.chat-scroll {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.chat-scroll::-webkit-scrollbar {
  width: 6px;
}

.chat-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}

.chat-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.4), rgba(147, 51, 234, 0.4));
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.quick-action {
  transition: all 0.3s ease;
}

.quick-action:hover {
  transform: translateY(-2px);
}

.quick-action:active {
  transform: translateY(0);
}

.compact-mode {
  height: 280px;
}

.expanded-mode {
  height: min(450px, calc(100vh - 8rem));
}

.full-mode {
  height: min(600px, calc(100vh - 8rem));
}

.chat-widget {
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.touch-manipulation {
  -webkit-user-select: none;
  user-select: none;
}

.error-shake {
  animation: shake 0.3s cubic-bezier(0.4, 0, 0.6, 1);
}

#scrollToTop {
  transition: opacity 0.3s, transform 0.3s;
}

#scrollToTop.show {
  opacity: 1 !important;
  pointer-events: auto !important;
}

#clearChatModal.show {
  display: flex !important;
}

#clearChatModal.show #clearChatModalContent {
  animation: modalShow 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform: scale(1);
  opacity: 1;
}

.voice-recording {
  animation: voicePulse 1s infinite;
}

.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;
}

@media (max-width: 640px) {
  #chatButton {
    bottom: 5rem !important;
    right: 1rem !important;
    width: 56px !important;
    height: 56px !important;
  }

  /* Add bottom padding to footer */
  footer {
    padding-bottom: 6rem !important;
  }

  /* Adjust chat widget position */
  #chat-widget {
    bottom: 11rem !important;
  }

  @media (max-width: 640px) {
    .chat-widget {
      bottom: 5rem !important;
      right: 0.5rem !important;
      left: 0.5rem !important;
      width: calc(100vw - 1rem) !important;
      max-width: none !important;
    }

    .compact-mode {
      height: 240px;
    }

    .expanded-mode {
      height: calc(50vh);
    }

    .full-mode {
      height: calc(100vh - 10rem);
      max-height: calc(100vh - 10rem);
    }

    #scrollToTop {
      bottom: 90px !important;
      right: 1rem !important;
    }

    input {
      font-size: 16px !important;
    }

    button {
      min-height: 44px;
      min-width: 44px;
    }
  }

  @media (min-width: 641px) and (max-width: 1024px) {
    .chat-widget {
      width: 360px !important;
    }

    .compact-mode {
      height: 260px;
    }

    .expanded-mode {
      height: min(420px, calc(100vh - 8rem));
    }

    .full-mode {
      height: min(550px, calc(100vh - 8rem));
    }
  }

  @media (max-height: 500px) and (orientation: landscape) {
    .chat-widget {
      height: calc(100vh - 6rem) !important;
      max-height: calc(100vh - 6rem) !important;
    }

    .compact-mode {
      height: 180px;
    }

    .expanded-mode {
      height: calc(100vh - 8rem);
    }

    .full-mode {
      height: calc(100vh - 6rem);
      max-height: calc(100vh - 6rem);
    }
  }

  @media (prefers-color-scheme: dark) {
    .chat-scroll::-webkit-scrollbar-thumb {
      background: rgba(139, 92, 246, 0.4);
    }
  }

  /* Fix Project Buttons on Mobile */
  @media (max-width: 640px) {
    #projects .flex.flex-wrap.gap-4 {
      flex-direction: column !important;
      gap: 0.75rem !important;
    }

    #projects a[href*="github"],
    #projects a[href*="vercel"],
    #projects a[href*="rakuten"],
    #projects a[href*="saucedemo"] {
      width: 100% !important;
      justify-content: center !important;
      font-size: 0.875rem !important;
      padding: 0.625rem 1rem !important;
    }
  }

  /* Fix Grid Stacking Issues */
  @media (max-width: 768px) {

    /* Skills Section */
    #skills .grid-cols-2.md\:grid-cols-3.lg\:grid-cols-4 {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: 0.75rem !important;
    }

    /* Certifications Grid */
    #certifications .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
      grid-template-columns: 1fr !important;
      gap: 1rem !important;
    }

    #certifications .grid {
      padding: 0 0.5rem;
    }
  }

  /* Prevent Text Overflow */
  @media (max-width: 640px) {

    /* Project Descriptions */
    #projects p {
      font-size: 0.813rem !important;
      line-height: 1.4 !important;
      overflow-wrap: break-word !important;
      word-break: break-word !important;
    }

    /* Project Titles */
    #projects h3 {
      font-size: 1.25rem !important;
      line-height: 1.3 !important;
    }

    /* Skills Text */
    #skills .text-sm {
      font-size: 0.75rem !important;
    }

    /* About Section */
    #about p {
      font-size: 0.875rem !important;
      line-height: 1.5 !important;
    }
  }
}

/* Fix Contact Form Inputs */
@media (max-width: 640px) {

  #contactForm input,
  #contactForm textarea {
    font-size: 16px !important;
    /* Prevents iOS zoom */
    padding: 0.75rem !important;
    width: 100% !important;
  }

  #contactForm button[type="submit"] {
    width: 100% !important;
    padding: 0.875rem !important;
    font-size: 1rem !important;
  }
}

/* Fix About Section Stats Grid */
@media (max-width: 640px) {
  #about .grid-cols-2.md\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  #about .grid-cols-1.md\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Fix service cards */
  #about .text-2xl {
    font-size: 1.5rem !important;
  }

  #about .text-sm {
    font-size: 0.813rem !important;
  }
}

/* Prevent Image Distortion */
@media (max-width: 768px) {

  #projects img,
  #certifications img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
  }

  #projects .relative.h-80 {
    height: auto !important;
    min-height: 200px !important;
    max-height: 300px !important;
  }
}

/* Emergency Responsive Override */
@media (max-width: 640px) {
  section {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .rounded-3xl {
    border-radius: 1rem !important;
  }

  .gap-8 {
    gap: 1rem !important;
  }

  .gap-6 {
    gap: 0.75rem !important;
  }

  .p-8 {
    padding: 1.25rem !important;
  }

  .text-3xl {
    font-size: 1.5rem !important;
  }

  .text-2xl {
    font-size: 1.25rem !important;
  }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    #2a2a2a 25%,
    #1a1a1a 50%,
    #2a2a2a 75%
  );
  background-size: 200% 100%;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Apply to images */
img {
  background: #f0f0f0;
}

img:not([src]), img[src=""] {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes blob {
    0%, 100% {
      transform: translate(0, 0) scale(1);
    }
    33% {
      transform: translate(30px, -50px) scale(1.1);
    }
    66% {
      transform: translate(-20px, 20px) scale(0.9);
    }
  }

  .animate-blob {
    animation: blob 7s infinite;
  }

  .animation-delay-2000 {
    animation-delay: 2s;
  }

  .animation-delay-4000 {
    animation-delay: 4s;
  }