/* Feature Grid Component Styles */
.feature-grid-section {
  padding: 100px 5vw;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.feature-grid-header {
  text-align: center;
  max-width: 900px;
  margin-bottom: 60px;
}

.feature-grid-container {
  display: grid;
  /* Use 10 columns to allow 40% (4/10) and 60% (6/10) proportions */
  grid-template-columns: repeat(10, 1fr);
  gap: 30px;
  width: 70%;
  max-width: 1400px;
}

/* Special handling for 3-item grids - use 3 equal columns */
.feature-grid-container:has(.feature-grid-card:nth-child(3):last-child) {
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
}

/* Special handling for 2-item grids - use 2 equal columns */
.feature-grid-container:has(.feature-grid-card:nth-child(2):last-child) {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 30px;
}

.feature-grid-container:has(.feature-grid-card:nth-child(2):last-child)
  .feature-grid-card {
  grid-column: span 1 !important;
}

.feature-grid-container:has(.feature-grid-card:nth-child(3):last-child)
  .feature-grid-card {
  grid-column: span 1 !important;
}

/* Special handling for 1-item grids - use full width */
.feature-grid-container:has(.feature-grid-card:only-child) .feature-grid-card {
  grid-column: span 10 !important;
  min-width: 60%;
  max-width: 80%; /* Limit width for cleaner look */
  margin: 0 auto; /* Center it */
}

.feature-grid-card {
  background: #1e1e24; /* Solid dark background */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  height: 400px; /* Fixed height for consistency */
  /* transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); REMOVED to prevent scroll jitter */
  transition: box-shadow 0.3s, border-color 0.3s, transform 0.3s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  /* New Flex Layout */
  display: flex;
  flex-direction: column;
}

/* 
   Row 1 (Items 1, 2): 4 cols (40%) | 6 cols (60%)
   Row 2 (Items 3, 4): 6 cols (60%) | 4 cols (40%)
   Row 3 (Items 5, 6): 4 cols (40%) | 6 cols (60%)
   ... and so on.
   Logic:
   - 4n+1 (1st, 5th...) -> span 4
   - 4n+2 (2nd, 6th...) -> span 6
   - 4n+3 (3rd, 7th...) -> span 6
   - 4n+4 (4th, 8th...) -> span 4
*/

.feature-grid-card:nth-child(4n + 1) {
  grid-column: span 4;
}
.feature-grid-card:nth-child(4n + 2) {
  grid-column: span 6;
}
.feature-grid-card:nth-child(4n + 3) {
  grid-column: span 6;
}
.feature-grid-card:nth-child(4n + 4) {
  grid-column: span 4;
}

.feature-grid-card:hover {
  transform: translateY(-5px);
  border-color: var(--c-accent);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.feature-grid-img-wrapper {
  width: 90%; /* Fixed percentage */
  height: 75%; /* Fixed percentage height */
  position: absolute;
  bottom: 0;
  right: 0;
  overflow: hidden;
  z-index: 1; /* Behind title but visible */
}

.feature-grid-img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: fill; /* Stretch to exactly match wrapper dimensions */
  object-position: bottom right; /* Anchor to bottom right corner */
  padding: 0; /* Remove padding to let it flush against edges */
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  opacity: 1;
}

.feature-grid-card:hover .feature-grid-img {
  /* transform: scale(1.05); Removed to prevent cutting */
  opacity: 1;
}

/* Item Title - Now Relative/Block */
.feature-grid-item-title {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  color: white;
  font-size: 20px;
  font-weight: 500;
  width: 100%;
  padding: 20px 25px 0 25px; /* Padding for spacing */
  text-align: left;
  font-family: var(--font-display, sans-serif);
  pointer-events: none;
}

/* Optional: Overlay text if needed in future, hidden by default if not passed */
.feature-grid-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 30px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
  transform: translateY(100%);
  transition: transform 0.3s;
}

/* Ensure responsiveness */
@media (max-width: 1024px) {
  /* On tablets, show 3-item grids in 2 columns, then 1 on next row */
  .feature-grid-container:has(.feature-grid-card:nth-child(3):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .feature-grid-container {
    display: flex;
    flex-direction: column;
    width: 90%; /* Wider on mobile */
  }

  /* Reset 3-column and 2-column grid to single column on mobile */
  .feature-grid-container:has(.feature-grid-card:nth-child(3):last-child),
  .feature-grid-container:has(.feature-grid-card:nth-child(2):last-child) {
    display: flex;
    flex-direction: column;
  }

  .feature-grid-card {
    width: 100%;
    grid-column: span 10 !important; /* Reset spans for mobile */
    height: 300px;
  }
  .feature-grid-item-title {
    font-size: 18px;
    top: 20px;
    left: 20px;
  }
}

/* Override for Plug & Play Section (User Request: 60/40 then 40/60) */
#feature-plug-play .feature-grid-card:nth-child(4n + 1) {
  grid-column: span 6;
}
#feature-plug-play .feature-grid-card:nth-child(4n + 2) {
  grid-column: span 4;
}
#feature-plug-play .feature-grid-card:nth-child(4n + 3) {
  grid-column: span 4;
}
#feature-plug-play .feature-grid-card:nth-child(4n + 4) {
  grid-column: span 6;
}

/* Override for Built For Scale Section (User Request: 4 cards total, so 2x2 layout) */
#feature-realtime .feature-grid-container {
  grid-template-columns: repeat(2, 1fr) !important;
  width: 90% !important;
  max-width: 1400px !important;
}

#feature-realtime .feature-grid-card {
  grid-column: span 1 !important;
  height: auto !important; /* Allow auto height for content cards */
  min-height: 440px; /* Taller min-height for scale section */
}

/* --- HAS DESCRIPTION VARIANT (Top Image -> Title -> Desc) --- */
.feature-grid-card.has-description {
  justify-content: flex-start;
  padding-bottom: 0; /* Removed padding to ensure strict 60/40 split */
}

/* Image at TOP using order */
.feature-grid-card.has-description .feature-grid-img-wrapper {
  order: -1; /* Moves to top */
  position: relative;
  width: 100%;
  flex: 0 0 60%; /* STRICTLY enforce 60% height, do not shrink/grow */
  height: 60%;
  max-height: 60%;
  margin: 0;
  border-radius: 0;
  mask-image: none;
  -webkit-mask-image: none;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-grid-card.has-description .feature-grid-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.feature-grid-card.has-description .feature-grid-item-title {
  padding: 25px 30px 5px 30px; /* Increased side padding for better aesthetic */
  height: auto;
  font-size: 19px; /* Slightly adjusted size */
  line-height: 1.3;
  margin-top: 0;
  color: white;
  flex-shrink: 0; /* Title should not shrink */
}

.feature-grid-item-desc {
  padding: 5px 30px 20px 30px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  line-height: 1.5;
  z-index: 2;
  position: relative;
  flex-grow: 1;
  overflow: hidden; /* Prevent spillover */
}
/* PROTOCOL CARDS */
.proto-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 50px;
  width: 100%;
  max-width: 1400px; /* Aligned with other grids */
}
.proto-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 40px;
  border-radius: 12px;
  transition: transform 0.3s, background 0.3s;
}
.proto-card:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-10px);
  border-color: rgba(0, 242, 234, 0.3);
}
.proto-card h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: var(--c-accent);
  margin-top: 20px;
}
.proto-card p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}
.box-icon {
  font-size: 28px;
  color: var(--c-accent);
  margin-bottom: 20px;
  display: inline-block;
}
@media (max-width: 900px) {
  .proto-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .proto-grid {
    grid-template-columns: 1fr;
  }
}
