/* ===================================
   Resources Bento Grid Layout - Bloom-inspired
   Order, design, readability, style
   =================================== */

/* Bento Grid Section Wrapper - full width, centered */
.categories-bento-grid {
  width: 100%;
  max-width: min(1400px, calc(100vw - 2 * var(--youth-spacing-lg)));
  margin: 0 auto var(--youth-spacing-xl);
  padding: 0 var(--youth-spacing-lg);
  box-sizing: border-box;
}

/* Section header - Bloom-style */
.categories-bento-grid__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  padding: 0 4px;
}

.categories-bento-grid__title {
  font-family: var(--resources-font-heading);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--resources-text-warm);
  margin: 0;
}

.categories-bento-grid__link {
  color: var(--resources-coral);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

.categories-bento-grid__link:hover {
  color: var(--resources-amber);
}

/* The actual grid - 12 columns, intentional bento layout */
.categories-bento-grid .swipe-wrapper {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(3, minmax(180px, 1fr));
  gap: 20px;
  width: 100%;
}

/* Card Base Styles - Category-colored with readable contrast */
.categories-bento-grid .category-card {
  background: var(--category-bg) !important;
  border-radius: 24px;
  padding: var(--youth-spacing-xl);
  text-decoration: none;
  color: var(--category-text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid var(--category-border);
  position: relative;
  overflow: clip;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Desktop: more generous padding for breathing room */
@media (min-width: 1025px) {
  .categories-bento-grid .category-card {
    padding: 1.75rem 1.5rem;
  }
  .category-card.hero-faith-basics {
    padding: 2rem 1.75rem;
  }
  .category-card.small-culture-media {
    padding: 1.75rem 1.5rem;
  }
}

/* Subtle gradient overlay for depth (Bloom-style) - override micro-interactions */
.categories-bento-grid .category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
  height: auto;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Colors from resources-library.html - Understanding Your Mind, Study Smarter, etc. */
.category-faith_basics {
  --category-color: #FF6B5B;
  --category-color-light: #FFA598;
  --category-bg: #FF6B5B;
  --category-border: #E85A4A;
  --category-text: #ffffff;
  --category-text-muted: rgba(255,255,255,0.9);
}

.category-apologetics {
  --category-color: #FFB347;
  --category-color-light: #FFDDA0;
  --category-bg: #FFF0D6;
  --category-border: #FFDDA0;
  --category-text: #2D2726;
  --category-text-muted: #5C4D4D;
}

.category-identity_purpose {
  --category-color: #7BC8F6;
  --category-color-light: #AADCF5;
  --category-bg: #DCF0FC;
  --category-border: #AADCF5;
  --category-text: #1A3350;
  --category-text-muted: #2A4A70;
}

.category-tough_questions {
  --category-color: #1C1B2E;
  --category-color-light: #3A3850;
  --category-bg: #1C1B2E;
  --category-border: #2A2940;
  --category-text: #ffffff;
  --category-text-muted: rgba(255,255,255,0.9);
}

.category-culture_media {
  --category-color: #F7A8B8;
  --category-color-light: #FBCFE8;
  --category-bg: #F7A8B8;
  --category-border: #E895A5;
  --category-text: #5A1A2E;
  --category-text-muted: rgba(90,26,46,0.9);
}

.category-dating_friendships {
  --category-color: #6DDAB4;
  --category-color-light: #99F6E4;
  --category-bg: #6DDAB4;
  --category-border: #5AC9A3;
  --category-text: #1A3D2E;
  --category-text-muted: rgba(26,61,46,0.9);
}

.category-daily_discipleship {
  --category-color: #C3B1E1;
  --category-color-light: #D4C5F0;
  --category-bg: #C3B1E1;
  --category-border: #B3A0D1;
  --category-text: #3A2D5A;
  --category-text-muted: #5A4A7A;
}

.category-emotional_health {
  --category-color: #A8D5A2;
  --category-color-light: #C8E8C4;
  --category-bg: #A8D5A2;
  --category-border: #98C592;
  --category-text: #1A3D1E;
  --category-text-muted: #2A5D2E;
}

/* Saturated/dark cards: brighter overlay. Light pastels: softer overlay. */
.categories-bento-grid .category-faith_basics::before,
.categories-bento-grid .category-tough_questions::before {
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.categories-bento-grid .category-apologetics::before,
.categories-bento-grid .category-identity_purpose::before,
.categories-bento-grid .category-culture_media::before,
.categories-bento-grid .category-dating_friendships::before,
.categories-bento-grid .category-daily_discipleship::before,
.categories-bento-grid .category-emotional_health::before {
  background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 50%);
}

/* Focus states for accessibility */
.category-card:focus-visible {
  outline: 3px solid var(--category-color);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(0,0,0,0.1);
}

/* BENTO GRID LAYOUT - Intentional, artful distribution */
/* Row 1–2: Hero left | Stacked cards right */
/* 1. Faith Basics - hero, dominant left */
.category-card.hero-faith-basics {
  grid-column: 1 / 7;
  grid-row: 1 / 3;
  min-height: 360px;
}

/* 2. Apologetics - top right */
.category-card.medium-apologetics {
  grid-column: 7 / 10;
  grid-row: 1 / 2;
  min-height: 180px;
}

/* 3. Identity & Purpose - top right */
.category-card.medium-identity-purpose {
  grid-column: 10 / -1;
  grid-row: 1 / 2;
  min-height: 180px;
}

/* 4. Tough Questions - mid right */
.category-card.small-tough-questions {
  grid-column: 7 / 10;
  grid-row: 2 / 3;
  min-height: 180px;
}

/* 5. Culture & Media - same height as Tough Questions */
.category-card.small-culture-media {
  grid-column: 10 / -1;
  grid-row: 2 / 3;
  min-height: 180px;
}

/* Row 3: Bottom band */
/* 6. Dating & Friendships */
.category-card.small-dating-friendships {
  grid-column: 1 / 4;
  grid-row: 3 / 4;
  min-height: 180px;
}

/* 7. Daily Discipleship */
.category-card.small-daily-discipleship {
  grid-column: 4 / 8;
  grid-row: 3 / 4;
  min-height: 180px;
}

/* 8. Emotional Health - wide anchor */
.category-card.wide-emotional-health {
  grid-column: 8 / -1;
  grid-row: 3 / 4;
  min-height: 180px;
}

/* Card hover effects - override micro-interactions */
.categories-bento-grid .category-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.13);
  border-color: var(--category-color);
}

/* Card content styling - readable text per category */
.category-card .category-content {
  position: relative;
  z-index: 1;
}

/* Art placeholder removed - no longer used */

.category-card .category-icon {
  font-size: 2rem;
  margin-bottom: var(--youth-spacing-sm);
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.category-card.hero-faith-basics .category-icon {
  font-size: 2.8rem;
  margin-bottom: var(--youth-spacing-md);
}

.category-card .category-title {
  font-family: var(--resources-font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--category-text);
  margin-bottom: var(--youth-spacing-xs, 0.25rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow: clip;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  border-bottom: none;
  padding-bottom: 0;
}

/* Saturated/dark cards: add text shadow for legibility */
.category-faith_basics .category-title,
.category-tough_questions .category-title {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.category-card.hero-faith-basics .category-title {
  font-size: 1.5rem;
  margin-bottom: var(--youth-spacing-sm);
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.category-card .category-description {
  font-family: var(--resources-font-base);
  font-size: 0.78rem;
  color: var(--category-text-muted);
  line-height: 1.5;
  overflow: clip;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1;
  min-height: 0;
}

.category-faith_basics .category-description,
.category-tough_questions .category-description {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* RESPONSIVE DESIGN - BETTER SPACE MANAGEMENT */
@media (max-width: 1200px) {
  .categories-bento-grid {
    max-width: min(1200px, calc(100vw - 2 * var(--youth-spacing-md)));
    padding: 0 var(--youth-spacing-md);
  }
  
  .categories-bento-grid .swipe-wrapper {
    gap: 18px;
  }
}

@media (max-width: 1024px) {
  .categories-bento-grid .swipe-wrapper {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(160px, 1fr);
    gap: 16px;
  }
  
  .category-card.hero-faith-basics {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 340px;
  }
  
  .category-card.wide-emotional-health {
    grid-column: span 2;
    grid-row: span 1;
    min-height: 160px;
  }
  
  .category-card.medium-apologetics,
  .category-card.medium-identity-purpose,
  .category-card.small-tough-questions,
  .category-card.small-culture-media,
  .category-card.small-dating-friendships,
  .category-card.small-daily-discipleship {
    grid-column: span 1;
    grid-row: span 1;
    min-height: 160px;
  }
}

@media (max-width: 768px) {
  .categories-bento-grid {
    padding: 0 var(--youth-spacing-sm);
  }
  
  /* 2-col grid from mobile-experience.css; card spans overridden here */
  .category-card {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    min-height: 180px !important;
    padding: var(--youth-spacing-lg);
  }
  
  .category-card.small-culture-media {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    min-height: 180px !important;
  }
  
  .category-card.hero-faith-basics {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    min-height: 200px !important;
  }
  
  .category-card.wide-emotional-health {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    min-height: 200px !important;
  }
  
  .category-card.medium-apologetics,
  .category-card.medium-identity-purpose {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
  }
  
  .category-card.small-daily-discipleship {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
  }
}

@media (max-width: 480px) {
  .categories-bento-grid .swipe-wrapper {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .categories-bento-grid {
    padding: 0 var(--youth-spacing-sm);
  }
  
  .category-card {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    min-height: 160px !important;
    padding: var(--youth-spacing-md);
  }
  
  .category-card.hero-faith-basics,
  .category-card.wide-emotional-health {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
  }
  
  .category-card .category-icon {
    font-size: 2.5rem;
  }
  
  .category-card .category-title {
    font-size: 1.25rem;
  }
  
  .category-card .category-description {
    font-size: 0.875rem;
  }
}

/* Dark mode adjustments */
html.dark-mode .category-faith_basics {
  --category-bg: #E85A4A;
  --category-border: #D04A3A;
}

html.dark-mode .category-apologetics {
  --category-bg: #2A2218;
  --category-border: #3A3228;
  --category-text: #FFFBF7;
  --category-text-muted: #D4C4B0;
}

html.dark-mode .category-identity_purpose {
  --category-bg: #2A2438;
  --category-border: #3A3250;
  --category-text: #EDE6F8;
  --category-text-muted: #C4B8D8;
}

html.dark-mode .category-tough_questions {
  --category-bg: #1A2A38;
  --category-border: #2A3A50;
  --category-text: #DCF0FC;
  --category-text-muted: #A8C8E0;
}

html.dark-mode .category-culture_media {
  --category-bg: #134E4A;
  --category-border: #0F766E;
  --category-text: #CCFBF1;
  --category-text-muted: #99F6E4;
}

html.dark-mode .category-dating_friendships {
  --category-bg: #9D174D;
  --category-border: #831843;
  --category-text: #FCE7F3;
  --category-text-muted: #FBCFE8;
}

html.dark-mode .category-daily_discipleship {
  --category-bg: #312E81;
  --category-border: #4338CA;
  --category-text: #E0E7FF;
  --category-text-muted: #C7D2FE;
}

html.dark-mode .category-emotional_health {
  --category-bg: #1A2E24;
  --category-border: #2A3E34;
  --category-text: #D8F8ED;
  --category-text-muted: #A8D0C0;
}

html.dark-mode .category-card {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

html.dark-mode .category-card:hover {
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

html.dark-mode .categories-bento-grid__title {
  color: var(--resources-text-warm);
}

html.dark-mode .categories-bento-grid__link {
  color: var(--resources-coral-light);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .category-card {
    transition: none;
  }
  
  .category-card:hover {
    transform: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .category-card {
    border-width: 4px;
  }
  
  .category-card:focus-visible {
    outline-width: 4px;
    outline-offset: 4px;
  }
}
