/* Men of Grace & Granite — design system.
   Three themes (light / dark / paper) and two typefaces (serif / sans),
   switched entirely through custom properties on <html data-theme data-font>. */

/* ---------- Fonts (Linguistics Pro, SIL OFL — see assets/fonts/) ---------- */

@font-face {
  font-family: 'Linguistics Pro';
  src: url('fonts/LinguisticsPro-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Linguistics Pro';
  src: url('fonts/LinguisticsPro-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Linguistics Pro';
  src: url('fonts/LinguisticsPro-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Linguistics Pro';
  src: url('fonts/LinguisticsPro-BoldItalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  --serif: 'Linguistics Pro', Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --sans: 'Gill Sans', 'Gill Sans Nova', 'Gill Sans MT', Lato, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --content-font: var(--serif);

  --grad-blue: linear-gradient(40deg, #45cafc, #303f9f);
  --grad-fab: linear-gradient(to top, #30cfd0 0%, #330867 100%);

  /* light theme (default) */
  --bg: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --link: #3f729b;
  --quote: #78909c;
  --surface: #e9ecef;
  --hairline: rgba(0, 0, 0, 0.12);
  --hover: rgba(0, 0, 0, 0.05);
  --header-bg: rgba(255, 255, 255, 0.88);
  --panel-bg: #ffffff;
  --drawer-bg: #ffffff;
  --card-bg: transparent;
  --card-border: transparent;
}

[data-font='sans'] {
  --content-font: var(--sans);
}

[data-theme='dark'] {
  --bg: #212121;
  --text: #fafafa;
  --muted: #9e9e9e;
  --link: #6ea8d0;
  --quote: #90a4ae;
  --surface: #2e2e2e;
  --hairline: rgba(255, 255, 255, 0.14);
  --hover: rgba(255, 255, 255, 0.07);
  --header-bg: rgba(33, 33, 33, 0.88);
  --panel-bg: #2e2e2e;
  --drawer-bg: #2e2e2e;
  --card-bg: transparent;
  --card-border: transparent;
}

[data-theme='paper'] {
  --bg: #f0ecea;
  --text: #333333;
  --muted: #99948e;
  --link: #436cae;
  --quote: #6d7f8c;
  --surface: #f0ecea;
  --hairline: rgba(0, 0, 0, 0.12);
  --hover: rgba(0, 0, 0, 0.045);
  --header-bg: rgba(240, 236, 234, 0.88);
  --panel-bg: #ffffff;
  --drawer-bg: #ffffff;
  --card-bg: #ffffff;
  --card-border: #d8d2cc;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--link);
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

img {
  max-width: 100%;
}

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

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 3.25rem;
  padding: 0 0.6rem;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  margin-right: auto;
  padding: 0.25rem 0.4rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--content-font);
  font-variant: small-caps;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--hover);
}

/* ---------- Settings popover ---------- */

.settings {
  position: relative;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  width: 230px;
  padding: 0.9rem 1rem 0.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.settings-panel fieldset {
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
}

.settings-panel legend {
  padding: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg {
  display: flex;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  flex: 1;
  padding: 0.45rem 0.3rem;
  border: 0;
  border-left: 1px solid var(--hairline);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.seg button:first-child {
  border-left: 0;
}

.seg button[aria-pressed='true'] {
  background: var(--link);
  color: #fff;
  font-weight: 600;
}

/* ---------- Drawer ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.45);
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  width: min(85vw, 340px);
  padding: 1rem 1rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--drawer-bg);
  box-shadow: 2px 0 18px rgba(0, 0, 0, 0.2);
  transform: translateX(-105%);
  transition: transform 0.25s ease;
}

.drawer.open {
  transform: none;
}

.drawer-brand {
  display: block;
  margin: 0.25rem 0 0.75rem;
  text-align: center;
}

.drawer-brand img {
  width: 140px;
  height: 140px;
}

[data-theme='dark'] .drawer-brand img,
[data-theme='dark'] .hero-mark {
  background: #fafafa;
  border-radius: 14px;
  padding: 8px;
}

.nav-home {
  display: block;
  padding: 0.55rem 0.25rem;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.drawer details {
  border-top: 1px solid var(--hairline);
}

.drawer summary {
  padding: 0.6rem 0.25rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.drawer summary::-webkit-details-marker {
  display: none;
}

.drawer summary::before {
  content: '\25B8';
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.drawer details[open] summary::before {
  transform: rotate(90deg);
}

.drawer ul {
  margin: 0 0 0.6rem;
  padding: 0 0 0 1.1rem;
  list-style: none;
}

.drawer li a {
  display: block;
  padding: 0.35rem 0.35rem;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
}

.drawer li a:hover,
.nav-home:hover {
  background: var(--hover);
}

.drawer a[aria-current='page'] {
  color: var(--link);
  font-weight: 600;
}

/* ---------- Main layout ---------- */

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 5.5rem 1.25rem 3rem;
}

.content-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}

[data-theme='paper'] .content-card {
  border-radius: 4px;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

/* ---------- Prose ---------- */

.prose {
  font-family: var(--content-font);
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: -0.005em;
}

.prose p {
  margin: 0.9em 0;
}

.crumb {
  margin: 0 0 0.25rem;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--link);
}

.page-head {
  margin-bottom: 2.25rem;
  text-align: center;
}

.kicker {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose h1 {
  margin: 0.25rem 0 0;
  font-weight: 400;
  font-variant: small-caps;
  font-size: clamp(1.9rem, 5.5vw, 2.5rem);
  line-height: 1.15;
}

.prose h2 {
  position: relative;
  margin: 2.4em 0 0.8em;
  padding-bottom: 0.35rem;
  font-size: 1.35rem;
  line-height: 1.25;
}

.prose h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-blue);
}

.prose h3 {
  margin: 1.9em 0 0.6em;
  font-size: 1.15rem;
}

.prose hr {
  margin: 2.2em auto;
  width: 40%;
  border: 0;
  height: 1px;
  background: var(--hairline);
}

/* Outline lists: 1. -> a) -> i) -> (1) -> dash, matching the source PDF. */

@counter-style gg-alpha-paren {
  system: extends lower-alpha;
  suffix: ') ';
}
@counter-style gg-roman-paren {
  system: extends lower-roman;
  suffix: ') ';
}
@counter-style gg-decimal-paren {
  system: extends decimal;
  prefix: '(';
  suffix: ') ';
}
@counter-style gg-dash {
  system: cyclic;
  symbols: '\2013';
  suffix: '\2002';
}

.prose ol {
  margin: 0.9em 0;
  padding-left: 1.6em;
  list-style: decimal;
}

.prose ol ol {
  margin: 0.4em 0;
  list-style: gg-alpha-paren;
}

.prose ol ol ol {
  list-style: gg-roman-paren;
}

.prose ol ol ol ol {
  list-style: gg-decimal-paren;
}

.prose ul {
  margin: 0.9em 0;
  padding-left: 1.5em;
  list-style: gg-dash;
}

.prose li {
  margin: 0.45em 0;
}

.prose li::marker {
  color: var(--muted);
}

/* Pull quotes: the old site's italic blue-grey voice. */

.prose blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 1.1em;
  color: var(--quote);
  font-style: italic;
}

.prose blockquote p {
  margin: 0.5em 0;
}

/* Bible passages card (old site's jumbotron treatment). */

.bible-refs {
  margin: 1.9rem 0;
  padding: 1.35rem 1.6rem;
  border-radius: 0.35rem;
  background: var(--surface);
}

[data-theme='paper'] .bible-refs {
  border: 1px solid var(--card-border);
}

.bible-refs h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.bible-refs ul {
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  columns: 9.5em;
  column-gap: 2rem;
}

.bible-refs li {
  margin: 0.18em 0;
  break-inside: avoid;
  font-size: 0.97rem;
}

/* Footnotes */

.fn-ref a {
  font-weight: 600;
  text-decoration: none;
}

.footnotes {
  margin-top: 3.5rem;
  font-size: 0.9rem;
}

.footnotes h2 {
  font-size: 1.05rem;
}

.footnotes ol {
  padding-left: 1.4em;
  list-style: decimal;
}

.footnotes li {
  margin: 0.6em 0;
}

.fn-back {
  text-decoration: none;
}

/* Tables */

.table-wrap {
  margin: 1.6em 0;
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.prose th,
.prose td {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.prose thead th {
  border-bottom: 2px solid var(--hairline);
  font-family: var(--sans);
  font-size: 0.8em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* LSB reference links */

.prose a.lsb-reftagger-link {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.prose a.lsb-reftagger-link:hover {
  border-bottom-style: solid;
}

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

.hero {
  padding: 1.5rem 0 0.5rem;
  text-align: center;
}

.hero-mark {
  width: min(55vw, 220px);
  height: auto;
}

.hero h1 {
  margin: 0.75rem 0 0;
}

.byline {
  margin: 0.4rem 0 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.tagline {
  max-width: 34em;
  margin: 1.1rem auto;
  color: var(--muted);
}

.toc-series {
  margin: 1.6rem 0;
}

.toc-series h3 {
  margin: 0.2rem 0;
}

.toc-series h3 a {
  color: inherit;
  text-decoration: none;
}

.toc-series h3 a:hover {
  color: var(--link);
}

.toc-series ul {
  margin: 0.35rem 0;
  padding-left: 1.1rem;
  list-style: none;
}

.toc-series li {
  margin: 0.3em 0;
}

.toc-series li a {
  text-decoration: none;
}

.toc-series li a:hover {
  text-decoration: underline;
}

/* ---------- Series landing ---------- */

.study-list {
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.study-list li {
  margin: 0.6rem 0;
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

.study-list a {
  display: block;
  padding: 0.85rem 1.1rem;
  color: inherit;
  text-decoration: none;
}

.study-list a:hover {
  background: var(--hover);
}

.study-kicker {
  display: block;
  margin-bottom: 0.15rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.pager a {
  max-width: 48%;
  color: var(--link);
  text-decoration: none;
}

.pager a:hover {
  text-decoration: underline;
}

.pager-next {
  margin-left: auto;
  text-align: right;
}

/* ---------- Footer ---------- */

.site-foot {
  margin: 3.5rem 0 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-foot p {
  margin: 0.3em 0;
}

.site-foot a {
  color: inherit;
}

.site-foot .fine {
  font-size: 0.78rem;
}

/* ---------- FAB (morpheus-den, as on the old site) ---------- */

.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  border: 0;
  border-radius: 50%;
  background-image: var(--grad-fab);
  color: #fff;
  box-shadow: 0 5px 11px rgba(0, 0, 0, 0.18), 0 4px 15px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s, visibility 0.5s;
}

.fab.show {
  opacity: 1;
  visibility: visible;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .drawer,
  .fab,
  .drawer summary::before,
  body {
    transition: none;
  }
}
