/* Living Coherence — editorial stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Alegreya:ital,wght@0,400;0,500;0,700;0,800;1,400;1,500&family=Alegreya+Sans:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Exo+2:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand tokens (from Brand Book) */
  --klint-blue: #415476;
  --hilma-orange: #e6804f;
  --arum: #2a394f;
  --concorde: #556684;
  --swan: #afc0d5;
  --dune: #ffc7b6;
  --ginger: #d3714a;
  --mondrian: #144682;
  --atom: #121921;
  --dove: #f2f3f4;
  --chaos: #545760;

  /* Paper / ink — default: Warm */
  --paper: #f4f0e6;
  --paper-2: #ebe5d6;
  --rule: #d9cfb8;
  --ink: #2a394f;
  --ink-soft: #556684;
  --ink-mute: #8a8170;
  --accent: #c9633a;
  --accent-soft: #e6804f;

  /* Type scale */
  --serif: 'Alegreya', Georgia, serif;
  --sans: 'Exo 2', 'Alegreya Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --col: min(720px, 92vw);
  --gutter: clamp(16px, 3vw, 40px);
}

/* Palette variants */
[data-palette="light"] {
  --paper: #fafaf6;
  --paper-2: #f0efe8;
  --rule: #dcd9ce;
  --ink: #121921;
  --ink-soft: #3a3a3a;
  --ink-mute: #8a8680;
  --accent: #e56133;
  --accent-soft: #e6804f;
}
[data-palette="cool"] {
  --paper: #eef1f4;
  --paper-2: #e2e7ed;
  --rule: #c8d0da;
  --ink: #1a2330;
  --ink-soft: #415476;
  --ink-mute: #6d7a90;
  --accent: #415476;
  --accent-soft: #698cb5;
}
[data-palette="dark"] {
  --paper: #0f1014;
  --paper-2: #171922;
  --rule: #2a2e3a;
  --ink: #e8e4d8;
  --ink-soft: #b8b4a8;
  --ink-mute: #8a8680;
  --accent: #e6804f;
  --accent-soft: #d4a574;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.6;
  font-feature-settings: "onum", "liga";
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  transition: background 600ms ease, color 600ms ease;
}

a { color: inherit; text-decoration: none; }
a.inline { border-bottom: 1px solid var(--rule); transition: border-color 200ms, color 200ms; }
a.inline:hover { border-bottom-color: var(--accent); color: var(--accent); }

/* Paper grain */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(0,0,0,0.018) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  opacity: 0.6;
}
[data-palette="dark"] body::before { mix-blend-mode: screen; opacity: 0.25; }

/* Masthead */
.masthead {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px var(--gutter) 22px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 2;
}

.mast-left {
  display: flex; align-items: baseline; gap: 14px;
}
.mast-mark {
  width: 28px; height: 28px;
  flex: none;
  transform: translateY(6px);
}
.mast-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.mast-sub {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

nav.mast-nav { display: flex; gap: 28px; }
nav.mast-nav a {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  position: relative;
  padding-bottom: 4px;
  transition: color 200ms;
}
nav.mast-nav a:hover { color: var(--accent); }
nav.mast-nav a::after {
  content: '';
  position: absolute; left: 0; right: 100%; bottom: -3px;
  height: 1px; background: var(--accent);
  transition: right 300ms ease;
}
nav.mast-nav a:hover::after { right: 0; }

/* Section rule */
.rule {
  max-width: 1200px; margin: 0 auto;
  padding: 0 var(--gutter);
}
.rule hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

/* Eyebrow */
.eyebrow {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.eyebrow-dot::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  margin-right: 10px;
  transform: translateY(-2px);
}

/* Headings */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; color: var(--ink); }
h1 { font-size: clamp(48px, 8vw, 104px); line-height: 1.02; letter-spacing: -0.015em; font-weight: 500; }
h2 { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.15; letter-spacing: -0.005em; }
h3 { font-size: clamp(22px, 2.4vw, 30px); line-height: 1.25; }
h4 { font-size: 18px; line-height: 1.3; }

.h-italic { font-style: italic; font-weight: 400; }

/* Hero */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px var(--gutter) 72px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: center;
  position: relative;
  z-index: 2;
}
.hero .eyebrow { margin-bottom: 22px; }
.hero h1 { margin: 0 0 24px; }
.hero .lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 52ch;
}
.hero-art {
  position: relative;
  aspect-ratio: 1/1;
  min-height: 360px;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 44px; padding-bottom: 52px; }
  .hero-art { order: -1; min-height: 260px; max-height: 340px; }
}

/* Three lines of inquiry */
.inquiry {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px var(--gutter) 64px;
  position: relative; z-index: 2;
}
.inquiry-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 40px;
}
.inquiry-header h2 {
  margin: 0;
  font-style: italic;
  font-weight: 400;
}
.inquiry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
}
.inquiry-card {
  padding: 36px 32px 40px;
  border-right: 1px solid var(--rule);
  position: relative;
  display: block;
  transition: background 300ms;
}
.inquiry-card:last-child { border-right: 0; }
.inquiry-card:hover { background: var(--paper-2); }
.inquiry-card .card-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
}
.inquiry-card .card-kind {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 18px 0 14px;
  display: block;
}
.inquiry-card h3 {
  margin: 0 0 14px;
  font-size: 30px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.inquiry-card p {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.55;
}
.inquiry-card .card-diagram {
  height: 120px;
  margin-bottom: 22px;
}
.inquiry-card .card-link {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: gap 300ms, color 200ms;
}
.inquiry-card:hover .card-link { gap: 18px; color: var(--accent); }
.inquiry-card .card-link svg { width: 22px; height: 8px; }

@media (max-width: 900px) {
  .inquiry-grid { grid-template-columns: 1fr; }
  .inquiry-card { border-right: 0; border-bottom: 1px solid var(--rule); }
  .inquiry-card:last-child { border-bottom: 0; }
}

/* Archive / RHOE list */
.archive {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px var(--gutter) 96px;
  position: relative; z-index: 2;
}
.archive-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 40px;
}
.archive-header h2 {
  margin: 0; font-style: italic; font-weight: 400;
}
.archive-filters {
  display: flex; gap: 22px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.archive-filters button {
  background: none; border: 0; padding: 6px 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--ink-mute); cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 200ms, border-color 200ms;
}
.archive-filters button:hover { color: var(--ink); }
.archive-filters button.active { color: var(--ink); border-bottom-color: var(--accent); }

.archive-list { border-top: 1px solid var(--rule); }
.archive-item {
  display: grid;
  grid-template-columns: 64px 112px 1fr 140px 96px 44px;
  gap: 24px;
  align-items: center;
  padding: 22px 4px;
  border-bottom: 1px solid var(--rule);
  transition: background 220ms, padding 220ms;
  position: relative;
  cursor: pointer;
}
.archive-item:hover { background: var(--paper-2); padding-left: 12px; }
.archive-item .rhoe-num {
  font-family: var(--mono); font-size: 12px; color: var(--ink-mute);
}
.archive-item .rhoe-kind {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--accent);
}
.archive-item .rhoe-title {
  font-family: var(--serif); font-size: 22px; line-height: 1.3;
  font-weight: 500; color: var(--ink);
  letter-spacing: -0.005em;
}
.archive-item .rhoe-title em { font-style: italic; font-weight: 400; color: var(--ink-soft); }
.archive-item .rhoe-date {
  font-family: var(--sans); font-size: 11px; color: var(--ink-mute);
  letter-spacing: 0.08em;
}
.archive-item .rhoe-length {
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
}
.archive-item .rhoe-glyph {
  width: 32px; height: 32px;
  opacity: 0.55; transition: opacity 220ms, transform 220ms;
}
.archive-item:hover .rhoe-glyph { opacity: 1; transform: rotate(20deg); color: var(--accent); }

@media (max-width: 860px) {
  .archive-item {
    grid-template-columns: 72px 1fr 36px;
    grid-template-areas:
      "num    kind    glyph"
      "num    title   glyph"
      "meta   meta    meta";
    row-gap: 6px;
  }
  .archive-item .rhoe-num { grid-area: num; align-self: start; }
  .archive-item .rhoe-kind { grid-area: kind; }
  .archive-item .rhoe-title { grid-area: title; font-size: 18px; }
  .archive-item .rhoe-glyph { grid-area: glyph; }
  .archive-item .rhoe-date, .archive-item .rhoe-length {
    grid-area: meta; display: inline;
  }
  .archive-item .rhoe-date::after { content: ' · '; color: var(--rule); }
}

/* Featured (recent) */
.featured {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px var(--gutter);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 48px;
  align-items: center;
  position: relative; z-index: 2;
}
.featured-art { aspect-ratio: 4/3; min-height: 280px; }
.featured .eyebrow { margin-bottom: 18px; }
.featured h2 {
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 500;
  font-style: normal;
  letter-spacing: -0.01em;
  margin: 6px 0 18px;
  line-height: 1.08;
}
.featured p {
  font-size: 19px; line-height: 1.55; color: var(--ink-soft);
  max-width: 58ch; font-style: italic; font-weight: 400;
  margin: 0 0 26px;
}
.featured .meta {
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-mute);
  display: flex; gap: 20px; align-items: center; margin-bottom: 18px;
}
.featured .meta .bar { width: 40px; height: 1px; background: var(--rule); }

@media (max-width: 860px) {
  .featured { grid-template-columns: 1fr; }
}

/* Footer / colophon */
.colophon {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px var(--gutter) 64px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  position: relative; z-index: 2;
}
.colophon h4 {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-mute);
  font-weight: 500; margin: 0 0 14px;
}
.colophon .colo-stmt {
  font-family: var(--serif); font-style: italic;
  font-size: 20px; line-height: 1.4; color: var(--ink-soft);
  max-width: 34ch; margin: 0;
}
.colophon ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.colophon a.inline { font-size: 15px; }
.colo-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.colo-mark svg { width: 28px; height: 28px; }
.colo-mark span { font-family: var(--serif); font-style: italic; font-size: 22px; }

.copyright {
  max-width: 1200px; margin: 0 auto;
  padding: 18px var(--gutter) 38px;
  border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between; gap: 20px;
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
}

@media (max-width: 860px) {
  .colophon { grid-template-columns: 1fr 1fr; }
  .colophon .colo-stmt-wrap { grid-column: 1 / -1; }
}

/* Tweaks panel */
.tweaks {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 18px 20px 16px;
  min-width: 240px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(20, 30, 50, 0.08);
  display: none;
}
body.tweaks-on .tweaks { display: block; }
.tweaks h5 {
  margin: 0 0 12px; font-size: 10.5px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-mute); font-weight: 500;
}
.tweak-row { margin-bottom: 14px; }
.tweak-row:last-child { margin-bottom: 0; }
.tweak-row label {
  display: block; font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-mute); margin-bottom: 8px;
}
.tweak-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.tweak-opts button {
  background: transparent; border: 1px solid var(--rule);
  padding: 6px 10px; font: inherit;
  color: var(--ink-soft); cursor: pointer;
  letter-spacing: 0.08em;
  transition: all 200ms;
}
.tweak-opts button:hover { border-color: var(--ink-soft); color: var(--ink); }
.tweak-opts button.active {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
}
[data-palette="dark"] .tweak-opts button.active { background: var(--accent); border-color: var(--accent); color: var(--atom); }

/* Article */
.article-hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px var(--gutter) 48px;
  position: relative; z-index: 2;
}
.article-meta {
  display: flex; gap: 22px; align-items: center;
  margin-bottom: 28px;
  font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-mute);
}
.article-meta .kind { color: var(--accent); }
.article-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(44px, 6.2vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0 0 28px;
  max-width: 18ch;
}
.article-title em { font-style: italic; font-weight: 400; color: var(--ink-soft); }
.article-dek {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 24px; line-height: 1.45; color: var(--ink-soft);
  max-width: 52ch; margin: 0 0 40px;
}
.article-byline {
  display: flex; gap: 36px;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 12px;
}
.article-byline .lab {
  font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 4px;
}
.article-byline .val { color: var(--ink); }

.article-hero-art {
  width: 100%; height: 340px;
  margin-bottom: 48px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  position: relative;
}

/* Article body */
.article-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter) 80px;
  display: grid;
  grid-template-columns: 1fr minmax(0, 680px) 220px 1fr;
  column-gap: 32px;
  position: relative;
  z-index: 2;
}
.article-body > * { grid-column: 2; }
.article-body > .full { grid-column: 2 / span 2; }
.article-body > .margin { grid-column: 3; font-family: var(--sans); font-size: 12.5px; line-height: 1.5; color: var(--ink-mute); }

.article-body p {
  margin: 0 0 22px;
  font-size: 19.5px;
  line-height: 1.68;
  color: var(--ink);
}
.article-body p.lead { font-size: 22px; line-height: 1.55; color: var(--ink-soft); }
.article-body p.lead::first-letter {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  float: left; font-size: 5.4em; line-height: 0.82; padding: 6px 12px 0 0;
  color: var(--accent);
}
.article-body h2 {
  margin: 56px 0 20px;
  font-family: var(--serif); font-style: italic;
  font-weight: 400; font-size: 32px; letter-spacing: -0.005em;
}
.article-body h2 .num {
  font-family: var(--mono); font-style: normal;
  font-size: 14px; color: var(--ink-mute); letter-spacing: 0.1em;
  display: block; margin-bottom: 8px;
}
.article-body h3 {
  margin: 36px 0 12px; font-size: 22px; font-weight: 500;
}
.article-body blockquote {
  margin: 40px 0; padding: 4px 0 4px 28px;
  border-left: 2px solid var(--accent);
  font-family: var(--serif); font-style: italic;
  font-size: 24px; line-height: 1.5; color: var(--ink);
}
.article-body blockquote cite {
  display: block; margin-top: 14px; font-style: normal;
  font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-mute);
}
.article-body ul { padding-left: 24px; margin: 0 0 22px; }
.article-body ul li { margin-bottom: 10px; font-size: 19px; line-height: 1.6; }

.article-figure {
  margin: 48px 0;
  padding: 28px 0 20px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.article-figure .fig-num {
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  letter-spacing: 0.1em;
}
.article-figure .fig-cap {
  font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft);
  margin-top: 14px; max-width: 54ch; line-height: 1.5;
}
.article-figure .fig-art { height: 320px; margin: 18px 0 4px; }

@media (max-width: 960px) {
  .article-body { grid-template-columns: var(--gutter) 1fr var(--gutter); }
  .article-body > * { grid-column: 2; }
  .article-body > .margin { grid-column: 2; border-left: 2px solid var(--rule); padding-left: 14px; margin: 16px 0; }
}

/* Dividers */
.section-mark {
  max-width: 1200px; margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; justify-content: center;
}
.section-mark svg { width: 28px; height: 28px; color: var(--accent); opacity: 0.7; }

/* Pull quote */
.pullquote {
  grid-column: 2 / span 2 !important;
  margin: 60px 0;
  padding: 30px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 22ch;
}

/* Table of contents (article margin) */
.margin-toc {
  position: sticky; top: 40px;
  padding-top: 8px;
}
.margin-toc h5 {
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 500; margin: 0 0 14px;
}
.margin-toc ol {
  list-style: none; padding: 0; margin: 0;
  counter-reset: toc;
}
.margin-toc li {
  counter-increment: toc;
  margin-bottom: 10px;
  padding-left: 28px; position: relative;
  font-size: 12px; line-height: 1.35;
}
.margin-toc li::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute; left: 0; top: 0;
  font-family: var(--mono); color: var(--ink-mute);
}
.margin-toc a { color: var(--ink-soft); transition: color 200ms; display: block; }
.margin-toc a:hover { color: var(--accent); }
.margin-toc li.active a { color: var(--accent); }

/* Reading progress bar */
.progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px; background: transparent; z-index: 40;
}
.progress-bar {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width 120ms linear;
}

/* Utility */
.stroke-fig { color: var(--ink); }
.stroke-fig path, .stroke-fig line, .stroke-fig circle, .stroke-fig polygon, .stroke-fig rect, .stroke-fig polyline, .stroke-fig ellipse {
  vector-effect: non-scaling-stroke;
}
