/**
 * AI Services Blog - Service Card Styles
 * Path: /ai-services/css/service-card.css
 * 
 * Description: Comprehensive styling for service cards including container,
 * image container, typography, badges, benefits section, hover effects,
 * and responsive design for mobile, tablet, and desktop layouts.
 * 
 * Features:
 * - Service card container with border, shadow, and padding
 * - Fixed aspect ratio image container
 * - Service name (H3) with typography and color
 * - Short description text (50-100 words)
 * - Business benefit section with highlight background
 * - Category and framework badges with colors
 * - Hover effect with translateY(-8px) and shadow increase
 * - Learn More button with proper colors and hover state
 * - Responsive padding/margins (1 column mobile, 2 columns tablet, 3-4 columns desktop)
 * 
 * Requirements: 4.1-4.8, 10.1-10.6
 */

/* ===================================================================
   1. SERVICE CARD CONTAINER
   =================================================================== */

.service-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--color-white);
  border: 1px solid var(--color-border-gray);
  border-radius: var(--radius-lg);
  padding: var(--spacing-4);
  transition: all var(--transition-base) cubic-bezier(0.17, 0.85, 0.438, 0.99);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  
  /* Ensure card takes full height in grid */
  &:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
  }
  
  /* Active state for keyboard navigation */
  &:focus-within {
    outline: 2px solid var(--color-accent);
    outline-offset: 0;
  }
}

/* Card state: loading skeleton */
.service-card.loading {
  opacity: 0.6;
  pointer-events: none;
  
  .service-card-image,
  .service-name,
  .service-description,
  .service-benefit {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    color: transparent;
    
    * {
      color: transparent;
    }
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===================================================================
   2. SERVICE CARD IMAGE CONTAINER
   =================================================================== */

.service-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-4);
  background-color: var(--color-light-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.service-card-image img,
.service-card-image .service-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform var(--transition-base);
  display: block;
  
  /* Lazy loading placeholder effect */
  &[loading="lazy"]:not([src]) {
    background-color: var(--color-light-gray);
  }
}

/* Image zoom effect on card hover */
.service-card:hover .service-card-image img,
.service-card:hover .service-card-image .service-icon {
  transform: scale(1.05);
}

/* ===================================================================
   3. SERVICE CARD CONTENT CONTAINER
   =================================================================== */

.service-card-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: var(--spacing-4);
}

/* ===================================================================
   4. SERVICE NAME (H3)
   =================================================================== */

.service-name {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: #1e293b;
  line-height: var(--line-height-tight);
  margin: 0;
  padding: 0;
  transition: color var(--transition-base);
  word-break: break-word;
  
  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  
  /* Subtle color shift on hover — not harsh pink */
  .service-card:hover & {
    color: #2563eb;
  }
  
  .service-card:focus-within & {
    color: #2563eb;
  }
}

/* ===================================================================
   5. SERVICE DESCRIPTION TEXT
   =================================================================== */

.service-description {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  color: #475569;
  line-height: var(--line-height-relaxed);
  margin: 0;
  padding: 0;
  flex-grow: 1;
  
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  
  &[title] {
    cursor: help;
    text-decoration: underline dotted;
    text-decoration-color: #94a3b8;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }
}

/* Description text should only show first 50-100 words */
.service-card-meta {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

/* ===================================================================
   6. BUSINESS BENEFIT SECTION
   =================================================================== */

.service-benefit {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-3);
  padding: var(--spacing-3) var(--spacing-4);
  background-color: #f0fdf4;
  border-left: 4px solid #22c55e;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.service-card:hover .service-benefit {
  background-color: #dcfce7;
  border-left-color: #16a34a;
}

.benefit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  flex-shrink: 0;
  font-weight: var(--font-weight-bold);
  color: #16a34a;
  font-size: var(--font-size-lg);
}

.benefit-text {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: #1e293b;
  line-height: var(--line-height-tight);
  
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===================================================================
   7. CATEGORY AND FRAMEWORK BADGES
   =================================================================== */

.service-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
}

.badge {
  display: inline-block;
  padding: var(--spacing-1) var(--spacing-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: all var(--transition-base);
  border: 1px solid transparent;
  line-height: 1;
}

/* Badge Category Styling */
.badge-category {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.service-card:hover .badge-category {
  background-color: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
  transform: translateY(-2px);
}

/* Badge Industry Styling */
.badge-industry {
  background-color: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.service-card:hover .badge-industry {
  background-color: #dcfce7;
  color: #15803d;
  border-color: #86efac;
  transform: translateY(-2px);
}

/* Badge Department Styling */
.badge-department {
  background-color: #faf5ff;
  color: #6b21a8;
  border-color: #e9d5ff;
}

.service-card:hover .badge-department {
  background-color: #f3e8ff;
  color: #7e22ce;
  border-color: #d8b4fe;
  transform: translateY(-2px);
}

/* Badge Framework Styling */
.badge-framework {
  background-color: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.service-card:hover .badge-framework {
  background-color: #ffedd5;
  color: #9a3412;
  border-color: #fdba74;
  transform: translateY(-2px);
}

/* Generic badge styling for other types */
.badge-secondary {
  background-color: var(--color-secondary);
  color: var(--color-white);
}

.badge-success {
  background-color: var(--color-success);
  color: var(--color-white);
}

.badge-warning {
  background-color: var(--color-warning);
  color: #333;
}

.badge-error {
  background-color: var(--color-error);
  color: var(--color-white);
}

/* Badge accessibility */
.badge[role="status"],
.badge[aria-label] {
  position: relative;
  
  &:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
  }
}

/* ===================================================================
   8. LEARN MORE BUTTON
   =================================================================== */

.btn-learn-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-4);
  background-color: #2563eb;
  color: #ffffff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  border: 2px solid #2563eb;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  min-height: 36px;
  min-width: 120px;
  
  &:hover {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
  }
  
  &:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
  }
  
  &:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  }
  
  &:disabled {
    background-color: #94a3b8;
    border-color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
  }
  
  i {
    transition: transform var(--transition-base);
    font-size: var(--font-size-sm);
  }
  
  &:hover i {
    transform: translateX(3px);
  }
}

/* Alternative button style (outline) */
.btn-learn-more-outline {
  background-color: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  
  &:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
  }
}

/* ===================================================================
   9. RESPONSIVE DESIGN
   =================================================================== */

/* Mobile (< 768px) - Single column layout */
@media (max-width: 767.98px) {
  .service-card {
    margin-bottom: var(--spacing-4);
    padding: var(--spacing-3);
  }
  
  .service-card-image {
    margin-bottom: var(--spacing-3);
    aspect-ratio: 16 / 9;
  }
  
  .service-name {
    font-size: var(--font-size-xl);
  }
  
  .service-description {
    font-size: var(--font-size-sm);
  }
  
  .badge {
    font-size: 10px;
    padding: var(--spacing-1) var(--spacing-2);
  }
  
  .btn-learn-more {
    width: 100%;
    min-width: auto;
  }
  
  /* Single column grid on mobile */
  .services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-4);
  }
}

/* Tablet (768px - 1024px) - Two column layout */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .service-card {
    padding: var(--spacing-4);
  }
  
  .service-card-image {
    margin-bottom: var(--spacing-4);
    aspect-ratio: 3 / 2;
  }
  
  .service-name {
    font-size: var(--font-size-2xl);
  }
  
  /* Two column grid on tablet */
  .services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-4);
  }
  
  /* Allow some cards to span if needed */
  .service-card.featured {
    grid-column: span 2;
  }
}

/* Desktop (1024px - 1200px) - Three column layout */
@media (min-width: 1024px) and (max-width: 1199.98px) {
  .service-card {
    padding: var(--spacing-4);
  }
  
  .service-card-image {
    margin-bottom: var(--spacing-4);
    aspect-ratio: 4 / 3;
  }
  
  /* Three column grid on desktop */
  .services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-5);
  }
}

/* Large Desktop (>= 1200px) - Four column layout */
@media (min-width: 1200px) {
  .service-card {
    padding: var(--spacing-5);
  }
  
  .service-card-image {
    margin-bottom: var(--spacing-5);
    aspect-ratio: 4 / 3;
  }
  
  /* Four column grid on large desktop */
  .services-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-6);
  }
  
  /* Three columns for some sections */
  .services-grid.three-column {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===================================================================
   10. TOUCH-FRIENDLY TARGETS (Mobile)
   =================================================================== */

@media (max-width: 1023.98px) {
  .service-card {
    /* Ensure minimum touch target size of 44x44px */
    min-height: 200px;
  }
  
  .btn-learn-more {
    min-height: 48px;
    min-width: 100%;
  }
  
  .service-card:active {
    background-color: rgba(0, 0, 0, 0.02);
  }
}

/* ===================================================================
   11. DEPARTMENT SECTION ORGANIZATION
   =================================================================== */

.department-section {
  margin-bottom: var(--spacing-12);
  
  &:last-child {
    margin-bottom: var(--spacing-8);
  }
}

.department-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-8);
  padding-bottom: var(--spacing-6);
  border-bottom: 2px solid var(--color-border-gray);
}

.department-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  background-color: rgba(255, 31, 142, 0.1);
  border-radius: var(--radius-lg);
  color: var(--color-primary);
  font-size: var(--font-size-2xl);
  transition: all var(--transition-base);
}

.department-section:hover .department-icon {
  background-color: var(--color-primary);
  color: var(--color-white);
  transform: scale(1.1);
}

.department-info {
  flex-grow: 1;
}

.department-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-1) 0;
  line-height: var(--line-height-tight);
}

.department-description {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
  margin: 0;
}

.department-count {
  display: inline-block;
  font-size: var(--font-size-sm);
  color: var(--text-light);
  margin-top: var(--spacing-1);
}

/* Department section responsive adjustments */
@media (max-width: 767.98px) {
  .department-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-3);
    margin-bottom: var(--spacing-6);
  }
  
  .department-title {
    font-size: var(--font-size-2xl);
  }
  
  .department-description {
    font-size: var(--font-size-sm);
  }
}

/* ===================================================================
   12. CARD GRID CONTAINER
   =================================================================== */

.services-grid {
  width: 100%;
  padding: 0;
  margin: 0;
  list-style: none;
}

/* ===================================================================
   13. NO RESULTS STATE
   =================================================================== */

#no-results-message {
  padding: var(--spacing-12);
  text-align: center;
  
  i {
    display: block;
    font-size: var(--font-size-6xl);
    color: var(--text-light);
    margin-bottom: var(--spacing-6);
  }
  
  h3 {
    font-size: var(--font-size-3xl);
    color: var(--text-primary);
    margin-bottom: var(--spacing-4);
  }
  
  p {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-6);
  }
}

/* ===================================================================
   14. CARD ANIMATION CLASSES
   =================================================================== */

.card-fade-in {
  animation: fadeIn var(--transition-base);
}

.card-fade-out {
  animation: fadeOut var(--transition-base);
}

.card-scale-in {
  animation: scaleUp var(--transition-base);
}

/* ===================================================================
   15. ACCESSIBILITY ENHANCEMENTS
   =================================================================== */

/* Ensure high contrast for links and buttons */
.service-card a,
.service-card button {
  position: relative;
}

/* Focus indicators for keyboard users */
.service-card:focus-visible,
.service-card a:focus-visible,
.service-card button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Ensure badges are readable for color blind users */
.badge {
  /* Always include text, not just color */
  position: relative;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  .service-card {
    border-width: 2px;
    border-color: var(--text-primary);
  }
  
  .badge {
    border-width: 2px;
  }
  
  .btn-learn-more {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .service-card,
  .service-card-image img,
  .badge,
  .btn-learn-more {
    transition: none;
    animation: none;
  }
  
  .service-card:hover {
    transform: none;
  }
  
  .btn-learn-more:hover i {
    transform: none;
  }
}

/* ===================================================================
   16. PRINT STYLES
   =================================================================== */

@media print {
  .service-card {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .btn-learn-more {
    display: none;
  }
  
  .services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

/* ===================================================================
   17. DARK MODE SUPPORT (Optional)
   =================================================================== */

/* Dark mode: keep cards light so they stay readable */
@media (prefers-color-scheme: dark) {
  .service-card {
    background-color: #f8fafc;
    border-color: #e2e8f0;
  }
  
  .service-card:hover {
    border-color: #93c5fd;
    background-color: #ffffff;
  }
  
  .service-name {
    color: #1e293b;
  }
  
  .service-card:hover .service-name {
    color: #1d4ed8;
  }
  
  .service-description {
    color: #475569;
  }
  
  .service-benefit {
    background-color: #f0fdf4;
    border-left-color: #22c55e;
  }
  
  .badge-category {
    background-color: #eff6ff;
    color: #1d4ed8;
  }
  
  .badge-industry {
    background-color: #f0fdf4;
    color: #166534;
  }
  
  .badge-department {
    background-color: #faf5ff;
    color: #6b21a8;
  }
  
  .badge-framework {
    background-color: #fff7ed;
    color: #c2410c;
  }
}

/* ===================================================================
   18. LIGHT CARD BASE OVERRIDE
   Make sure cards always render with a light background regardless
   of any inherited dark-mode or global class overrides.
   =================================================================== */

.service-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
}

/* ===================================================================
   19. ANIMATED ILLUSTRATION (replaces missing images)
   =================================================================== */

.service-card-illustration {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md, 8px);
  margin-bottom: var(--spacing-4, 1rem);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Large central icon */
.illustration-icon {
  font-size: 3rem;
  line-height: 1;
  z-index: 2;
  animation: icon-float 3s ease-in-out infinite;
  user-select: none;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0px) scale(1); }
  50%       { transform: translateY(-8px) scale(1.06); }
}

/* Floating dots in top-right corner */
.illustration-dots {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.7;
}

.dot-1 { animation: dot-pulse 1.8s ease-in-out infinite 0s; }
.dot-2 { animation: dot-pulse 1.8s ease-in-out infinite 0.3s; }
.dot-3 { animation: dot-pulse 1.8s ease-in-out infinite 0.6s; }

@keyframes dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.5; }
  50%       { transform: scale(1.5); opacity: 1;   }
}

/* Bar chart at the bottom */
.illustration-bar-group {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  z-index: 2;
}

.bar {
  width: 10px;
  border-radius: 3px 3px 0 0;
  opacity: 0.75;
}

.bar-1 { height: 20px; animation: bar-grow 2s ease-in-out infinite 0s; }
.bar-2 { height: 34px; animation: bar-grow 2s ease-in-out infinite 0.25s; }
.bar-3 { height: 26px; animation: bar-grow 2s ease-in-out infinite 0.5s; }
.bar-4 { height: 40px; animation: bar-grow 2s ease-in-out infinite 0.75s; }

@keyframes bar-grow {
  0%, 100% { transform: scaleY(0.7); opacity: 0.55; }
  50%       { transform: scaleY(1);   opacity: 0.9;  }
}

/* Hover: speed up the icon float */
.service-card:hover .illustration-icon {
  animation-duration: 1.5s;
}

/* Category-specific subtle ring decoration */
.anim-analytics::before,
.anim-automation::before,
.anim-vision::before,
.anim-nlp::before,
.anim-default::before {
  content: '';
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  opacity: 0.15;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: ring-pulse 2.5s ease-in-out infinite;
}

.anim-analytics::before  { background: #0284c7; }
.anim-automation::before { background: #16a34a; }
.anim-vision::before     { background: #9333ea; }
.anim-nlp::before        { background: #ea580c; }
.anim-default::before    { background: #6366f1; }

@keyframes ring-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   opacity: 0.12; }
  50%       { transform: translate(-50%, -50%) scale(1.3); opacity: 0.22; }
}
