/* =========================================================
   My Village OT — Journal
   A warm editorial system: paper, ink, terracotta.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..900;1,9..144,300..900&family=Karla:ital,wght@0,300..700;1,300..700&display=swap');

:root {
  /* Paper & ink */
  --paper:        #FBF6ED;
  --paper-deep:   #F1E7D8;
  --paper-edge:   #E3D5C1;
  --ink:          #221E19;
  --ink-soft:     #57504704;
  --ink-mid:      #5B5348;
  --ink-faint:    #8B8073;

  /* Accents */
  --terracotta:   #B24E2A;
  --terracotta-d: #8E3D20;
  --ochre:        #C98A2E;
  --sage:         #6B7C5E;

  /* Type */
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --body:    'Karla', 'Helvetica Neue', Helvetica, sans-serif;

  /* Rhythm */
  --measure: 64ch;
  --gutter:  clamp(1.25rem, 5vw, 4rem);

  --rule: 1px solid var(--paper-edge);
  --shadow-soft: 0 1px 2px rgba(60, 44, 26, .05),
                 0 8px 24px -12px rgba(60, 44, 26, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #14120E;
    --paper-deep: #1D1A14;
    --paper-edge: #332E25;
    --ink:        #EFE7DA;
    --ink-mid:    #B9AE9D;
    --ink-faint:  #8A8072;
    --terracotta: #E08356;
    --terracotta-d: #F0A277;
    --ochre:      #DDA954;
    --sage:       #9AAE8B;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .4),
                   0 8px 24px -12px rgba(0, 0, 0, .7);
  }
}

/* ---------------------------------------------------------
   Reset-ish
   --------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* `clip`, not `hidden` — hidden would create a scroll container and
     break the sticky masthead. Guards the oversized decorative numeral. */
  overflow-x: clip;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 70% at 50% -10%, rgba(201, 138, 46, .13), transparent 62%),
    radial-gradient(90% 50% at 85% 105%, rgba(107, 124, 94, .10), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1.02rem, .96rem + .3vw, 1.15rem);
  line-height: 1.72;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Paper grain — the thing that stops it feeling like a screen */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: .30;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  body::before { mix-blend-mode: overlay; opacity: .16; }
}

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

::selection {
  background: var(--terracotta);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------------------------------------------------------
   Masthead
   --------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem var(--gutter) .8rem;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: var(--rule);
}

.wordmark {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -.015em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark em {
  font-style: italic;
  color: var(--terracotta);
}

.masthead nav {
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}

.masthead nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color .25s ease, border-color .25s ease;
}

.masthead nav a:hover {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}

/* Reading progress — pure CSS scroll-driven, degrades to nothing */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--terracotta), var(--ochre));
  z-index: 60;
  transform: scaleX(0);
}

@supports (animation-timeline: scroll()) {
  .progress {
    animation: grow linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes grow { to { transform: scaleX(1); } }

/* ---------------------------------------------------------
   Editorial grid
   --------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, 7rem)
    [main-start] min(var(--measure), calc(100% - (var(--gutter) * 2))) [main-end]
    minmax(0, 7rem) [wide-end]
    minmax(var(--gutter), 1fr) [full-end];
}

.grid > * { grid-column: main; }

/* ---------------------------------------------------------
   Essay head
   --------------------------------------------------------- */

.essay-head {
  position: relative;
  padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(2rem, 4vw, 3rem);
}

.essay-head::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 1px;
  margin-top: clamp(2rem, 4vw, 3rem);
  background: var(--terracotta);
}

.ghost-num {
  position: absolute;
  top: clamp(1rem, 4vw, 3rem);
  right: -.06em;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 40, 'WONK' 1;
  font-weight: 700;
  font-size: clamp(7rem, 22vw, 15rem);
  line-height: .78;
  color: var(--terracotta);
  opacity: .09;
  pointer-events: none;
  user-select: none;
  z-index: -1;
}

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin: 0 0 1.4rem;
  display: flex;
  align-items: center;
  gap: .8rem;
}

.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--paper-edge);
}

h1 {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 70, 'WONK' 1;
  font-weight: 500;
  font-size: clamp(2.4rem, 1.4rem + 4.4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -.028em;
  margin: 0 0 1.5rem;
  text-wrap: balance;
}

h1 em {
  font-style: italic;
  color: var(--terracotta);
}

.standfirst {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 80, 'WONK' 0;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.2rem, 1.05rem + .55vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink-mid);
  margin: 0 0 2rem;
  max-width: 46ch;
  text-wrap: pretty;
}

.byline {
  font-size: .76rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
  margin: 0;
}

/* Staggered entrance */
.essay-head > * {
  animation: rise .9s cubic-bezier(.19, 1, .22, 1) both;
}
.essay-head .eyebrow    { animation-delay: .05s; }
.essay-head h1          { animation-delay: .14s; }
.essay-head .standfirst { animation-delay: .24s; }
.essay-head .byline     { animation-delay: .34s; }

/* The numeral keeps its own keyframes — a shared `rise` would animate it
   up to opacity 1 and override the .09 it is supposed to sit at. */
.essay-head .ghost-num {
  animation-name: ghost-rise;
  animation-delay: 0s;
  animation-duration: 1.7s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(1.1rem); }
  to   { opacity: 1; transform: none; }
}

@keyframes ghost-rise {
  from { opacity: 0; transform: translateY(1.6rem); }
  to   { opacity: .09; transform: none; }
}

/* ---------------------------------------------------------
   Prose
   --------------------------------------------------------- */

.prose {
  padding-bottom: clamp(3rem, 7vw, 6rem);
}

.prose p {
  margin: 0 0 1.45em;
  text-wrap: pretty;
}

.prose > p.lede::first-letter {
  float: left;
  font-family: var(--display);
  font-variation-settings: 'SOFT' 30, 'WONK' 1;
  font-weight: 600;
  font-size: 4.1em;
  line-height: .78;
  margin: .06em .04em 0 0;
  color: var(--terracotta);
}

.prose h2 {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  font-weight: 500;
  font-size: clamp(1.5rem, 1.25rem + .9vw, 2rem);
  line-height: 1.18;
  letter-spacing: -.018em;
  margin: 2.8em 0 .7em;
  text-wrap: balance;
}

.prose h2::before {
  content: "";
  display: block;
  width: 1.6rem;
  height: 2px;
  background: var(--ochre);
  margin-bottom: .9rem;
}

.prose h3 {
  font-family: var(--body);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-mid);
  margin: 2.2em 0 .6em;
}

.prose a {
  color: var(--terracotta-d);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}

.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose ul, .prose ol {
  margin: 0 0 1.6em;
  padding-left: 1.3em;
}

.prose li {
  margin-bottom: .6em;
  padding-left: .25em;
}

.prose li::marker { color: var(--terracotta); }

/* Pull quote — deliberately breaks the measure */
.pull {
  grid-column: wide;
  margin: 2.8rem 0;
  padding-left: clamp(1rem, 3vw, 2rem);
  border-left: 3px solid var(--terracotta);
  font-family: var(--display);
  font-variation-settings: 'SOFT' 70, 'WONK' 1;
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.35rem, 1.1rem + 1.1vw, 1.95rem);
  line-height: 1.32;
  letter-spacing: -.015em;
  color: var(--ink);
  text-wrap: balance;
}

/* Practical aside */
.practice {
  grid-column: wide;
  margin: 3rem 0;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  background: var(--paper-deep);
  border: 1px dashed var(--paper-edge);
  border-radius: 3px;
  box-shadow: var(--shadow-soft);
}

.practice h3 {
  margin-top: 0;
  color: var(--terracotta);
  font-size: .78rem;
  letter-spacing: .18em;
}

.practice p:last-child,
.practice ul:last-child { margin-bottom: 0; }

.practice ul { padding-left: 1.1em; }

/* Scroll-revealed sections, CSS-only where supported */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .prose > h2,
    .prose > .pull,
    .prose > .practice {
      animation: fade-up linear both;
      animation-timeline: view();
      animation-range: entry 5% cover 22%;
    }
  }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(1.4rem); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------
   Essay footer / pagination
   --------------------------------------------------------- */

.essay-foot {
  border-top: var(--rule);
  padding: clamp(2rem, 5vw, 3.5rem) 0;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.pagelink {
  text-decoration: none;
  color: var(--ink);
  display: block;
  padding: 1.1rem 1.3rem;
  border: var(--rule);
  border-radius: 3px;
  background: color-mix(in srgb, var(--paper-deep) 55%, transparent);
  transition: transform .3s cubic-bezier(.19,1,.22,1), border-color .3s ease, background .3s ease;
}

.pagelink:hover {
  transform: translateY(-3px);
  border-color: var(--terracotta);
  background: var(--paper-deep);
}

.pagelink span {
  display: block;
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--terracotta);
  margin-bottom: .4rem;
}

.pagelink strong {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  font-weight: 500;
  font-size: 1.12rem;
  line-height: 1.25;
  letter-spacing: -.015em;
  display: block;
}

.pagelink.next { text-align: right; }

/* ---------------------------------------------------------
   Index page
   --------------------------------------------------------- */

.hero {
  padding: clamp(4rem, 12vw, 9rem) 0 clamp(2.5rem, 6vw, 4.5rem);
}

.hero h1 {
  font-size: clamp(3rem, 1.6rem + 7vw, 7rem);
  font-weight: 400;
  line-height: .95;
  margin-bottom: 1.8rem;
}

.hero .standfirst { max-width: 52ch; font-size: clamp(1.25rem, 1.05rem + .8vw, 1.7rem); }

.hero > * { animation: rise 1s cubic-bezier(.19,1,.22,1) both; }
.hero .eyebrow    { animation-delay: .05s; }
.hero h1          { animation-delay: .15s; }
.hero .standfirst { animation-delay: .28s; }
.hero .hero-note  { animation-delay: .4s; }

.hero-note {
  max-width: 54ch;
  color: var(--ink-mid);
  border-top: var(--rule);
  padding-top: 1.6rem;
  margin-top: 2.5rem;
}

.contents {
  list-style: none;
  margin: 0 0 clamp(3rem, 8vw, 6rem);
  padding: 0;
  border-top: var(--rule);
}

.contents li { margin: 0; }

.contents a {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  gap: clamp(.75rem, 2vw, 1.75rem);
  align-items: baseline;
  padding: clamp(1.5rem, 3vw, 2.2rem) 0;
  border-bottom: var(--rule);
  text-decoration: none;
  color: var(--ink);
  position: relative;
  transition: color .3s ease;
}

.contents a::before {
  content: "";
  position: absolute;
  inset: 0 -1rem;
  background: var(--paper-deep);
  opacity: 0;
  z-index: -1;
  transition: opacity .3s ease;
  border-radius: 3px;
}

.contents a:hover::before { opacity: .8; }
.contents a:hover .c-title { color: var(--terracotta); }

.c-num {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 40, 'WONK' 1;
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--terracotta);
  opacity: .55;
  letter-spacing: -.02em;
}

.c-title {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 65, 'WONK' 1;
  font-weight: 500;
  font-size: clamp(1.35rem, 1.1rem + 1.1vw, 2rem);
  line-height: 1.12;
  letter-spacing: -.022em;
  display: block;
  margin-bottom: .5rem;
  transition: color .3s ease;
  text-wrap: balance;
}

.c-dek {
  color: var(--ink-mid);
  font-size: .97rem;
  line-height: 1.6;
  max-width: 58ch;
  display: block;
  margin-bottom: .7rem;
}

.c-meta {
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------
   Site footer
   --------------------------------------------------------- */

.site-foot {
  border-top: 2px solid var(--ink);
  padding: clamp(2.5rem, 6vw, 4rem) 0 clamp(3rem, 6vw, 4rem);
  font-size: .9rem;
  color: var(--ink-mid);
}

.site-foot p { margin: 0 0 1rem; max-width: 60ch; }
.site-foot p:last-child { margin-bottom: 0; }

.site-foot .disclaimer {
  font-size: .82rem;
  color: var(--ink-faint);
  font-style: italic;
  line-height: 1.6;
}

.site-foot a { color: var(--terracotta-d); }

/* ---------------------------------------------------------
   Motion & print courtesies
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  body::before, .masthead, .progress, .essay-foot, .ghost-num { display: none; }
  body { background: #fff; color: #000; }
  .prose { font-size: 11pt; }
  .pull, .practice { break-inside: avoid; }
}
