/* ─── Patristics Reader — design system ─── */
:root {
  --bg: #030304;
  --bg-elevated: #0a0a0c;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.055);
  --surface-solid: #111114;
  --accent: #8b7cf6;
  --accent-bright: #a99bff;
  --accent-dim: #5c4db8;
  --accent-glow: rgba(139, 124, 246, 0.35);
  --warm: #d4a853;
  --warm-light: #f0d9a8;
  --warm-glow: rgba(212, 168, 83, 0.3);
  /* Iron-gall ink — the second, quieter accent for marginalia and quotes */
  --ink: #a8452e;
  --ink-bright: #c9613f;
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --page-pad: clamp(1.25rem, 5vw, 4rem);
  --max: 1320px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

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

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration: none;
}

/* ─── Intro veil — brief ink-wash before the page is revealed ─── */
.intro-veil {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.intro-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--warm-light);
  letter-spacing: 0.01em;
  opacity: 0;
}

body.js-ready:not(.reduced-motion) .intro-veil {
  transition: visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
  .intro-veil {
    display: none;
  }
}

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

::selection {
  background: rgba(139, 124, 246, 0.35);
  color: var(--text);
}

/* ─── Nav ─── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.1rem var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition:
    background 0.5s var(--ease-out),
    border-color 0.5s,
    padding 0.5s var(--ease-out);
  border-bottom: 1px solid transparent;
}

.nav.is-scrolled {
  padding-block: 0.85rem;
  background: rgba(3, 3, 4, 0.72);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-color: var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
}

.nav-links a {
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-cta {
  color: var(--text) !important;
  background: var(--accent) !important;
  font-weight: 600 !important;
}

.nav-cta:hover {
  background: var(--accent-bright) !important;
}

.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  font-size: 1.1rem;
  line-height: 1;
}

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 4rem var(--page-pad) 3rem;
  max-width: var(--max);
  margin: 0 auto;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  margin: 1rem 0 0;
  max-width: 26rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.footer-cols {
  display: flex;
  gap: 4rem;
}

.footer-col h4 {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.footer-col a {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.55rem;
  transition: color 0.2s;
}

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

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

/* ─── Legal pages ─── */
.legal-page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 8rem var(--page-pad) 4rem;
}

.legal-page h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4.5vw, 2.5rem);
  font-weight: 500;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.legal-page .updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.legal-page h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.legal-page p,
.legal-page li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.legal-page a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-page ul {
  padding-left: 1.25rem;
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: var(--page-pad);
    left: var(--page-pad);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: rgba(10, 10, 12, 0.96);
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links a {
    border-radius: var(--radius-sm);
  }

  .nav-toggle {
    display: block;
  }

  .footer-cols {
    flex-direction: column;
    gap: 1.5rem;
  }
}