/* Dissertation chapter pages — extends bradleycantrell.com/style.css
   Bradley Cantrell · Adaptive Epistemologies and Neo-Wilds · 2026 */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&display=swap');

/* ── Vars ─────────────────────────────────────────────────────────────── */
:root {
  --ch-sidebar: 220px;
  --ch-content: 680px;
  --ch-figure: 820px;
  --ch-serif: 'Cormorant Garamond', 'Freight Text Pro', 'Georgia', serif;
  --ch-hero-h: 90vh;
  --ch-hero-min: 560px;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body.chapter-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ch-serif);
  font-weight: 300;
  line-height: 1.8;
  min-height: 100vh;
}

/* ── Site nav — z-index 300 so it always floats above everything ──────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem var(--pad);
  background: linear-gradient(to bottom, rgba(8,8,8,0.92) 0%, transparent 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Nav name: both words dim, brighten together on hover */
.nav-name {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-sans);
}
.nav-name a {
  color: var(--text-dimmer);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-name a:hover { color: var(--text); }
/* Remove the separate span brightening */
.nav-name span { color: inherit; }

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); }

/* ── Layout ───────────────────────────────────────────────────────────── */
.chapter-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.ch-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--ch-sidebar);
  height: 100vh;
  background: rgba(8,8,8,0.88);
  border-right: 1px solid var(--border);
  padding: 6rem 1.25rem 2rem;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.ch-sidebar__diss {
  font-family: var(--ch-serif);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
.ch-sidebar__divider { height: 1px; background: var(--border); margin-bottom: 1.25rem; }
.ch-sidebar__nav { list-style: none; flex: 1; }
.ch-sidebar__nav li { margin-bottom: 0; }
.ch-sidebar__nav a {
  font-family: var(--ch-serif);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-dimmer);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
  line-height: 1.35;
}
.ch-sidebar__nav a:hover { color: var(--text-dim); background: rgba(255,255,255,0.03); }
.ch-sidebar__nav a.active { color: var(--accent); background: rgba(200,184,154,0.06); }
.ch-sidebar__num { font-size: 0.58rem; color: var(--text-dimmer); letter-spacing: 0.06em; flex-shrink: 0; }
.ch-sidebar__nav a.active .ch-sidebar__num { color: var(--accent); opacity: 0.7; }

/* ── Main ─────────────────────────────────────────────────────────────── */
.ch-main {
  margin-left: var(--ch-sidebar);
  width: calc(100% - var(--ch-sidebar));
  min-height: 100vh;
}

/* ── Hero ─────────────────────────────────────────────────────────────── */
.ch-hero {
  position: relative;
  height: var(--ch-hero-h);
  min-height: var(--ch-hero-min);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 clamp(2rem, 6vw, 5rem) clamp(3rem, 6vh, 5rem);
}

.ch-hero__bg {
  position: absolute;
  inset: -10%;
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  filter: brightness(0.35) saturate(0.7);
  will-change: transform;
}

.ch-hero__bg--generated {
  background: radial-gradient(ellipse at 30% 60%, rgba(100,80,60,0.3) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 40%, rgba(60,80,100,0.2) 0%, transparent 60%),
              var(--bg);
}

/* Gradient veil */
.ch-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(8,8,8,0.15) 0%, rgba(8,8,8,0.1) 40%, rgba(8,8,8,0.72) 75%, rgba(8,8,8,0.97) 100%);
  z-index: 1;
}

/* DRAFT / IN DEVELOPMENT watermark — sits over image, below text */
.ch-hero__watermark {
  position: absolute;
  top: 18%;
  left: clamp(2rem, 6vw, 5rem);
  font-family: var(--ch-serif);
  font-size: clamp(5rem, 14vw, 11rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.06);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  user-select: none;
}

.ch-hero__content {
  position: relative;
  z-index: 3;
  max-width: var(--ch-content);
}

.ch-hero__label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.75;
  margin-bottom: 1rem;
}

.ch-hero__num {
  font-family: var(--ch-serif);
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 0.5rem;
}

.ch-hero__title {
  font-family: var(--ch-serif);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  font-weight: 300;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
}

.ch-hero__subtitle {
  font-family: var(--ch-serif);
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 300;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ── IN DEVELOPMENT page — shows only hero, no body ─────────────────── */
.ch-in-development {
  max-width: var(--ch-content);
  padding: 4rem clamp(1.5rem, 5vw, 3rem) 8rem;
  margin: 0 auto;
  text-align: center;
}

.ch-in-development p {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 2rem;
}

.ch-in-development a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(200,184,154,0.3);
  padding-bottom: 0.2rem;
  transition: border-color 0.2s;
}

.ch-in-development a:hover { border-color: var(--accent); }

/* ── Reading content ──────────────────────────────────────────────────── */
.ch-content {
  width: 100%;
  max-width: var(--ch-content);
  padding: 4rem clamp(1.5rem, 5vw, 3rem) 3rem;
  margin: 0 auto;
}

.ch-content p {
  font-family: var(--ch-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 1.3em;
  hyphens: auto;
  font-weight: 300;
}

.ch-content h2 {
  font-family: var(--ch-serif);
  font-size: 1.85rem;
  font-weight: 400;
  color: var(--text);
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.ch-content h3 {
  font-family: var(--ch-serif);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.ch-content h4 {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.ch-content em { font-style: italic; }
.ch-content strong { font-weight: 500; color: var(--text); }

/* ── Inline diagram figures ───────────────────────────────────────────── */
/* Sit within the text column, full content width, inverted for dark mode */
.ch-inline-figure {
  margin: 3rem 0 2.5rem;
  width: 100%;
}

.ch-inline-figure img {
  width: 100%;
  display: block;
  border-radius: 1px;
  /* Invert diagrams: white bg → dark, black lines → light */
  filter: invert(1) brightness(0.88) contrast(1.05);
}

/* Photos used as inline figures — no inversion */
.ch-inline-figure--photo img {
  filter: brightness(0.85) saturate(0.85);
}

.ch-inline-figure figcaption {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.75rem;
  align-items: baseline;
}

.ch-inline-figure__num {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  white-space: nowrap;
  padding-top: 0.1em;
}

.ch-inline-figure__caption {
  font-family: var(--ch-serif);
  font-size: 0.85rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.5;
}

.ch-inline-figure__desc {
  grid-column: 2;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--text-dimmer);
  line-height: 1.6;
  margin-top: 0.3rem;
  letter-spacing: 0.01em;
}

.ch-content blockquote {
  margin: 2.5rem 0;
  padding: 1.5rem 2rem;
  border-left: 2px solid var(--accent);
  background: rgba(200,184,154,0.04);
  border-radius: 0 2px 2px 0;
}
.ch-content blockquote p { font-style: italic; color: var(--text-dim); margin-bottom: 0.5em; font-size: 1.05rem; }
.ch-content blockquote p:last-child { margin-bottom: 0; }

/* ── Atmospheric scroll backdrop sections ─────────────────────────────── */
/* ── Atmospheric scroll backdrop sections ─────────────────────────────────
   Full-viewport-width image breaks between text sections.
   The sidebar is fixed-positioned, so backdrops must break OUT of the
   .ch-main column using a negative left margin equal to sidebar width.
   Width must also add the sidebar back to reach full viewport.         */
.ch-backdrop {
  position: relative;
  /* Break out of the content column to true full viewport width */
  width: 100vw;
  margin-left: calc(-1 * var(--ch-sidebar));
  /* On mobile (sidebar hidden, --ch-sidebar = 0) this becomes margin-left:0 */
  height: 85vh;
  min-height: 480px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  /* Small vertical breathing room between text sections */
  margin-top: 0;
  margin-bottom: 0;
}

.ch-backdrop__img {
  position: absolute;
  inset: -8%;
  background-size: cover;
  background-position: center 40%;
  background-repeat: no-repeat;
  filter: brightness(0.38) saturate(0.72);
  will-change: transform;
}

/* Fade edges so text above and below reads cleanly */
.ch-backdrop::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(8,8,8,0.92) 0%,
    rgba(8,8,8,0.08) 18%,
    rgba(8,8,8,0.05) 50%,
    rgba(8,8,8,0.08) 82%,
    rgba(8,8,8,0.92) 100%
  );
  z-index: 1;
}

/* Caption — bottom, offset right of sidebar so it sits in the text column margin.
   The backdrop breaks out of .ch-main with a negative margin-left equal to the
   sidebar width, so to bring the caption back into alignment with the text we
   add the same sidebar width as padding-left.                                 */
.ch-backdrop__caption {
  position: relative;
  z-index: 2;
  /* Left padding = sidebar + comfortable content inset */
  padding: 1.25rem clamp(2rem, 4vw, 4rem) 1.25rem calc(var(--ch-sidebar) + clamp(1.5rem, 5vw, 3rem));
  width: 100%;
}

.ch-backdrop__caption-title {
  font-family: var(--ch-serif);
  font-size: 0.78rem;
  font-weight: 300;
  font-style: italic;
  color: rgba(232,228,220,0.55);
  line-height: 1.5;
  margin-bottom: 0.2rem;
}

.ch-backdrop__caption-credit {
  font-family: var(--font-sans);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.22);
  line-height: 1.5;
}

.ch-backdrop__caption-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(255,255,255,0.15);
  transition: color 0.2s;
}

.ch-backdrop__caption-credit a:hover {
  color: rgba(200,184,154,0.6);
}

/* On mobile sidebar is hidden — caption goes back to simple left padding */
@media (max-width: 1024px) {
  .ch-backdrop__caption {
    padding: 1.25rem clamp(1.5rem, 5vw, 3rem);
  }
}

/* ── Figures (inline diagrams) ────────────────────────────────────────── */
/* Note: inline placement via [FIGURE: name] markers — coming post-Asheville */
/* For now, figures gallery appears after body text */

.ch-figures-section {
  width: 100%;
  max-width: var(--ch-figure);
  margin: 0 auto;
  padding: 3rem clamp(1.5rem, 5vw, 3rem) 0;
  border-top: 1px solid var(--border);
}

.ch-figures-section__label {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 2.5rem;
}

.ch-figure-item {
  margin-bottom: 3.5rem;
}

.ch-figure-item img {
  width: 100%;
  display: block;
  border-radius: 1px;
  /* Invert diagrams for dark bg — white → dark, black lines → light */
  filter: invert(1) brightness(0.88) contrast(1.05);
}

.ch-figure-item figcaption {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--text-dimmer);
  line-height: 1.55;
  margin-top: 0.75rem;
  padding: 0 0.1rem;
  letter-spacing: 0.02em;
}

.ch-figure-item figcaption .fig-num {
  color: var(--accent);
  opacity: 0.7;
  margin-right: 0.5em;
  font-weight: 500;
}

/* ── Glossary-specific styles ─────────────────────────────────────────── */
.ch-content--glossary .glossary-letter {
  font-family: var(--ch-serif);
  font-size: 3rem;
  font-weight: 300;
  color: var(--text-dimmer);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* Term name (H3) */
.ch-content--glossary h3 {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.4rem;
  letter-spacing: 0;
}

/* Definition text */
.ch-content--glossary p {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.5em;
  line-height: 1.75;
}

/* Reference lines in italics */
.ch-content--glossary p em {
  color: var(--text-dimmer);
  font-style: italic;
  font-size: 0.85rem;
}

/* Cross-reference section H2 */
.ch-content--glossary h2:not(.glossary-letter) {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-dimmer);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
}

/* Cross-ref entries */
.ch-content--glossary h2:not(.glossary-letter) + p,
.ch-content--glossary h2:not(.glossary-letter) ~ p {
  font-size: 0.82rem;
  color: var(--text-dimmer);
}

/* ── References ───────────────────────────────────────────────────────── */
.ch-references {
  margin-top: 5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.ch-references h2 {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 1.5rem;
  border-bottom: none;
  margin-top: 0;
  padding-bottom: 0;
}

.ch-references p {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--text-dimmer);
  padding-left: 2em;
  text-indent: -2em;
  margin-bottom: 0.6em;
}

/* ── Chapter nav (prev/next) — z-index below site nav ────────────────── */
.ch-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2.5rem clamp(1.5rem, 5vw, 3rem) 5rem;
  border-top: 1px solid var(--border);
  max-width: calc(var(--ch-content) + clamp(3rem, 10vw, 6rem));
  margin: 0 auto;
  gap: 2rem;
  position: relative;
  z-index: 10; /* well below nav z-index: 300 */
}

.ch-nav__item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  max-width: 45%;
}

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

.ch-nav__label {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dimmer);
}

.ch-nav__title {
  font-family: var(--ch-serif);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.3;
  transition: color 0.2s;
}

.ch-nav__item:hover .ch-nav__title { color: var(--accent); }

/* ── Running header ───────────────────────────────────────────────────── */
.ch-running {
  position: fixed;
  top: 0;
  left: var(--ch-sidebar);
  right: 0;
  height: 56px;
  background: linear-gradient(rgba(8,8,8,0.8) 50%, transparent);
  display: flex;
  align-items: center;
  padding: 0 clamp(1.5rem, 5vw, 3rem);
  z-index: 50; /* below nav, just a fader */
  pointer-events: none;
}

.ch-running__text {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  opacity: 0.6;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.ch-footer {
  border-top: 1px solid var(--border);
  padding: 2rem clamp(1.5rem, 5vw, 3rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.ch-footer p { font-family: var(--font-sans); font-size: 0.75rem; color: var(--text-dimmer); }
.ch-footer a { color: var(--text-dimmer); text-decoration: none; transition: color 0.2s; }
.ch-footer a:hover { color: var(--accent); }

/* ── Scrollbar / selection ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dimmer); }
::selection { background: rgba(200,184,154,0.18); color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --ch-sidebar: 0px; }
  .ch-sidebar { display: none; }
  .ch-main { margin-left: 0; width: 100%; }
  .ch-running { left: 0; }
  .ch-backdrop { margin-left: 0; width: 100vw; }
}

@media (max-width: 768px) {
  html { font-size: 16px; }
  .nav-links { display: none; }
  .ch-hero { height: 65vh; min-height: 420px; }
  .ch-content p { font-size: 1rem; }
  .ch-nav { flex-direction: column; gap: 1.5rem; }
  .ch-nav__item--next { text-align: left; margin-left: 0; }
  .ch-nav__item { max-width: 100%; }
  .ch-backdrop { height: 50vh; min-height: 300px; }
}

@media print {
  body { background: white; color: #1a1a1a; }
  .ch-sidebar, .ch-running, nav, .ch-nav, .ch-backdrop { display: none; }
  .ch-main { margin-left: 0; }
  .ch-figure-item img { filter: none; }
}
