/* Modal/Detail Screen - scrollable so all content is reachable */
.detail-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #101010;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 24px 20px;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

/* Recommended Books detail pages - white background */
.detail-modal.recommended-book {
  background-color: #fff;
}

.detail-modal.recommended-book .detail-title {
  color: #000;
  font-size: 18px;
}

.detail-modal.recommended-book .detail-description {
  color: #333;
  font-size: 18px;
}

.detail-modal.recommended-book .detail-close {
  background-color: rgba(255, 255, 255, 0.7);
  color: #000;
}

.detail-modal.recommended-book .detail-close:hover {
  background-color: rgba(255, 255, 255, 0.9);
}

/* Block layout so content can overflow and modal scrolls (image + text modals) */
.detail-modal.active {
  display: block;
}

.detail-modal.active .detail-image {
  margin-bottom: 4px;
  max-height: 420px;
}

.detail-modal.active .detail-image img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  object-position: top center;
  min-height: 200px;
  display: block;
}

/* Video-only: keep flex so video fills viewport */
.detail-modal.active.video-only {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.detail-modal.active.video-only .detail-video {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.detail-modal.active.video-only .detail-video video,
.detail-modal.active.video-only .detail-youtube-wrap {
  height: 100%;
}

/* Card-list-only: scrollable list */
.detail-modal.active.card-list-only {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.detail-modal.active.card-list-only .detail-card-list {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 1001;
  /* Ensure touch target is large enough on mobile */
  touch-action: manipulation;
}

.detail-close:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Header-style image: consistent max size on desktop */
.detail-image {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 4px;
  margin-top: 0;
  border-radius: 12px;
  overflow: hidden;
  min-height: 200px;
  max-height: 420px;
  display: flex !important;
  align-items: flex-start;
  justify-content: center;
  background-color: transparent;
  position: relative;
  visibility: visible !important;
}

.detail-image img {
  width: 100%;
  height: auto;
  max-height: 420px;
  display: block !important;
  max-width: 100%;
  min-height: 200px;
  min-width: 0;
  object-fit: contain;
  object-position: top center;
  background-color: transparent;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative;
}

.detail-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 0 16px;
  margin-top: 0;
  min-height: 0;
}

.detail-title {
  font-size: 26px;
  font-weight: bold;
  color: #fff;
  margin: 0 0 4px 0;
  visibility: visible;
}

.detail-description {
  font-size: 26px;
  line-height: 1.5;
  color: #e0e0e0;
  white-space: pre-line;
  visibility: visible;
}

.detail-button {
  width: 100%;
  padding: 16px;
  background-color: #e3af4a;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 24px;
  text-decoration: none;
  display: none;
  text-align: center;
  transition: background-color 0.2s;
}

.detail-button:hover {
  background-color: #f0bc5f;
}

.detail-button:active {
  background-color: #cc9d3f;
}

.detail-video {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 24px;
  display: none;
}

.detail-video.active {
  display: block;
}

.detail-video video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #000;
}

.detail-youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
.detail-youtube-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Video-only detail (no image, title, or description) */
.detail-modal.video-only .detail-image {
  display: none !important;
}
.detail-modal.video-only .detail-content {
  display: none !important;
}
.detail-modal.video-only .detail-video {
  margin-top: 0;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  position: relative;
  flex: 1 1 0;
  min-height: 0;
}
.detail-modal.video-only .detail-youtube-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  padding-bottom: 0;
}
.detail-modal.video-only .detail-youtube-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.detail-modal.video-only {
  padding-top: 10px;
}

/* Vertical card list in detail modal */
.detail-card-list {
  max-width: 600px;
  margin: 24px auto 0;
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-card-list .detail-list-card {
  width: 100%;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background-color: #1a1a1a;
}

.detail-card-list .detail-list-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  vertical-align: middle;
}

/* Hide other detail elements when showing card list */
.detail-modal.card-list-only .detail-image {
  display: none !important;
}
.detail-modal.card-list-only .detail-content {
  display: none !important;
}
.detail-modal.card-list-only .detail-video {
  display: none !important;
}

.bible-reading-link {
  display: block;
  width: 100%;
  margin-top: 2px;
  margin-bottom: 16px;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
}

.bible-reading-link img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
}

/* Bible Search modal (same as bible-reader) */
.home-search-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}
.home-search-modal.is-open {
  display: block;
}
.home-search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.7);
}
.home-search-modal-card {
  position: relative;
  max-width: 760px;
  margin: 80px auto 0;
  background: #1a1f2e;
  border: 1px solid #374151;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.home-search-modal-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #374151;
}
.home-search-modal-title {
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #e5e7eb;
}
.home-search-close-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #1a1f2e;
  cursor: pointer;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  padding: 0;
}
.home-search-close-btn:hover {
  color: #e5e7eb;
}
.home-search-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.home-search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}
.home-search-input {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #374151;
  padding: 0 12px;
  font-weight: 700;
  font-size: 16px;
  background: #0a0e1a;
  color: #e5e7eb;
  outline: none;
  touch-action: manipulation;
}
.home-search-input::placeholder {
  color: #6b7280;
}
.home-search-input:focus {
  border-color: rgba(47, 111, 237, 0.6);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}
.home-search-submit-btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  background: #2f6fed;
  color: #fff;
  border: 1px solid #2f6fed;
  cursor: pointer;
}
.home-search-submit-btn:hover {
  background: #2559c2;
  border-color: #2559c2;
}
.home-search-meta {
  margin-top: 10px;
  color: #9ca3af;
  font-weight: 600;
  font-size: 13px;
}
.home-search-results {
  margin-top: 12px;
  max-height: min(60vh, 520px);
  overflow: auto;
  padding-right: 4px;
  color: #e5e7eb;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 12px 0;
  background-color: #101010;
  border-top: 1px solid #1a1a1a;
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
  cursor: pointer;
  padding: 4px 12px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.bottom-nav-item a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.bottom-nav-item:hover {
  color: #ffd700;
}

.bottom-nav-item span,
.bottom-nav-item .bottom-nav-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
}

.bottom-nav-item svg {
  stroke-width: 1;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .nav-title {
    font-size: 20px;
  }
  
  .section-title {
    font-size: 18px;
  }
  
  .category-btn {
    padding: 6px 16px;
    font-size: 13px;
  }

  .list-card {
    width: 180px;
    min-width: 180px;
    height: 120px;
  }

  /* Featured Directions (1st section) - portrait, taller photos */
  .content-section:nth-of-type(1) .list-card {
    width: 140px;
    min-width: 140px;
    height: 200px;
  }

  /* Recommended Books (2nd section) - wider cards */
  .content-section:nth-of-type(2) .list-card {
    width: 200px;
    min-width: 200px;
    height: 134px;
  }

  /* Videos (4th section) - landscape, larger */
  .content-section:nth-of-type(4) .list-card {
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 240px;
    min-width: 240px;
    height: 135px;
  }

  .list-card img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
    max-width: 100% !important;
    max-height: 100% !important;
  }

  .list-card-title {
    font-size: 18px;
    padding: 8px 6px 6px;
  }

  .list-card-icon {
    width: 20px;
    height: 20px;
    top: 4px;
    right: 4px;
  }

  .bible-reading-link {
    margin-top: 24px;
  }

  /* Detail modal mobile styles - shrink to fit */
  .detail-modal {
    padding: 0 10px 24px 10px;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  /* Header image: smaller max on mobile for consistent size */
  .detail-modal.active .detail-image {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    margin-bottom: 4px !important;
    max-height: 280px !important;
  }

  .detail-modal.active .detail-image img {
    min-height: 200px !important;
    max-height: 280px !important;
  }

  .detail-content {
    padding-bottom: 0;
    -webkit-text-size-adjust: 100%;
  }

  .detail-modal .detail-title,
  .detail-modal .detail-description {
    font-size: 26px !important;
    -webkit-text-size-adjust: 100%;
  }
  .detail-modal.recommended-book .detail-title,
  .detail-modal.recommended-book .detail-description {
    font-size: 18px !important;
  }

  /* Block layout on mobile so content overflows and modal scrolls (exclude video-only so video keeps flex and displays) */
  .detail-modal.active:not(.video-only):not(.card-list-only) {
    display: block !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }
  /* Video-only: keep flex on mobile so video/iframe has height */
  .detail-modal.active.video-only {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .detail-modal.active.video-only .detail-video {
    flex: 1 1 0;
    min-height: 0;
    position: relative;
  }
  .detail-modal.active.video-only .detail-video video,
  .detail-modal.active.video-only .detail-youtube-wrap {
    height: 100%;
  }

  .detail-card-list {
    padding-bottom: 0;
  }

  .detail-close {
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    font-size: 28px;
  }

}

/* Video modal (YouTube popup with dark backdrop) */
.video-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1001;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.video-modal.is-open {
  display: flex;
}

.video-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.video-modal-inner {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 16px;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 80px);
  z-index: 1;
}

.video-modal-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.video-modal-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.video-modal-player-wrap {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.video-modal-player-wrap #ytPlayerContainer,
.video-modal-player-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
