/* ==========================================================================
   Responsive & Adaptive Styles
   ========================================================================== */

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
  .category-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .deity-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .main-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .hero-quote-callout {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }

  .footer-brand-col {
    grid-column: 1 / -1;
  }
}

/* Mobile Devices (768px and below) */
@media (max-width: 768px) {
  :root {
    --lyrics-font-size: 20px;
    --lyrics-line-height: 2.05;
  }

  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* Room for fixed bottom dock */
  }

  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .header-inner {
    height: 60px;
    gap: 10px;
  }

  .brand-logo {
    gap: 10px;
    min-width: 0;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .brand-icon svg {
    width: 34px;
    height: 34px;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-title {
    font-size: 1.25rem;
    white-space: nowrap;
    line-height: 1;
  }

  .brand-tagline {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .header-btn {
    width: 36px;
    height: 36px;
  }

  .hero-section {
    padding: 32px 0 24px;
  }

  .hero-bg-container {
    opacity: 0.85;
  }

  .hero-bg-image {
    object-position: center 25%;
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 4px 12px;
    margin-bottom: 10px;
    max-width: 100%;
    line-height: 1.35;
    text-align: center;
    justify-content: center;
  }

  .hero-badge-icon {
    font-size: 0.88rem;
    flex-shrink: 0;
  }

  .hero-filigree {
    margin-bottom: 8px;
  }

  .hero-title {
    font-size: clamp(1.9rem, 7.5vw, 2.35rem);
    line-height: 1.18;
    margin-bottom: 6px;
  }

  .hero-subtitle {
    font-size: clamp(0.95rem, 3.8vw, 1.1rem);
    line-height: 1.35;
    margin-bottom: 4px;
  }

  .hero-verse {
    font-size: 0.86rem;
    margin-bottom: 18px;
  }

  .hero-search-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 16px;
  }

  .hero-search-box {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 4px 6px 4px 14px;
    border-radius: var(--radius-full);
  }

  .search-input-icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    flex-shrink: 0;
  }

  .search-input {
    font-size: 0.92rem;
    padding: 9px 4px;
    min-width: 0;
    width: 100%;
  }

  .search-btn {
    padding: 8px 16px;
    font-size: 0.88rem;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    white-space: nowrap;
  }

  .search-btn svg {
    width: 13px;
    height: 13px;
    margin-left: 3px;
  }

  .hero-quote-callout {
    display: none;
  }

  /* Spiritual stats row on mobile */
  .hero-stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .hero-stat-divider {
    display: none; /* Prevents orphan bullets when wrapping */
  }

  .hero-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.65);
    border-radius: var(--radius-full);
    border: 1px solid rgba(183, 131, 47, 0.15);
  }

  [data-theme="dark"] .hero-stat-item {
    background: rgba(33, 27, 23, 0.7);
    border-color: rgba(212, 163, 81, 0.2);
  }

  .hero-stat-icon {
    font-size: 0.85rem;
  }

  .popular-searches {
    gap: 6px 8px;
    margin-bottom: 18px;
  }

  .popular-label {
    font-size: 0.82rem;
    margin-right: 2px;
  }

  .search-tag {
    font-size: 0.78rem;
    padding: 4px 10px;
    gap: 4px;
    white-space: nowrap;
  }

  .category-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }

  .category-card {
    padding: 12px 6px;
  }

  .category-icon-wrap {
    width: 36px;
    height: 36px;
    margin-bottom: 4px;
  }

  .category-name {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .deity-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }

  .deity-card {
    padding: 12px 6px;
  }

  .deity-icon-wrap {
    width: 38px;
    height: 38px;
    margin-bottom: 4px;
  }

  .deity-name {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .section-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .section-title {
    font-size: 1.28rem;
  }

  .section-subtitle {
    font-size: 0.86rem;
  }

  .view-all-link {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .two-col-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .ranked-row {
    padding: 11px 12px;
    gap: 8px;
  }

  .ranked-left {
    gap: 10px;
    min-width: 0;
  }

  .ranked-title {
    font-size: 0.94rem;
  }

  .rank-badge {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  .quote-banner {
    padding: 28px 16px;
    margin: 20px 0;
  }

  .quote-text {
    font-size: 1.18rem;
    line-height: 1.45;
  }

  /* Reader Page on Mobile */
  .reader-page-header {
    padding: 16px 0 14px;
  }

  .reader-title {
    font-size: clamp(1.65rem, 6.5vw, 2.1rem);
    line-height: 1.22;
  }

  .reader-author {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  .reading-toolbar-wrap {
    top: 60px;
    padding: 6px 0 10px;
  }

  .reading-controls {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    width: 100%;
    justify-content: flex-start;
    padding: 5px 8px;
    gap: 4px;
    border-radius: var(--radius-full);
  }

  .reading-controls::-webkit-scrollbar {
    display: none;
  }

  .ctrl-btn {
    padding: 5px 8px;
    font-size: 0.78rem;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .reading-book-card {
    padding: 22px 14px;
  }

  .meaning-section {
    padding: 20px 14px;
  }

  /* Search Overlay Modal on Mobile */
  .search-modal-backdrop {
    padding: 12px 10px;
    align-items: flex-start;
  }

  .search-modal-card {
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
  }

  .search-modal-header {
    padding: 12px 14px;
    gap: 8px;
  }

  .search-modal-input {
    font-size: 1rem;
    min-width: 0;
  }

  .search-modal-results {
    flex: 1;
    overflow-y: auto;
    max-height: none;
    padding: 8px 10px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .mobile-bottom-dock {
    display: block;
  }
}

/* Medium Mobile (600px and below) */
@media (max-width: 600px) {
  /* Hide search trigger button in header because mobile dock + hero search already provide it */
  .header-actions .open-search-modal {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .category-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .deity-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
}

/* Small mobile (480px and below) */
@media (max-width: 480px) {
  .header-inner {
    height: 56px;
  }

  .reading-toolbar-wrap {
    top: 56px;
  }

  .brand-logo {
    gap: 8px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .brand-icon svg {
    width: 30px;
    height: 30px;
  }

  .brand-title {
    font-size: 1.14rem;
  }

  .header-btn {
    width: 33px;
    height: 33px;
  }

  .lang-switch {
    padding: 2px 7px;
    font-size: 0.74rem;
  }

  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .deity-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .category-card,
  .deity-card {
    padding: 10px 4px;
    border-radius: var(--radius-sm);
  }

  .category-icon-wrap,
  .deity-icon-wrap {
    width: 32px;
    height: 32px;
    margin-bottom: 3px;
  }

  .category-icon-wrap svg,
  .deity-icon-wrap svg {
    width: 20px;
    height: 20px;
  }

  .category-name,
  .deity-name {
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .hero-badge {
    font-size: 0.72rem;
    padding: 3px 10px;
  }

  .hero-search-box {
    padding: 3px 4px 3px 10px;
  }

  .search-input {
    font-size: 0.88rem;
    padding: 8px 2px;
  }

  .search-btn {
    padding: 7px 13px;
    font-size: 0.84rem;
  }

  .hero-stats-row {
    gap: 6px 8px;
    padding: 4px 6px;
  }

  .hero-stat-item {
    font-size: 0.74rem;
    padding: 3px 7px;
  }
}

/* Extra Small mobile (350px and below) */
@media (max-width: 350px) {
  .brand-title {
    font-size: 1.05rem;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .deity-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-search-box {
    padding: 3px 3px 3px 8px;
  }

  .search-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

/* Mobile Slide-Out Navigation Drawer */
.mobile-nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 2500;
  pointer-events: none;
  visibility: hidden;
  transition: visibility var(--transition-normal);
}

.mobile-nav-drawer.open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(23, 19, 16, 0.5);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.mobile-nav-drawer.open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 82%;
  max-width: 320px;
  height: 100%;
  background-color: var(--sv-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  overflow-y: auto;
}

.mobile-nav-drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--sv-border);
}

.drawer-links {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-link {
  font-family: var(--font-hindi-sans);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--sv-text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid var(--sv-border-light);
}

.drawer-link:hover {
  color: var(--sv-maroon);
}
