/* ============================================
   The Religious Method — Design System
   Warm & inviting, optimized for reading
   ============================================ */

/* --- Google Fonts loaded in base.html --- */

:root {
  --bg-primary: #FDF6EC;
  --bg-surface: #FFFFFF;
  --text-primary: #2C1810;
  --text-secondary: #6B4C3B;
  --text-muted: #8B7B6B;
  --accent: #8B4513;
  --accent-hover: #A0522D;
  --accent-light: #D4A574;
  --border: #E8D5C4;
  --border-light: #F0E6D8;
  --nav-bg: #3E2723;
  --nav-text: #FDF6EC;
  --nav-hover: #5D4037;
  --shadow: rgba(44, 24, 16, 0.08);
  --shadow-md: rgba(44, 24, 16, 0.12);
}

/* --- Reset & Base --- */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Serif 4', 'Georgia', serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */

h1, h2, h3, h4, h5, h6 {
  font-family: 'Lora', 'Georgia', serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2.25rem; margin-bottom: 1rem; }
h2 { font-size: 1.75rem; margin-top: 2.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.375rem; margin-top: 2rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.125rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

blockquote {
  border-left: 3px solid var(--accent-light);
  padding: 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--border-light);
  border-radius: 0 4px 4px 0;
}

em { font-style: italic; }
strong { font-weight: 700; }

/* --- Navigation --- */

.nav {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px var(--shadow-md);
}

.nav-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.nav-brand {
  font-family: 'Lora', serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--nav-text);
  text-decoration: none;
}

.nav-brand:hover {
  color: var(--nav-text);
  text-decoration: none;
  opacity: 0.9;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-links a {
  color: var(--nav-text);
  text-decoration: none;
  padding: 0.5rem 0.875rem;
  border-radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--nav-hover);
  text-decoration: none;
}

/* Hamburger menu (CSS-only) */
.nav-toggle {
  display: none;
}

.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  background: var(--nav-text);
  height: 2px;
  width: 1.5rem;
  border-radius: 2px;
  position: relative;
  transition: transform 0.3s;
}

.nav-toggle-label span::before,
.nav-toggle-label span::after {
  content: '';
  position: absolute;
}

.nav-toggle-label span::before { top: -7px; }
.nav-toggle-label span::after { top: 7px; }

@media (max-width: 700px) {
  .nav-toggle-label {
    display: block;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    padding: 0.5rem 1rem 1rem;
    box-shadow: 0 4px 8px var(--shadow-md);
  }

  .nav-links a {
    padding: 0.75rem 1rem;
    display: block;
  }

  .nav-toggle:checked ~ .nav-links {
    display: flex;
  }

  .nav-toggle:checked ~ .nav-toggle-label span {
    background: transparent;
  }
  .nav-toggle:checked ~ .nav-toggle-label span::before {
    transform: rotate(45deg);
    top: 0;
  }
  .nav-toggle:checked ~ .nav-toggle-label span::after {
    transform: rotate(-45deg);
    top: 0;
  }
}

/* --- Layout --- */

.container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

.container-narrow {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* --- Hero (Home) --- */

.hero {
  text-align: center;
  padding: 4rem 1.5rem;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 2.75rem;
  margin-bottom: 0.25rem;
}

.hero .byline {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-style: italic;
}

.hero .tagline {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 38rem;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Buttons --- */

.btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border-radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 2px 8px var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
}

/* --- Cards --- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.75rem;
  box-shadow: 0 1px 4px var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px var(--shadow-md);
  transform: translateY(-2px);
}

.card h3 {
  margin-top: 0;
  font-size: 1.25rem;
  color: var(--accent);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.card a {
  font-weight: 500;
}

/* --- Chapter Reading --- */

.chapter-layout {
  display: flex;
  gap: 3rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.chapter-sidebar {
  flex: 0 0 14rem;
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-right: 1rem;
}

.chapter-sidebar h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.chapter-sidebar ul {
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.5;
}

.chapter-sidebar li {
  margin-bottom: 0.375rem;
}

.chapter-sidebar a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  border-left: 2px solid transparent;
}

.chapter-sidebar a:hover {
  color: var(--accent);
  background: var(--border-light);
  border-left-color: var(--accent-light);
  text-decoration: none;
}

.chapter-content {
  flex: 1;
  min-width: 0;
  max-width: 48rem;
  font-size: 1.125rem;
  line-height: 1.75;
}

.chapter-content h1 {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}

.chapter-content h2 {
  font-size: 1.625rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

.chapter-content h3 {
  font-size: 1.3rem;
  margin-top: 2rem;
}

.chapter-content h4 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  color: var(--text-secondary);
}

.chapter-content ol {
  padding-left: 1.75rem;
  margin-bottom: 1rem;
}

.chapter-content ol li {
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

.chapter-content ul {
  padding-left: 1.75rem;
  margin-bottom: 1rem;
}

.chapter-content ul li {
  margin-bottom: 0.5rem;
}

/* Indented note blocks (rm02 has NOTE: blocks indented with spaces) */
.chapter-content pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-style: italic;
  color: var(--text-secondary);
  background: var(--border-light);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  margin: 1.5rem 0;
  font-size: 1rem;
}

/* --- Chapter Navigation --- */

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.95rem;
}

.chapter-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: background 0.2s;
}

.chapter-nav a:hover {
  background: var(--border-light);
  text-decoration: none;
}

.chapter-nav .prev::before { content: '\2190\00a0'; }
.chapter-nav .next::after { content: '\00a0\2192'; }
.chapter-nav .spacer { flex: 1; }

/* --- Table of Contents (Read page) --- */

.toc-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.toc-section h2 {
  margin-top: 0;
  font-size: 1.5rem;
}

.toc-section h2 a {
  color: var(--text-primary);
}

.toc-section h2 a:hover {
  color: var(--accent);
}

.toc-section p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.toc-section ul {
  list-style: none;
  padding-left: 0;
  columns: 2;
  column-gap: 2rem;
}

.toc-section ul li {
  padding: 0.2rem 0;
  break-inside: avoid;
}

@media (max-width: 600px) {
  .toc-section ul {
    columns: 1;
  }
}

/* --- Store --- */

.store-section {
  text-align: center;
  padding: 2rem;
}

.retailer-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 24rem;
  margin: 2rem auto;
}

.retailer-link {
  display: block;
  padding: 1rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  transition: background 0.2s, box-shadow 0.2s;
}

.retailer-link:hover {
  background: var(--border-light);
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
}

/* --- Footer --- */

.footer {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 2rem 1.5rem;
  margin-top: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
}

.footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer a {
  color: var(--accent-light);
}

.footer a:hover {
  color: #fff;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .chapter-layout {
    flex-direction: column;
  }

  .chapter-sidebar {
    position: static;
    flex: none;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    padding-right: 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }
}

@media (max-width: 600px) {
  .hero {
    padding: 2.5rem 1rem;
  }

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

  .chapter-content {
    font-size: 1rem;
    line-height: 1.7;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
