/* Features Section Complete Fix - Maintains proportions while ensuring visibility */

/* Base styles for all desktop/laptop screens */
@media screen and (min-width: 768px) {
  /* Container adjustments */
  .interactive-features {
    width: 100% !important;
    overflow: visible !important;
  }

  .interactive-features .container {
    max-width: 100% !important;
    overflow: visible !important;
  }

  .feature-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
  }

  /* Feature item base layout */
  a.feature-item,
  .feature-item {
    display: grid !important;
    width: 100% !important;
    height: auto !important;
    min-height: max-content !important;
    max-height: none !important;
    align-items: center !important;
    overflow: visible !important;
    border-bottom: 1px solid #e0e0e0 !important;
    transition: background-color 0.3s ease !important;
  }

  /* Remove any absolute positioning */
  .feature-description,
  .feature-video-container,
  .feature-title {
    position: relative !important;
    overflow: visible !important;
  }
}

/* Large screens (1440px+) - Swapped proportions */
@media screen and (min-width: 1440px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: 1.2fr 1.8fr 2.5fr !important;
    padding: 3rem 160px !important;
    gap: 3rem !important;
    min-height: 320px !important;
  }

  .feature-description {
    order: 1 !important;
    padding-right: 2rem !important;
  }

  .feature-description p {
    font-size: 1.1rem !important;
    line-height: 1.6 !important;
  }

  .feature-video-container {
    order: 2 !important;
    height: 240px !important;
  }

  .feature-title {
    order: 3 !important;
    padding-left: 2rem !important;
  }

  .feature-title h3 {
    font-size: 4rem !important;
    font-weight: 600 !important;
  }

  .feature-number {
    font-size: 1rem !important;
  }
}

/* Medium-large screens (1280px - 1439px) */
@media screen and (min-width: 1280px) and (max-width: 1439px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: 1fr 1.6fr 2.4fr !important;
    padding: 2.5rem 80px !important;
    gap: 2.5rem !important;
    min-height: 280px !important;
  }

  .feature-description {
    order: 1 !important;
    padding-right: 1.5rem !important;
  }

  .feature-description p {
    font-size: 1rem !important;
    line-height: 1.55 !important;
  }

  .feature-video-container {
    order: 2 !important;
    height: 200px !important;
  }

  .feature-title {
    order: 3 !important;
    padding-left: 1.5rem !important;
  }

  .feature-title h3 {
    font-size: 3.5rem !important;
    font-weight: 600 !important;
  }

  .feature-number {
    font-size: 0.95rem !important;
  }
}

/* Small-medium screens (1024px - 1279px) - CRITICAL FIX AREA */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
  .interactive-features .container {
    padding: 0 40px !important;
  }

  .feature-list {
    margin: 0 -40px !important;
  }

  a.feature-item,
  .feature-item {
    grid-template-columns: 0.8fr 1.4fr 2.3fr !important;
    padding: 2rem 40px !important;
    gap: 2rem !important;
    min-height: 240px !important;
  }

  .feature-description {
    order: 1 !important;
    padding-right: 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  .feature-description p {
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
    margin: 0 0 0.75rem 0 !important;
    /* Ensure text doesn't overflow */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
  }

  .feature-video-container {
    order: 2 !important;
    height: 160px !important;
    width: 100% !important;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    background: #f5f5f5 !important;
  }

  .feature-video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
  }

  .feature-title {
    order: 3 !important;
    padding-left: 1rem !important;
    display: flex !important;
    align-items: center !important;
  }

  .feature-title h3 {
    font-size: 2.8rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  .feature-number {
    font-size: 0.85rem !important;
    opacity: 0.7 !important;
  }
}

/* Very small laptops (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  .interactive-features .container {
    padding: 0 20px !important;
  }

  .feature-list {
    margin: 0 !important;
  }

  a.feature-item,
  .feature-item {
    grid-template-columns: 0.7fr 1.3fr 2fr !important;
    padding: 1.5rem 20px !important;
    gap: 1.5rem !important;
    min-height: 200px !important;
  }

  .feature-description {
    order: 1 !important;
    padding-right: 0.5rem !important;
  }

  .feature-description p {
    font-size: 0.85rem !important;
    line-height: 1.45 !important;
    margin: 0 0 0.5rem 0 !important;
  }

  .feature-video-container {
    order: 2 !important;
    height: 140px !important;
  }

  .feature-title {
    order: 3 !important;
    padding-left: 0.5rem !important;
  }

  .feature-title h3 {
    font-size: 2.2rem !important;
    font-weight: 600 !important;
  }

  .feature-number {
    font-size: 0.8rem !important;
  }
}

/* Ensure proportional scaling */
@media screen and (min-width: 768px) {
  /* Maintain aspect ratios */
  .feature-video-container {
    position: relative !important;
    background: #f0f0f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
  }

  .feature-video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Ensure videos are always visible */
  .feature-video {
    opacity: 0.8 !important;
  }

  a.feature-item:hover .feature-video,
  .feature-item:hover .feature-video {
    opacity: 1 !important;
  }
}

/* Fix for ensuring all content is visible */
@media screen and (min-width: 768px) and (max-width: 1439px) {
  /* Allow feature items to grow as needed */
  a.feature-item,
  .feature-item {
    height: auto !important;
    min-height: max-content !important;
  }

  /* Ensure description text is fully visible */
  .feature-description {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }

  .feature-description p {
    overflow: visible !important;
    text-overflow: initial !important;
    -webkit-line-clamp: unset !important;
    display: block !important;
    max-height: none !important;
  }

  /* Ensure title doesn't get cut off */
  .feature-title {
    height: auto !important;
    min-height: auto !important;
  }
}

/* Proportional font scaling formula */
@media screen and (min-width: 768px) and (max-width: 1440px) {
  .feature-title h3 {
    /* Scale from 2.2rem at 768px to 4rem at 1440px */
    font-size: calc(
      2.2rem + (4 - 2.2) * ((100vw - 768px) / (1440 - 768))
    ) !important;
  }

  .feature-description p {
    /* Scale from 0.85rem at 768px to 1.1rem at 1440px */
    font-size: calc(
      0.85rem + (1.1 - 0.85) * ((100vw - 768px) / (1440 - 768))
    ) !important;
  }

  .feature-video-container {
    /* Scale height from 140px at 768px to 240px at 1440px */
    height: calc(
      140px + (240 - 140) * ((100vw - 768px) / (1440 - 768))
    ) !important;
  }
}

/* Hover effects */
@media screen and (min-width: 768px) {
  a.feature-item:hover,
  .feature-item:hover {
    background-color: #f8f8f8 !important;
  }

  a.feature-item:hover .feature-title h3,
  .feature-item:hover .feature-title h3 {
    transform: translateX(-8px) !important;
  }
}

/* Debug helper - remove in production */
@media screen and (min-width: 768px) and (max-width: 1279px) {
  /* Outline to see element boundaries during testing
  .feature-description { outline: 1px solid red !important; }
  .feature-video-container { outline: 1px solid blue !important; }
  .feature-title { outline: 1px solid green !important; }
  */
}
