/* wastepbc.com
   Editorial typographic system. Self-hosted Literata variable.
   No third-party requests, no JavaScript, no tracking.
   Designed for long-form reading, in keeping with the Waste PBC charter.
*/

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/literata-latin-var.woff2") format("woff2-variations"),
       url("/fonts/literata-latin-var.woff2") format("woff2");
  font-variation-settings: "opsz" 14;
}

@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/literata-latin-italic-var.woff2") format("woff2-variations"),
       url("/fonts/literata-latin-italic-var.woff2") format("woff2");
  font-variation-settings: "opsz" 14;
}

/* ---- Design tokens ----------------------------------------------------- */

:root {
  --paper:       #f6f1e7;   /* warm cream, archival */
  --paper-fold:  #ede7d8;   /* slightly deeper, for rules and asides */
  --ink:         #1c1a17;   /* near-black, warm */
  --ink-soft:    #4a4640;
  --ink-faint:   #877f72;
  --rule:        #cdc4b3;
  --accent:      #2e4a36;   /* deep forest, not bright */
  --accent-soft: #6a8073;

  --serif:       "Literata", Charter, "Iowan Old Style", "Source Serif Pro",
                 "Apple Garamond", Georgia, Cambria, "Times New Roman", serif;

  /* Modular scale, ratio ~1.25 (major third) anchored on body */
  --fs-mono:     0.78rem;
  --fs-meta:     0.82rem;
  --fs-body:     1.0625rem;   /* 17px */
  --fs-lede:     1.22rem;
  --fs-h2:       1.18rem;
  --fs-h1:       2.45rem;
  --fs-display:  3.1rem;

  --measure:     33rem;     /* ~560px optimum */
  --measure-wide: 44rem;
  --leading:     1.62;

  --rule-thin:   0.5px solid var(--rule);
}

/* ---- Reset & base ------------------------------------------------------ */

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-body);
  line-height: var(--leading);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "onum" 1;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  hanging-punctuation: first last;
}

/* ---- Page frame -------------------------------------------------------- */

.page {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 2.5rem) 5rem;
}

main, header.masthead, footer.colophon {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}

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

header.masthead {
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
  padding-top: 0.25rem;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--serif);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1.6rem;
  font-feature-settings: "kern" 1, "lnum" 1;
  font-variant-numeric: lining-nums;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.2rem;
  height: 1px;
  background: var(--ink-faint);
  flex: 0 0 auto;
}

.eyebrow a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}

.eyebrow a:hover { border-bottom-color: var(--ink-faint); }

h1 {
  font-family: var(--serif);
  font-size: var(--fs-h1);
  font-weight: 450;
  line-height: 1.08;
  letter-spacing: -0.018em;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
  font-variation-settings: "opsz" 60;
}

/* Optical micro-typography: hang the opening punctuation, balance heading. */

.masthead h1 + p,
.masthead h1 + .lede {
  margin-top: 1.5rem;
}

/* ---- Body text -------------------------------------------------------- */

p {
  margin: 0 0 1.2em;
  color: var(--ink);
  max-width: 100%;
  text-wrap: pretty;
}

p.lede {
  font-size: var(--fs-lede);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 2rem;
  font-weight: 400;
  font-variation-settings: "opsz" 18;
  letter-spacing: -0.003em;
}

/* Drop the first line of the lede in small caps for editorial effect, but
   only on the home page where the lede opens with "I am 44 years old." */

main > p.lede:first-of-type::first-line {
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

h2 {
  font-family: var(--serif);
  font-size: var(--fs-h2);
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 3.2rem 0 0.9rem;
  color: var(--ink);
  font-variation-settings: "opsz" 24;
  text-wrap: balance;
}

h2 + p { margin-top: 0; }

em, i {
  font-style: italic;
}

strong, b {
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 0.04em;
  transition: border-color 120ms ease, color 120ms ease;
}

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

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

/* Quoted phrases keep the curly quotes Literata provides */
::selection {
  background: rgba(46, 74, 54, 0.18);
  color: var(--ink);
}

/* ---- Hairline rule ----------------------------------------------------- */

hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3.2rem 0;
  position: relative;
}

hr::after {
  content: "§";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 0 0.7rem;
  color: var(--ink-faint);
  font-size: 0.92rem;
  font-weight: 400;
  font-style: italic;
}

/* ---- Charter contents card -------------------------------------------- */

nav.toc {
  margin: 2.5rem 0 3.5rem;
  padding: 1.6rem 1.6rem 1.4rem;
  background: transparent;
  border-top: var(--rule-thin);
  border-bottom: var(--rule-thin);
  font-size: var(--fs-meta);
  color: var(--ink-soft);
}

nav.toc > p {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-feature-settings: "kern" 1, "lnum" 1;
  font-variant-numeric: lining-nums;
}

nav.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 0.45rem;
}

nav.toc li {
  counter-increment: toc;
  padding-left: 2.2rem;
  position: relative;
  line-height: 1.4;
}

nav.toc li::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.05em;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-variant-numeric: lining-nums;
}

nav.toc a {
  color: var(--ink-soft);
  border-bottom-color: transparent;
}

nav.toc a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---- Principles list -------------------------------------------------- */

ol.principles {
  list-style: none;
  padding: 0;
  margin: 3rem 0 0;
  counter-reset: principle;
}

ol.principles > li {
  counter-increment: principle;
  position: relative;
  margin: 0 0 3.4rem;
  padding: 2.4rem 0 0;
  border-top: var(--rule-thin);
}

ol.principles > li:first-child {
  border-top: 0;
  padding-top: 0;
}

ol.principles > li::before {
  content: counter(principle, decimal-leading-zero);
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  font-variant-numeric: lining-nums;
}

ol.principles > li > h2 {
  margin: 0 0 1rem;
  font-size: 1.32rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.008em;
  font-variation-settings: "opsz" 36;
}

ol.principles > li > h2 a.anchor {
  color: var(--ink);
  border-bottom: none;
  padding-bottom: 0;
}

ol.principles > li > h2 a.anchor:hover {
  color: var(--accent);
}

ol.principles > li p:last-child { margin-bottom: 0; }

/* Smooth anchor focus when jumping from TOC */

ol.principles > li:target {
  animation: target-glow 1.6s ease-out 1;
}

@keyframes target-glow {
  0%   { background: rgba(46, 74, 54, 0.07); }
  100% { background: transparent; }
}

ol.principles > li:target {
  scroll-margin-top: 2rem;
}

/* ---- Credo (closing belief statement) -------------------------------- */

aside.credo {
  margin: 3.6rem 0 3rem;
  padding: 1.6rem 0 1.6rem 1.6rem;
  border-left: 2px solid var(--accent);
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.45;
  font-style: italic;
  font-variation-settings: "opsz" 18;
  letter-spacing: -0.002em;
  text-wrap: pretty;
}

aside.credo p {
  margin: 0 0 0.7rem;
}

aside.credo p:last-child {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  aside.credo {
    padding-left: 1.1rem;
    font-size: 1.06rem;
  }
}

/* ---- Crumb / back nav ------------------------------------------------- */

nav.crumb {
  font-size: var(--fs-meta);
  margin-top: 4rem;
  color: var(--ink-faint);
}

nav.crumb a {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
}

/* ---- Colophon / footer ------------------------------------------------- */

footer.colophon,
footer {
  margin-top: 5rem;
  padding-top: 1.6rem;
  border-top: var(--rule-thin);
  font-size: var(--fs-meta);
  color: var(--ink-faint);
  line-height: 1.55;
}

footer p {
  margin: 0 0 0.4rem;
}

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

footer a {
  color: var(--ink-faint);
  border-bottom-color: var(--rule);
}

/* ---- Responsive tightening ------------------------------------------- */

@media (max-width: 480px) {
  :root {
    --fs-h1: 2rem;
    --fs-lede: 1.1rem;
  }
  .page { padding-top: 2rem; }
  hr { margin: 2.4rem 0; }
  ol.principles > li { margin-bottom: 2.6rem; padding-top: 2rem; }
}

@media (min-width: 1100px) {
  :root {
    --measure: 34rem;
  }
}

/* ---- Print ------------------------------------------------------------ */

@media print {
  :root {
    --paper: #ffffff;
    --ink: #000000;
  }
  body { background: #fff; color: #000; }
  .page { padding: 1in; }
  a { color: #000; border-bottom: none; }
  hr::after { background: #fff; }
  nav.toc { border-color: #000; }
  ol.principles > li { page-break-inside: avoid; }
}

/* ---- Reduced motion --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  ol.principles > li:target { animation: none; }
  * { transition: none !important; }
}
