/* ============================================================
   Reformed Confessions & Catechisms — Topical Reference
   ============================================================ */

:root {
  --bg: #faf7f2;
  --bg-panel: #f1ece3;
  --bg-card: #ffffff;
  --text: #2b2620;
  --text-muted: #6e6455;
  --accent: #8b2e2e;
  --accent-soft: #f3e2e2;
  --border: #ddd4c6;
  --mark-bg: #ffe9a8;
  --mark-text: #4a3b00;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --sidebar-w: 320px;
}

[data-theme="dark"] {
  --bg: #1d1b17;
  --bg-panel: #26231e;
  --bg-card: #2c2823;
  --text: #e8e2d6;
  --text-muted: #a89f8f;
  --accent: #d98f6c;
  --accent-soft: #3d2e28;
  --border: #3d382f;
  --mark-bg: #6b5a17;
  --mark-text: #ffefc2;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  height: 100%;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
  color: var(--accent);
}

.search-wrap { flex: 1; max-width: 480px; margin-left: auto; }

#searchInput {
  width: 100%;
  padding: 8px 14px;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
}
#searchInput:focus { border-color: var(--accent); }

.icon-btn {
  font-size: 1.15rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 4px 10px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }

/* Off-canvas drawer backdrop (only visible on small screens; see media query) */
#backdrop { display: none; }

/* Sidebar toggle. Subtle icon on desktop (sidebar is always visible); becomes a
   prominent labeled "Browse" button on small screens (see media query). */
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: var(--text);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}
.menu-btn:hover { background: var(--accent-soft); }
.menu-btn .mb-icon { font-size: 1.15rem; line-height: 1; }
.menu-btn .mb-text { display: none; }   /* desktop: icon only */

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-h, 54px));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 18px 14px 40px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h, 54px));
  position: sticky;
  top: var(--topbar-h, 54px);
}

.sidebar.hidden { display: none; }

.nav-home {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 6px;
  cursor: pointer;
}
.nav-home:hover { background: var(--accent-soft); }

.nav-section h2 {
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 6px 8px;
}

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-list li {
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-list li:hover { background: var(--accent-soft); }
.nav-list li.active {
  background: var(--accent);
  color: #fff;
}
.nav-topics li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.nav-topics li > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-count {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: .8rem;
}
.nav-list li.active .topic-count { color: rgba(255,255,255,.75); }

/* ---------- Main content ---------- */

.content {
  flex: 1;
  padding: 34px 26px 90px;
  min-width: 0;
}

.reading {
  max-width: 700px;
  margin: 0 auto;
}

.view-title {
  font-size: 1.7rem;
  margin: 0 0 4px;
  line-height: 1.25;
}
.view-subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: .95rem;
  font-style: italic;
}

.section-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px 26px;
  margin-bottom: 22px;
}

.section-label {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--accent);
}

.section-doc {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
}
.section-doc:hover { text-decoration: underline; }

.section-text p { margin: 0 0 12px; }
.section-text p:last-child { margin-bottom: 0; }

.topic-tags { margin-top: 14px; }
.tag {
  display: inline-block;
  font-size: .76rem;
  padding: 2px 10px;
  margin: 2px 4px 2px 0;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.tag:hover { text-decoration: underline; }
.tag.tag-active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  padding: 0 2px;
  border-radius: 3px;
}

.empty-msg {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-top: 60px;
}

/* ---------- Home ---------- */

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  max-width: 950px;
  margin: 0 auto;
}
.home-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.home-card:hover { border-color: var(--accent); }
.home-card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--accent); }
.home-card p { margin: 0; font-size: .85rem; color: var(--text-muted); }

@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 10px 12px; }
  .site-title { display: none; }   /* home lives in the drawer on mobile */
  .search-wrap { max-width: none; }
  #searchInput { padding: 7px 12px; }

  /* Primary "Browse" button: filled accent with visible label. */
  .menu-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-size: .92rem;
    font-weight: 700;
    padding: 7px 13px;
  }
  .menu-btn:hover { background: var(--accent); filter: brightness(1.08); }
  .menu-btn .mb-text { display: inline; }
  .menu-btn .mb-icon { font-size: 1rem; }

  /* Content spans the full width; the sidebar is lifted out of flow. */
  .layout { display: block; }
  .content { padding: 22px 16px 96px; }
  .reading { max-width: 100%; }
  .home-grid { grid-template-columns: 1fr; }
  .view-title { font-size: 1.4rem; }
  .section-block { padding: 16px 18px; }

  /* Sidebar becomes an off-canvas drawer, closed by default. */
  .sidebar {
    position: fixed;
    top: var(--topbar-h, 54px); left: 0; bottom: 0;
    width: min(88vw, var(--sidebar-w));
    max-height: none;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.45);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  #backdrop.show {
    display: block;
    position: fixed;
    inset: var(--topbar-h, 54px) 0 0 0;
    background: rgba(0,0,0,.5);
    z-index: 35;
  }
}
