/* Services Section Styles */

.services-section {
  /* Fluid padding: adapts naturally to viewport size */
  padding: clamp(var(--space-8), 8vw, var(--space-16)) clamp(var(--space-4), 5vw, var(--space-24));
  background-color: var(--color-bg-light);
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--color-bg-light) 0%, rgba(246, 247, 252, 0.97) 100%);
  /* Enable container queries for intrinsic responsiveness */
  container-type: inline-size;
  container-name: services-section;
}

.services-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)), url('../pattern/pattern.svg');
  background-repeat: repeat;
  background-size: cover;
  opacity: 0.035;
  z-index: 0;
  pointer-events: none;
  animation: subtlePatternShift 120s infinite linear;
  transform-origin: center;
  will-change: transform;
  transform: translateY(var(--pattern-shift-y, 0));
  transition: transform 0.1s ease-out;
}

@keyframes subtlePatternShift {
  0% {
    transform: translateX(0) translateY(0) scale(1);
  }
  25% {
    transform: translateX(-5px) translateY(-5px) scale(1.02);
  }
  50% {
    transform: translateX(0) translateY(-8px) scale(1.01);
  }
  75% {
    transform: translateX(-3px) translateY(-2px) scale(1.015);
  }
  100% {
    transform: translateX(0) translateY(0) scale(1);
  }
}

.services-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.services-header {
  text-align: center;
  margin-bottom: clamp(var(--space-10), 5vw, var(--space-16));
}

.services-title {
  color: var(--color-accent-dark);
  /* 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));
}

.services-subtitle {
  color: var(--color-fg-base);
  /* 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;
  /* Smooth text rendering */
  text-wrap: balance;
}

/* Service Cards Grid - Flexible Box System with Clear Relationships */
.services-grid {
  display: grid;
  /* Intrinsic sizing: cards adapt to content while maintaining balance */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: clamp(var(--space-4), 3vw, var(--space-6));
  margin-bottom: var(--space-16);
  /* Ensure grid maintains natural rhythm */
  align-items: stretch;
  justify-content: center;
}

/* Desktop: 3-column layout for optimal reading width */
@media (min-width: 1025px) {
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.service-card {
  background-color: #fff;
  border-radius: var(--radius-2);
  box-shadow: 
    0 var(--space-1) var(--space-4) rgba(7, 17, 41, 0.05),
    0 8px 32px -8px rgba(7, 17, 41, 0.03);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  position: relative;
  z-index: 1;
  transform: translateY(0) scale(1);
  cursor: default;
}

/* Premium depth effect on cards */
.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0) 60%
  );
  opacity: 0;
  z-index: 0;
  transition: opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1);
  pointer-events: none;
}

.service-card:hover::before {
  opacity: 0.6;
}

/* Reset card overlay */
.service-card:not(:hover)::before {
  opacity: 0;
}

.service-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: 
    0 var(--space-3) var(--space-8) rgba(7, 17, 41, 0.1),
    0 20px 48px -12px rgba(7, 17, 41, 0.15);
}

/* Explicit reset on mouse leave */
.service-card:not(:hover) {
  transform: translateY(0) scale(1);
  box-shadow: 
    0 var(--space-1) var(--space-4) rgba(7, 17, 41, 0.05),
    0 8px 32px -8px rgba(7, 17, 41, 0.03);
}

.service-card:active {
  transform: translateY(-4px) scale(0.99);
  transition-duration: 0.2s;
  box-shadow: 
    0 var(--space-2) var(--space-5) rgba(7, 17, 41, 0.06),
    0 10px 30px -10px rgba(7, 17, 41, 0.1);
}

.service-image {
  position: relative;
  height: 120px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.service-image-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.service-card:nth-child(1) .service-image-gradient {
  background: linear-gradient(135deg, rgba(32, 87, 214, 0.85), rgba(21, 56, 138, 0.9));
}

.service-card:nth-child(2) .service-image-gradient {
  background: linear-gradient(135deg, rgba(22, 87, 51, 0.85), rgba(16, 65, 38, 0.9));
}

.service-card:nth-child(3) .service-image-gradient {
  background: linear-gradient(135deg, rgba(21, 56, 138, 0.85), rgba(7, 17, 41, 0.9));
}

.service-card:nth-child(4) .service-image-gradient {
  background: linear-gradient(135deg, rgba(32, 87, 214, 0.85), rgba(7, 17, 41, 0.9));
}

.service-card:nth-child(5) .service-image-gradient {
  background: linear-gradient(135deg, rgba(22, 87, 51, 0.85), rgba(21, 56, 138, 0.9));
}

.service-card:nth-child(6) .service-image-gradient {
  background: linear-gradient(135deg, rgba(7, 17, 41, 0.85), rgba(21, 56, 138, 0.9));
}

.service-icon {
  position: relative;
  z-index: 2;
  width: var(--space-12);
  height: var(--space-12);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  margin-bottom: 0;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
              backdrop-filter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: scale(1) translateY(0);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Premium icon animation */
.service-card:hover .service-icon {
  transform: scale(1.15) translateY(-5px);
  box-shadow: 
    0 15px 25px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 0 20px rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Explicit reset for icon */
.service-card:not(:hover) .service-icon {
  transform: scale(1) translateY(0);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Dynamic light ring effect for icons */
.service-icon::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: conic-gradient(
    transparent, 
    rgba(255, 255, 255, 0.5), 
    transparent 45%
  );
  -webkit-mask: radial-gradient(circle, transparent 62%, white 63%);
  mask: radial-gradient(circle, transparent 62%, white 63%);
  opacity: 0;
  transform: rotate(0deg);
  transition: opacity 0.5s ease, transform 4s linear;
  z-index: -1;
}

.service-card:hover .service-icon::before {
  opacity: 0.8;
  transform: rotate(360deg);
}

/* Reset icon ring effect */
.service-card:not(:hover) .service-icon::before {
  opacity: 0;
  transform: rotate(0deg);
}

.service-icon svg {
  width: var(--space-6);
  height: var(--space-6);
  fill: var(--color-fg-inverse);
}

.service-content {
  /* Fluid padding that adapts to available space */
  padding: clamp(var(--space-4), 3vw, var(--space-6)) clamp(var(--space-5), 4vw, var(--space-8));
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  z-index: 2;
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.service-description {
  position: relative;
  max-height: none;  
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0;
}

.service-description::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2em;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.service-title {
  font-size: var(--font-size-h3);
  color: var(--color-fg-base);
  margin-bottom: var(--space-3);
  font-weight: var(--font-weight-bold);
  position: relative;
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.3s ease;
}

.service-title::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(to right, var(--color-accent-dark), var(--color-accent-primary));
  transition: width 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.service-card:hover .service-title {
  color: var(--color-accent-dark);
  transform: translateX(3px);
}

.service-card:hover .service-title::after {
  width: 50px;
}

.service-description {
  color: var(--color-fg-base);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  margin-bottom: var(--space-4);
}

.service-features {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 0;
}

.service-features li {
  position: relative;
  padding-left: var(--space-6);
  margin-bottom: var(--space-2);
  font-size: 0.95em;
  color: var(--color-fg-base);
  opacity: 0.8;
  transition: all 0.3s ease, transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.service-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 12px;
  height: 1px;
  background-color: var(--color-accent-dark);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.service-card:hover .service-features li {
  opacity: 0.95;
  transform: translateX(2px);
}

.service-card:hover .service-features li::before {
  width: 18px;
  background-color: var(--color-accent-primary);
}

.service-cta {
  margin-top: var(--space-4);
  display: inline-block;
  background-color: var(--color-mariner);
  color: var(--color-fg-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-2);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-small);
  text-align: center;
  transition: background-color 0.3s ease, transform 0.3s ease;
  align-self: flex-start;
}

.service-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 var(--space-1) var(--space-3) rgba(0, 0, 0, 0.1);
}

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

/* Tablet Landscape (769px - 1024px): 2-column layout with balanced spacing */
@media (min-width: 769px) and (max-width: 1024px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(var(--space-5), 4vw, var(--space-6));
    /* Maintain visual rhythm with adjusted spacing */
  }
  
  .services-section {
    padding: var(--space-12) var(--space-8);
  }
  
  .service-image {
    height: 110px;
  }
  
  .service-content {
    padding: var(--space-5) var(--space-6);
  }
  
  /* Adjust typography for better readability */
  .service-title {
    font-size: clamp(1.5rem, 2.5vw, var(--font-size-h3));
  }
  
  .service-description {
    font-size: clamp(0.9rem, 1.8vw, var(--font-size-body));
  }
}

/* Tablet Portrait (481px - 768px): Single column with optimized card proportions */
@media (min-width: 481px) and (max-width: 768px) {
  .services-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .services-section {
    padding: var(--space-10) var(--space-6);
  }
  
  .service-card {
    /* Horizontal card layout for better use of space */
    flex-direction: row;
    align-items: stretch;
  }
  
  .service-image {
    width: 140px;
    min-width: 140px;
    height: auto;
    flex-shrink: 0;
  }
  
  .service-content {
    padding: var(--space-5) var(--space-6);
    flex: 1;
  }
  
  .service-title {
    font-size: var(--font-size-h4);
    margin-bottom: var(--space-2);
  }
  
  .service-description {
    font-size: 0.95rem;
    line-height: 1.6;
  }
  
  .services-header {
    margin-bottom: var(--space-10);
  }
  
  .services-title {
    font-size: var(--font-size-h2);
  }
  
  .services-subtitle {
    font-size: 0.95rem;
  }
}

/* Mobile (320px - 480px): Vertical stacking with priority-based spacing */
@media (max-width: 480px) {
  .services-section {
    padding: var(--space-8) var(--space-4);
  }
  
  .services-grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
  
  .service-card {
    flex-direction: column;
  }
  
  .service-image {
    height: 100px;
    width: 100%;
  }
  
  .service-content {
    padding: var(--space-4) var(--space-5);
  }
  
  .service-title {
    font-size: var(--font-size-h4);
    margin-bottom: var(--space-2);
  }
  
  .service-description {
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: var(--space-3);
  }
  
  .services-header {
    margin-bottom: var(--space-8);
  }
  
  .services-title {
    font-size: clamp(1.75rem, 6vw, var(--font-size-h2));
  }
  
  .services-subtitle {
    font-size: 0.9rem;
    line-height: 1.6;
  }
  
  /* Optimize icon size for mobile */
  .service-icon {
    width: var(--space-10);
    height: var(--space-10);
  }
  
  .service-icon svg {
    width: var(--space-5);
    height: var(--space-5);
  }
  
  /* Reduce hover effects on mobile for better performance */
  .service-card:hover {
    transform: translateY(-4px) scale(1.005);
  }
}

/* Extra Small Mobile (< 360px): Compact layout with essential content prioritization */
@media (max-width: 359px) {
  .services-section {
    padding: var(--space-6) var(--space-3);
  }
  
  .services-grid {
    gap: var(--space-4);
  }
  
  .service-content {
    padding: var(--space-3) var(--space-4);
  }
  
  .service-title {
    font-size: 1.25rem;
  }
  
  .service-description {
    font-size: 0.85rem;
  }
  
  .services-title {
    font-size: 1.5rem;
  }
  
  .services-subtitle {
    font-size: 0.85rem;
  }
}

/* ========================================= */
/* CONTAINER QUERIES - Intrinsic Design     */
/* Modern browsers: Cards adapt to their    */
/* container, not just viewport             */
/* ========================================= */

@container services-section (max-width: 480px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
  
  .service-card {
    flex-direction: column;
  }
}

@container services-section (min-width: 481px) and (max-width: 768px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
  
  .service-card {
    flex-direction: row;
  }
  
  .service-image {
    width: 140px;
    min-width: 140px;
  }
}

@container services-section (min-width: 769px) and (max-width: 1024px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container services-section (min-width: 1025px) {
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .service-card,
  .service-card:hover,
  .service-icon,
  .service-card:hover .service-icon,
  .service-title,
  .service-card:hover .service-title,
  .service-description,
  .service-card:hover .service-description,
  .service-card::after,
  .service-card:hover::after,
  .service-features li,
  .service-card:hover .service-features li {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
}
