@import url('./base-tokens.css');

/* Background: promote to its own composited layer and keep animations cheap */
    .background-animation {
      position: fixed;
      inset: 0;
      z-index: -1;
      overflow: hidden;
      pointer-events: none;
      -webkit-transform: translateZ(0); /* promote to GPU layer */
      transform: translateZ(0);
      will-change: transform, opacity;
    }

    .color-splash {
      position: absolute;
      opacity: 0.45;
      /* blur is costly — lowered here; remove on mobile below */
      filter: blur(18px);
      /* only animate transform/opacity (avoid animating border-radius) */
      animation: splash 20s infinite ease-in-out;
      border-radius: 50% / 50%;
      transform-origin: center;
      -webkit-transform: translate3d(0,0,0);
      transform: translate3d(0,0,0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      will-change: transform, opacity;
    }

    /* keep keyframes cheap — only transform and opacity */
    @keyframes splash {
      0%   { transform: translateY(0) translateX(0) scale(1) rotate(0deg); opacity: .45; }
      33%  { transform: translateY(-20px) translateX(10px) scale(1.05) rotate(6deg); opacity: .5; }
      66%  { transform: translateY(10px) translateX(-8px) scale(.98) rotate(-3deg); opacity: .45; }
      100% { transform: translateY(0) translateX(0) scale(1) rotate(0deg); opacity: .45; }
    }

    /* Disable heavy effects on small / touch devices (Android) */
    @media (max-width: 900px), (pointer: coarse) {
      .background-animation { /* simpler background on mobile to avoid repaints */
        /* optionally hide entirely if still problematic */
        /* display: none; */
      }
      .color-splash {
        animation: none !important;
        filter: none !important;
        opacity: 0.25;
      }
      .container {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background-color: var(--bg);
      }
    }

    :root {
      --bg: #f8fafc;
      --card: #ffffff;
      --text: #0f172a;
      --muted: #64748b;
      --primary: #7c3aed;
      --border: #e2e8f0;
      --highlight: #d1fae5;
      
      /* Pastel colors for shapes */
      --pastel1: #ffccf9;
      --pastel2: #d8f3ff;
      --pastel3: #e5ffe5;
      --pastel4: #ffe9c9;
      --pastel5: #ede6ff;
    }
    
    @media (prefers-color-scheme: dark) {
      :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #f1f5f9;
        --muted: #94a3b8;
        --border: #334155;
        --highlight: #065f46;
        
        /* Darker pastel colors for dark mode */
        --pastel1: #552f52;
        --pastel2: #253847;
        --pastel3: #1e3a1e;
        --pastel4: #3d2f1f;
        --pastel5: #2a2642;
      }
    }
    
    @keyframes float {
      0% {
        transform: translateY(0) translateX(0) rotate(0);
      }
      33% {
        transform: translateY(-40px) translateX(20px) rotate(10deg);
      }
      66% {
        transform: translateY(20px) translateX(-15px) rotate(-5deg);
      }
      100% {
        transform: translateY(0) translateX(0) rotate(0);
      }
    }
    
    /* Adding slight backdrop blur to make content stand out */
    .container {
      position: relative;
      z-index: 1;
      backdrop-filter: blur(1px);
      -webkit-backdrop-filter: blur(1px);
      background-color: rgba(var(--bg-rgb, 248, 250, 252), 0.7);
      border-radius: 16px;
      padding: 30px;
      max-width: 800px;
      margin: 0 auto;
      padding-top: 5vh;
    }
    
    body {
      font-family: system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      margin: 0;
      padding: 20px;
      min-height: 100vh;
    }

    /* Update the container width to use more screen space */
    .container {
      max-width: 800px;  /* Increased from 600px */
      margin: 0 auto;
      padding-top: 5vh;
    }

    /* For larger screens, allow even more width */
    @media (min-width: 1200px) {
      .container {
        max-width: 1000px;
      }
    }

    .header {
      margin-bottom: 1.5rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .title {
      font-size: 1.5rem;
      font-weight: bold;
    }

    .subtitle {
      font-size: 0.9rem;
      color: var(--muted);
    }
    
    .header-buttons {
      display: flex;
      gap: 12px;
      align-items: center;
    }
    
    .github-link, .login-link {
      display: flex;
      align-items: center;
      color: var(--muted);
      text-decoration: none;
      font-size: 0.9rem;
      gap: 4px;
      transition: color 0.2s;
    }
    
    .github-link:hover, .login-link:hover {
      color: var(--primary);
    }
    
    .login-link {
      padding: 4px 10px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--card);
    }

    .search-container {
      position: relative;
      margin-bottom: 1rem;
      display: flex;
      gap: 10px;
    }

    .search-input-wrapper {
      position: relative;
      flex-grow: 1;
    }

    .search-input {
      width: 100%;
      box-sizing: border-box;
      padding: 12px 12px 12px 40px;
      font-size: 1rem;
      border: 2px solid var(--border);
      border-radius: 8px;
      background: var(--card);
      color: var(--text);
    }

    .search-icon {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted);
    }

    .search-button {
      padding: 0 20px;
      background: var(--primary);
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 1rem;
      font-weight: bold;
      cursor: pointer;
      min-width: 100px;
    }

    /* New styles for Bible category selector */
    .bible-category-selector {
      margin-top: 2rem;
      margin-bottom: 2rem;
    }
    
    .category-container {
      display: flex;
      flex-wrap: wrap;
      gap: 1.5rem;
      margin-top: 1rem;
    }
    
    .category-column {
      flex: 1;
      min-width: 250px;
    }
    
    .category-group h3 {
      font-size: 1.2rem;
      margin-bottom: 0.75rem;
      color: var(--primary);
      font-weight: 600;
    }
    
    .category-section {
      margin-bottom: 1.5rem;
    }
    
    .category-section h4 {
      font-size: 1rem;
      margin-bottom: 0.5rem;
      color: var(--text);
      font-weight: 500;
      padding-bottom: 0.25rem;
      border-bottom: 1px solid var(--border);
    }
    
    .book-list {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
    }
    
    .book-link {
      font-size: 0.9rem;
      padding: 0.35rem 0.6rem;
      background-color: var(--card);
      border-radius: 6px;
      border: 1px solid var(--border);
      text-decoration: none;
      color: var(--text);
      transition: all 0.2s ease;
      display: inline-block;
    }
    
    .book-link:hover {
      background-color: var(--primary);
      color: white;
      border-color: var(--primary);
    }
    
    /* Mobile responsive adjustments */
    @media (max-width: 768px) {
      .category-container {
        flex-direction: column;
      }
      
      .book-list {
        flex-wrap: wrap;
      }
    }

    /* Quick Picks Styling */
    .quick-picks {
      margin-top: 2rem;
    }
    
    .chips {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 1rem;
    }
    
    .chip {
      padding: 8px 16px;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 20px;
      font-size: 0.9rem;
      color: var(--text);
      text-decoration: none;
      transition: all 0.2s;
    }
    
    .chip:hover {
      border-color: var(--primary);
      color: var(--primary);
    }
    
    .more-button {
      cursor: pointer;
      background-color: var(--card);
    }
    
    .more-button:hover {
      background-color: var(--border);
    }
    
    .hidden {
      display: none;
    }
    
    /* Text transition effect */
    .text-transition {
      position: relative;
      display: inline-block;
    }
    
    .text-option {
      position: absolute;
      left: 0;
      top: 0;
      opacity: 0;
      transition: opacity 1.2s ease-in-out;
      visibility: hidden;
    }
    
    .text-option.visible {
      opacity: 1;
      position: relative;
      visibility: visible;
    }

    body.light-mode {
      --bg: #f8fafc;
      --card: #ffffff;
      --text: #0f172a;
      --muted: #64748b;
      --primary: #7c3aed;
      --border: #e2e8f0;
      --highlight: #d1fae5;
      --pastel1: #ffccf9;
      --pastel2: #d8f3ff;
      --pastel3: #e5ffe5;
      --pastel4: #ffe9c9;
      --pastel5: #ede6ff;
    }

    .section-header {
      font-size: 1.3rem;
      color: var(--primary);
      margin-bottom: 1.2rem;
      text-align: left; /* or center, as needed */
      font-weight: 600;
    }

    /* Custom Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 2px solid var(--primary);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background-color: var(--primary);
  color: white;
}

.autocomplete-item .verse-ref {
  font-weight: 600;
  font-size: 0.95rem;
}

.autocomplete-item .verse-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 8px;
}

.autocomplete-item:hover .verse-desc,
.autocomplete-item.selected .verse-desc {
  color: rgba(255, 255, 255, 0.8);
}

.no-results {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Update search input when dropdown is open */
.search-input:focus {
  border-color: var(--primary);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.search-input-wrapper:has(.autocomplete-dropdown.show) .search-input {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* View toggle buttons */
.view-toggle-buttons {
  display: flex;
  gap: 8px;
}

.view-toggle-btn {
  padding: 6px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.view-toggle-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.view-toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

/* Compact view styles */
.compact-testament-section {
  margin-bottom: 2rem;
}

.compact-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.compact-category-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  transition: all 0.2s;
}

.compact-category-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

.compact-category-header {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.compact-book-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.book-chip {
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 500;
}

.book-chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Compact View V2 Styles */
.testament-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.testament-emoji {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.testament-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.compact-category-grid-v2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.compact-category-card-v2 {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.compact-category-card-v2:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.15);
  transform: translateY(-2px);
}

.category-emoji-side {
  font-size: 6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
}

.category-content {
  flex: 1;
  min-width: 0;
}

.compact-category-header-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.category-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.book-count {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.compact-book-chips-v2 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.book-chip-v2 {
  padding: 8px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.book-chip-v2::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.1), transparent);
  transition: left 0.3s;
}

.book-chip-v2:hover::before {
  left: 100%;
}

.book-chip-v2:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(124, 58, 237, 0.25);
}

.compact-testament-section {
  margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
  .compact-category-grid-v2 {
    grid-template-columns: 1fr;
  }
  
  .testament-emoji {
    font-size: 4rem;
  }
  
  .testament-title {
    font-size: 1.2rem;
  }
  
  .category-emoji-side {
    font-size: 4rem;
  }
  
  .compact-category-card-v2 {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* Alphabetical View Styles */
.alphabetical-books-view {
  display: none;
}

.alphabetical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 2rem;
}

.alphabetical-book-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.alphabetical-book-link:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(124, 58, 237, 0.25);
}

.book-emoji {
  font-size: 1.2rem;
  line-height: 1;
}

/* Force compact views on mobile (even before JS runs) */
@media (max-width: 768px) {
  .bible-category-selector .detailed-books-view { display: none !important; }
  .bible-category-selector .compact-books-view { display: block !important; }
  .themes-topics-section .themes-detailed-view { display: none !important; }
  .themes-topics-section .themes-compact-view { display: block !important; }
}
