/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --tint: #f1f7fc;
  --sky: #dcebf7;
  --text: #1c2a3b;
  --muted: #536478;
  --accent: #2a72b0;
  --accent-dark: #1d5a92;
  --rule: #e2ecf5;
  --glow: #ffeeb8;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --measure: 38rem; /* comfortable reading width */
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

section { padding: 5rem 1.25rem; }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.95rem;
}

@media (min-width: 40.01rem) {
  .site-header { position: sticky; top: 0; }
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-left: auto;
}

.main-nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.langs {
  display: flex;
  gap: 0.15rem;
  padding: 0.2rem;
  background: var(--tint);
  border-radius: 999px;
}

.langs a {
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

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

.langs a[aria-current="page"] {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 1px 4px rgba(42, 114, 176, 0.2);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 4.5rem 1.25rem 7rem;
  background:
    radial-gradient(42rem 26rem at 84% 6%, rgba(255, 236, 179, 0.7), transparent 70%),
    linear-gradient(180deg, #e4f0fa 0%, #f3f9fd 55%, #ffffff 100%);
}

/* fog that dissolves the bottom of the hero into the page */
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 8rem;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  align-items: center;
  gap: 2.5rem 3.5rem;
  max-width: 62rem;
  margin: 0 auto;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.3rem);
  max-width: 18ch;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.word { display: inline-block; }

.lead {
  max-width: 32rem;
  margin: 0 0 2rem;
  font-size: 1.3rem;
  color: var(--muted);
}

.button {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(42, 114, 176, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(42, 114, 176, 0.32);
}

/* ---------- Portrait ---------- */
.portrait {
  position: relative;
  justify-self: center;
  width: min(78vw, 320px);
  margin: 0;
  aspect-ratio: 1;
}

.portrait::before {
  content: "";
  position: absolute;
  inset: -16%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), rgba(255, 255, 255, 0));
  animation: glow 7s ease-in-out infinite;
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  border-radius: 50%;
  border: 6px solid #fff;
  box-shadow: 0 18px 44px rgba(42, 114, 176, 0.24);
}

/* ---------- Crosses in the mist ---------- */
.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.cross {
  position: absolute;
  left: var(--x);
  top: var(--y);
  height: var(--h);
  width: calc(var(--h) * 0.6667);
  filter: blur(var(--b));
  opacity: var(--o);
  transform-origin: 50% 100%;
  will-change: transform;
  animation:
    appear 2.8s ease-out var(--delay) both,
    float var(--dur) ease-in-out var(--delay) infinite;
}

.mist {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
  animation: drift var(--t) ease-in-out infinite alternate;
}

.mist-a { left: -12%; top: 38%; width: 62%; height: 46%; --t: 23s; }
.mist-b { right: -14%; top: 22%; width: 58%; height: 42%; --t: 29s; animation-direction: alternate-reverse; }
.mist-c { left: 18%; bottom: -14%; width: 70%; height: 44%; --t: 35s; }

/* ---------- Story ---------- */
.story {
  max-width: var(--measure);
  margin: 0 auto;
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.chapter {
  padding: 2.25rem 0;
  border-top: 1px solid var(--rule);
}

.chapter:first-child { border-top: 0; }

.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 0 0.75rem;
  border-radius: 50%;
  background: var(--sky);
  color: var(--accent-dark);
  font: 700 0.95rem var(--sans);
}

.chapter h2 { font-size: 1.9rem; }

.chapter p:not(.chapter-number) { margin: 0 0 1.25rem; }

/* ---------- Verse ---------- */
.verse {
  background: linear-gradient(180deg, var(--tint), #fff);
  text-align: center;
}

.verse-inner { max-width: 40rem; margin: 0 auto; }

.verse-cross {
  display: block;
  width: 1.6rem;
  height: 2.4rem;
  margin: 0 auto 1.25rem;
}

.verse blockquote { margin: 0; }

.verse p {
  font-size: clamp(1.35rem, 3.4vw, 1.8rem);
  font-style: italic;
  line-height: 1.5;
  margin: 0 0 1rem;
}

.verse footer {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
}

/* ---------- Contact ---------- */
.contact {
  text-align: center;
  max-width: var(--measure);
  margin: 0 auto;
}

.contact h2 { font-size: 2rem; }
.contact p { color: var(--muted); margin: 0 0 1.75rem; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 2rem 1.25rem 3rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}

.site-footer p { margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 40rem) {
  body { font-size: 1.05rem; }
  section { padding: 3.5rem 1.25rem; }

  .header-inner { flex-direction: column; }
  .main-nav { margin-left: 0; justify-content: center; }

  .hero { padding: 2.5rem 1.25rem 5.5rem; }
  .hero-inner { grid-template-columns: 1fr; text-align: center; gap: 1.75rem; }
  .portrait { order: -1; width: min(58vw, 230px); }
  .hero h1, .lead { margin-left: auto; margin-right: auto; }
}

/* ---------- Animation ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes word-in {
  from { opacity: 0; transform: translateY(0.45em); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes appear {
  from { opacity: 0; }
  to   { opacity: var(--o); }
}

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-1deg); }
  50%      { transform: translate3d(0, -16px, 0) rotate(1deg); }
}

@keyframes drift {
  from { transform: translateX(-7%); }
  to   { transform: translateX(7%); }
}

@keyframes glow {
  0%, 100% { opacity: 0.75; transform: scale(0.96); }
  50%      { opacity: 1; transform: scale(1.04); }
}

/* hero entrance (CSS only, works without JavaScript) */
.fade { animation: rise 0.9s ease-out var(--d, 0s) both; }

/* the title is split into words by script.js */
.js .word {
  animation: word-in 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) calc(0.25s + var(--i) * 0.09s) both;
}

/* sections fade in as you scroll to them */
.js .reveal > * {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--n, 0) * 110ms);
}

.js .reveal.in > * { opacity: 1; transform: none; }

.reveal > :nth-child(1) { --n: 0; }
.reveal > :nth-child(2) { --n: 1; }
.reveal > :nth-child(3) { --n: 2; }
.reveal > :nth-child(4) { --n: 3; }
.reveal > :nth-child(5) { --n: 4; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade, .word, .cross, .mist, .portrait::before { animation: none !important; }
  .js .reveal > * { opacity: 1; transform: none; transition: none; }
}
