:root {
  --primary-dark: #0c111d;
  --secondary-dark: #151c2c;
  --bg-light: #fcfbfa;
  --card-light: #ffffff;
  --text-main-light: #0f172a; /* 15.6:1 contrast ratio on light bg */
  --hebrew-color-light: #020617; /* 18.5:1 contrast ratio on light bg */
  --muted-light: #334155; /* 9.5:1 AAA contrast ratio on light bg */
  --border-light: #cbd5e1;

  --accent-gold: #7c5800; /* 7.1:1 AAA contrast ratio on white card bg */
  --accent-gold-hover: #5d4200;
  --accent-gold-subtle: rgba(124, 88, 0, 0.1);

  --navbar-height: 64px;
  --sidebar-width: 280px;
  --transition-speed: 0.22s;
}

body.dark-mode {
  --bg-light: #090d16;
  --card-light: #111827;
  --text-main-light: #f8fafc; /* 16.2:1 contrast ratio on dark bg */
  --hebrew-color-light: #ffffff; /* 17.5:1 contrast ratio on dark bg */
  --muted-light: #cbd5e1; /* 8.2:1 contrast ratio on dark bg (was #94a3b8) */
  --border-light: #334155;

  --accent-gold: #f3ce5e; /* 10.4:1 contrast ratio on dark bg */
  --accent-gold-hover: #fde047;
  --accent-gold-subtle: rgba(243, 206, 94, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  scroll-behavior: smooth;
}

/* Custom Sitewide Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.4) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.35);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-main-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  -webkit-font-smoothing: antialiased;
}

.navbar {
  height: var(--navbar-height);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 2px solid var(--accent-gold);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
}

.brand-title {
  font-family: 'Cinzel', serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-categories {
  display: flex;
  align-items: center;
  gap: 0px;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 auto;
  justify-content: flex-end;
  margin: 0 8px;
}

.nav-categories::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #cbd5e1; /* 8.2:1 contrast ratio on navbar dark background */
  border-bottom: 3px solid transparent;
  transition: color var(--transition-speed), background-color var(--transition-speed), border-color var(--transition-speed);
  white-space: nowrap;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.category-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.category-tab.active {
  color: #fbbf24; /* 11.5:1 contrast ratio on dark navbar background */
  border-bottom-color: #fbbf24;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.btn-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-speed);
}

.bookmark-count-badge {
  background: var(--accent-gold);
  color: #0c111d;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn-icon-only {
  padding: 8px;
  border-radius: 50%;
}

.mobile-hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.app-main {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--navbar-height));
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-light);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
  transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.sidebar-section-header {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-portion-item {
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted-light); /* 9.5:1 AAA ratio in light mode, 8.2:1 in dark mode */
  transition: all 0.2s;
  border-left: 4px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-portion-item:hover {
  background: var(--accent-gold-subtle);
  color: var(--accent-gold);
  padding-left: 18px;
}

.sidebar-portion-item.active {
  background: var(--accent-gold-subtle);
  color: var(--accent-gold); /* 15.6:1 AAA ratio in light mode, 16.2:1 in dark mode */
  font-weight: 700;
  border-left-color: var(--accent-gold);
}

.reader-area {
  flex: 1;
  overflow-y: scroll;
  padding: 30px 40px;
  position: relative;
}

.portion-header-card {
  max-width: 920px;
  margin: 0 auto 30px auto;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.portion-title {
  font-family: 'Cinzel', serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main-light);
  letter-spacing: 1px;
}

.portion-category-badge {
  font-size: 0.82rem;
  color: var(--accent-gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.verses-container {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.verse-card {
  background: var(--card-light);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  gap: 20px;
  transition: border-color 0.25s;
  position: relative;
}

.verse-card:hover {
  border-color: rgba(212, 175, 55, 0.4);
}

.verse-card.bookmarked {
  border-left: 4px solid var(--accent-gold);
  background: rgba(212, 175, 55, 0.04);
}

.verse-side-control {
  flex: 0 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.verse-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted-light);
}

.bookmark-icon-btn {
  background: none;
  border: none;
  color: var(--muted-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.bookmark-icon-btn:hover, .bookmark-icon-btn.active {
  color: var(--accent-gold);
  transform: scale(1.15);
}

.verse-bilingual-content {
  flex: 1;
  display: flex;
  gap: 30px;
}

.english-text {
  flex: 1;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--text-main-light);
}

.hebrew-text {
  flex: 1;
  font-family: 'SBL Hebrew', 'David', Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.85;
  color: var(--hebrew-color-light);
  text-align: right;
  direction: rtl;
  border-left: 1px solid var(--border-light);
  padding-left: 30px;
}

.portion-navigation {
  max-width: 920px;
  margin: 50px auto 20px auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.nav-portion-card {
  flex: 1;
  max-width: 320px;
  background: var(--card-light);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all 0.25s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.nav-portion-card:hover:not(.disabled) {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: var(--accent-gold-glow);
}

.nav-portion-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-card-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted-light);
  margin-bottom: 4px;
}

.nav-card-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main-light);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, backdrop-filter 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.search-modal {
  width: 100%;
  max-width: 800px;
  height: 80vh;
  background: #141a28;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), var(--accent-gold-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .search-modal {
  transform: scale(1) translateY(0);
}

.search-modal-header {
  padding: 20px;
  display: flex;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  align-items: center;
}

.search-input-field {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: inherit;
  font-size: 1.1rem;
  padding: 12px 18px;
  border-radius: 10px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input-field:focus {
  border-color: var(--accent-gold);
  box-shadow: var(--accent-gold-glow);
}

.btn-search-trigger {
  background: var(--accent-gold);
  color: var(--primary-dark);
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-search-trigger:hover {
  background: var(--accent-gold-hover);
  transform: translateY(-1px);
}

.btn-search-trigger:active {
  transform: translateY(0);
}

.close-modal-icon {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 8px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close-modal-icon:hover {
  color: #fff;
  transform: scale(1.1);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-result-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fadeIn 0.3s ease both;
}

.search-result-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--accent-gold);
  transform: translateX(4px);
}

.search-meta-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.snippet-en {
  font-family: 'Lora', serif;
  font-size: 0.95rem;
  color: #cbd5e0;
  margin-bottom: 6px;
}

.snippet-he {
  font-family: 'SBL Hebrew', serif;
  font-size: 1.1rem;
  color: #e2e8f0;
  text-align: right;
  direction: rtl;
}

mark.search-highlight {
  background: rgba(212, 175, 55, 0.4);
  color: #fff;
  padding: 0 4px;
  border-radius: 4px;
}

.mobile-drawer {
  position: fixed;
  top: var(--navbar-height);
  inset: 0;
  background: var(--primary-dark);
  z-index: 90;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Subtle animations for smooth reader experience */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.portion-fade-in {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (max-width: 900px) {
  .verse-bilingual-content {
    flex-direction: column;
    gap: 16px;
  }
  .hebrew-text {
    border-left: none;
    padding-left: 0;
    text-align: right;
  }
}

@media (max-width: 1300px) {
  .nav-categories {
    display: none;
  }
  .mobile-hamburger {
    display: block;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .reader-area {
    padding: 20px 16px;
  }
  .portion-title {
    font-size: 1.4rem;
  }
  .verse-card {
    padding: 16px;
  }
}
