/* Contact Section Styles */

.contact-section {
  /* Fluid padding: adapts naturally to viewport size */
  padding: clamp(var(--space-10), 8vw, var(--space-16)) clamp(var(--space-4), 4vw, var(--space-8));
  background: linear-gradient(135deg, #0f1925 0%, #1a2a3a 100%);
  position: relative;
  overflow: hidden;
  color: #fff;
  /* Enable container queries for intrinsic responsiveness */
  container-type: inline-size;
  container-name: contact-section;
}

.contact-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(63, 121, 230, 0.08) 0%, rgba(10, 20, 30, 0) 70%);
  opacity: 0.7;
  animation: subtle-rotate 120s linear infinite;
  pointer-events: none;
}

/* Ambient floating particles */
.contact-section::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(63, 121, 230, 0.12) 0%, rgba(63, 121, 230, 0) 20%),
    radial-gradient(circle at 80% 70%, rgba(63, 121, 230, 0.08) 0%, rgba(63, 121, 230, 0) 20%),
    radial-gradient(circle at 40% 80%, rgba(63, 121, 230, 0.06) 0%, rgba(63, 121, 230, 0) 30%);
  pointer-events: none;
  mix-blend-mode: soft-light;
  z-index: 0;
}

@keyframes subtle-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.contact-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  /* Fluid padding for natural spacing */
  padding: 0 clamp(var(--space-3), 3vw, var(--space-6));
}

.contact-header {
  text-align: center;
  margin-bottom: clamp(var(--space-8), 5vw, var(--space-12));
  position: relative;
}

.contact-title {
  color: #fff;
  /* Fluid typography: scales naturally between breakpoints */
  font-size: clamp(1.75rem, 4vw + 0.5rem, var(--font-size-h2));
  font-weight: var(--font-weight-bold);
  margin-bottom: clamp(var(--space-3), 2vw, var(--space-4));
  position: relative;
  display: inline-block;
  letter-spacing: -0.02em;
}

.contact-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, rgba(63, 121, 230, 0), rgba(63, 121, 230, 1), rgba(63, 121, 230, 0));
  transform: translateX(-50%);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.contact-header:hover .contact-title::after {
  width: 100px;
}

.contact-subtitle {
  color: rgba(255, 255, 255, 0.85);
  /* Fluid body text for optimal readability */
  font-size: clamp(0.9rem, 1.5vw + 0.5rem, var(--font-size-body));
  line-height: var(--line-height-body);
  max-width: min(768px, 90%);
  margin: 0 auto clamp(var(--space-8), 5vw, var(--space-12));
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.01em;
  /* Smooth text rendering */
  text-wrap: balance;
}

/* Premium Contact Card Styles */
.contact-card {
  background: rgba(20, 30, 45, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-3);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 1px 0 0 rgba(255, 255, 255, 0.1) inset;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  perspective: 1000px;
  transform-style: preserve-3d;
  will-change: transform, box-shadow;
  transition: box-shadow 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  opacity: 1 !important;
  display: block !important;
}

.contact-card:hover {
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.07) inset,
    0 1px 0 0 rgba(255, 255, 255, 0.15) inset;
}

.contact-card-inner {
  /* Fluid padding that adapts to available space */
  padding: clamp(var(--space-5), 4vw, var(--space-8));
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  transform: translateZ(0);
  z-index: 1;
  opacity: 1 !important;
}

/* Subtle gradient glow effect that follows mouse movement */
.contact-card-glow {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background: radial-gradient(
    circle at center,
    rgba(63, 121, 230, 0.15) 0%,
    rgba(63, 121, 230, 0) 50%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1);
  transform: translateZ(0);
}

.contact-card:hover .contact-card-glow {
  opacity: 1;
}

.contact-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(var(--space-6), 4vw, var(--space-8));
  position: relative;
}

.contact-content::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-3);
  padding: 2px;
  background: linear-gradient(135deg, rgba(255,255,255,0) 20%, rgba(21, 56, 138, 0.1) 50%, rgba(255,255,255,0) 80%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

/* Contact Form Styles */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--color-fg-base);
  font-size: var(--font-size-body);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(7, 17, 41, 0.08);
  border-radius: var(--radius-2);
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--color-fg-base);
  font-family: inherit;
  font-size: var(--font-size-body);
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 
    0 2px 4px rgba(7, 17, 41, 0.01),
    0 0 0 transparent;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transform: translateZ(0);
  will-change: transform, box-shadow, border-color;
}

.form-control:focus {
  outline: none;
  border-color: rgba(32, 87, 214, 0.5);
  box-shadow: 
    0 4px 10px rgba(7, 17, 41, 0.03),
    0 0 0 2px rgba(32, 87, 214, 0.2);
  transform: translateY(-1px);
  background-color: #fff;
}

/* Animation classes for form validation */
.input-focused {
  animation: input-focus-pulse 2s infinite;
}

@keyframes input-focus-pulse {
  0% {
    box-shadow: 
      0 4px 10px rgba(7, 17, 41, 0.03),
      0 0 0 2px rgba(32, 87, 214, 0.2);
  }
  50% {
    box-shadow: 
      0 4px 10px rgba(7, 17, 41, 0.05),
      0 0 0 2px rgba(32, 87, 214, 0.3);
  }
  100% {
    box-shadow: 
      0 4px 10px rgba(7, 17, 41, 0.03),
      0 0 0 2px rgba(32, 87, 214, 0.2);
  }
}

.input-filled {
  border-color: rgba(32, 87, 214, 0.4);
  background-color: rgba(255, 255, 255, 0.95);
}

.input-error {
  border-color: rgba(220, 53, 69, 0.5);
  box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.2);
  animation: input-error-shake 0.4s ease-in-out;
}

@keyframes input-error-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.form-group {
  position: relative;
  margin-bottom: var(--space-6);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.form-group:focus-within {
  transform: scale(1.01);
}

.form-group label {
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.form-group:focus-within label {
  color: rgba(32, 87, 214, 0.8);
  transform: translateX(3px);
}

.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(7, 17, 41, 0.15);
  border-radius: var(--radius-1);
  background-color: #fff;
  color: var(--color-fg-base);
  font-family: inherit;
  font-size: var(--font-size-body);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23071129' d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-accent-primary);
  box-shadow: 0 0 0 2px rgba(22, 87, 51, 0.1);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.submit-button {
  display: inline-block;
  background-color: var(--color-accent-dark);
  color: var(--color-fg-inverse);
  padding: var(--space-3) var(--space-8);
  border: none;
  border-radius: 30px;
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-body);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 
    0 2px 10px rgba(21, 56, 138, 0.2),
    0 6px 16px -6px rgba(21, 56, 138, 0.1),
    0 0 0 0 rgba(21, 56, 138, 0);
  align-self: flex-start;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.03em;
}

.submit-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0) 100%);
  transform: translateX(-100%);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.submit-button:hover {
  background-color: var(--color-mariner);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 
    0 4px 12px rgba(21, 56, 138, 0.25),
    0 10px 24px -8px rgba(21, 56, 138, 0.2),
    0 0 0 2px rgba(21, 56, 138, 0.1);
}

.submit-button:hover::before {
  transform: translateX(100%);
}

.submit-button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 
    0 2px 8px rgba(21, 56, 138, 0.2),
    0 0 0 1px rgba(21, 56, 138, 0.1);
  transition-duration: 0.2s;
}

/* Submit button states */
.submit-button.is-loading {
  background-color: var(--color-accent-dark);
  color: transparent;
  pointer-events: none;
}

.submit-button.is-loading::after {
  content: '';
  position: absolute;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: button-spinner 0.8s linear infinite;
}

@keyframes button-spinner {
  to { transform: rotate(360deg); }
}

.submit-button.is-success {
  background-color: #2ecc71;
  color: transparent;
  pointer-events: none;
}

.submit-button.is-success::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 10px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: translate(-50%, -60%) rotate(-45deg);
  animation: button-success 0.3s ease-out;
}

@keyframes button-success {
  from { opacity: 0; transform: translate(-50%, -60%) rotate(-45deg) scale(0.5); }
  to { opacity: 1; transform: translate(-50%, -60%) rotate(-45deg) scale(1); }
}

/* Submit button ripple effect */
.submit-ripple {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  transform: scale(0);
  animation: submit-ripple 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes submit-ripple {
  to { transform: scale(2); opacity: 0; }
}

/* Form success message */
.form-success-message {
  background-color: rgba(46, 204, 113, 0.15);
  border-left: 3px solid #2ecc71;
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  color: #2a865a;
  border-radius: var(--radius-1);
  transition: opacity 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  font-weight: var(--font-weight-medium);
}

/* Contact Info Styles */
.contact-info {
  padding: var(--space-8) var(--space-6);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(246, 247, 252, 0.8));
  border-radius: var(--radius-2);
  border: 1px solid rgba(7, 17, 41, 0.03);
  height: fit-content;
  box-shadow: 
    0 10px 30px -10px rgba(7, 17, 41, 0.04),
    0 1px 3px rgba(7, 17, 41, 0.02);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateZ(0);
}

.contact-info:hover {
  transform: translateY(-5px) translateZ(0);
  box-shadow: 
    0 20px 40px -15px rgba(7, 17, 41, 0.1),
    0 1px 5px rgba(7, 17, 41, 0.03);
}

.info-title {
  color: var(--color-accent-dark);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-6);
  position: relative;
  display: inline-block;
  letter-spacing: -0.01em;
}

.info-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, rgba(21, 56, 138, 0.8), rgba(21, 56, 138, 0.3));
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.contact-info:hover .info-title::after {
  width: 100%;
}

.info-section {
  margin-bottom: var(--space-6);
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section-title {
  color: var(--color-accent-dark);
  font-size: var(--font-size-h5);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-2);
}

.info-item {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-5);
  position: relative;
  padding-left: var(--space-1);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.info-item:hover {
  transform: translateX(5px);
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-icon {
  margin-right: var(--space-3);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(32, 87, 214, 0.9), rgba(21, 56, 138, 0.85));
  box-shadow: 
    0 4px 8px rgba(21, 56, 138, 0.2),
    0 2px 4px rgba(21, 56, 138, 0.1);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateZ(0);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.info-item:hover .info-icon {
  transform: scale(1.1) rotate(5deg) translateZ(0);
  box-shadow: 
    0 6px 12px rgba(21, 56, 138, 0.25),
    0 2px 4px rgba(21, 56, 138, 0.2);
  background: linear-gradient(145deg, rgba(32, 87, 214, 1), rgba(21, 56, 138, 0.9));
}

.info-icon svg {
  width: var(--space-4);
  height: var(--space-4);
  fill: var(--color-accent-primary);
}

.info-text {
  flex: 1;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  color: var(--color-fg-base);
  font-size: var(--font-size-body);
  position: relative;
  padding-bottom: 3px;
}

.info-text::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(21, 56, 138, 0.2), transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.info-item:hover .info-text::after {
  transform: scaleX(1);
}

.info-item:hover .info-text {
  color: rgba(21, 56, 138, 0.9);
}

.office-hours {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: center;
}

.hours-day {
  color: var(--color-fg-base);
  font-weight: var(--font-weight-medium);
}

.hours-time {
  color: var(--color-fg-base);
}

/* ========================================= */
/* RESPONSIVE REARRANGEMENT WITH PURPOSE    */
/* ========================================= */

/* Tablet Landscape (769px - 1024px): Maintain single column with optimized spacing */
@media (min-width: 769px) and (max-width: 1024px) {
  .contact-section {
    padding: clamp(var(--space-10), 8vw, var(--space-14)) var(--space-8);
  }
  
  .contact-card {
    max-width: 800px;
  }
  
  .contact-card-inner {
    padding: var(--space-6) var(--space-8);
  }
  
  .contact-content {
    gap: var(--space-6);
  }
}

/* Tablet Portrait (481px - 768px): Single column with adjusted proportions */
@media (min-width: 481px) and (max-width: 768px) {
  .contact-section {
    padding: var(--space-10) var(--space-6);
  }
  
  .contact-card {
    max-width: 600px;
  }
  
  .contact-card-inner {
    padding: var(--space-6);
  }
  
  .contact-content {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  
  .contact-header {
    margin-bottom: var(--space-8);
  }
  
  .contact-title {
    font-size: clamp(1.75rem, 5vw, 2rem);
  }
  
  .contact-subtitle {
    font-size: 0.95rem;
  }
}

/* Mobile (320px - 480px): Vertical stacking with priority-based spacing */
@media (max-width: 480px) {
  .contact-section {
    padding: var(--space-8) var(--space-4);
  }
  
  .contact-container {
    padding: 0 var(--space-3);
  }
  
  .contact-card {
    border-radius: var(--radius-2);
  }
  
  .contact-card-inner {
    padding: var(--space-5) var(--space-4);
  }
  
  .contact-content {
    gap: var(--space-5);
  }
  
  .contact-header {
    margin-bottom: var(--space-6);
  }
  
  .contact-title {
    font-size: clamp(1.5rem, 6vw, 1.875rem);
  }
  
  .contact-subtitle {
    font-size: 0.9rem;
    line-height: 1.6;
  }
  
  /* Optimize form elements for mobile */
  .form-control {
    padding: var(--space-3);
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .submit-button {
    width: 100%;
    padding: var(--space-3) var(--space-6);
    justify-content: center;
  }
}

/* Extra Small Mobile (< 360px): Compact layout with essential content */
@media (max-width: 359px) {
  .contact-section {
    padding: var(--space-6) var(--space-3);
  }
  
  .contact-card-inner {
    padding: var(--space-4) var(--space-3);
  }
  
  .contact-title {
    font-size: 1.5rem;
  }
  
  .contact-subtitle {
    font-size: 0.85rem;
  }
  
  .form-control {
    padding: var(--space-2) var(--space-3);
  }
}

/* ========================================= */
/* CONTAINER QUERIES - Intrinsic Design     */
/* Modern browsers: Content adapts to       */
/* container, not just viewport             */
/* ========================================= */

@container contact-section (max-width: 480px) {
  .contact-card {
    border-radius: var(--radius-2);
  }
  
  .contact-content {
    gap: var(--space-5);
  }
}

@container contact-section (min-width: 481px) and (max-width: 768px) {
  .contact-card {
    max-width: 600px;
  }
}

@container contact-section (min-width: 769px) {
  .contact-card {
    max-width: 900px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .contact-card,
  .contact-card:hover,
  .contact-card-glow,
  .contact-card-inner,
  .form-control,
  .submit-button,
  .submit-button:hover {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
}
