:root {
  --parchment: #F6F1E8;
  --parchment-deep: #EFE8DB;
  --ink: #221B15;
  --ink-soft: #5C5348;
  --forest: #1D4A38;
  --forest-deep: #123527;
  --sage: #8FA893;
  --terracotta: #C9836B;
  --millie-teal: #11737B;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(1.25rem, 6vw, 6rem);
}

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

body {
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(29,74,56,0.05) 0 1px, transparent 1px 96px),
    var(--parchment);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

em { font-style: italic; }

.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--forest);
}

.kicker--light { color: var(--sage); }

h2 {
  font-family: var(--serif);
  font-weight: 450;
  font-size: clamp(1.75rem, 3.4vw, 2.6rem);
  line-height: 1.1;
  margin-top: 0.75rem;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.5rem var(--gutter);
}

.nav--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
}

.nav__wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--ink);
  text-decoration: none;
}

.nav--overlay .nav__wordmark, .nav--overlay .nav__wordmark em { color: var(--parchment); }

.nav__wordmark em, .footer__mark em { color: var(--forest); }

.nav__right { display: flex; align-items: center; gap: 2rem; }

.nav__logo {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  overflow: hidden;
  transition: transform 250ms var(--ease);
}

.nav__logo:hover { transform: translateY(-1px); }

.nav__logo img { display: block; width: 100%; height: 100%; border-radius: 11px; }

.nav__links { display: flex; gap: 2rem; }

.nav__links a {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 250ms var(--ease);
}

.nav--overlay .nav__links a { color: rgba(246, 241, 232, 0.75); }

.nav__links a:hover { color: var(--forest); }

.nav__links a[aria-current="page"] { color: var(--forest); }

.nav--overlay .nav__links a:hover { color: var(--parchment); }

.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(165deg, #1A3A2D 0%, var(--forest-deep) 70%);
}

/* Wide screens: the animation fills the right side; the copy sits lower-left. */
.hero__art {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 56%;
  height: 100%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 22%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 22%);
}

.hero__content {
  position: relative;
  z-index: 2;
  padding: 0 var(--gutter);
  margin-bottom: 0;
  max-width: 60rem;
  transform: translateY(clamp(-3rem, -4vh, -1.5rem));
}

.hero__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 8vw, 6.5rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
  color: var(--parchment);
  margin: 1.1rem 0 1.4rem;
}

.hero__title em { color: var(--sage); font-weight: 480; }

.swap-word { display: inline-block; }

html.js-enabled .swap-word.is-swapping { animation: swap 600ms var(--ease); }

@keyframes swap {
  0% { opacity: 1; transform: translateY(0); }
  45% { opacity: 0; transform: translateY(0.35em); }
  55% { opacity: 0; transform: translateY(-0.35em); }
  100% { opacity: 1; transform: translateY(0); }
}

.hero__sub {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: rgba(246, 241, 232, 0.85);
  max-width: 44ch;
  margin-bottom: 2rem;
}

.hero__actions { display: flex; align-items: center; gap: 1.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  background: var(--forest);
  color: var(--parchment);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.85rem 1.9rem;
  border-radius: 999px;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: background 250ms var(--ease), transform 250ms var(--ease);
}

.btn:hover { background: var(--forest-deep); transform: translateY(-1px); }

.btn--light { background: var(--parchment); color: var(--forest-deep); }

.btn--light:hover { background: #fff; }

.link-mono {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--forest);
  text-decoration: none;
  border-bottom: 1px solid rgba(29, 74, 56, 0.3);
  padding-bottom: 2px;
  transition: border-color 250ms var(--ease);
}

.link-mono:hover { border-color: var(--forest); }

.link-mono--light {
  color: var(--sage);
  border-color: rgba(143, 168, 147, 0.4);
}

.link-mono--light:hover { color: var(--parchment); border-color: var(--parchment); }

.diff { padding: clamp(4rem, 11vh, 8rem) var(--gutter); }

.diff__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: clamp(2.5rem, 7vw, 7rem);
  align-items: center;
}

.diff__head { margin-bottom: 2rem; }

.diff__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.diff__list li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  border-top: 1px solid var(--sage);
  padding-top: 1.25rem;
}

.diff__num {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--terracotta);
}

.diff__list h3 {
  font-family: var(--serif);
  font-weight: 480;
  font-size: 1.35rem;
  line-height: 1.2;
}

.diff__list p { font-size: 0.95rem; color: var(--ink-soft); margin-top: 0.5rem; max-width: 46ch; }

.lab__book { position: relative; display: flex; flex-direction: column; align-items: center; }

.lab__hint {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--sage);
  margin-bottom: 1.25rem;
  transition: opacity 400ms var(--ease);
}

.lab__book.is-open .lab__hint { opacity: 0; }

.flipbook {
  perspective: 1600px;
  width: min(300px, 74%);
}

.flipbook__inner {
  position: relative;
  aspect-ratio: 3 / 4;
  transform: rotateX(4deg) rotateY(-10deg) rotateZ(1deg);
  transform-style: preserve-3d;
  transition: transform 700ms var(--ease);
}

.lab__book.is-open .flipbook__inner { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }

.flipbook__page {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, #FBF7EF 0%, var(--parchment) 60%, #EDE5D6 100%);
  border: 1px solid rgba(143, 168, 147, 0.5);
  border-radius: 4px 10px 10px 4px;
  padding: clamp(1.1rem, 2vw, 1.5rem);
  display: flex;
  flex-direction: column;
  box-shadow: 14px 20px 44px rgba(34, 27, 21, 0.22);
  visibility: hidden;
  transition: visibility 0s 400ms;
}

.lab__book.is-open .flipbook__page { visibility: visible; transition-delay: 0s; }

.page__kicker {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--terracotta);
  margin-bottom: 0.9rem;
}

.page__toc { list-style: none; flex: 1; }

.page__toc li { border-top: 1px solid rgba(143, 168, 147, 0.4); }

.page__toc li:last-child { border-bottom: 1px solid rgba(143, 168, 147, 0.4); }

.page__toc a {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.55rem 0.2rem;
  font-family: var(--serif);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: var(--ink);
  text-decoration: none;
  transition: color 250ms var(--ease), transform 250ms var(--ease);
}

.page__toc a span {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--sage);
}

.page__toc a:hover { color: var(--forest); transform: translateX(4px); }

.page__folio {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: var(--sage);
  margin-top: 0.9rem;
}

.flipbook__cover {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 900ms var(--ease);
  background: transparent;
  border: 0;
  border-radius: 4px 10px 10px 4px;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  z-index: 2;
}

.flipbook__cover:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 4px; }

.lab__book.is-open .flipbook__cover { transform: rotateY(-152deg); }

.cover__front, .cover__back {
  position: absolute;
  inset: 0;
  border-radius: 4px 10px 10px 4px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.cover__front {
  background: linear-gradient(155deg, #235743 0%, var(--forest) 55%, #17402F 100%);
  padding: clamp(1.1rem, 2vw, 1.5rem);
  display: flex;
  flex-direction: column;
  box-shadow: 14px 20px 44px rgba(34, 27, 21, 0.28), inset 1px 0 0 rgba(246, 241, 232, 0.18);
}

.cover__back {
  background: var(--forest-deep);
  transform: rotateY(180deg);
}

.cover__top { display: flex; justify-content: space-between; align-items: center; }

.cover__badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--forest-deep);
  background: var(--parchment);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}

.cover__brand { font-family: var(--serif); font-size: 0.9rem; color: var(--parchment); }

.cover__brand em { color: var(--sage); }

.cover__title {
  font-family: var(--serif);
  font-weight: 450;
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  line-height: 1.12;
  color: var(--parchment);
  margin: auto 0 1rem;
  display: block;
}

.cover__chart { width: 100%; height: auto; opacity: 0.9; }

.cover__foot {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(246, 241, 232, 0.25);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--sage);
}

.cta-band { background: var(--forest-deep); }

.cta-band__inner {
  padding: clamp(3rem, 8vh, 5rem) var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.cta-band h2 { color: var(--parchment); margin: 0; }

.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 2rem var(--gutter);
  border-top: 1px solid rgba(143, 168, 147, 0.35);
}

.footer__mark { font-family: var(--serif); font-size: 1.1rem; }

.footer__mono { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; color: var(--sage); }

.reveal { transition: opacity 700ms var(--ease), transform 700ms var(--ease); }
html.js-enabled .reveal { opacity: 0; transform: translateY(24px); }
html.js-enabled .reveal.is-visible { opacity: 1; transform: none; }

@media (max-width: 860px) {
  .diff__grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .diff__head { max-width: none; }
  .lab__book { margin-top: 0.5rem; }
  .flipbook { width: min(250px, 78%); }
  .nav__links { gap: 1.1rem; }
}

/* Narrow / portrait: stack the hero. The animation sits on top; the copy sits
   below in a block that is centered in the viewport but left-aligned inside. */
@media (max-aspect-ratio: 5/4), (max-width: 860px) {
  .hero {
    align-items: center;
    justify-content: center;
    min-height: 86vh;
    padding: clamp(4.5rem, 11vh, 7rem) 0 clamp(2.5rem, 6vh, 4rem);
  }
  .hero__art {
    position: relative;
    inset: auto;
    width: 100%;
    height: clamp(230px, 33vh, 400px);
    -webkit-mask-image: none;
    mask-image: none;
  }
  .hero__content {
    width: 100%;
    max-width: 40rem;
    margin-top: clamp(1.25rem, 4vh, 2.5rem);
    margin-bottom: 0;
    text-align: left;
  }
  .hero__sub { max-width: 46ch; }
}

/* Narrow nav: drop the left "hello millie" wordmark at the width where it would
   otherwise wrap to two lines (~588px; hidden at <=600 for a small cushion). It
   is redundant with the logo anyway (both link home), so the logo anchors the
   right edge alone. On phones the links wrap to a second row instead of clipping. */
@media (max-width: 600px) {
  .nav { justify-content: flex-end; }
  .nav__wordmark { display: none; }
  .nav__links a { padding: 0.45rem 0; }   /* larger tap target for touch */
}

@media (max-width: 560px) {
  .nav__right { gap: 1.1rem; }
  .nav__links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.3rem 0.9rem;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .btn, .flipbook__inner, .flipbook__cover, .page__toc a, .lab__hint, .swap-word { transition: none !important; animation: none !important; }
  html.js-enabled .reveal { opacity: 1; transform: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* === App shell embedding ===
   Every page is a standalone document, but the site is stitched together by a
   single-document app shell (index.html) that loads each page into one frame so
   the nav never reloads. When a page is framed it hides its OWN nav and defers
   to the shell's persistent nav. Opened directly (not framed), the page shows
   its own nav and works as a normal standalone document. */
html.embedded .nav { display: none; }
