/* ------------------------------------------------*/
/* Work With Me Button Component */
/* ------------------------------------------------*/

/* Base Button */
.qw-magical-button {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  margin-right: 4.5rem; /* Make space for back-to-top button */
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 2.5rem;
  min-width: 240px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(156, 163, 175, 0.25);
  border-radius: 24px;
  transition: all 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
}

/* Project Button Variant */
.qw-magical-button--project {
  position: static;
  margin: 0;
  width: auto;
  min-width: 330px; /* Increased by 50px */
  padding: 1.8rem 3.5rem; /* Further increased padding */
  gap: 1.4rem; /* Increased gap for better spacing */
  display: inline-flex;
  justify-content: center;
  font-size: 2rem; /* Increased font size */
}

.qw-magical-button--project i {
  font-size: 2.4rem;
  color: var(--t-bright);
  transition: all 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
}

/* White sparkles for project buttons */
.qw-magical-button--project .qw-sparkle {
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
}

/* CV Button Variant */
.qw-magical-button--cv {
  position: static;
  margin: 0;
  width: auto; /* Prevent stretching */
  max-width: 230px; /* Use max-width instead of min-width */
  padding: 1.4rem 2.4rem;
  gap: 1.2rem;
  display: inline-flex; /* Change to inline-flex to prevent full-width */
  justify-content: center; /* Center content */
}

.qw-magical-button--cv i {
  font-size: 2rem; /* Increased from 1.8rem */
  color: var(--t-bright);
  transition: all 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
}

/* Profile Photo */
.qw-magical-button__photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--stroke-elements);
  transition: transform 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
}

/* Button Text */
.qw-magical-button__text {
  font-family: var(--_font-default);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--t-bright);
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
}

/* Sparkle Container */
.qw-sparkles {
  position: absolute;
  inset: -15px; /* Reduced from -30px to bring sparkles closer */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1; /* Ensure sparkles appear above button */
}

/* Individual Sparkle */
.qw-sparkle {
  position: absolute;
  width: 20px; /* Base size slightly smaller */
  height: 20px;
  color: rgba(246, 198, 246, 0.9);
  filter: drop-shadow(0 0 4px rgba(246, 198, 246, 0.6));
  transform-origin: center;
  mix-blend-mode: screen;
}

/* Sparkle Positions and Sizes */
.qw-sparkle:nth-child(1) { 
  top: -5px; 
  left: 25%; 
  width: 28px; /* Larger top sparkle */
  height: 28px;
}
.qw-sparkle:nth-child(2) { 
  top: -5px; 
  right: 25%;
  width: 16px; /* Smaller top sparkle */
  height: 16px;
}
.qw-sparkle:nth-child(3) { 
  bottom: -5px; 
  left: 25%;
  width: 18px; /* Small-medium bottom sparkle */
  height: 18px;
}
.qw-sparkle:nth-child(4) { 
  bottom: -5px; 
  right: 25%;
  width: 24px; /* Medium-large bottom sparkle */
  height: 24px;
}
.qw-sparkle:nth-child(5) { 
  top: 50%; 
  left: -10px; 
  transform: translateY(-50%);
  width: 22px; /* Medium side sparkle */
  height: 22px;
}
.qw-sparkle:nth-child(6) { 
  top: 50%; 
  right: -10px; 
  transform: translateY(-50%);
  width: 26px; /* Large side sparkle */
  height: 26px;
}

/* Hover Effects */
@media (hover: hover) {
  /* Default gradient hover for Work With Me and CV buttons */
  .qw-magical-button--cv:hover,
  .qw-magical-button:not(.qw-magical-button--project):hover {
    transform: translateY(-2px);
    border-color: var(--stroke-controls);
    background: linear-gradient(135deg, #f6c6f6 0%, #b6d0f9 100%);
  }

  .qw-magical-button--cv:hover .qw-magical-button__text,
  .qw-magical-button--cv:hover i,
  .qw-magical-button:not(.qw-magical-button--project):hover .qw-magical-button__text,
  .qw-magical-button:not(.qw-magical-button--project):hover i {
    color: #151617;
  }

  /* White hover effect for project buttons */
  .qw-magical-button--project:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
  }

  .qw-magical-button--project:hover .qw-magical-button__text,
  .qw-magical-button--project:hover i {
    color: #ffffff;
  }

  .qw-magical-button:hover .qw-magical-button__photo {
    transform: scale(1.05);
  }

  .qw-magical-button:hover .qw-sparkles {
    opacity: 1;
  }

  /* Staggered sparkle animations */
  .qw-magical-button:hover .qw-sparkle:nth-child(1) { animation: sparkleIn 0.3s ease forwards, sparkleRotate 2s linear infinite; }
  .qw-magical-button:hover .qw-sparkle:nth-child(2) { animation: sparkleIn 0.4s ease forwards, sparkleRotate 2s linear infinite 0.2s; }
  .qw-magical-button:hover .qw-sparkle:nth-child(3) { animation: sparkleIn 0.5s ease forwards, sparkleRotate 2s linear infinite 0.4s; }
  .qw-magical-button:hover .qw-sparkle:nth-child(4) { animation: sparkleIn 0.6s ease forwards, sparkleRotate 2s linear infinite 0.6s; }
  .qw-magical-button:hover .qw-sparkle:nth-child(5) { animation: sparkleIn 0.7s ease forwards, sparkleRotate 2s linear infinite 0.8s; }
  .qw-magical-button:hover .qw-sparkle:nth-child(6) { animation: sparkleIn 0.8s ease forwards, sparkleRotate 2s linear infinite 1s; }
}

/* Sparkle Animations */
@keyframes sparkleRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Sparkle Fade Animation */
@keyframes sparkleIn {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Modal Styles */
.white-popup-block {
  position: relative;
  background: var(--bg-base); /* Uses theme background */
  padding: 0;
  width: auto;
  max-width: 680px;
  margin: 40px auto;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--stroke-elements);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Magnific Popup Integration */
.mfp-bg {
  background: #FFFFFF;
}

.mfp-fade.mfp-bg {
  opacity: 0;
  transition: all 0.3s ease-out;
}

.mfp-fade.mfp-bg.mfp-ready {
  opacity: 0.98;
}

/* Dark mode specific styles */
[color-scheme="dark"] .mfp-bg {
  background: rgba(0, 0, 0, 0.9);
}

[color-scheme="dark"] .white-popup-block {
  background: var(--bg-dark);
  border-color: var(--stroke-elements);
}

[color-scheme="dark"] .qw-modal__content,
[color-scheme="dark"] .qw-modal__input,
[color-scheme="dark"] .qw-modal__textarea {
  background: var(--bg-dark);
  color: var(--t-bright);
}

[color-scheme="dark"] .qw-modal__label {
  color: var(--t-bright);
}

.mfp-fade.mfp-bg.mfp-removing {
  opacity: 0;
}

.mfp-fade.mfp-wrap .mfp-content {
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease-out;
}

.mfp-fade.mfp-wrap.mfp-ready .mfp-content {
  opacity: 1;
  transform: scale(1);
}

.mfp-fade.mfp-wrap.mfp-removing .mfp-content {
  opacity: 0;
  transform: scale(0.8);
}

.mfp-with-zoom .mfp-container,
.mfp-with-zoom.mfp-bg {
  opacity: 0;
  backface-visibility: hidden;
  transition: all 0.3s ease-out;
}

.mfp-with-zoom.mfp-ready .mfp-container {
  opacity: 1;
}

.mfp-with-zoom.mfp-ready.mfp-bg {
  opacity: 0.9;
}

.mfp-with-zoom.mfp-removing .mfp-container,
.mfp-with-zoom.mfp-removing.mfp-bg {
  opacity: 0;
}

.qw-modal__content {
  position: relative;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: 32px;
  background: var(--bg-base);
  border-radius: 24px;
  color: var(--t-base); /* Uses theme text color */
  text-align: left;
}

/* Close button styling */
button.mfp-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px !important;
  height: 32px;
  background: var(--stroke-elements) !important;
  border-radius: 50%;
  border: none;
  color: var(--t-bright) !important;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1 !important;
  font-size: 0 !important; /* Hide the default × character */
  padding: 0 !important;
}

button.mfp-close:hover {
  background: var(--stroke-controls) !important;
  transform: scale(1.1);
}

button.mfp-close::before {
  content: "×";
  font-size: 24px;
  line-height: 32px;
  font-family: Arial, sans-serif;
}

.qw-modal__header {
  margin-bottom: 2.4rem;
  text-align: center;
}

.qw-modal__title {
  font-size: 2.4rem;
  margin-bottom: 1rem;
}

.qw-modal__subtitle {
  font-size: 1.6rem;
  opacity: 0.8;
}

.qw-modal__form {
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
}

.qw-modal__field {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.6rem;
}

.qw-modal__label {
  font-size: 1.4rem;
  color: var(--t-base);
  font-weight: 500;
}

.qw-modal__input,
.qw-modal__textarea {
  height: 48px;
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  background: var(--bg-base);
  border: 1px solid var(--stroke-elements);
  color: var(--t-base);
  font-size: 1.6rem;
  transition: all 0.3s ease;
  width: 100%;
}

.qw-modal__textarea {
  height: 120px; /* Reduced from 160px */
  resize: vertical;
  min-height: 80px;
}

.qw-modal__input:focus,
.qw-modal__textarea:focus {
  outline: none;
  border-color: var(--stroke-controls);
  box-shadow: 0 0 0 2px rgba(246, 198, 246, 0.1);
}

.qw-modal__button {
  height: 48px; /* Reduced from 60px */
  background: linear-gradient(135deg, #f6c6f6 0%, #b6d0f9 100%);
  border: none;
  border-radius: 12px;
  color: var(--bg-dark);
  font-size: 1.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 0.8rem;
}

.qw-modal__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(246, 198, 246, 0.2);
}

/* Form response messages */
.qw-modal__form-response {
  display: none;
  margin-top: 1.6rem;
  padding: 1.2rem;
  border-radius: 8px;
  font-size: 1.4rem;
  text-align: center;
}

.qw-modal__form-response.success {
  display: block;
  background: rgba(52, 211, 153, 0.1);
  color: #34D399;
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.qw-modal__form-response.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

@media (max-width: 767px) {
  .qw-modal__content {
    margin: 20px;
    padding: 30px 20px;
  }
  
  .qw-modal__input,
  .qw-modal__textarea,
  .qw-modal__button {
    font-size: 1.6rem;
  }
}

/* Global Link Sparkles */
.qw-link-sparkles {
  position: absolute;
  inset: -8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1;
}

.qw-link-sparkle {
  position: absolute;
  width: 12px;
  height: 12px;
  color: rgba(44, 46, 52, 0.3); /* Default light mode color */
  filter: drop-shadow(0 0 2px rgba(44, 46, 52, 0.15));
  transform-origin: center;
  mix-blend-mode: multiply;
}

/* Light mode sparkle positions (4 larger sparkles) */
.qw-link-sparkle:nth-child(1) { top: -6px; left: 20%; width: 14px; height: 14px; }
.qw-link-sparkle:nth-child(2) { top: -4px; right: 20%; width: 10px; height: 10px; }
.qw-link-sparkle:nth-child(3) { bottom: -5px; left: 30%; width: 12px; height: 12px; }
.qw-link-sparkle:nth-child(4) { bottom: -6px; right: 30%; width: 14px; height: 14px; }

/* Hide extra sparkles */
.qw-link-sparkle:nth-child(n+5) { display: none; }

/* Link hover effects */
@media (hover: hover) {
  [data-qw-sparkles] {
    position: relative;
  }

  [data-qw-sparkles]:hover .qw-link-sparkles {
    opacity: 1;
  }

  /* Staggered sparkle animations */
  [data-qw-sparkles]:hover .qw-link-sparkle:nth-child(1) { animation: linkSparkleIn 0.2s ease forwards, microSparkle 2s ease infinite 0.1s; }
  [data-qw-sparkles]:hover .qw-link-sparkle:nth-child(2) { animation: linkSparkleIn 0.2s ease forwards, microSparkle 2s ease infinite 0.4s; }
  [data-qw-sparkles]:hover .qw-link-sparkle:nth-child(3) { animation: linkSparkleIn 0.2s ease forwards, microSparkle 2s ease infinite 0.2s; }
  [data-qw-sparkles]:hover .qw-link-sparkle:nth-child(4) { animation: linkSparkleIn 0.2s ease forwards, microSparkle 2s ease infinite 0.3s; }
}

/* Dark mode sparkle styles */
[color-scheme="dark"] .qw-link-sparkle {
  color: rgba(255, 255, 255, 0.4);
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.2));
  mix-blend-mode: screen;
}

/* Micro sparkle animations */
@keyframes linkSparkleIn {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes microSparkle {
  0% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
}

/* Focus States */
.qw-magical-button:focus {
  outline: none;
}

.qw-magical-button:focus-visible {
  outline: 2px solid var(--stroke-controls);
  outline-offset: 4px;
}

/* Responsive Styles */
@media only screen and (max-width: 767px) {
  .qw-magical-button {
    padding: 1.2rem 2rem;
    min-width: 220px;
    gap: 1.2rem;
  }
  
  .qw-magical-button__photo {
    width: 48px;
    height: 48px;
  }
  
  .qw-magical-button__text {
    font-size: 1.6rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .qw-magical-button,
  .qw-magical-button__photo,
  .qw-magical-button__text,
  .qw-sparkles,
  .qw-sparkle {
    transition: none;
    animation: none;
  }
  
  .qw-magical-button:hover {
    transform: none;
  }
  
  .qw-magical-button:hover .qw-magical-button__photo {
    transform: none;
  }
}
