/* ===================================================
   Open Heart Journey — Stylesheet v4
   Essential beauty. What remains after everything
   unnecessary has been removed — and what remains
   is perfect.
   =================================================== */

/* --- Font Faces --- */

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/eb-garamond-variable.woff2') format('woff2');
}

@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/eb-garamond-italic-variable.woff2') format('woff2');
}

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

:root {
  --surface: #F4EDE4;
  --surface-warm: #EDE5D9;
  --text: #2C2418;
  --text-secondary: #7A6E5D;
  --accent: #9C8B74;
  --accent-gold: #A0845C;
  --rule: #C9BBA8;
  --link: #5C4E3C;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1A1612;
    --surface-warm: #211C16;
    --text: #E2D9CC;
    --text-secondary: #9C8B74;
    --accent: #7A6E5D;
    --accent-gold: #B8A07A;
    --rule: #3D3428;
    --link: #C9BBA8;
  }
}

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

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  font-family: 'EB Garamond', 'Georgia', 'Times New Roman', serif;
  font-size: clamp(1.125rem, 1rem + 0.56vw, 1.3125rem);
  line-height: 1.78;
  color: var(--text);
  background-color: var(--surface);
  min-height: 100vh;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  opacity: 0;
  animation: page-present 800ms ease-out 100ms forwards;
}

/* Subtle paper texture via layered radial noise */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, var(--surface-warm) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, var(--surface-warm) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}

@keyframes page-present {
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  body { opacity: 1; animation: none; }
}

/* --- Selection --- */

::selection {
  background-color: var(--accent-gold);
  color: var(--surface);
}

/* --- Links (global) --- */

a {
  color: var(--link);
  text-decoration: none;
  transition: color 250ms ease;
}

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

/* --- Layout --- */

.page-column {
  max-width: 34em;
  margin: 0 auto;
  padding: 6rem clamp(1.5rem, 6vw, 2.5rem) 4rem;
}

@media (min-width: 640px) {
  .page-column { padding-top: 8rem; }
}

@media (min-width: 1024px) {
  .page-column { padding-top: 10rem; padding-left: 0; padding-right: 0; }
}

/* --- Site Header --- */

.site-header {
  margin-bottom: 4rem;
  text-align: center;
}

@media (min-width: 640px) {
  .site-header { margin-bottom: 5rem; }
}

@media (min-width: 1024px) {
  .site-header { margin-bottom: 6rem; }
}

.site-title {
  font-family: 'EB Garamond', 'Georgia', serif;
  font-size: clamp(1rem, 0.85rem + 0.68vw, 1.25rem);
  font-weight: 400;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.4;
}

.site-title a {
  color: inherit;
  transition: color 250ms ease;
}

.site-title a:hover {
  color: var(--accent-gold);
}

/* --- Site Nav --- */

.site-nav {
  margin-top: 1.25rem;
  font-family: 'EB Garamond', serif;
  font-size: 0.875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--accent);
  margin: 0 0.75em;
  transition: color 250ms ease;
}

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

/* Subpage header */
.page-chapter .site-header,
.page-about .site-header {
  padding-bottom: 2rem;
  position: relative;
}

.page-chapter .site-header::after,
.page-about .site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 1px;
  background-color: var(--rule);
}

/* --- Chapter List (Home) --- */

.chapter-list {
  list-style: none;
}

.chapter-entry {
  margin-top: 4rem;
  text-align: center;
}

.chapter-entry:first-child {
  margin-top: 0;
}

.chapter-separator {
  display: block;
  width: 1.5rem;
  max-width: 1.5rem;
  height: 1px;
  background-color: var(--rule);
  border: none;
  margin: 0 auto 4rem;
  opacity: 0.7;
}

.chapter-entry:first-child .chapter-separator {
  display: none;
}

.chapter-number {
  font-family: 'EB Garamond', serif;
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.75rem;
}

.chapter-title-link {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.75rem, 1.4rem + 1.56vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  display: block;
  margin-bottom: 0.75rem;
  transition: color 250ms ease;
}

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

.chapter-epigraph-preview {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1rem, 0.92rem + 0.34vw, 1.125rem);
  font-style: italic;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 28em;
  margin: 0 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Archive / Begin Links --- */

.archive-link,
.begin-link {
  text-align: center;
  margin-top: 3rem;
  font-family: 'EB Garamond', serif;
  font-size: 0.9375rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.archive-link a,
.begin-link a {
  color: var(--accent);
  transition: color 250ms ease;
}

.archive-link a:hover,
.begin-link a:hover {
  color: var(--accent-gold);
}

.begin-link {
  margin-top: 1.5rem;
}

/* --- Chapter Page --- */

.chapter-header {
  text-align: center;
  margin-bottom: 0;
}

.chapter-header .chapter-number {
  margin-bottom: 1rem;
}

.chapter-page-title {
  font-family: 'EB Garamond', serif;
  font-size: clamp(2rem, 1.6rem + 1.78vw, 2.75rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--text);
}

/* --- Epigraph --- */

.epigraph {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.3125rem, 1.1rem + 0.94vw, 1.625rem);
  font-style: italic;
  line-height: 1.55;
  color: var(--text);
  margin: 3.5rem 0 4rem;
  text-align: center;
  position: relative;
  padding: 2.5rem 0;
}

.epigraph::before,
.epigraph::after {
  content: '';
  display: block;
  width: 3rem;
  height: 1px;
  background-color: var(--rule);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.epigraph::before { top: 0; }
.epigraph::after { bottom: 0; }

.epigraph p { margin: 0; }

/* --- Chapter Body --- */

.chapter-body {
  text-align: left;
}

.chapter-body p {
  margin-bottom: 1.5em;
  text-indent: 1.5em;
}

.chapter-body p:first-child {
  text-indent: 0;
}

.chapter-body p:first-child::first-letter {
  font-size: 3.5em;
  float: left;
  line-height: 0.8;
  padding-right: 0.08em;
  padding-top: 0.05em;
  color: var(--accent-gold);
  font-weight: 500;
}

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

.chapter-divider {
  display: block;
  width: 1.5rem;
  max-width: 1.5rem;
  height: 1px;
  background-color: var(--rule);
  border: none;
  margin: 3rem auto;
  opacity: 0.7;
}

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

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-family: 'EB Garamond', serif;
  font-size: 0.9375rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.chapter-nav a {
  color: var(--accent);
  transition: color 250ms ease;
}

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

.chapter-nav-next {
  margin-left: auto;
}

/* --- About Page --- */

.about-body {
  font-size: clamp(1.0625rem, 0.95rem + 0.45vw, 1.25rem);
}

.about-body p {
  margin-bottom: 1.5em;
}

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

/* --- Page Title --- */

.page-title {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.75rem, 1.4rem + 1.56vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 2.5rem;
  text-align: center;
}

/* --- Footer --- */

.site-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  padding-bottom: 4rem;
  text-align: center;
  font-family: 'EB Garamond', serif;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1.8;
  border-top: 1px solid var(--rule);
}

.site-footer a {
  color: var(--accent);
  transition: color 250ms ease;
}

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

.colophon {
  margin-bottom: 0.5rem;
}

/* --- Focus States --- */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
  border-radius: 2px;
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* --- Print --- */

@media print {
  body {
    background: #fff;
    color: #2C2418;
    font-size: 12pt;
    line-height: 1.75;
    opacity: 1;
    animation: none;
  }
  body::before { display: none; }
  .chapter-nav, .site-footer { display: none; }
  .page-column { max-width: 100%; padding: 0; }
  .epigraph { color: #5C4E3C; }
  .epigraph::before, .epigraph::after { background-color: #999; }
  .chapter-divider, .chapter-separator { background-color: #ccc; }
  a { color: #2C2418; }
}
