/* Scoped styles pentru Homepage Cards Module */
#custom-cards-section {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 1px; /* Minimal padding as requested */
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

#custom-cards-section * {
  box-sizing: border-box;
}


/* Updated grid to support 4 columns for flexible layout */
#custom-cards-section .card-container {
  display: grid;
  /* Using minmax(0, 1fr) to enforce equal column widths and prevent content overflow */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* Added grid-auto-flow to ensure proper row-based layout */
  grid-auto-flow: row dense;
  gap: 12px; /* Reduced gap for tighter layout */
  max-width: 100vw;
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

#custom-cards-section .card-item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Softer shadow */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* Added will-change to optimize transform performance and prevent affecting other cards */
  will-change: transform;
  /* Added backface-visibility to ensure smooth transform */
  backface-visibility: hidden;
  /* Added width and min-width to ensure cards fill their grid cell equally */
  width: 100%;
  min-width: 0;
  max-width: 100%; /* Enforcing width constraints to prevent expansion */
}

/* Enhanced styles for clickable cards to prevent layout issues */
#custom-cards-section .card-link {
  cursor: pointer;
  display: block;
  text-decoration: none !important;
  color: inherit !important;
  /* Ensure anchor tag doesn't add extra spacing */
  margin: 0;
  padding: 0;
  /* Prevent anchor from affecting grid layout */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  /* Ensure it behaves as a proper grid item */
  box-sizing: border-box;
}

#custom-cards-section .card-link:hover {
  text-decoration: none;
  color: inherit;
}

#custom-cards-section .card-link:focus,
#custom-cards-section .card-link:active,
#custom-cards-section .card-link:visited {
  text-decoration: none !important;
  color: inherit !important;
  outline: none;
}

#custom-cards-section .card-item:hover {
  /* Using translate3d instead of translateY for better performance and isolation */
  transform: translate3d(0, -3px, 0); /* Subtle hover effect */
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Large cards now span 2 columns */
#custom-cards-section .card-large {
  min-height: 350px;
  grid-column: span 2;
}

#custom-cards-section .card-small {
  min-height: 350px; /* Increased height to match reference */
}

/* Added class for cards that span 2 columns in row 3 */
#custom-cards-section .card-span-2 {
  grid-column: span 2;
}

#custom-cards-section .card-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

/* Removed overlay gradient for cleaner look matching reference */
#custom-cards-section .card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent; /* No overlay, let background show through */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: column;
  padding: 20px;
}

#custom-cards-section .card-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
  text-align: center;
  z-index: 2;
}

/* New wrapper for top content (label + title) */
#custom-cards-section .card-top-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-top: 10px;
}

/* New wrapper for bottom content (button) */
#custom-cards-section .card-bottom-content {
  display: flex;
  justify-content: center;
  width: 100%;
  padding-bottom: 10px;
}

#custom-cards-section .card-logo {
  margin-bottom: 20px;
}

#custom-cards-section .card-logo img {
  max-width: 150px;
  height: auto;
}

#custom-cards-section .card-title,
#custom-cards-section .card-title-small,
#custom-cards-section .card-title-large {
  font-size: 30px; /* Matching reference design */
  font-weight: 700;
  margin: 5px 0 0 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
}

#custom-cards-section .card-title-small {
  color: #ff6b35;
}

#custom-cards-section .card-label {
  font-size: 11px; /* Smaller label text matching reference */
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.3;
}

#custom-cards-section .card-subtitle {
  font-size: 1.1rem;
  /* Adjusted margin for new layout */
  margin: 10px 0 0 0;
  font-weight: 400;
  line-height: 1.5;
}

/* Updated button styling to match reference design */
#custom-cards-section .card-button {
  display: inline-block;
  background-color: #e67200; /* Orange color from reference */
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 40px; /* More rounded buttons */
  text-decoration: none;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  border: none;
  line-height: 100%;
}

#custom-cards-section .card-button:hover {
  background-color: #000000; /* Black on hover matching reference */
  color: #ffffff;
  transform: none; /* No scale on hover */
}

/* Enhanced responsive design for multiple device resolutions */

/* Large Laptop / Desktop (1200px+) - Default 4 column grid */
@media (min-width: 1200px) {
  #custom-cards-section .card-container {
    gap: 16px;
  }
}

/* Standard Laptop (992px - 1199px) - 4 columns but tighter spacing */
@media (max-width: 1199px) and (min-width: 992px) {
  #custom-cards-section .card-container {
    gap: 14px;
  }

  #custom-cards-section .card-title,
  #custom-cards-section .card-title-small,
  #custom-cards-section .card-title-large {
    font-size: 26px;
  }

  #custom-cards-section .card-subtitle {
    font-size: 1rem;
  }
}

/* Tablet Landscape (768px - 991px) - 2 columns */
@media (max-width: 991px) and (min-width: 768px) {
  #custom-cards-section {
    padding: 0 1px;
  }

  #custom-cards-section .card-container {
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* Using minmax(0, 1fr) instead of just 1fr for equal columns */
    gap: 12px;
  }

  #custom-cards-section .card-large,
  #custom-cards-section .card-span-2 {
    grid-column: span 2;
  }

  #custom-cards-section .card-small {
    grid-column: span 1;
  }

  #custom-cards-section .card-title,
  #custom-cards-section .card-title-small,
  #custom-cards-section .card-title-large {
    font-size: 24px;
  }

  #custom-cards-section .card-subtitle {
    font-size: 0.95rem;
  }

  #custom-cards-section .card-large,
  #custom-cards-section .card-small {
    min-height: 300px;
  }
}

/* Tablet Portrait & Mobile (below 768px) - 2 small cards per row, 1 large per row */
@media (max-width: 767px) {
  #custom-cards-section {
    /* Removed all padding on mobile to prevent right shift */
    padding: 0;
    margin: 0;
    width: 100%;
  }

  /* 2 column grid for mobile to show 2 small cards per row */
  #custom-cards-section .card-container {
    /* Using 1fr 1fr instead of repeat for more reliable equal columns */
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  /* Large cards span full width (1 per row) */
  #custom-cards-section .card-large,
  #custom-cards-section .card-span-2 {
    grid-column: span 2;
    min-height: 320px;
    max-width: 100%; /* Added max-width to prevent overflow */
  }

  /* Small cards take 1 column (2 per row) */
  #custom-cards-section .card-small {
    grid-column: span 1;
    min-height: 300px;
    max-width: 100%; /* Added max-width to prevent overflow */
  }

  #custom-cards-section .card-title,
  #custom-cards-section .card-title-small,
  #custom-cards-section .card-title-large {
    font-size: 20px;
    letter-spacing: 1px;
  }

  #custom-cards-section .card-label {
    font-size: 9px;
  }

  #custom-cards-section .card-subtitle {
    font-size: 0.9rem;
    margin-bottom: 20px;
  }

  /* Smaller buttons for tablet */
  #custom-cards-section .card-button {
    padding: 8px 15px;
    font-size: 9px;
  }

  #custom-cards-section .card-overlay {
    padding: 15px;
  }

  /* Added class to hide buttons on mobile */
  #custom-cards-section .hide-on-mobile {
    display: none !important;
  }
}

/* Mobile Small (below 480px) - 2 small cards per row, 1 large card per row */
@media (max-width: 479px) {
  #custom-cards-section {
    /* Removed all padding on small mobile */
    padding: 0;
    margin: 0;
    width: 100%;
  }

  /* 2 column grid for small mobile */
  #custom-cards-section .card-container {
    /* Using 1fr 1fr for perfectly equal columns */
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  /* Large cards span full width */
  #custom-cards-section .card-large,
  #custom-cards-section .card-span-2 {
    grid-column: span 2;
    min-height: 320px;
    max-width: 100%; /* Added max-width to prevent overflow */
  }

  /* Small cards take 1 column (2 per row) */
  #custom-cards-section .card-small {
    grid-column: span 1;
    min-height: 300px;
    max-width: 100%; /* Added max-width to prevent overflow */
  }

  #custom-cards-section .card-title,
  #custom-cards-section .card-title-small,
  #custom-cards-section .card-title-large {
    font-size: 18px;
    letter-spacing: 0.5px;
  }

  #custom-cards-section .card-label {
    font-size: 8px;
  }

  #custom-cards-section .card-subtitle {
    font-size: 0.75rem;
    margin-bottom: 14px;
    line-height: 1.4;
  }

  /* Much smaller buttons for small mobile */
  #custom-cards-section .card-button {
    padding: 6px 12px;
    font-size: 8px;
    border-radius: 30px;
  }

  #custom-cards-section .card-overlay {
    padding: 12px;
  }

  #custom-cards-section .card-logo {
    margin-bottom: 12px;
  }

  #custom-cards-section .card-logo img {
    max-width: 80px;
  }
}

/* Hover effects disabled on touch devices for better mobile experience */
@media (hover: none) and (pointer: coarse) {
  #custom-cards-section .card-item:hover {
    transform: none;
  }

  #custom-cards-section .card-item:hover .card-image {
    transform: none;
  }

  #custom-cards-section .card-button:hover {
    transform: none;
  }
}
