/**
 * Bento Box Section Styles
 * Matches live Morae bento box module (e.g. /solutions/ai-managed-solutions/ "How It Works")
 * Supporting Three Columns, Two Columns, and Masonry (Left & Right) Layouts
 */

/* ==========================================================================
   1. Base Section Container & Themes
   ========================================================================== */
.morae-bento-box-section {
  background-color: var(--bento-bg, #ffffff);
  color: var(--bento-text, #262626);
  padding-top: var(--morae-section-py-lg, clamp(4.4375rem, 2.055rem + 10.166vw, 10.1875rem));
  padding-bottom: var(--morae-section-py-lg, clamp(4.4375rem, 2.055rem + 10.166vw, 10.1875rem));
  width: 100%;
  position: relative;
  box-sizing: border-box;
}

/* Same-theme consecutive sections: remove duplicate top padding */
section.morae-theme-dark + .morae-bento-box-section.morae-theme-dark:not(.ignore-same-theme-rule),
section:is(.morae-theme-light, .morae-theme-default, .light) + .morae-bento-box-section:is(.morae-theme-light, .morae-theme-default, .light):not(.ignore-same-theme-rule),
section.morae-theme-natural + .morae-bento-box-section.morae-theme-natural:not(.ignore-same-theme-rule) {
  padding-top: 0 !important;
}

/* Light / Default Theme */
.morae-bento-box-section.morae-theme-light,
.morae-bento-box-section.morae-theme-default {
  --bento-bg: #ffffff;
  --bento-text: #262626;
  --bento-border: #ede5de;
  --bento-card-bg: transparent;
  --bento-card-desc: #6e6e6e;
  background-color: #ffffff;
  color: #262626;
}

/* Natural Theme */
.morae-bento-box-section.morae-theme-natural {
  --bento-bg: #f5f4f0;
  --bento-text: #262626;
  --bento-border: #e0dcd5;
  --bento-card-bg: transparent;
  --bento-card-desc: #6e6e6e;
  background-color: #f5f4f0;
  color: #262626;
}

/* Dark Theme */
.morae-bento-box-section.morae-theme-dark {
  --bento-bg: #101010;
  --bento-text: #f5f4f0;
  --bento-border: rgba(255, 255, 255, 0.15);
  --bento-card-bg: #101010;
  --bento-card-desc: #cac5be;
  background-color: #101010;
  color: #f5f4f0;
}

.morae-bento-box-section.morae-theme-dark .morae-bento-title {
  color: #ffffff;
}

/* ==========================================================================
   2. Container (Aligned to Side Padding)
   ========================================================================== */
.morae-bento-container {
  max-width: 1920px !important;
  width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: var(--morae-side-padding, clamp(2rem, 1.5rem + 2vw, 5rem)) !important;
  padding-right: var(--morae-side-padding, clamp(2rem, 1.5rem + 2vw, 5rem)) !important;
  box-sizing: border-box;
}

/* ==========================================================================
   3. Section Header (Topline & Headline)
   ========================================================================== */
.morae-bento-header {
  margin-bottom: var(--spacing-2xl, clamp(2.625rem, 2.1934rem + 1.84vw, 3.6875rem)) !important;
  max-width: min(740px, 58.333vw);
  display: flex;
  flex-direction: column;
}

.morae-bento-topline {
  font-family: var(--morae-font, 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  color: var(--primary-accessible, #e03100);
  font-size: var(--morae-font-size-topline, clamp(1.125rem, 1.0732rem + 0.221vw, 1.25rem));
  line-height: 1.5;
  font-weight: 500;
  margin: 0 0 0.5rem 0;
  letter-spacing: normal;
  display: block;
}

.morae-bento-title {
  font-family: var(--morae-font, 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  color: inherit;
  font-size: var(--morae-font-size-display-2xl, clamp(1.9375rem, 1.5231rem + 1.768vw, 2.9375rem));
  line-height: clamp(2.5rem, 1.9302rem + 2.4309vw, 3.875rem);
  font-weight: 400;
  letter-spacing: 0em;
  margin: 0;
  text-wrap: balance;
}

/* ==========================================================================
   4. Bento Grid Layouts
   ========================================================================== */
.morae-bento-grid {
  display: grid;
  gap: var(--morae-gutter, clamp(1.25rem, 1.15rem + 0.35vw, 1.5rem)) !important;
  width: 100%;
  box-sizing: border-box;
}

/* 3 Columns Grid */
.morae-bento-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 2 Columns Grid */
.morae-bento-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Masonry Grid (3 Columns x 2 Rows) */
.morae-bento-masonry {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
}

/* ==========================================================================
   5. Masonry Card Positioning (Alignment Left / Right)
   ========================================================================== */
.morae-bento-align-right .morae-bento-card-featured {
  grid-column: 2 / span 2;
  grid-row: 1 / span 2;
}

.morae-bento-align-right .morae-bento-small-1 {
  grid-column: 1;
  grid-row: 1;
}

.morae-bento-align-right .morae-bento-small-2 {
  grid-column: 1;
  grid-row: 2;
}

.morae-bento-align-left .morae-bento-card-featured {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
}

.morae-bento-align-left .morae-bento-small-1 {
  grid-column: 3;
  grid-row: 1;
}

.morae-bento-align-left .morae-bento-small-2 {
  grid-column: 3;
  grid-row: 2;
}

/* Masonry Featured Card Desktop Layout (Matches Live Next.js behavior) */
@media (min-width: 1024px) {
  .morae-bento-masonry {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, auto) !important;
  }

  .morae-bento-masonry .morae-bento-card-featured {
    position: relative !important;
    overflow: clip !important;
    height: 100% !important;
    padding: 0 !important;
    display: block !important;
    border-top: none !important;
    border-right: none !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-inner {
    position: absolute !important;
    inset: 0 !important;
    padding: 1.2em 1.6em !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-image-wrap {
    flex: 1 0 auto !important;
    flex-shrink: 0 !important;
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    position: relative !important;
    margin-top: 1.5rem !important;
    display: block !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: 50% 50% !important;
    display: block !important;
  }
}

/* ==========================================================================
   6. Bento Card Article Base Styles
   ========================================================================== */
.morae-bento-card {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  row-gap: var(--spacing-xl, clamp(2rem, 1.8rem + 0.8vw, 2.4375rem)) !important;
  font-size: var(--morae-font-size-body-lg, clamp(1.125rem, 1.081rem + 0.1878vw, 1.25rem));
  line-height: 1.5;
  padding: 1.2em 1.6em !important;
  box-sizing: border-box !important;
  position: relative;
  border-top: none !important;
  border-right: none !important;
  border-left: 1px solid var(--bento-border, #ece8e2) !important;
  border-bottom: 1px solid var(--bento-border, #ece8e2) !important;
  background-color: var(--bento-card-bg, transparent);
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Card Content Area (Top) */
.morae-bento-card-content {
  display: flex !important;
  flex-direction: column !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Pictogram (w-[2.4em] aspect-square) */
.morae-bento-pictogram-wrap {
  width: 2.4em !important;
  height: 2.4em !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-shrink: 0 !important;
}

.morae-bento-pictogram-mask {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  background: var(--pictogram-gradient, linear-gradient(119.49deg, #ff3600 12.98%, #ff7700 60.83%, #ffbd00 102.78%)) !important;
  -webkit-mask-size: contain !important;
  -webkit-mask-repeat: no-repeat !important;
  -webkit-mask-position: left center !important;
  mask-size: contain !important;
  mask-repeat: no-repeat !important;
  mask-position: left center !important;
}

/* Card Title (display-base mt-[1.2em]) */
.morae-bento-card-title {
  font-family: var(--morae-font, 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: var(--morae-font-size-display-base, clamp(1.125rem, 1.081rem + 0.1878vw, 1.25rem)) !important;
  line-height: 1.5 !important;
  font-weight: 500 !important;
  margin-top: 1.2em !important;
  margin-bottom: 0 !important;
  letter-spacing: 0em;
  color: inherit;
}

/* Card Description (typo-sm mt-[0.4706em] text-muted) */
.morae-bento-card-desc {
  font-family: var(--morae-font, 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: var(--morae-font-size-body-sm, clamp(0.9375rem, 0.9001rem + 0.1596vw, 1.04375rem)) !important;
  line-height: 1.5 !important;
  margin-top: 0.4706em !important;
  margin-bottom: 0 !important;
  color: var(--bento-card-desc, #6e6e6e) !important;
}

/* Card Image Wrappers (aspect-video relative) */
.morae-bento-card-image-wrap {
  width: 100% !important;
  aspect-ratio: 16 / 9 !important;
  position: relative !important;
  overflow: hidden !important;
  margin-top: auto !important;
}

.morae-bento-card-img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* Featured Card Image Wrap in Masonry */
.morae-bento-featured-image-wrap {
  width: 100% !important;
  aspect-ratio: 16 / 9 !important;
  position: relative !important;
  overflow: hidden !important;
  margin-top: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.morae-bento-featured-img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center bottom !important;
  display: block !important;
}

/* ==========================================================================
   7. Specific Card Themes (Highlight Dark Card vs Light Card)
   ========================================================================== */
/* Highlighted Dark Card (bg-background dark text-foreground) */
.morae-bento-card-dark {
  background-color: var(--morae-charcoal-900, #0f0f0f) !important;
  color: var(--morae-natural-0, #f5f4f0) !important;
  border-left-color: #424242 !important;
  border-bottom-color: #424242 !important;
}

.morae-bento-card-dark .morae-bento-card-title {
  color: #f5f4f0 !important;
}

.morae-bento-card-dark .morae-bento-card-desc {
  color: rgba(245, 242, 239, 0.72) !important;
}

/* Light Card */
.morae-bento-card-light {
  background-color: transparent !important;
  color: #262626 !important;
  border-left-color: var(--bento-border, #ece8e2) !important;
  border-bottom-color: var(--bento-border, #ece8e2) !important;
}

.morae-bento-card-light .morae-bento-card-title {
  color: #262626 !important;
}

.morae-bento-card-light .morae-bento-card-desc {
  color: #6e6e6e !important;
}

/* Dark Theme Section Overrides */
.morae-bento-box-section.morae-theme-dark .morae-bento-card {
  background-color: #101010 !important;
  border-left-color: rgba(255, 255, 255, 0.15) !important;
  border-bottom-color: rgba(255, 255, 255, 0.15) !important;
}

.morae-bento-box-section.morae-theme-dark .morae-bento-card .morae-bento-card-title {
  color: #ffffff !important;
}

.morae-bento-box-section.morae-theme-dark .morae-bento-card .morae-bento-card-desc {
  color: #cac5be !important;
}

/* ==========================================================================
   8. Large Desktop Viewport Scaling (>= 90rem / 1440px)
   ========================================================================== */
@media (min-width: 90rem), (min-width: 1440px) {
  .morae-bento-box-section {
    padding-top: clamp(4.4375rem, 2.0549rem + 10.1657vw, 10.1875rem) !important;
    padding-bottom: clamp(4.4375rem, 2.0549rem + 10.1657vw, 10.1875rem) !important;
  }

  .morae-bento-container {
    padding-left: 5.55556vw !important;
    padding-right: 5.55556vw !important;
  }

  .morae-bento-header {
    margin-bottom: 3.6111vw !important;
    max-width: 51.157vw !important;
  }

  .morae-bento-topline {
    font-size: 1.3889vw !important;
    line-height: 1.5 !important;
  }

  .morae-bento-title {
    font-size: 3.2895833vw !important;
    line-height: 1.3 !important;
  }

  .morae-bento-grid {
    gap: 1.66667vw !important;
  }

  .morae-bento-card {
    font-size: 1.38899vw !important;
    padding: 1.66667vw 2.2222vw !important;
    row-gap: 2.70833vw !important;
  }

  .morae-bento-pictogram-wrap {
    width: 3.3333vw !important;
    height: 3.3333vw !important;
  }

  .morae-bento-card-title {
    font-size: 1.38899vw !important;
    line-height: 1.5 !important;
    margin-top: 1.66667vw !important;
  }

  .morae-bento-card-desc {
    font-size: 1.15972vw !important;
    line-height: 1.5 !important;
    margin-top: 0.5458vw !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-inner {
    padding: 1.66667vw 2.2222vw !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-image-wrap {
    margin-top: 2.7083vw !important;
  }
}

/* ==========================================================================
   9. Responsive Breakpoints (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 1023.98px) {
  .morae-bento-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .morae-bento-cols-3 .morae-bento-card:last-child {
    grid-column: span 2;
  }

  .morae-bento-masonry {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .morae-bento-align-right .morae-bento-card-featured,
  .morae-bento-align-left .morae-bento-card-featured {
    grid-column: 1;
    grid-row: auto;
  }

  .morae-bento-align-right .morae-bento-small-1,
  .morae-bento-align-right .morae-bento-small-2,
  .morae-bento-align-left .morae-bento-small-1,
  .morae-bento-align-left .morae-bento-small-2 {
    grid-column: 1;
    grid-row: auto;
  }

  .morae-bento-masonry .morae-bento-card-featured {
    height: auto !important;
    padding: 1.25rem !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-inner {
    position: relative !important;
    inset: auto !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .morae-bento-masonry .morae-bento-card-featured .morae-bento-featured-image-wrap {
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    position: relative !important;
    margin-top: 1.5rem !important;
    display: block !important;
  }
}

@media (max-width: 767.98px) {
  .morae-bento-box-section {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }

  .morae-bento-container {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  .morae-bento-header {
    max-width: 100%;
    margin-bottom: 2rem !important;
  }

  .morae-bento-title {
    font-size: clamp(1.75rem, 6vw, 2.25rem);
    line-height: 1.2;
  }

  .morae-bento-cols-3,
  .morae-bento-cols-2,
  .morae-bento-masonry {
    grid-template-columns: 1fr;
  }

  .morae-bento-cols-3 .morae-bento-card:last-child {
    grid-column: span 1;
  }

  .morae-bento-card {
    padding: 1.25rem !important;
    row-gap: 1.75rem !important;
  }
}
