/* ================================================================
   STORIES FOR THE FUTURE — Shared Stylesheet
   Design tokens, masthead, menu overlay, section primitives,
   text links, reveal, footer, shared mobile breakpoints.
   Page-specific composition lives in each page's <style> block.
   ================================================================ */

:root {
  /* Palette — warm paper + accents pulled from the photograph */
  --paper:      #f7f4ea;
  --paper-soft: #efe9d9;
  --sky-pale:   #c3d1b8;
  --sky-deep:   #7a9488;
  --olive:      #85826b;
  --tan:        #b8a07a;
  --ink:        #3c3430;
  --ink-soft:   #5a4f48;
  --ink-faint:  #7d6f64;
  --rule:       rgba(60, 52, 48, 0.14);
  --rule-hair:  rgba(60, 52, 48, 0.08);

  /* Typography */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Rhythm */
  --column:      680px;
  --column-wide: 880px;
  --column-tool: 960px;
}

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  background-color: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
}

/* Paper grain — Steadman technique, ~7% effective opacity */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
}

/* All content sits above the noise overlay */
.masthead, main, footer { position: relative; z-index: 2; }

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


/* ================================================================
   MASTHEAD (fixed, transparent → paper on scroll)
   ================================================================ */

.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid transparent;
  transition: background-color 0.45s ease, backdrop-filter 0.45s ease, -webkit-backdrop-filter 0.45s ease, border-color 0.45s ease;
}

.masthead__inner {
  max-width: var(--column-wide);
  margin: 0 auto;
  padding: 1.75rem 2rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.masthead__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  font-variation-settings: "opsz" 14;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.masthead__title em { font-style: italic; font-weight: 400; }

.masthead__nav {
  display: flex;
  align-items: center;
  gap: 2.25rem;
}

.masthead__nav a,
.masthead__nav-link {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s ease;
}

.masthead__nav a:hover,
.masthead__nav-link:hover { color: var(--ink); }

.masthead__nav a.is-active,
.masthead__nav-link.is-active {
  color: var(--ink);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink);
}

/* Dropdown — Chapters parent on hover */
.masthead__nav-item {
  position: relative;
  /* keep the hover-area continuous between trigger and panel so the
     panel doesn't disappear while moving the cursor toward it */
  padding-bottom: 14px;
  margin-bottom: -14px;
}

.masthead__nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  min-width: 220px;
  background-color: rgba(247, 244, 234, 0.97);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  border: 1px solid var(--rule);
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s, transform 0.2s ease;
  z-index: 30;
}

.masthead__nav-item:hover .masthead__nav-dropdown,
.masthead__nav-item:focus-within .masthead__nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.2s ease, visibility 0s linear 0s, transform 0.2s ease;
}

.masthead__nav-dropdown a {
  padding: 0.7rem 1.4rem;
  border-bottom: none !important;
  text-align: left;
  white-space: nowrap;
  color: var(--ink-soft);
}

.masthead__nav-dropdown a:hover {
  color: var(--ink);
}

.masthead__nav-dropdown a.is-active {
  border-bottom: none !important;
  padding-bottom: 0.7rem !important;
  color: var(--ink);
}


.masthead.is-solid {
  background-color: rgba(247, 244, 234, 0.93);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  border-bottom-color: var(--rule);
}

/* Hamburger toggle — three-line icon, hidden on desktop */
.masthead__toggle {
  display: none;
  position: relative;
  width: 26px;
  height: 20px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.masthead__toggle-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  background-color: var(--ink);
  border-radius: 1px;
  transition: top 0.25s ease, bottom 0.25s ease, transform 0.25s ease, opacity 0.15s ease;
}

.masthead__toggle-line:nth-child(1) { top: 2px; }
.masthead__toggle-line:nth-child(2) { top: calc(50% - 0.75px); }
.masthead__toggle-line:nth-child(3) { bottom: 2px; }

.masthead__toggle[aria-expanded="true"] .masthead__toggle-line:nth-child(1) {
  top: calc(50% - 0.75px);
  transform: rotate(45deg);
}

.masthead__toggle[aria-expanded="true"] .masthead__toggle-line:nth-child(2) {
  opacity: 0;
}

.masthead__toggle[aria-expanded="true"] .masthead__toggle-line:nth-child(3) {
  bottom: calc(50% - 0.75px);
  transform: rotate(-45deg);
}

/* Menu overlay — full-screen paper panel */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background-color: var(--paper);
  padding: 7rem 1.5rem 3rem;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
  overflow-y: auto;
}

.menu-overlay.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0s linear 0s;
}

.menu-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
}

.menu-overlay__nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--column);
  margin: 0 auto;
  border-top: 1px solid var(--rule-hair);
}

.menu-overlay__nav a {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink);
  text-decoration: none;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule-hair);
  transition: color 0.2s ease;
}

.menu-overlay__nav a:hover { color: var(--sky-deep); }

.menu-overlay__nav a.is-active { color: var(--sky-deep); }

/* Mobile overlay — Chapters group */
.menu-overlay__group-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.92rem !important;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink);
  padding: 1.5rem 0 !important;
  border-bottom: 1px solid var(--rule-hair);
  margin-bottom: 0;
  text-decoration: none;
  transition: color 0.2s ease;
}

.menu-overlay__group-label:hover { color: var(--sky-deep); }

.menu-overlay__group-label.is-active { color: var(--sky-deep); }

.menu-overlay__child {
  font-family: var(--font-body);
  font-size: 0.82rem !important;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 1rem 0 1rem 1.5rem !important;
  border-bottom: 1px solid var(--rule-hair);
  transition: color 0.2s ease;
  display: block;
}

.menu-overlay__child:hover { color: var(--sky-deep); }
.menu-overlay__child.is-active { color: var(--sky-deep); }

body.is-menu-open { overflow: hidden; }


/* ================================================================
   SECTION PRIMITIVES
   ================================================================ */

.section-rule {
  border: none;
  border-top: 1px solid var(--rule-hair);
  margin: 0 auto;
}

.section__label {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  margin-bottom: 2rem;
  text-align: center;
}

.section__heading {
  font-family: var(--font-display);
  font-weight: 350;
  font-style: italic;
  font-variation-settings: "opsz" 72;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.18;
  letter-spacing: -0.002em;
  color: var(--ink);
  text-align: center;
  margin-bottom: 4rem;
  text-wrap: balance;
}

.section__body {
  font-family: var(--font-body);
  font-size: 1.08rem;
  line-height: 1.72;
  color: var(--ink);
}

.section__body p { margin-bottom: 1.4em; }
.section__body p:last-child { margin-bottom: 0; }

.section__close {
  font-family: var(--font-display);
  font-weight: 350;
  font-style: italic;
  font-variation-settings: "opsz" 60;
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.3;
  color: var(--ink-soft);
  margin-top: 3rem;
  text-align: center;
  letter-spacing: -0.002em;
}


/* ================================================================
   TEXT LINKS (the only CTA pattern on the page)
   ================================================================ */

.text-link {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.text-link:hover {
  color: var(--sky-deep);
  border-bottom-color: var(--sky-deep);
}

.text-link__arrow {
  display: inline-block;
  margin-left: 0.45em;
  transition: transform 0.2s ease;
}

.text-link:hover .text-link__arrow {
  transform: translateX(3px);
}

.text-link--muted {
  color: var(--ink-faint);
  border-bottom-color: var(--ink-faint);
}

.text-link--muted:hover {
  color: var(--ink-soft);
  border-bottom-color: var(--ink-soft);
}


/* ================================================================
   REVEAL ON SCROLL
   ================================================================ */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 1.4s ease-out,
    transform 1.4s ease-out;
  will-change: opacity, transform;
}

.reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.is-revealed {
    opacity: 1;
    transform: none;
    transition: none;
  }
}


/* ================================================================
   FOOTER
   ================================================================ */

.site-footer {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

.footer-rule {
  border: none;
  border-top: 1px solid var(--rule-hair);
  margin-bottom: 3rem;
}

.footer__bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer__brand {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.95rem;
  font-variation-settings: "opsz" 14;
  color: var(--ink);
}

.footer__brand em { font-style: italic; }

.footer__links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.footer__links a {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer__links a:hover { color: var(--ink); }

.footer__copyright {
  width: 100%;
  margin-top: 2rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
}


/* ================================================================
   MOBILE — 820px (shared rules only)
   ================================================================ */

@media (max-width: 820px) {
  html { font-size: 17px; }

  .masthead__inner {
    padding: 1.25rem 1.25rem;
    flex-direction: row;
    align-items: center;
    gap: 0;
  }

  .masthead__nav { display: none; }
  .masthead__toggle { display: block; }

  .section__heading {
    font-size: clamp(26px, 6.6vw, 34px);
    margin-bottom: 3rem;
  }

  .section__body { font-size: 1.02rem; }

  .section__close {
    font-size: clamp(22px, 5.4vw, 28px);
  }

  .site-footer { padding: 0 1.5rem 3rem; }
}


/* ================================================================
   MOBILE — 600px (shared rules only)
   ================================================================ */

@media (max-width: 600px) {
  .site-footer { padding: 0 1.25rem 2.5rem; }
}
