/* ============================================================
   KINGSMOOT — a field guide to self-rule
   Design: editorial almanac / old charter. Parchment & ink.
   Type: Young Serif (display) · Source Serif 4 (text) · IBM Plex Mono (labels)
   ============================================================ */

:root {
  --bone:    #F2ECDF;
  --bone-2:  #EAE2CF;
  --bone-3:  #DFD3B8;
  --ink:     #221D14;
  --ink-2:   #443D2F;
  --ink-3:   #6E6553;
  --ember:   #A03D1E;
  --ember-2: #7E2F16;
  --moss:    #55613C;
  --brass:   #8F6B26;
  --night:   #1A1610;
  --night-2: #241F16;
  --line:    rgba(34, 29, 20, .16);
  --line-2:  rgba(34, 29, 20, .34);

  --serif:   "Source Serif 4", Georgia, serif;
  --display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --mono:    "IBM Plex Mono", "SF Mono", monospace;

  --measure: 66ch;
  --gutter:  clamp(1.25rem, 4vw, 3rem);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.1875rem);
  line-height: 1.68;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* paper grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--ember); color: var(--bone); }

img, svg { max-width: 100%; height: auto; }

a { color: inherit; text-decoration-color: rgba(160, 61, 30, .5); text-underline-offset: 3px; }
a:hover { color: var(--ember); text-decoration-color: var(--ember); }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.12;
  margin: 0;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

p { margin: 0 0 1.4em; }

/* ---------- primitives ---------- */

.wrap {
  max-width: 74rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.overline {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.overline .no { color: var(--ember); }

.rule {
  border: 0;
  border-top: 1px solid var(--line-2);
  margin: 0;
}

/* charter-style double rule */
.rule-double {
  border: 0;
  height: 5px;
  border-top: 1px solid var(--line-2);
  border-bottom: 3px double var(--line-2);
  margin: 0;
}

/* ---------- header ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bone) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: .8rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.18rem;
  letter-spacing: .04em;
}
.wordmark:hover { color: var(--ink); }
.wordmark svg { width: 26px; height: 26px; flex: none; }
.wordmark .crown-fill { fill: var(--ember); }
.wordmark .crown-line { stroke: var(--ink); }

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(.9rem, 2.5vw, 1.8rem);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.site-nav a { text-decoration: none; color: var(--ink-2); padding-block: .35rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ember); }
.site-nav a[aria-current="page"] { border-bottom: 1px solid var(--ember); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  overflow: clip;
  border-bottom: 1px solid var(--line);
}

.hero .wrap {
  padding-block: clamp(4.5rem, 11vw, 8.5rem) clamp(3.5rem, 8vw, 6rem);
  position: relative;
}

.hero-sigil {
  position: absolute;
  right: calc(-1 * clamp(2rem, 8vw, 4rem));
  top: 50%;
  translate: 0 -50%;
  width: clamp(280px, 42vw, 560px);
  opacity: .07;
  pointer-events: none;
}

.hero h1 {
  font-size: clamp(2.9rem, 8.5vw, 6.4rem);
  max-width: 12ch;
  margin: 1.1rem 0 1.4rem;
}

.hero h1 em {
  font-style: normal;
  color: var(--ember);
}

.hero .standfirst {
  max-width: 44ch;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  margin-top: 2.2rem;
}

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .95rem 1.5rem;
  border: 1px solid var(--ink);
  color: var(--ink);
  transition: background .18s ease, color .18s ease, translate .18s ease, box-shadow .18s ease;
}
.btn:hover { translate: 0 -2px; box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
.btn-solid { background: var(--ink); color: var(--bone); }
.btn-solid:hover { background: var(--ember-2); border-color: var(--ember-2); color: var(--bone); box-shadow: 0 3px 0 var(--ember-2); }

/* staggered load reveal */
@media (prefers-reduced-motion: no-preference) {
  .rise {
    opacity: 0;
    translate: 0 18px;
    animation: rise .8s cubic-bezier(.2, .65, .25, 1) forwards;
  }
  .rise-2 { animation-delay: .12s; }
  .rise-3 { animation-delay: .24s; }
  .rise-4 { animation-delay: .36s; }
  @keyframes rise { to { opacity: 1; translate: 0 0; } }

  html.js .reveal {
    opacity: 0;
    translate: 0 26px;
    transition: opacity .7s ease, translate .7s cubic-bezier(.2, .65, .25, 1);
  }
  html.js .reveal.in { opacity: 1; translate: 0 0; }
}

/* ---------- section scaffolding ---------- */

.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: clamp(1.8rem, 4vw, 3rem);
}

.section-head h2 { font-size: clamp(1.9rem, 4.2vw, 3rem); }
.section-head .overline { display: block; margin-bottom: .7rem; }

/* ---------- pillars ---------- */

.pillars {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line-2);
  border-left: 1px solid var(--line-2);
}
@media (min-width: 620px)  { .pillars { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .pillars { grid-template-columns: repeat(3, 1fr); } }

.pillar {
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 1.6rem 1.4rem 1.8rem;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background .2s ease;
  background: transparent;
}
.pillar:hover { background: var(--bone-2); color: inherit; }
.pillar:hover .pillar-go { translate: 6px 0; color: var(--ember); }

.pillar .overline { display: block; margin-bottom: 1rem; }
.pillar h3 { font-size: 1.45rem; margin-bottom: .55rem; }
.pillar p { font-size: .95rem; color: var(--ink-2); margin: 0; line-height: 1.55; }
.pillar-go {
  position: absolute;
  top: 1.5rem;
  right: 1.3rem;
  font-family: var(--mono);
  transition: translate .2s ease, color .2s ease;
  color: var(--ink-3);
}

/* ---------- the code (manifesto) ---------- */

.code-section {
  background: var(--night);
  color: #EDE5D2;
  --line: rgba(237, 229, 210, .14);
  --line-2: rgba(237, 229, 210, .3);
}
.code-section .overline { color: #A99F87; }
.code-section ::selection { background: var(--bone); color: var(--night); }

.tenets {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: tenet;
  columns: 2;
  column-gap: clamp(2rem, 5vw, 4rem);
  column-rule: 1px solid var(--line);
}
@media (max-width: 760px) { .tenets { columns: 1; } }

.tenets li {
  counter-increment: tenet;
  break-inside: avoid;
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: .4rem 1rem;
}

.tenets li::before {
  content: counter(tenet, upper-roman) ".";
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--ember);
  filter: brightness(1.45);
  line-height: 1.3;
}

.tenets strong {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.28rem;
  margin-bottom: .35rem;
  line-height: 1.25;
}
.tenets p { margin: 0; font-size: .95rem; color: #BFB49B; grid-column: 2; line-height: 1.6; }

/* ---------- almanac lists ---------- */

.post-list { list-style: none; margin: 0; padding: 0; }

.post-item { border-bottom: 1px solid var(--line-2); }
.post-item:first-child { border-top: 1px solid var(--line-2); }

.post-link {
  display: grid;
  grid-template-columns: 5.2rem 1fr auto;
  gap: 1.2rem 1.6rem;
  align-items: baseline;
  padding: 1.7rem .4rem;
  text-decoration: none;
  color: inherit;
  transition: background .2s ease, padding-left .2s ease;
}
.post-link:hover { background: var(--bone-2); padding-left: 1rem; color: inherit; }
.post-link:hover .post-title { color: var(--ember); }

.post-no {
  font-family: var(--display);
  font-size: 1.9rem;
  color: var(--bone-3);
  -webkit-text-stroke: 1px var(--ink-3);
  line-height: 1;
}

.post-title {
  font-family: var(--display);
  font-size: clamp(1.3rem, 2.6vw, 1.8rem);
  line-height: 1.2;
  transition: color .2s ease;
  display: block;
  margin-bottom: .45rem;
}

.post-dek {
  font-size: .97rem;
  color: var(--ink-2);
  margin: 0;
  max-width: 62ch;
  line-height: 1.55;
}

.post-meta {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.post-meta .pillar-tag { color: var(--ember); }

@media (max-width: 640px) {
  .post-link { grid-template-columns: 1fr; gap: .5rem; padding-inline: 0; }
  .post-link:hover { padding-left: .4rem; }
  .post-no { display: none; }
}

/* ---------- app teaser ---------- */

.app-teaser {
  border: 1px solid var(--line-2);
  outline: 1px solid var(--line-2);
  outline-offset: 5px;
  padding: clamp(2.2rem, 6vw, 4.5rem);
  text-align: center;
  background:
    radial-gradient(ellipse 60% 80% at 50% -20%, rgba(160, 61, 30, .09), transparent),
    var(--bone-2);
  margin-block: 4px;
}
.app-teaser h2 { font-size: clamp(1.9rem, 4.5vw, 3.1rem); max-width: 22ch; margin: 1rem auto .9rem; }
.app-teaser p { max-width: 52ch; margin-inline: auto; color: var(--ink-2); }

/* ---------- raven form (waitlist) ---------- */

.raven-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .8rem;
  margin: 2rem auto .9rem;
  max-width: 34rem;
}

.raven-input {
  flex: 1 1 15rem;
  font-family: var(--mono);
  font-size: .85rem;
  letter-spacing: .04em;
  color: var(--ink);
  background: var(--bone);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: .95rem 1.1rem;
  appearance: none;
}
.raven-input::placeholder { color: var(--ink-3); }
.raven-input:focus {
  outline: 2px solid var(--ember);
  outline-offset: 1px;
  border-color: var(--ember);
}

.raven-trap {
  position: absolute;
  left: -5000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.raven-note {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
  min-height: 1.2em;
  transition: color .3s ease;
}
.raven-note.is-good { color: var(--moss); }
.raven-note.is-bad { color: var(--ember); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.site-foot {
  background: var(--night);
  color: #BFB49B;
  font-size: .92rem;
  --line: rgba(237, 229, 210, .14);
}
.site-foot .wrap {
  padding-block: 3rem 2.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 3.5rem;
  justify-content: space-between;
  align-items: flex-start;
}
.site-foot .wordmark { color: #EDE5D2; font-size: 1.05rem; }
.site-foot .wordmark .crown-line { stroke: #EDE5D2; }
.site-foot nav { display: grid; gap: .55rem; }
.site-foot a { text-decoration: none; color: #BFB49B; }
.site-foot a:hover { color: #EDE5D2; }
.site-foot .colophon {
  flex-basis: 100%;
  border-top: 1px solid var(--line);
  padding-top: 1.4rem;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #857B63;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .8rem;
}

/* ============================================================
   ARTICLE
   ============================================================ */

.article-head { border-bottom: 1px solid var(--line); }
.article-head .wrap {
  padding-block: clamp(3rem, 7vw, 5.5rem) clamp(2.2rem, 5vw, 3.5rem);
  max-width: 56rem;
}
.article-head h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
  margin: 1.1rem 0 1.2rem;
}
.article-head .standfirst {
  font-size: clamp(1.08rem, 1rem + .4vw, 1.28rem);
  color: var(--ink-2);
  max-width: 52ch;
  line-height: 1.6;
  margin: 0;
}
.article-head .byline {
  margin-top: 1.8rem;
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
}

.article-body {
  max-width: 56rem;
  margin-inline: auto;
  padding: clamp(2.5rem, 6vw, 4rem) var(--gutter) clamp(3rem, 7vw, 5rem);
}

.article-body > * { max-width: var(--measure); }

.article-body h2 {
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  margin: 2.6em 0 .9em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line-2);
}
.article-body h2 .kicker {
  display: block;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ember);
  margin-bottom: .8em;
}

.article-body h3 {
  font-size: 1.25rem;
  margin: 2em 0 .7em;
}

/* drop cap on the opening paragraph */
.article-body > p.lede::first-letter {
  font-family: var(--display);
  font-size: 3.3em;
  float: left;
  line-height: .82;
  padding: .08em .12em 0 0;
  color: var(--ember);
}

.article-body ul, .article-body ol { padding-left: 1.3rem; margin: 0 0 1.4em; }
.article-body li { margin-bottom: .5em; }
.article-body li::marker { color: var(--ember); }

.article-body strong { font-weight: 620; }

/* the short version — TL;DR charter box */
.tldr {
  border: 1px solid var(--line-2);
  outline: 1px solid var(--line-2);
  outline-offset: 4px;
  background: var(--bone-2);
  padding: 1.5rem 1.7rem 1.1rem;
  margin: 0 3px 3em;
}
.tldr .overline { display: block; margin-bottom: .9rem; color: var(--ember); }
.tldr ul { margin: 0; padding-left: 1.2rem; }
.tldr li { margin-bottom: .55em; font-size: .98rem; }

/* field note aside */
.fieldnote {
  border-left: 3px solid var(--ember);
  background: var(--bone-2);
  padding: 1.2rem 1.5rem 1rem;
  margin: 2.2em 0;
  font-size: .96rem;
}
.fieldnote .overline { display: block; color: var(--ember); margin-bottom: .6rem; }
.fieldnote p { margin-bottom: .6em; }
.fieldnote p:last-child { margin-bottom: 0; }

/* ledger tables */
.ledger-scroll { overflow-x: auto; margin: 2em 0; }
table.ledger {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
  font-variant-numeric: tabular-nums lining-nums;
}
.ledger caption {
  text-align: left;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: .7rem;
}
.ledger th {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-2);
  border-top: 1px solid var(--line-2);
  border-bottom: 3px double var(--line-2);
  padding: .6rem .9rem .5rem 0;
}
.ledger td {
  border-bottom: 1px solid var(--line);
  padding: .55rem .9rem .55rem 0;
  vertical-align: top;
}
.ledger tr:last-child td { border-bottom: 1px solid var(--line-2); }
.ledger td:last-child, .ledger th:last-child { padding-right: 0; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.ledger th.num { text-align: right; }

/* formula strip */
.formula {
  font-family: var(--mono);
  font-size: .88rem;
  background: var(--night);
  color: #EDE5D2;
  padding: 1.1rem 1.4rem;
  margin: 1.8em 0;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.8;
}
.formula b { color: #E8A276; font-weight: 600; }

/* checklist */
.checklist { list-style: none; padding: 0; margin: 0 0 1.6em; }
.checklist li {
  padding: .55em 0 .55em 2rem;
  position: relative;
  border-bottom: 1px solid var(--line);
}
.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .95em;
  width: .8rem;
  height: .8rem;
  border: 1.5px solid var(--ink-3);
}

/* pull quote */
.pull {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1.3;
  color: var(--ink);
  border-top: 3px double var(--line-2);
  border-bottom: 3px double var(--line-2);
  padding: 1.6rem .2rem;
  margin: 2.6em 0;
  text-align: center;
}
.pull .attr {
  display: block;
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* prev / next */
.article-nav {
  border-top: 1px solid var(--line-2);
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.article-nav a {
  padding: 2rem var(--gutter) 2.4rem;
  text-decoration: none;
  color: inherit;
  transition: background .2s ease;
}
.article-nav a:hover { background: var(--bone-2); }
.article-nav a:hover .post-title { color: var(--ember); }
.article-nav .next { text-align: right; border-left: 1px solid var(--line-2); }
.article-nav .overline { display: block; margin-bottom: .8rem; }
.article-nav .post-title { font-size: 1.2rem; margin: 0; }
@media (max-width: 640px) {
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { border-left: 0; border-top: 1px solid var(--line-2); text-align: left; }
}

/* ---------- 404 ---------- */
.lost { text-align: center; padding-block: clamp(5rem, 15vw, 10rem); }
.lost h1 { font-size: clamp(3rem, 10vw, 6rem); margin-bottom: 1rem; }
.lost p { color: var(--ink-2); }

/* ---------- small screens ---------- */
@media (max-width: 620px) {
  .site-head .wrap {
    flex-direction: column;
    gap: .55rem;
    padding-block: .75rem .65rem;
  }
  .site-nav { gap: 1.1rem; font-size: .66rem; }
  .hero-sigil { opacity: .05; }
  .byline { gap: .8rem 1.4rem; }
}
