/* ==========================================================================
   The Manuscript Almanac — letterpress editorial skin over Bootstrap 5.3
   Palette evolved from the domain's own twenty-year history:
   teal-ink (#006890/#006699, 2005-08) + red pencil (#990000/#e23a3e, 2016)
   on paper cream. Serif display, sans body, thin rules, marginalia rail.
   ========================================================================== */

:root {
  /* Letterpress palette: printer's ink brown-black + vermilion + brass on
     paper cream. The domain's own 2005-2011 teal (#006890) survives as the
     link colour; the 2016 era's red survives as the vermilion accent. */
  --ink:        #33261c;
  --ink-mid:    #4e3c2c;
  --ink-soft:   #6b5540;
  --teal:       #0f5468;
  --teal-mid:   #146680;
  --pencil:     #c0432b;
  --pencil-lt:  #d6603f;
  --paper:      #faf6ee;
  --paper-alt:  #f3ecdd;
  --paper-deep: #eae0cb;
  --rule:       #d8cbb0;
  --rule-soft:  #e7dcc6;
  --text:       #2a231c;
  --text-mid:   #55483b;
  --text-mute:  #7a6c5b;
  --brass:      #a8842c;

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --measure: 40rem;
  --rail: 15rem;
}

/* ---------- base ---------- */

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

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
  color: var(--text);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 8%,  rgba(168,132,44,.06)  0, transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(51,38,28,.045)  0, transparent 46%);
  background-attachment: fixed;
  overflow-x: hidden;
}

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

a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: .16em; }
a:hover, a:focus { color: var(--pencil); }

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

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

/* Safeguard: content is NEVER hidden waiting on JavaScript. Any reveal
   animation here is progressive enhancement only. */
[data-aos] { opacity: 1 !important; transform: none !important; }

@keyframes wtwRise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.rise { animation: wtwRise .5s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise { animation: none; }
}

/* ---------- typography ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.012em;
  line-height: 1.18;
}

h1 {
  font-size: clamp(2rem, 1.35rem + 2.6vw, 3.1rem);
  font-weight: 700;
  margin: 0 0 1.1rem;
}

h2 {
  font-size: clamp(1.4rem, 1.15rem + 1.05vw, 1.9rem);
  margin: 2.9rem 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 3px double var(--rule);
}

h3 {
  font-size: clamp(1.14rem, 1.03rem + .5vw, 1.35rem);
  margin: 2rem 0 .6rem;
  color: var(--teal);
}

p { margin: 0 0 1.15rem; }

.eyebrow {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .19em;
  text-transform: uppercase;
  color: var(--pencil);
  margin: 0 0 .85rem;
  display: flex;
  align-items: center;
  gap: .7rem;
}
.eyebrow::after {
  content: "";
  flex: 1 1 auto;
  min-width: 0;
  height: 1px;
  background: var(--rule);
}

.lede {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 1rem + .55vw, 1.34rem);
  line-height: 1.6;
  color: var(--text-mid);
  margin-bottom: 1.9rem;
}
.lede::first-letter {
  float: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.55em;
  line-height: .78;
  color: var(--pencil);
  margin: .07em .1em -.02em 0;
}

blockquote {
  margin: 1.9rem 0;
  padding: 1rem 0 1rem 1.4rem;
  border-left: 3px solid var(--pencil);
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--text-mid);
}
blockquote p:last-child { margin-bottom: 0; }

.article ul, .article ol { margin: 0 0 1.3rem; padding-left: 1.35rem; }
.article li { margin-bottom: .55rem; }
.article ol { counter-reset: wtw; list-style: none; padding-left: 0; }
.article ol > li {
  counter-increment: wtw;
  position: relative;
  padding-left: 2.3rem;
}
.article ol > li::before {
  content: counter(wtw);
  position: absolute;
  left: 0;
  top: .08em;
  width: 1.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  color: var(--pencil);
  text-align: right;
}
.article strong { color: var(--ink); font-weight: 650; }
.article em { color: var(--text-mid); }

/* definition-style index */
.index-list { margin: 0 0 1.7rem; }
.index-list dt {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 650;
  margin-top: 1.35rem;
}
.index-list dd {
  margin: .28rem 0 0;
  color: var(--text-mid);
  font-size: .98rem;
  padding-left: 1rem;
  border-left: 2px solid var(--rule-soft);
}

/* ---------- masthead + nav (no JS, wraps by design) ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(51,38,28,.05);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem 1.6rem;
  min-width: 0;
  padding: .8rem 0 .65rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.22rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.015em;
  white-space: nowrap;
  min-width: 0;
}
.brand:hover { color: var(--pencil); }
.brand .brand-mark { color: var(--pencil); }

.sitenav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .1rem 1.05rem;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
  flex: 1 1 auto;
}
.sitenav a {
  display: inline-block;
  font-size: .84rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-mid);
  text-decoration: none;
  padding: .3rem 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.sitenav a:hover, .sitenav a:focus { color: var(--ink); border-bottom-color: var(--pencil); }
.sitenav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--pencil); }

/* ---------- page furniture ---------- */

.shell { max-width: 1140px; margin: 0 auto; padding: 0 1.1rem; }

.page-head { padding: 3rem 0 1.5rem; }
.page-head .kicker {
  font-size: .82rem;
  color: var(--text-mute);
  margin-top: -.4rem;
}

.crumbs {
  font-size: .78rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 1.4rem;
}
.crumbs a { color: var(--text-mute); text-decoration: none; }
.crumbs a:hover { color: var(--pencil); }
.crumbs span { margin: 0 .45rem; color: var(--rule); }

/* article + marginalia rail */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.4rem;
  padding-bottom: 3.5rem;
}
@media (min-width: 992px) {
  .layout { grid-template-columns: minmax(0, 1fr) var(--rail); gap: 3.4rem; }
}
.article { max-width: var(--measure); min-width: 0; }
.layout.wide .article { max-width: none; }

.rail { min-width: 0; }
.rail-inner { position: sticky; top: 5.6rem; }

.marginalia {
  border-left: 3px solid var(--brass);
  padding: .1rem 0 .1rem 1rem;
  margin-bottom: 2rem;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text-mid);
}
.marginalia h4 {
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--brass);
  margin: 0 0 .4rem;
}
.marginalia ul { list-style: none; margin: 0; padding: 0; }
.marginalia li { margin-bottom: .45rem; }
.marginalia a { text-decoration: none; }
.marginalia a:hover { text-decoration: underline; }

/* figures */
.figure-plate { margin: 0 0 2.2rem; }
.figure-plate img {
  width: 100%;
  border: 1px solid var(--rule);
  padding: .45rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(42,35,28,.07);
}
.figure-plate figcaption {
  font-size: .8rem;
  color: var(--text-mute);
  margin-top: .55rem;
  padding-left: .1rem;
  font-style: italic;
}

/* home hero */
.hero { padding: 3.2rem 0 1rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 2rem; align-items: center; }
@media (min-width: 992px) {
  .hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 3.2rem; }
}
.hero h1 { font-size: clamp(2.2rem, 1.4rem + 3.4vw, 3.7rem); }
.hero-plate img {
  width: 100%;
  border: 1px solid var(--rule);
  padding: .5rem;
  background: #fff;
  box-shadow: 0 3px 14px rgba(51,38,28,.11);
}

/* card grid for hubs */
.plate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1.3rem;
  margin: 1.6rem 0 2.4rem;
}
.plate {
  background: var(--paper-alt);
  border: 1px solid var(--rule-soft);
  border-top: 3px solid var(--teal);
  padding: 1.15rem 1.2rem 1.25rem;
  min-width: 0;
}
.plate h3 { margin-top: 0; font-size: 1.06rem; }
.plate p { font-size: .93rem; color: var(--text-mid); margin-bottom: 0; }
.plate a { text-decoration: none; }
.plate a:hover { text-decoration: underline; }

/* pull rule */
.rule-break {
  border: 0;
  height: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-top: 2px;
  margin: 2.6rem 0;
}

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

.colophon {
  background: var(--ink);
  color: #e2d8c6;
  margin-top: 2rem;
  padding: 2.8rem 0 1.7rem;
  font-size: .92rem;
}
.colophon a { color: #f3ebdc; text-decoration: none; }
.colophon a:hover { color: #fff; text-decoration: underline; }
.colophon h4 {
  font-family: var(--font-body);
  font-size: .72rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: #b79f6f;
  margin: 0 0 .8rem;
}
.colophon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 1.8rem 2.2rem;
}
.colophon ul { list-style: none; margin: 0; padding: 0; }
.colophon li { margin-bottom: .38rem; }
.colophon .wordmark {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: block;
  margin-bottom: .5rem;
}
.colophon .fine {
  border-top: 1px solid rgba(255,255,255,.14);
  margin-top: 2rem;
  padding-top: 1.1rem;
  font-size: .8rem;
  color: #a8977c;
}
.colophon .index-line {
  font-size: .78rem;
  color: #a8977c;
  margin-top: .5rem;
  line-height: 2;
}
.colophon .index-line a { color: #cfbf9f; }

/* ---------- 404 ---------- */

.notfound { text-align: center; padding: 5rem 0 4rem; }
.notfound .code {
  font-family: var(--font-display);
  font-size: clamp(4rem, 3rem + 7vw, 8rem);
  font-weight: 700;
  color: var(--pencil);
  line-height: 1;
  margin: 0 0 .4rem;
}
.notfound .article { margin: 0 auto; text-align: left; }

/* ---------- small screens ---------- */

@media (max-width: 575.98px) {
  body { font-size: 1rem; }
  .masthead-inner { padding: .7rem 0 .5rem; }
  .sitenav { gap: .05rem .85rem; }
  .sitenav a { font-size: .78rem; }
  .lede::first-letter { font-size: 3.1em; }
  .page-head { padding: 2rem 0 1.1rem; }
  .hero { padding: 2rem 0 .5rem; }
}
