/* ============================================================================
   1. DESIGN TOKENS
   ============================================================================ */
:root {
  /* Colors */
  --color-bg: #f5efe6;
  --color-bg-alt: #efe6d6;
  --color-navy: #1a2a4a;
  --color-navy-light: #2c4270;
  --color-gold: #d4a543;
  --color-gold-soft: #e8c778;
  --color-ink: #2c2418;
  --color-ink-soft: #5a5040;
  --color-surface: rgba(255, 255, 255, 0.3);
  --color-surface-strong: rgba(255, 255, 255, 0.5);
  --color-border: rgba(255, 255, 255, 0.25);
  --color-shadow: rgba(0, 0, 0, 0.08);

  /* Type */
  --font-display: 'Cinzel', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-reading: Georgia, 'Times New Roman', serif;

  /* Radii & shadow */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 8px 30px rgba(26, 42, 74, 0.12);
  --shadow-lift: 0 16px 45px rgba(26, 42, 74, 0.18);

  /* Motion — one easing curve used everywhere for consistency */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Slow-start, fast-finish curve (like a video-editing ease-in) — used for
     the category/resource accordions so the expand/collapse feels weighted
     instead of snapping open instantly. */
  --ease-accordion: cubic-bezier(0.6, 0, 0.35, 1);
  --dur-fast: 160ms;
  --dur-med: 300ms;
  --dur-slow: 420ms;
  --dur-sheet: 500ms;
  --dur-accordion: 480ms;

  /* Layout */
  --header-h: 76px;
  --max-width: 1180px;
  --content-pad: 28px;
}

/* ============================================================================
   2. RESET & BASE
   ============================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-bg);
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(212, 165, 67, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(26, 42, 74, 0.06), transparent 55%),
    var(--color-bg);
  background-color: var(--color-bg);
  background-attachment: fixed;
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Applied while the reading overlay / mobile menu is open, to lock the page
   in place without letting the scroll position jump around underneath. */
html.scroll-locked {
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  height: 100%;
}

html.scroll-locked body {
  position: fixed;
  left: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

img {
  max-width: 100%;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  outline: none;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--color-navy);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

:focus-visible {
  outline: 2.5px solid var(--color-gold);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }


/* ============================================================================
   3. HEADER & TAB NAV (IPHONE GLASSMORPHISM)
   ============================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(25px) saturate(200%);
  -webkit-backdrop-filter: blur(25px) saturate(200%);
  /* Very subtle white border at the bottom for that sharp glass edge */
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05); /* Hairline shadow for definition */
}

.header-inner {
  max-width: var(--max-width);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--content-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { display: flex; align-items: center; justify-content: center; }
.brand-mark img { display: block; border-radius: 4px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--color-navy); }
.brand-sub { font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-ink-soft); }

.tab-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  /* Darker, "Smoked" glass background */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.06) 60%);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  /* Darker border to define the shape, plus a bright top edge for glass sheen */
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 4px;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.08);
}

.tab-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  /* Dark Navy but semi-transparent when not selected */
  color: rgba(26, 42, 74, 0.5); 
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.tab-btn[aria-selected="true"] { 
  color: var(--color-navy); 
  opacity: 1;
}

.tab-btn svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.tab-btn[aria-selected="true"] { 
  color: var(--color-navy); 
  font-weight: 700;
  /* Adds a subtle "pressed" depth to the icon */
  filter: drop-shadow(0 0 1px rgba(255,255,255,1)); 
}
.tab-btn[aria-selected="true"] svg { opacity: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1)); }

.tab-indicator {
  position: absolute;
  z-index: 1;
  top: 4px;
  height: calc(100% - 8px);
  border-radius: 16px;
  /* iOS-style translucent glass thumb */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.35));
  backdrop-filter: blur(18px) saturate(220%);
  -webkit-backdrop-filter: blur(18px) saturate(220%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  /* Stronger shadow makes it look physically higher */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.08);
  left: 0;
  will-change: transform, width;
}

/* Fallback for browsers/devices without backdrop-filter support so the
   nav stays legible instead of looking flat or too transparent. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header { background: rgba(255, 255, 255, 0.92); }
  .tab-nav { background: rgba(0, 0, 0, 0.08); }
  .bottom-nav-inner { background: rgba(255, 255, 255, 0.96); }
  .bottom-nav-links { background: rgba(0, 0, 0, 0.08); }
  .tab-indicator, #mobile-indicator { background: rgba(255, 255, 255, 0.92); }
}

/* Small pop when a tab is selected — replaces the previous per-direction
   bounce classes with a single, simpler keyframe applied uniformly. */
@keyframes tab-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(0.94); } /* Snappy press effect */
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.tab-btn.is-bouncing { animation: tab-pop 380ms var(--ease); }

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--color-navy);
  border-radius: 2px;
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }


/* ============================================================================
   4. BOTTOM NAVIGATION (PC STYLE ON MOBILE)
   ============================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: min(400px, calc(100% - 48px));
  height: 64px;
  z-index: 50;
  display: none;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.bottom-nav.nav-hidden { transform: translate3d(0, 130%, 0); opacity: 0; }

/* The outer "Glass" container - optimized with higher opacity to resolve Android GPU lag & text bleed */
.bottom-nav-inner {
  height: 100%;
  background: linear-gradient(180deg, rgba(245, 239, 230, 0.98), rgba(239, 230, 214, 0.96));
  backdrop-filter: blur(22px) saturate(200%);
  -webkit-backdrop-filter: blur(22px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  padding: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 12px 40px rgba(0, 0, 0, 0.12);
}

/* The inner "Smoked" track - optimized by removing redundant nested blurs for Android GPU performance */
.bottom-nav-links {
  position: relative;
  height: 100%;
  display: flex;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.05) 60%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.6);
  border-radius: 26px;
  padding: 4px;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.mobile-tab-btn {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(26, 42, 74, 0.5);
  transition: all var(--dur-fast) var(--ease);
}

/* --- MOBILE NAV REORDERING --- */
/* Group reading material on the left, utility on the right, Home in center */
.mobile-tab-btn[data-tab-id="guides"]      { order: 1; }
.mobile-tab-btn[data-tab-id="cheatsheets"]  { order: 2; }
.mobile-tab-btn[data-tab-id="home"]         { order: 3; }
.mobile-tab-btn[data-tab-id="software"]     { order: 4; }
.mobile-tab-btn[data-tab-id="resources"]    { order: 5; }

/* Make the center Home button slightly larger to stand out as the anchor */
.mobile-tab-btn[data-tab-id="home"] svg {
  width: 23px;
  height: 23px;
}

.mobile-tab-btn svg { 
  width: 20px; 
  height: 20px; 
  opacity: 0.8;
  transition: opacity var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}

.mobile-tab-btn[aria-selected="true"] { 
  color: var(--color-navy); 
  font-weight: 700;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 1)); 
}

.mobile-tab-btn[aria-selected="true"] svg { 
  opacity: 1; 
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1)); 
}

.mobile-tab-btn.is-bouncing { 
  animation: tab-pop 380ms var(--ease); 
}

/* Match the bright 92% opaque white and strong drop shadows of .tab-indicator */
#mobile-indicator {
  position: absolute;
  z-index: 1;
  top: 4px;
  height: calc(100% - 8px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.35));
  backdrop-filter: blur(18px) saturate(220%);
  -webkit-backdrop-filter: blur(18px) saturate(220%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.08);
  left: 0;
  will-change: transform, width;
}

@media (max-width: 720px) {
  .bottom-nav { display: block; }
}


/* ============================================================================
   5. LAYOUT & PANELS
   ============================================================================ */
main {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-pad) 80px;
  min-height: 100vh;
}

.tab-panel {
  animation: panel-in var(--dur-slow) var(--ease) both;
  min-height: 100vh;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-inner { padding-top: 40px; }
.panel-header { margin-bottom: 28px; }
.panel-title { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 6px; }
.panel-desc { color: var(--color-ink-soft); font-size: 0.96rem; }


/* ============================================================================
   6. HOME TAB
   ============================================================================ */
.hero { text-align: center; padding: 18px 10px 30px; }

.hero-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-gold);
  font-weight: 700;
  margin: 0 0 10px;
}

.hero-verse {
  font-family: var(--font-reading);
  font-style: italic;
  font-size: clamp(0.95rem, 3.5vw, 1.25rem);
  color: var(--color-navy);
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.65;
}

.hero-divider {
  margin: 26px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--color-gold);
  max-width: 300px;
}
.hero-divider span { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, var(--color-gold), transparent); }

.featured-card {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 34px 36px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  margin-bottom: 44px;
}

@media (min-width: 1025px) {
  .featured-card { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

.featured-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(212, 165, 67, 0.22), transparent 70%);
  pointer-events: none;
}

.featured-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-navy-light);
  font-weight: 700;
  margin-bottom: 10px;
  display: block;
}

.featured-title { font-size: clamp(1.05rem, 3.5vw, 1.3rem); margin-bottom: 12px; }

.featured-dropcap::first-letter {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 2.8rem);
  float: left;
  line-height: 0.85;
  padding: 2px 8px 0 0;
  margin-top: 3px;
  color: var(--color-gold);
  font-weight: 700;
}

.featured-body { font-family: var(--font-reading); font-size: clamp(0.92rem, 2.5vw, 1.00rem); color: var(--color-ink); line-height: 1.68; text-align: justify; text-justify: inter-word; }
.featured-body p { margin: 0 0 18px; }

.writer-credit, .reading-writer-credit {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(212, 165, 67, 0.3);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-navy);
  letter-spacing: 0.02em;
}

.writer-credit img, .reading-writer-credit img {
  opacity: 0.7;
  filter: brightness(0) saturate(100%) invert(13%) sepia(24%) saturate(1900%) hue-rotate(185deg) brightness(90%) contrast(95%);
}

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

.home-block {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
}

@media (min-width: 721px) {
  .home-block { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

.block-heading {
  font-size: clamp(0.95rem, 3vw, 1.05rem);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-gold);
  display: inline-block;
}

.mini-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 264px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.mini-list::-webkit-scrollbar { width: 6px; }
.mini-list::-webkit-scrollbar-track { background: transparent; }
.mini-list::-webkit-scrollbar-thumb { background: rgba(212, 165, 67, 0.35); border-radius: 999px; }

.search-bar-mini {
  max-width: none;
  margin-bottom: 16px;
}
.search-bar-mini input { padding: 10px 14px 10px 40px; font-size: 0.84rem; }
.search-bar-mini .search-icon { left: 14px; width: 16px; height: 16px; }

.mini-list li {
  font-size: clamp(0.82rem, 2.5vw, 0.88rem);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
  border-left: 3px solid var(--color-gold);
  color: var(--color-ink);
  line-height: 1.45;
}

.mini-list .mini-empty {
  border-left-color: transparent;
  color: var(--color-ink-soft);
  font-style: italic;
  background: transparent;
  padding-left: 0;
}

.mini-list button { width: 100%; text-align: left; display: block; font-size: inherit; color: inherit; }


/* ============================================================================
   7. SEARCH BAR
   ============================================================================ */
.search-bar { position: relative; max-width: 480px; margin-bottom: 30px; }

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-ink-soft);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.94rem;
  color: var(--color-ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

@media (min-width: 721px) {
  .search-bar input { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}

.search-bar input:focus-visible {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 4px rgba(212, 165, 67, 0.18);
  outline: none;
}

.search-bar input::placeholder { color: var(--color-ink-soft); opacity: 0.75; }


/* ============================================================================
   8. TOPIC CARDS  (gospel card / Q&A card / bookmark card — same component)
   ============================================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.topic-card {
  position: relative;
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur-med) var(--ease), box-shadow var(--dur-med) var(--ease);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.category-body.is-animating .topic-card {
  transition: none !important;
  /* content-visibility:auto skips layout for cards inside a collapsed
     (max-height:0) section and substitutes the contain-intrinsic-size
     placeholder height instead of the real one. That made scrollHeight
     measurements wrong the moment a section had never been opened before,
     so the max-height transition target didn't match the real content and
     the section appeared to snap open instead of animating smoothly. Force
     real layout while a section is actively animating so the measured
     height is accurate. */
  content-visibility: visible !important;
}

@media (min-width: 721px) {
  .topic-card { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

.card-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.category-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(26, 42, 74, 0.09);
  color: var(--color-navy);
}

.bookmark-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-ink-soft);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.bookmark-toggle:active { transform: scale(0.9); }
.bookmark-toggle[aria-pressed="true"] { color: var(--color-gold); }
.bookmark-toggle svg path { transition: fill var(--dur-fast) var(--ease); }
.bookmark-toggle[aria-pressed="true"] svg path { fill: var(--color-gold); }

.topic-card-title { font-size: 1.1rem; line-height: 1.35; font-family: var(--font-display); color: var(--color-navy); }
.topic-card-excerpt { font-size: 0.88rem; color: var(--color-ink-soft); line-height: 1.55; flex: 1; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.card-date { font-size: 0.7rem; color: var(--color-ink-soft); opacity: 0.7; font-weight: 500; letter-spacing: 0.02em; }

.card-read-link {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-navy);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.card-read-link svg { transition: transform var(--dur-fast) var(--ease); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--color-ink-soft); font-style: italic; }


/* ============================================================================
   9. ACCORDION SECTIONS  (shared expand/collapse system)
   ----------------------------------------------------------------------------
   This is a CSS-only accordion using the "grid-template-rows: 0fr -> 1fr"
   technique. Unlike animating `max-height` (which needs a JS-measured pixel
   value and looks janky because the transition duration doesn't match the
   real content height), animating a *fr* unit is driven entirely by layout
   and stays smooth on every device, including low-powered Android browsers.
   No JavaScript height measurement is required at all.
   ============================================================================ */
.accordion-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  will-change: max-height;
  transition: max-height var(--dur-accordion) var(--ease-accordion),
              opacity var(--dur-accordion) var(--ease-accordion);
}

.accordion-body > .accordion-body-inner {
  overflow: hidden;
}

.category-body-inner .topic-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 220px;
}

.accordion-body.is-open {
  max-height: none;
  opacity: 1;
}

.accordion-chevron {
  transition: transform var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
  color: var(--color-gold);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.accordion-header[aria-expanded="false"] .accordion-chevron { transform: rotate(-90deg); }


/* ============================================================================
   10. CATEGORY SECTIONS  (Gospels & Q&A — grouped by category)
   ============================================================================ */
.category-section {
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  isolation: isolate;
}

.category-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: linear-gradient(135deg, rgba(26, 42, 74, 0.04), rgba(212, 165, 67, 0.06));
  border-bottom: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  cursor: pointer;
}

.category-header[aria-expanded="true"] {
  border-bottom-color: var(--color-gold);
  background: linear-gradient(135deg, rgba(26, 42, 74, 0.06), rgba(212, 165, 67, 0.10));
}

.category-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.category-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--color-navy);
  letter-spacing: 0.03em;
  /* Long category names simply wrap onto a second line instead of being
     clipped — the header row grows to fit them. */
  white-space: normal;
  overflow-wrap: break-word;
}

.category-count-wrapper {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: rgba(212, 165, 67, 0.12);
  padding: 6px 16px;
  border-radius: 100px;
  border: 1.5px solid rgba(212, 165, 67, 0.25);
  transition: all var(--dur-fast) var(--ease);
  box-shadow: 0 2px 8px rgba(212, 165, 67, 0.08);
  min-width: 44px;
  justify-content: center;
}

.category-header[aria-expanded="true"] .category-count-wrapper {
  background: rgba(212, 165, 67, 0.18);
  border-color: var(--color-gold);
  box-shadow: 0 4px 12px rgba(212, 165, 67, 0.15);
}

.category-count {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-navy);
  font-variant-numeric: tabular-nums;
  min-width: 2.2em;
  text-align: center;
}

.category-body-inner { padding: 24px 24px 28px; }




/* ============================================================================
   11. RESOURCE SECTIONS
   ============================================================================ */
.resource-section {
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  isolation: isolate;
}

@media (min-width: 721px) {
  .resource-section { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}

.resource-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-navy);
  font-size: 1.02rem;
  cursor: pointer;
}

.resource-header .section-count {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-ink-soft);
  font-family: var(--font-body);
  margin-left: 6px;
  opacity: 0.7;
}

.resource-body-inner { overflow: hidden; }

.resource-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-top: 1px solid var(--color-border);
}

.resource-body-inner .resource-item:first-child { border-top: none; }

.resource-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
}

.resource-info { flex: 1; min-width: 0; }
.resource-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-meta { font-size: 0.76rem; color: var(--color-ink-soft); }
.resource-actions { display: flex; gap: 8px; flex-shrink: 0; }

.resource-actions .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-navy);
  background: rgba(26, 42, 74, 0.07);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.resource-actions .icon-btn:active { transform: scale(0.9); }


/* ============================================================================
   12. BOOKMARKS TAB
   ============================================================================ */
.bookmark-category-section { margin-bottom: 28px; }

.bookmark-category-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-navy);
  padding: 10px 0 16px 0;
  border-bottom: 2.5px solid var(--color-gold);
  margin-bottom: 18px;
  display: inline-block;
  letter-spacing: 0.03em;
}


/* ============================================================================
   13. READING OVERLAY  (bottom sheet on mobile, centered modal on desktop)
   ============================================================================ */
.reading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.reading-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 10, 0.55);
  opacity: 0;
  transition: opacity var(--dur-sheet) var(--ease-accordion);
  will-change: opacity;
}

@media (min-width: 1025px) {
  .reading-backdrop { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
}

.reading-overlay.visible .reading-backdrop { opacity: 1; }

.reading-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  background: #fbf7ee;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translate3d(0, 100%, 0);
  transition: transform var(--dur-sheet) var(--ease-accordion);
  will-change: transform;
  backface-visibility: hidden;
}

.reading-overlay.visible .reading-panel { transform: translate3d(0, 0, 0); }

/* While the user is actively dragging the sheet, the transition is disabled
   so the panel tracks the finger 1:1 with zero lag. */
.reading-panel.dragging { transition: none; }

@media (min-width: 721px) {
  .reading-overlay { align-items: center; }
  .reading-panel {
    border-radius: var(--radius-lg);
    max-height: 86vh;
    max-height: 86dvh;
    transform: translate3d(0, 16px, 0) scale(0.98);
    opacity: 0;
    transition: transform var(--dur-sheet) var(--ease-accordion), opacity var(--dur-sheet) var(--ease-accordion);
  }
  .reading-overlay.visible .reading-panel { transform: translate3d(0, 0, 0) scale(1); opacity: 1; }
}

.reading-drag-handle {
  display: none;
  width: 100%;
  padding: 10px 0 4px;
  justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}

.reading-drag-bar { width: 40px; height: 4px; border-radius: 999px; background: var(--color-border); }

@media (max-width: 720px) {
  .reading-drag-handle { display: flex; }
  .reading-panel {
    position: fixed;
    inset: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

.reading-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 16px;
  background: rgba(251, 247, 238, 0.9);
  border-bottom: 1px solid var(--color-border);
}

@media (min-width: 1025px) {
  .reading-toolbar { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

.reading-category {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-navy-light);
  background: rgba(26, 42, 74, 0.08);
  padding: 6px 12px;
  border-radius: 999px;
}

.reading-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-navy);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.icon-btn:active { transform: scale(0.9); }
.icon-btn[aria-pressed="true"] { color: var(--color-gold); }
.icon-btn[aria-pressed="true"] svg path { fill: var(--color-gold); }

.reading-body {
  overflow-y: auto;
  padding: 30px 32px 50px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.reading-title { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 22px; }

.reading-content {
  font-family: var(--font-reading);
  font-size: 1.08rem;
  color: var(--color-ink);
  user-select: text;
  -webkit-user-select: text;
  text-align: justify;
  text-justify: inter-word;
}

.reading-content p { margin: 0 0 16px; }

.reading-content h3 {
  font-family: var(--font-reading);
  font-style: italic;
  font-weight: normal;
  font-size: 1.15em; /* Changed to relative em to sync with user font size */
  color: var(--color-navy-light);
  margin: 26px 0 12px;
}

.reading-content blockquote {
  margin: 20px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--color-gold);
  font-style: italic;
  color: var(--color-navy);
}

.reading-content .reading-question {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: 1.1em; /* Changed to relative em to sync with user font size */
  color: var(--color-navy);
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}


/* ============================================================================
   14. TOAST
   ============================================================================ */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-navy);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease);
  z-index: 200;
  white-space: nowrap;
}

.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ============================================================================
   15. COPY / SELECTION GUARDS
   ============================================================================ */
#verse-of-week, #featured-card, .featured-body, .hero-verse,
.reading-content, .reading-title, .reading-content * {
  user-select: text !important;
  -webkit-user-select: text !important;
}

.topic-card, .resource-item, .tab-btn, .card-read-link, .bookmark-toggle,
.category-badge, .site-header, .mobile-menu, .hamburger-btn,
.category-header, .resource-header {
  user-select: none !important;
  -webkit-user-select: none !important;
}


/* ============================================================================
   16. BACKGROUND DUST FX
   ============================================================================ */
#dust-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
}


/* ============================================================================
   17. RESPONSIVE BREAKPOINTS
   ============================================================================ */
@media (max-width: 820px) {
  .tab-btn .tab-label { display: none; }
  .tab-btn { padding: 10px 14px; }
  .header-inner { padding: 0 20px; }
  .home-grid { grid-template-columns: 1fr; }

  .category-header { padding: 14px 18px; }
  .category-name { font-size: 1rem; }
  .category-count-wrapper { padding: 4px 12px; min-width: 36px; }
  .category-count { font-size: 0.78rem; min-width: 1.8em; }
  .category-body-inner { padding: 16px 16px 20px; }
}

@media (max-width: 720px) {
  :root { --header-h: 66px; }
  .tab-nav { display: none; }
  .hamburger-btn { display: flex; }
  .header-inner { padding: 0 18px; }
  main { padding: 0 18px 70px; }
  .panel-inner { padding-top: 20px; }
  .featured-card { padding: 22px 18px; margin-bottom: 30px; }
  .home-grid { grid-template-columns: 1fr; gap: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .hero { padding: 10px 4px 20px; }
  #dust-canvas { opacity: 0.25; }
}

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .featured-card { padding: 20px 18px; border-radius: var(--radius-md); }
  .home-block { padding: 18px 18px; }
  .topic-card { padding: 18px; }
  .reading-body { padding: 22px 20px 40px; }
  .reading-toolbar { padding: 13px 16px; }
  .panel-title { font-size: 1.4rem; }
  .search-bar input { padding: 11px 14px 11px 40px; font-size: 0.9rem; }
  .category-header { padding: 12px 14px; }
  .category-name { font-size: 0.9rem; letter-spacing: 0.02em; }
  .category-header-left { gap: 8px; }
  .category-count-wrapper { padding: 3px 10px; min-width: 30px; border-radius: 80px; }
  .category-count { font-size: 0.72rem; min-width: 1.6em; }
  .category-body-inner { padding: 12px 12px 16px; }
}

@media (hover: hover) and (pointer: fine) {
  .tab-btn:not([aria-selected="true"]):hover {
    color: var(--color-navy);
    transform: scale(1.08) translateY(-1px);
  }
  .tab-btn:not([aria-selected="true"]):hover svg { transform: scale(1.08); }

  .mobile-close-btn:hover { background: var(--color-bg-alt); }
  .hamburger-btn:hover { background: var(--color-surface); }
  .mobile-tab-btn:not([aria-selected="true"]):hover {
    color: var(--color-navy);
    transform: scale(1.08);
  }
  .mobile-tab-btn:not([aria-selected="true"]):hover svg { transform: scale(1.08); }
  .bookmark-toggle:hover { background: var(--color-bg-alt); transform: scale(1.08); }

  .topic-card:hover, .topic-card:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
  .topic-card:hover .card-read-link svg { transform: translateX(3px); }

  .category-header:hover {
    background: linear-gradient(135deg, rgba(26, 42, 74, 0.08), rgba(212, 165, 67, 0.12));
    border-bottom-color: var(--color-gold);
  }

  .resource-section:hover { box-shadow: var(--shadow-soft); }
  .resource-header:hover { background: rgba(255, 255, 255, 0.45); }
  .resource-header:hover .section-count { opacity: 1; }
  .resource-header:hover .accordion-chevron { color: var(--color-gold-soft); }
  .resource-actions .icon-btn:hover { background: rgba(26, 42, 74, 0.15); transform: translateY(-2px); }
  .icon-btn:hover { background: rgba(26, 42, 74, 0.12); }

  .writer-credit:hover img, .reading-writer-credit:hover img {
    opacity: 1;
    filter: brightness(0) saturate(100%) invert(32%) sepia(77%) saturate(548%) hue-rotate(7deg) brightness(93%) contrast(87%);
  }
}


/* ============================================================================
   18. LOADING SCREEN & REVEAL ANIMATIONS
   ============================================================================ */
body:not(.app-ready) {
  overflow: hidden; /* Prevent scrolling while loading */
}

/* Keep the layout intact for physics calculations, but make it invisible */
body:not(.app-ready) .site-header,
body:not(.app-ready) #main-content,
body:not(.app-ready) .bottom-nav-inner {
  opacity: 0;
  visibility: hidden;
}

/* Beautiful cascading reveal animation when the app is ready */
body.app-ready .site-header,
body.app-ready #main-content,
body.app-ready .bottom-nav-inner {
  /* Increased duration and a silky, gliding ease curve */
  animation: app-reveal 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

body.app-ready .site-header { animation-delay: 0.1s; }
body.app-ready #main-content { animation-delay: 0.25s; }
/* Animate the inner box so the outer box is free to hide on scroll! */
body.app-ready .bottom-nav-inner { animation-delay: 0.4s; }

@keyframes app-reveal {
  0%   { opacity: 0; transform: translateY(35px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Fullscreen Loader Background */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Smoother, slightly slower fade out */
  transition: opacity 0.8s ease-in-out, visibility 0.8s;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* --- UIball Loader CSS --- */
.uib-dots-container {
  --uib-size: 60px;
  --uib-color: var(--color-gold);
  --uib-speed: 1.5s;
  --uib-dot-size: calc(var(--uib-size) * 0.1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: calc(var(--uib-size) * 0.64);
  width: calc(var(--uib-size) * 0.64);
}

@keyframes jump {
  0%,
  100% {
    transform: translateY(120%);
  }

  50% {
    transform: translateY(-120%);
  }
}

.dot {
  --uib-d1: -0.48;
  --uib-d2: -0.4;
  --uib-d3: -0.32;
  --uib-d4: -0.24;
  --uib-d5: -0.16;
  --uib-d6: -0.08;
  --uib-d7: -0;
  position: absolute;
  bottom: calc(var(--uib-bottom) + var(--uib-dot-size) / 2);
  right: calc(var(--uib-right) + var(--uib-dot-size) / 2);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: var(--uib-dot-size);
  width: var(--uib-dot-size);
  animation: jump var(--uib-speed) ease-in-out infinite;
  opacity: var(--uib-scale);
  will-change: transform;
  backface-visibility: hidden;
}

.dot::before {
  content: '';
  height: 100%;
  width: 100%;
  background-color: var(--uib-color);
  border-radius: 50%;
  transform: scale(var(--uib-scale));
  transition: background-color 0.3s ease;
}

.dot:nth-child(1) {
  --uib-bottom: 24%;
  --uib-right: -35%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d1));
}
.dot:nth-child(2) {
  --uib-bottom: 16%;
  --uib-right: -6%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d2));
}
.dot:nth-child(3) {
  --uib-bottom: 8%;
  --uib-right: 23%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d3));
}
.dot:nth-child(4) {
  --uib-bottom: -1%;
  --uib-right: 51%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d4));
}
.dot:nth-child(5) {
  --uib-bottom: 38%;
  --uib-right: -17.5%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d2));
}
.dot:nth-child(6) {
  --uib-bottom: 30%;
  --uib-right: 10%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d3));
}
.dot:nth-child(7) {
  --uib-bottom: 22%;
  --uib-right: 39%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d4));
}
.dot:nth-child(8) {
  --uib-bottom: 14%;
  --uib-right: 67%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d5));
}
.dot:nth-child(9) {
  --uib-bottom: 53%;
  --uib-right: -0.8%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d3));
}
.dot:nth-child(10) {
  --uib-bottom: 44.5%;
  --uib-right: 27%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d4));
}
.dot:nth-child(11) {
  --uib-bottom: 36%;
  --uib-right: 55.7%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d5));
}
.dot:nth-child(12) {
  --uib-bottom: 28.7%;
  --uib-right: 84.3%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d6));
}
.dot:nth-child(13) {
  --uib-bottom: 66.8%;
  --uib-right: 15%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d4));
}
.dot:nth-child(14) {
  --uib-bottom: 58.8%;
  --uib-right: 43%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d5));
}
.dot:nth-child(15) {
  --uib-bottom: 50%;
  --uib-right: 72%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d6));
}
.dot:nth-child(16) {
  --uib-bottom: 42%;
  --uib-right: 100%;
  animation-delay: calc(var(--uib-speed) * var(--uib-d7));
}

.dot:nth-child(3) {
  --uib-scale: 0.98;
}
.dot:nth-child(2),
.dot:nth-child(8) {
  --uib-scale: 0.96;
}
.dot:nth-child(1),
.dot:nth-child(7) {
  --uib-scale: 0.94;
}
.dot:nth-child(6),
.dot:nth-child(12) {
  --uib-scale: 0.92;
}
.dot:nth-child(5),
.dot:nth-child(11) {
  --uib-scale: 0.9;
}
.dot:nth-child(10),
.dot:nth-child(16) {
  --uib-scale: 0.88;
}
.dot:nth-child(9),
.dot:nth-child(15) {
  --uib-scale: 0.86;
}
.dot:nth-child(14) {
  --uib-scale: 0.84;
}
.dot:nth-child(13) {
  --uib-scale: 0.82;
}


/* ============================================================================
   19. MOTION & ACCESSIBILITY PREFERENCES
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  #dust-canvas { display: none; }
}
