/* ========================================
   THE WESTMARCH PROJECT
   Typography, Color, and Layout System
   ======================================== */

/* CSS Variables */
:root {
  --color-bg: #F7F5F2;
  --color-text: #2A2A2A;
  --color-muted: #6B6B6B;
  --color-accent: #2F4A5A;

  --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-heading: 'Cormorant Garamond', 'Garamond', 'Times New Roman', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --max-width: 68ch;
  --max-width-narrow: 58ch;
  --spacing-unit: 1.5rem;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.65;
}

/* Typography Scale */
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.25;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.7rem;
  margin-top: 3rem;
}

h3 {
  font-size: 1.35rem;
}

p {
  margin: 0 0 1.25rem 0;
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

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

/* Small Caps for Roman Numerals */
.small-caps {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.essay-label {
  display: block;
  margin-bottom: 0.5rem;
}

/* Layout */
.site-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.site-container--narrow {
  max-width: var(--max-width-narrow);
}

/* Header / Navigation */
.site-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 3rem;
}

.site-nav {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav a {
  color: var(--color-text);
  border-bottom: none;
  padding: 0.25rem 0;
  position: relative;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-accent);
  transition: width 0.2s ease;
}

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

/* Footer */
.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-muted);
  text-align: center;
}

.site-footer a {
  color: var(--color-muted);
}

/* Home / Threshold Page */
.threshold {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem 1.5rem;
}

.threshold-title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 2rem 0;
}

.threshold-text {
  max-width: 42ch;
  margin: 0 auto 1.5rem;
  color: var(--color-text);
}

.threshold-tagline {
  font-style: italic;
  color: var(--color-muted);
  margin-bottom: 3rem;
}

.threshold-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.threshold-links a {
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.threshold-links a:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
  border-bottom: 1px solid var(--color-accent);
}

/* Essays Index */
.essays-section {
  margin-bottom: 3rem;
}

.essays-section h2 {
  font-size: 1.25rem;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 0.75rem;
}

.essays-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.essays-list li {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.essays-list li:last-child {
  border-bottom: none;
}

.essay-item {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.essay-numeral {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  min-width: 2.5rem;
}

.essay-title-link {
  font-family: var(--font-heading);
  font-size: 1.25rem;
}

/* Essay Page */
.essay-header {
  margin-bottom: 2.5rem;
}

.essay-header h1 {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.essay-subtitle {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--color-muted);
  margin: 0;
}

/* Epigraph */
.epigraph {
  font-style: italic;
  color: var(--color-muted);
  border-left: none;
  padding: 1rem 0;
  margin: 2rem 0;
  text-align: center;
}

/* Blockquote */
blockquote {
  margin: 1.5rem 0;
  padding-left: 1.5rem;
  border-left: 3px solid rgba(0, 0, 0, 0.1);
  color: var(--color-text);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Figures */
.figure {
  margin: 2.5rem 0;
}

.figure img {
  width: 100%;
  height: auto;
  display: block;
}

.figure figcaption {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 0.75rem;
  text-align: center;
  font-style: italic;
}

.figure--wide {
  margin-left: -2rem;
  margin-right: -2rem;
}

.figure--full {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  max-width: 100vw;
}

/* Horizontal Rule / Divider */
hr, .divider {
  border: none;
  height: 1px;
  background-color: rgba(0, 0, 0, 0.1);
  margin: 3rem auto;
  width: 4rem;
}

/* Lists */
ul, ol {
  padding-left: 1.5rem;
  margin: 1.25rem 0;
}

li {
  margin-bottom: 0.5rem;
}

/* Strong / Emphasis */
strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

/* Essay Navigation */
.essay-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.essay-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 45%;
}

.essay-nav .nav-label {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.essay-nav .nav-title {
  color: var(--color-accent);
}

.essay-nav .nav-prev {
  text-align: left;
}

.essay-nav .nav-next {
  text-align: right;
  margin-left: auto;
}

/* Print Link */
.print-link {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 2rem;
  text-align: center;
}

/* Charter Page - Narrower, Plaque-like */
.charter-content {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
}

.charter-content h1 {
  text-align: center;
  font-size: 2rem;
}

.charter-content h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
}

/* Region Page */
.region-map {
  margin: 2rem 0;
  text-align: center;
}

.region-map img {
  max-width: 100%;
  height: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* 404 Page */
.not-found {
  text-align: center;
  padding: 4rem 1.5rem;
}

.not-found h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.not-found p {
  color: var(--color-muted);
  margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    font-size: 1.0625rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .site-nav {
    gap: 1.5rem;
    font-size: 0.85rem;
  }

  .threshold-title {
    font-size: 2rem;
  }

  .figure--wide {
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

@media (max-width: 480px) {
  .site-nav {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .threshold-links {
    width: 100%;
    padding: 0 1rem;
  }

  .threshold-links a {
    display: block;
    text-align: center;
  }
}
