/* ==========================================================================
   Rachel Nacer — Author site
   Editorial · Premium · Calm
   ========================================================================== */

:root {
  --bg: #f6f3ee;
  --bg-alt: #faf8f5;
  --bg-elevated: #ffffff;
  --text: #3a3632;
  --text-muted: #6e6862;
  --text-light: #9a928a;
  --border: #e5e0d8;
  --border-subtle: #ede9e3;
  --accent: #6d7f6e;
  --accent-hover: #5a6b5b;
  --accent-soft: rgba(109, 127, 110, 0.12);
  --accent-secondary: #b8957a;
  --taupe: #8a8279;
  --shadow: 0 4px 24px rgba(58, 54, 50, 0.06);
  --shadow-lg: 0 12px 48px rgba(58, 54, 50, 0.08);
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --header-h: 72px;
  --container: min(1120px, 92vw);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 2px;
  --transition: 0.35s var(--ease);
}

[data-theme="dark"] {
  --bg: #1e1c1a;
  --bg-alt: #252320;
  --bg-elevated: #2c2a27;
  --text: #e8e4de;
  --text-muted: #a8a29c;
  --text-light: #7a746e;
  --border: #3d3a36;
  --border-subtle: #33302c;
  --accent: #8fa890;
  --accent-hover: #a3b8a4;
  --accent-soft: rgba(143, 168, 144, 0.15);
  --accent-secondary: #c9a88a;
  --taupe: #9a928a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.3);
}

/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

body {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition), color var(--transition);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

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

ul {
  list-style: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  width: var(--container);
  margin-inline: auto;
}

/* Typography */
.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--taupe);
  margin-bottom: 1rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section-title--large {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
}

.section-lead {
  max-width: 36rem;
  margin-top: 1.25rem;
  font-size: 1.125rem;
  color: var(--text-muted);
  line-height: 1.75;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--header-h);
  background: rgba(246, 243, 238, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

[data-theme="dark"] .site-header {
  background: rgba(30, 28, 26, 0.92);
}

.site-header.is-scrolled {
  border-bottom-color: var(--border-subtle);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--container);
  height: 100%;
  margin-inline: auto;
  gap: 2rem;
}

.logo {
  display: flex;
  flex-direction: column;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
}

.logo:hover {
  color: var(--text);
}

.logo-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.logo-tagline {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-light);
}

.main-nav ul {
  display: flex;
  gap: 2rem;
}

.main-nav a {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  position: relative;
}

.main-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.main-nav a:hover,
.main-nav a.is-active {
  color: var(--text);
}

.main-nav a.is-active::after,
.main-nav a:hover::after {
  width: 100%;
}

.theme-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  position: relative;
}

[data-theme="dark"] .theme-icon {
  background: var(--text-muted);
  box-shadow: inset -4px -2px 0 var(--bg-alt);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:first-child {
  transform: translateY(3.75px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:last-child {
  transform: translateY(-3.75px) rotate(-45deg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.2s;
  text-decoration: none;
}

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

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

.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn--secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  padding-inline: 1.25rem;
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn--muted {
  background: var(--border-subtle);
  color: var(--text-muted);
  border-color: var(--border-subtle);
  cursor: default;
  pointer-events: none;
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.link-arrow {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.link-arrow::after {
  content: "→";
  transition: transform 0.2s;
}

.link-arrow:hover::after {
  transform: translateX(4px);
}

/* Sections */
.section {
  padding-block: clamp(5rem, 10vw, 8rem);
}

.section-intro {
  margin-bottom: clamp(3rem, 6vw, 5rem);
  max-width: 40rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

/* Hero */
.hero {
  padding-top: calc(var(--header-h) + clamp(3rem, 8vw, 6rem));
  background: var(--bg-alt);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  margin-bottom: clamp(4rem, 8vw, 7rem);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 4.5vw, 3.25rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.hero-title em {
  font-style: italic;
  font-weight: 400;
  color: var(--taupe);
}

.hero-lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 32rem;
  margin-bottom: 2.25rem;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.portrait-frame {
  position: relative;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-width: min(440px, 100%);
  margin-left: auto;
  background: var(--border-subtle);
  overflow: hidden;
}

.portrait-frame::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  z-index: 1;
  pointer-events: none;
}

.author-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.author-photo--hero {
  object-position: center 28%;
}

.author-photo--about {
  object-position: center 40%;
}

.manifesto-block {
  margin-bottom: clamp(4rem, 8vw, 6rem);
}

.manifesto {
  max-width: 48rem;
  margin-inline: auto;
  text-align: center;
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.manifesto p {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
}

/* Themes */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: clamp(5rem, 10vw, 8rem);
}

.theme-card {
  padding: 2rem 0 0;
  border-top: 1px solid var(--border);
}

.theme-number {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  color: var(--accent-secondary);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 1rem;
}

.theme-card h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.theme-card p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* Featured books */
.featured-books {
  padding-top: 2rem;
}

.section-header--center {
  justify-content: center;
  text-align: center;
}

.book-preview {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: center;
  max-width: 52rem;
  margin-inline: auto;
}

.book-preview__cover {
  display: block;
  box-shadow: var(--shadow-lg);
  transition: transform 0.4s var(--ease), box-shadow 0.4s;
}

.book-preview__cover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 56px rgba(58, 54, 50, 0.12);
}

.book-preview__cover img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.book-preview__body .book-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.book-preview__body .book-title a {
  color: var(--text);
  text-decoration: none;
}

.book-preview__body .book-title a:hover {
  color: var(--accent);
}

.book-preview__excerpt {
  color: var(--text-muted);
  margin: 1.25rem 0 1.75rem;
  line-height: 1.75;
  max-width: 32rem;
}

.book-preview__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.books-showcase--single {
  gap: 0;
}

.books-showcase--single .book-showcase {
  border-bottom: none;
  padding-bottom: 0;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.book-card--compact .book-card__cover-link {
  display: block;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-lg);
  transition: transform 0.4s var(--ease), box-shadow 0.4s;
}

.book-card--compact .book-card__cover-link:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 56px rgba(58, 54, 50, 0.12);
}

.book-card--compact img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.book-card__body h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.book-card__body h3 a {
  color: var(--text);
  text-decoration: none;
}

.book-card__body h3 a:hover {
  color: var(--accent);
}

.book-card__theme {
  font-size: 0.8125rem;
  color: var(--text-light);
  letter-spacing: 0.04em;
}

/* Books showcase */
.books-section {
  background: var(--bg);
}

.books-showcase {
  display: flex;
  flex-direction: column;
  gap: clamp(5rem, 10vw, 8rem);
}

.book-showcase {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  padding-bottom: clamp(3rem, 6vw, 5rem);
  border-bottom: 1px solid var(--border-subtle);
}

.book-showcase:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.book-showcase--reverse {
  direction: rtl;
}

.book-showcase--reverse > * {
  direction: ltr;
}

.book-showcase__cover {
  box-shadow: var(--shadow-lg);
  background: var(--bg-elevated);
}

.book-showcase__cover img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.book-meta {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.book-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.book-subtitle {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--taupe);
  margin-bottom: 1rem;
}

.book-theme-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.35rem 0.75rem;
  margin-bottom: 1.5rem;
}

.book-summary {
  color: var(--text-muted);
  max-width: 32rem;
  margin-bottom: 2rem;
  line-height: 1.75;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Newsletter */
.newsletter-section {
  background: var(--bg-alt);
  border-block: 1px solid var(--border-subtle);
}

.newsletter-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(3rem, 6vw, 5rem);
  align-items: start;
}

.newsletter-lead {
  color: var(--text-muted);
  margin: 1.25rem 0 2rem;
  max-width: 28rem;
  line-height: 1.75;
}

.newsletter-perks {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.newsletter-perks li {
  font-size: 0.9375rem;
  color: var(--text-muted);
  padding-left: 1.25rem;
  position: relative;
}

.newsletter-perks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 1px;
  background: var(--accent);
}

.newsletter-form,
.contact-form {
  background: var(--bg-elevated);
  padding: clamp(2rem, 4vw, 2.5rem);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
}

.form-row {
  margin-bottom: 1.25rem;
}

.form-row label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row textarea {
  resize: vertical;
  min-height: 120px;
}

.form-privacy {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--text-light);
  line-height: 1.5;
}

.form-feedback {
  margin-top: 1rem;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.form-feedback.is-success {
  color: var(--accent);
}

.form-feedback.is-error {
  color: #a65d4a;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: clamp(3rem, 6vw, 5rem);
  align-items: start;
}

.about-portrait {
  overflow: hidden;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-width: min(440px, 100%);
  box-shadow: var(--shadow-lg);
}

.about-intro {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin: 1rem 0 2rem;
  line-height: 1.7;
}

.about-text p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.about-vision,
.about-themes {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

.about-vision h3,
.about-themes h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.about-vision p {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text);
  line-height: 1.6;
}

.about-themes ul {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.about-themes li {
  font-size: 0.9375rem;
  color: var(--text-muted);
  padding-left: 1rem;
  border-left: 2px solid var(--accent-soft);
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(3rem, 6vw, 5rem);
  align-items: start;
}

.contact-lead {
  color: var(--text-muted);
  margin: 1rem 0 2rem;
  max-width: 28rem;
}

.contact-details {
  margin-bottom: 2rem;
}

.contact-details p {
  margin-bottom: 1rem;
}

.contact-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.contact-details a {
  font-size: 1.05rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s, color 0.2s;
}

.contact-details a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.social-links {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.social-link {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.social-link:hover {
  color: var(--accent);
}

.contact-note {
  font-size: 0.9375rem;
  color: var(--text-light);
  font-style: italic;
}

/* Footer */
.site-footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-alt);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-brand {
  font-size: 0.875rem;
  color: var(--text-light);
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-nav a {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal--delay {
  transition-delay: 0.12s;
}

.reveal--delay-2 {
  transition-delay: 0.24s;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .book-card--compact .book-card__cover-link:hover {
    transform: none;
  }
}

/* Responsive */
@media (max-width: 960px) {
  .hero-grid,
  .newsletter-inner,
  .about-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .portrait-frame {
    margin-inline: auto;
  }

  .hero-content {
    text-align: center;
  }

  .hero-lead {
    margin-inline: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .themes-grid {
    grid-template-columns: 1fr;
    max-width: 28rem;
    margin-inline: auto;
  }

  .book-preview {
    grid-template-columns: 1fr;
    text-align: center;
    max-width: 28rem;
  }

  .book-preview__cover {
    max-width: 240px;
    margin-inline: auto;
  }

  .book-preview__excerpt {
    margin-inline: auto;
  }

  .book-preview__actions {
    justify-content: center;
  }

  .book-showcase,
  .book-showcase--reverse {
    grid-template-columns: 1fr;
    direction: ltr;
    text-align: center;
  }

  .book-showcase__cover {
    max-width: 280px;
    margin-inline: auto;
  }

  .book-summary {
    margin-inline: auto;
  }

  .book-actions {
    justify-content: center;
  }

  .book-theme-tag {
    margin-inline: auto;
  }

  .about-portrait {
    margin-inline: auto;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .main-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.5rem;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s var(--ease), opacity 0.35s, visibility 0.35s;
  }

  .main-nav.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .main-nav li {
    border-bottom: 1px solid var(--border-subtle);
  }

  .main-nav a {
    display: block;
    padding: 1rem 0;
    font-size: 0.875rem;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   Chapter reading page
   ========================================================================== */

.chapter-page {
  background: var(--bg-alt);
}

.site-header--chapter .header-inner {
  gap: 1rem;
}

.chapter-back-link {
  margin-left: auto;
  margin-right: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.chapter-back-link:hover {
  color: var(--accent);
}

.chapter-main {
  padding-top: calc(var(--header-h) + clamp(2.5rem, 6vw, 4rem));
  padding-bottom: clamp(4rem, 8vw, 6rem);
}

.chapter-article {
  max-width: 42rem;
}

.chapter-header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 5vw, 3.25rem);
  font-weight: 500;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.chapter-subtitle {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  font-style: italic;
  color: var(--taupe);
}

.chapter-body {
  font-size: 1.125rem;
  line-height: 1.85;
  color: var(--text);
}

.chapter-body p {
  margin-bottom: 1.35rem;
  text-align: justify;
  hyphens: auto;
}

.chapter-body p:last-child {
  margin-bottom: 0;
}

.chapter-dropcap::first-letter {
  font-family: var(--font-serif);
  float: left;
  font-size: 3.75rem;
  line-height: 0.85;
  padding-right: 0.12em;
  padding-top: 0.06em;
  font-weight: 500;
  color: var(--accent);
}

.chapter-body em {
  font-style: italic;
}

.chapter-footer {
  margin-top: clamp(3rem, 6vw, 4.5rem);
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

.chapter-end {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-light);
  margin-bottom: 1.75rem;
}

.chapter-footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.site-footer--minimal {
  padding: 1.5rem 0;
}

@media (max-width: 768px) {
  .site-header--chapter .header-inner {
    flex-wrap: wrap;
  }

  .chapter-back-link {
    order: 3;
    width: 100%;
    margin-left: 0;
    margin-top: 0.25rem;
    text-align: center;
  }

  .chapter-body p {
    text-align: left;
    hyphens: none;
  }

  .book-preview__actions {
    justify-content: center;
  }
}
