/* ============================================================
   BOOK SITE — Modern & Clean
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400..800;1,400..800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,200..800;1,6..72,200..800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Tinos:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Arimo:ital,wght@0,400..700;1,400..700&family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
/* ── Variables ── */
:root {
  --bg:           #faf9f7;
  --surface:      #ffffff;
  --border:       #e8e4de;
  --text:         #1a1916;
  --muted:        #7a756c;
  --accent:       #2f6b4f;
  --accent-light: #eaf3ee;
  --sidebar-w:    260px;
  --content-max:  680px;
  --gap:          32px;
  --font-body:    'Tinos', Georgia, serif;
  --font-ui:      'Roboto', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;
  --radius:       8px;
  --transition:   150ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 17px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.75;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
a:hover { opacity: 0.75; }

/* ── LANDING PAGE ── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  max-width: 920px;
  margin: 0 auto;
}

.landing-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.landing h1 {
  font-family: var(--font-body);
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.landing-subtitle {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 500px;
  margin: 0 auto 3rem;
  margin-bottom: 20px;
  font-style: italic;
}

/* Centered cover image */
.landing-image {
  max-width: 420px;
  width: 100%;
  margin: 0 auto 2.5rem;
  display: flex;
  justify-content: center; /* Horizontally centers */
}

.landing-image img {
  display: block;
  width: 70%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.landing-image figcaption {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.75rem;
}

/* Short introduction paragraphs */
.landing-intro {
  max-width: 560px;
  margin: 0 auto 3rem;
  text-align: left;
}

.landing-intro p {
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 1.1rem;
  text-align: left;
}

.landing-intro p:last-child { margin-bottom: -1rem; }

.landing-divider {
  width: 48px;
  height: 2px;
  background: var(--border);
  margin: 0 auto 1rem;
}

.toc-landing {
  width: 100%;
  max-width: 480px;
  text-align: left;
}

.toc-landing h2 {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.toc-landing ol {
  list-style: none;
  counter-reset: toc-counter;
}

.toc-landing ol li {
  counter-increment: toc-counter;
  border-top: 1px solid var(--border);
  padding: 0.65rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
}

.toc-landing ol li:last-child { border-bottom: 1px solid var(--border); }


.toc-landing ol li a {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.toc-landing ol li a:hover { color: var(--accent); }

.toc-landing ol li .chapter-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
  font-family: var(--font-ui);
}

/* About the author */
.about-author {
  width: 100%;
  max-width: 560px;
  margin: 0 auto 3rem;
  text-align: left;
  margin-top:  1rem;
  padding-top: 2rem;

}

.about-author h2 {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.about-author p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 1rem;
}

.about-author p:last-child { margin-bottom: 0; }

/* ── CHAPTER PAGE LAYOUT ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header .book-title {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.site-header .book-title:hover { color: var(--text); opacity: 1; }

.header-chapter {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-nav {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chapter-nav a {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all var(--transition);
}

.chapter-nav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-light);
  opacity: 1;
}

/* ── THREE-COLUMN LAYOUT ── */
.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  grid-template-areas: "toc main footnotes";
  gap: 0;
  max-width: 1320px;
  margin: 0 auto;
  min-height: calc(100vh - 52px);
}

/* ── LEFT SIDEBAR: Table of Contents ── */
.sidebar-toc {
  grid-area: toc;
  padding: 2.5rem 0 2.5rem 2rem;
  border-right: 1px solid var(--border);
}

.sidebar-toc-inner {
  position: sticky;
  top: calc(52px + 2rem);
  max-height: calc(100vh - 52px - 4rem);
  overflow-y: auto;
}

.sidebar-toc-inner::-webkit-scrollbar { width: 3px; }
.sidebar-toc-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar-toc-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

#toc-list { list-style: none; }

#toc-list li {
  margin-bottom: 0.1rem;
}

#toc-list a {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 4px 8px;
  border-radius: 5px;
  transition: all var(--transition);
  line-height: 1.4;
}

#toc-list a:hover,
#toc-list a.active {
  color: var(--accent);
  background: var(--accent-light);
  opacity: 1;
}

#toc-list li.h3 a { padding-left: 1.4rem; font-size: 0.78rem; }
#toc-list li.h4 a { padding-left: 2.2rem; font-size: 0.74rem; }

/* ── MAIN CONTENT ── */
.main-content {
  grid-area: main;
  padding: 3rem var(--gap) 5rem;
  max-width: calc(var(--content-max) + var(--gap) * 2);
  margin: 0 auto;
  width: 100%;
}

/* Typography */
.main-content h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

.chapter-meta {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.main-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2.8rem 0 1rem;
  line-height: 1.3;
}

.main-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  font-style: italic;
  margin: 2rem 0 0.8rem;
}

.main-content h4 {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.6rem 0 0.6rem;
}

.main-content p {
  margin-bottom: 1.25rem;
}

.main-content p + p { text-indent: 1.5em; }
.main-content p + p:first-of-type { text-indent: 0; }

.main-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.5rem;
  margin: 2rem 0;
  color: var(--muted);
  font-style: italic;
}

.main-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--accent-light);
  padding: 1px 5px;
  border-radius: 3px;
}

.main-content pre {
  background: #f3f2ef;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.main-content pre code { background: none; padding: 0; }

.main-content ul, .main-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.main-content li { margin-bottom: 0.35rem; }

/* Footnote markers in text */
.fn-ref {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  vertical-align: super;
  line-height: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  transition: opacity var(--transition);
  padding: 0 1px;
}

.fn-ref:hover { opacity: 0.6; }

/* ── RIGHT SIDEBAR: Footnotes ── */
.sidebar-footnotes {
  grid-area: footnotes;
  padding: 2.5rem 2rem 2.5rem 1.75rem;
  border-left: 1px solid var(--border);
}

.sidebar-footnotes-inner {
  position: relative; /* anchor for absolute-positioned footnotes */
}

.sidebar-label-footnotes {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.footnote-list { list-style: none; position: relative; }

.footnote-item {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  border-radius: 5px;
  transition: color var(--transition), background var(--transition);
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  /* Positioned by JS; fallback to normal flow */
  position: absolute;
  width: 100%;
}

.footnote-item.highlight {
  color: var(--text);
  background: var(--accent-light);
}

.footnote-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 500;
}

/* ── MATH ── */
.math-block {
  overflow-x: auto;
  padding: 1rem 0;
  text-align: center;
}

/* ── CHAPTER NAV FOOTER ── */
.chapter-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.chapter-footer a {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.chapter-footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
  opacity: 1;
}

a.cite {
    vertical-align: super;
    font-size: 0.75em;
    line-height: 0;          /* keeps superscripts from stretching line spacing */
    text-decoration: none;
    margin-left: 0.1em;
}
a.cite:hover {
    text-decoration: underline;
}

#bibliography {
  font-size: 10px;
}

tr:nth-child(even) {
  background-color: #D6EEEE;
}

th, td {
  text-align: center;
  padding: 8px;
}

table {
    margin-left: auto; margin-right: auto;
}

.color-box {
    /*background-color: #3498db; /* Blue background */
            /*color: #ffffff;            /* White text for contrast */
            background-color: #fce0c7;
            padding: 40px;             /* Spacing inside the section */
            padding-top: 20px; padding-bottom: 2px;
            border-radius: 8px;        /* Optional: rounded corners */
            outline: 2px solid #000000; /* thickness, style, color */
            margin-bottom: 15px;
        }

figure {
  display: block; /* Ensures block behavior */
  max-width: 60%; /* Limits width so centering is visible */
  margin: 0 auto; /* Centers horizontally */
  text-align: center; /* Centers the caption text inside */
}

figcaption {
    font-style: italic;
    text-align: center; /* Centers the caption text inside */
    padding-bottom: 20px;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
}

@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toc"
      "main"
      "footnotes";
  }
  .sidebar-toc {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
  }
  .sidebar-toc-inner { position: static; max-height: none; }
  .sidebar-footnotes {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 1.5rem;
  }
  .sidebar-footnotes-inner { position: relative; }
  .footnote-item { position: static; width: auto; border-bottom: 1px solid var(--border); border-radius: 0; padding: 0.6rem 0; }
  .footnote-item:first-child { border-top: 1px solid var(--border); }
  .footnote-list { min-height: 0 !important; }
}
