/* ===========================
   CONTACT — Aurora + Glass UI (responsive)
   Fixed: removed backdrop-filter jitter on mobile
   =========================== */

/* fallbacks if core vars aren’t present */
:root {
  --contact-accent: #44ccff;
  --contact-accent-2: #60ffa8;
  --contact-bg-deep: #0b101d;
  --contact-bg-mid: #0e1424;
  --contact-text: #e9f3ff;
  --contact-text-dim: #a9b4c7;
  --contact-border: rgba(255,255,255,.14);
  --contact-shadow: 0 20px 60px rgba(0,0,0,.45);
}

/* Section frame */
#contact {
  position: relative;
  padding: clamp(48px, 7vw, 96px) 0;
  overflow: clip;
  background:
    radial-gradient(1200px 800px at 50% 5%, var(--contact-bg-mid) 0%, var(--contact-bg-deep) 65%);
  isolation: isolate; /* let our layers mix cleanly */
}

/* Aurora ribbons (behind content) */
#contact::before,
#contact::after {
  content:"";
  position:absolute; inset:-20%;
  background:
    conic-gradient(from 210deg at 30% 40%,
      rgba(96,255,168,.17),
      rgba(68,204,255,.18),
      rgba(96,255,168,.10),
      transparent 60%)
    ,
    radial-gradient(60% 40% at 70% 20%, rgba(68,204,255,.18), transparent 60%);
  filter: blur(24px) saturate(130%);
  opacity:.85;
  z-index:0;
  animation: auroraShift 16s linear infinite;
}
#contact::after{
  animation-duration: 22s;
  mix-blend-mode: screen;
}
@keyframes auroraShift {
  0%   { transform: translate3d(-2%, -1%, 0) rotate(0deg) scale(1.05); }
  50%  { transform: translate3d(1%,  1%,  0) rotate(2deg) scale(1.1); }
  100% { transform: translate3d(-2%, -1%, 0) rotate(0deg) scale(1.05); }
}

/* Container baseline */
#contact .container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

/* Cursor "spotlight" painterly glow */
#contact .container::before {
  content:"";
  position:absolute; inset:-2rem; pointer-events:none;
  background:
    radial-gradient(300px 260px at var(--mx,50%) var(--my,30%),
      rgba(96,255,168,.12), rgba(68,204,255,.10), transparent 60%);
  filter: blur(16px);
  z-index:0;
  transition: opacity .3s ease;
}
@media (hover:none) {
  #contact .container::before { opacity: .5; }
}

/* Heading */
#contact h2 {
  margin: 0 0 16px;
}

/* ====== DESKTOP LAYOUT ====== */
@media (min-width: 1024px) {
  #contact .container {
    display: grid;
    grid-template-columns: 0.9fr 1.4fr; /* left title / right form */
    gap: clamp(24px, 4vw, 56px);
    align-items: start;
  }
  #contact h2 {
    position: sticky; top: 24px;
    align-self: start;
    font-size: clamp(32px, 4.2vw, 56px);
    line-height: 1.05;
    margin: 0; /* handled by grid gap */
  }
}

/* Glassy card for the form */
#contact .form {
  position: relative;
  display: grid;
  gap: 14px;
  padding: clamp(16px, 2.4vw, 24px);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid var(--contact-border);
  border-radius: 16px;
  box-shadow: var(--contact-shadow);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  max-width: 720px; /* nice width on mobile/tablet when stacked */
  margin-inline: auto;
}

/* Two-up on wider screens (name + email), stack on small */
@media (min-width: 820px){
  #contact .form {
    grid-template-columns: repeat(12, 1fr);
    max-width: none;   /* allow wider on desktop grid area */
    margin: 0;         /* grid handles placement */
  }
  #contact .form .input[name="name"]   { grid-column: span 6; }
  #contact .form .input[name="email"]  { grid-column: span 6; }
  #contact .form .textarea             { grid-column: span 12; }
  #contact .form .btn                  { grid-column: span 4; justify-self: start; }
}

/* Fields */
#contact .field-wrap { display: contents; } /* wrapper created by JS; don't add extra boxes */

#contact .input,
#contact .textarea {
  width: 100%;
  color: var(--contact-text);
  background:
    linear-gradient(var(--field-bg, rgba(10,14,24,.55)), var(--field-bg, rgba(10,14,24,.55))) padding-box,
    linear-gradient(120deg, rgba(68,204,255,.35), rgba(96,255,168,.35)) border-box;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 14px;
  outline: none;
  transition: box-shadow .25s ease, background-color .25s ease, transform .06s ease;
  box-shadow: inset 0 0 0 0 rgba(68,204,255,.0);
  font-size: 16px;
}
#contact .input::placeholder,
#contact .textarea::placeholder { color: var(--contact-text-dim); opacity:.75; }
#contact .textarea { min-height: 140px; resize: none; }

/* Focus glow + subtle lift */
#contact .input:focus, #contact .textarea:focus {
  box-shadow:
    0 8px 28px rgba(68,204,255,.08),
    inset 0 0 0 1px rgba(68,204,255,.55);
  transform: translateY(-1px);
}

/* Invalid feedback */
#contact .field--invalid .input,
#contact .field--invalid .textarea {
  background:
    linear-gradient(rgba(25,10,14,.65), rgba(25,10,14,.65)) padding-box,
    linear-gradient(120deg, rgba(255,96,120,.6), rgba(255,188,96,.4)) border-box;
}
#contact .field-msg {
  font-size: 12px; line-height: 1.4;
  color: #ff9aa9; margin-top: -6px; margin-bottom: 6px;
  display: none;
}
#contact .field--invalid .field-msg { display: block; }

/* Character counter (message) */
#contact .counter {
  font-size: 12px; color: var(--contact-text-dim);
  display: flex; align-items: center; gap: 8px; margin-top: -2px;
}
#contact .counter__bar {
  position: relative; flex: 1; height: 4px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.08);
}
#contact .counter__fill {
  position:absolute; inset:0;
  transform-origin: left center;
  transform: scaleX(var(--pct,0));
  background: linear-gradient(90deg, var(--contact-accent), var(--contact-accent-2));
}

/* Button (morph to loader → check) */
#contact .btn {
  --btn-bg: linear-gradient(95deg, rgba(68,204,255,.85), rgba(96,255,168,.85));
  --btn-bg-hover: linear-gradient(95deg, rgba(68,204,255,1), rgba(96,255,168,1));
  --btn-text: #0a0f18;

  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.18);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .25s ease, background .25s ease;
  box-shadow: 0 10px 30px rgba(68,204,255,.15);
}
#contact .btn:hover { background: var(--btn-bg-hover); transform: translateY(-1px); }
#contact .btn:active { transform: translateY(0); }

/* spinner */
#contact .btn .spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(10,15,20,.35);
  border-top-color: rgba(10,15,20,.9);
  display: none;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* states */
#contact .btn.is-sending { pointer-events: none; }
#contact .btn.is-sending .spinner { display: inline-block; }
#contact .btn.is-sending .btn__label { opacity: .8; }

#contact .btn.is-success {
  background: linear-gradient(95deg, #60ffa8, #7effd1);
  box-shadow: 0 14px 36px rgba(96,255,168,.22);
}
#contact .btn .check {
  display: none; font-size: 16px;
}
#contact .btn.is-success .check { display: inline-block; }
#contact .btn.is-success .spinner,
#contact .btn.is-success .btn__label { display: none; }

/* result toast */
#contact .toast {
  position: absolute; right: 14px; bottom: 14px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(12,18,30,.7);
  border: 1px solid var(--contact-border);
  color: var(--contact-text);
  font-size: 13px;
  backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease;
}
#contact .toast.is-show { opacity: 1; transform: translateY(0); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  #contact::before, #contact::after { animation: none; }
  #contact .btn, #contact .input, #contact .textarea { transition: none; }
}

/* ========== MOBILE FIXES - Prevent scroll jitter ========== */
@media (max-width: 768px) {
  /* Remove backdrop-filter - main culprit of scroll jitter */
  #contact .form {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(11, 16, 29, 0.95);
  }
  
  /* Disable animated aurora backgrounds on mobile */
  #contact::before,
  #contact::after {
    display: none !important;
  }
  
  /* Disable cursor spotlight on mobile */
  #contact .container::before {
    display: none !important;
  }
  
  /* Remove transform animations that cause repaints */
  #contact .input:focus,
  #contact .textarea:focus,
  #contact .btn:hover,
  #contact .btn:active {
    transform: none !important;
  }
  
  /* Simplify focus styles for mobile */
  #contact .input:focus,
  #contact .textarea:focus {
    box-shadow: inset 0 0 0 1px rgba(68, 204, 255, 0.5);
  }
  
  /* Reduce motion on toast */
  #contact .toast {
    transition: opacity 0.2s ease;
    backdrop-filter: none;
  }
  
  /* Simplify button hover effect */
  #contact .btn:hover {
    background: var(--btn-bg);
  }
}