/* ═══════════════════════════════════════════════════════════
   2014P_ Codex — shared stylesheet for essay pages
   Used by: samatvartha.html, conway-debt.html, ai-is-the-audit.html,
   metacrisis.html, moloch.html, panca-rina.html, federated-unicorn.html,
   techno-memetic-commons.html, codex.html
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Melodrama';
  src: url('../fonts/melodrama/Melodrama-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

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

:root {
  --bg:       #0D0C0A;
  --bg-soft:  #14130F;
  --ink:      #EDE8DF;
  --mid:      rgba(237,232,223,0.62);
  --faint:    rgba(237,232,223,0.30);
  --rule:     rgba(237,232,223,0.1);
  --saffron:  #C97322;
  --gold:     #E0A040;
  --soft-sf:  rgba(201,115,34,0.08);
  --serif:    'Melodrama', serif;
  --sans:     'Outfit', sans-serif;
}

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

a { color: inherit; text-decoration: none; }

.w        { max-width: 1200px; margin: 0 auto; padding: 0 2.5rem; }
.w-narrow { max-width: 760px;  margin: 0 auto; padding: 0 2.5rem; }
.w-mid    { max-width: 920px;  margin: 0 auto; padding: 0 2.5rem; }

.label {
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--faint);
  padding-left: 0.85rem;
  border-left: 2px solid var(--saffron);
  display: inline-block;
}

/* ── reveal ── */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { transition: none; opacity: 1; transform: none; } }

/* ═══ HEADER ═══ */
header.site-header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--rule);
  background: rgba(13,12,10,0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.site-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.05rem 0;
}
.site-logo {
  font-family: var(--serif);
  font-size: 1.1rem; font-weight: 520; letter-spacing: 0.02em;
}
.site-logo small {
  font-family: var(--sans); font-size: 0.7rem; font-weight: 300;
  color: var(--faint); letter-spacing: 0.14em; text-transform: uppercase;
  margin-left: 0.55rem;
}
.site-nav { display: flex; align-items: center; gap: 1.85rem; }
.site-nav a {
  font-size: 0.78rem; color: var(--mid);
  transition: color 0.2s;
}
.site-nav a:hover, .site-nav a.active { color: var(--ink); }
.site-nav .cta {
  color: var(--saffron);
  border: 1px solid rgba(201,115,34,0.4);
  padding: 6px 14px; border-radius: 3px;
  font-size: 0.74rem; transition: background 0.2s;
}
.site-nav .cta:hover { background: rgba(201,115,34,0.1); }

/* ═══ ESSAY HERO ═══ */
.essay-hero {
  padding: 5.5rem 0 4.5rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.essay-hero.with-art { padding-bottom: 0; }
.essay-breadcrumb {
  display: flex; gap: 0.55rem; align-items: baseline;
  font-size: 0.74rem; color: var(--faint);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 2rem;
}
.essay-breadcrumb a {
  color: var(--mid); border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.essay-breadcrumb a:hover { color: var(--saffron); border-color: var(--saffron); }
.essay-breadcrumb span.sep { color: var(--rule); }

.essay-title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.02;
  margin-bottom: 1.6rem;
  max-width: 18ch;
}
.essay-title em { color: var(--saffron); font-style: normal; }
.essay-title .sanskrit {
  display: block; font-size: 0.52em;
  color: var(--mid); letter-spacing: 0;
  margin-top: 0.6rem; font-weight: 400;
}

.essay-dek {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
  font-weight: 400; font-style: italic;
  color: var(--mid);
  line-height: 1.5;
  max-width: 46ch;
}

.essay-meta {
  display: flex; gap: 0.9rem; flex-wrap: wrap;
  font-size: 0.7rem; color: var(--faint);
  letter-spacing: 0.16em; text-transform: uppercase;
  margin-top: 2rem;
}
.essay-meta span { display: inline-block; }
.essay-meta .dot { color: var(--rule); }

.essay-hero-art {
  margin-top: 3rem;
  height: clamp(220px, 36vw, 420px);
  background-size: cover; background-position: center;
  position: relative;
  border-top: 1px solid var(--rule);
}
.essay-hero-art::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,12,10,0) 50%, rgba(13,12,10,0.92) 100%);
}

/* ═══ TL;DR ═══ */
.tldr {
  background: var(--soft-sf);
  border-left: 3px solid var(--saffron);
  padding: 1.5rem 1.7rem;
  margin: 3rem 0 3.5rem;
  border-radius: 0 3px 3px 0;
}
.tldr-label {
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--saffron); margin-bottom: 0.6rem; display: block;
  font-weight: 500;
}
.tldr-body {
  font-size: 1rem; line-height: 1.7; color: var(--ink);
}
.tldr-body strong { font-weight: 400; color: var(--saffron); }

/* ═══ ESSAY BODY ═══ */
.essay-body {
  padding: 0 0 5rem;
}
.essay-body h2 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 2.6vw, 2.2rem);
  font-weight: 500;
  letter-spacing: -0.008em;
  line-height: 1.18;
  margin: 3rem 0 1.2rem;
  color: var(--ink);
}
.essay-body h2 em, .essay-body h3 em { color: var(--saffron); font-style: normal; }
.essay-body h3 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.3;
  margin: 2.2rem 0 0.8rem;
  color: var(--ink);
}
.essay-body h2 + p, .essay-body h3 + p { margin-top: 0; }
.essay-body p {
  font-size: 1.02rem;
  line-height: 1.82;
  color: var(--mid);
  margin-bottom: 1.2rem;
}
.essay-body p strong { color: var(--ink); font-weight: 400; }
.essay-body p em { color: var(--ink); font-style: italic; }
.essay-body p code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em; color: var(--gold);
  background: rgba(224,160,64,0.07);
  padding: 0.05em 0.45em; border-radius: 2px;
}
.essay-body a {
  color: var(--ink);
  border-bottom: 1px solid rgba(237,232,223,0.22);
  transition: color 0.2s, border-color 0.2s;
}
.essay-body a:hover {
  color: var(--saffron);
  border-color: var(--saffron);
}
.essay-body blockquote {
  border-left: 2px solid var(--saffron);
  padding: 0.4rem 0 0.4rem 1.5rem;
  margin: 1.8rem 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.essay-body blockquote cite {
  display: block; margin-top: 0.6rem;
  font-family: var(--sans); font-size: 0.78rem; font-style: normal;
  color: var(--faint); letter-spacing: 0.06em;
}
.essay-body ul, .essay-body ol {
  margin: 0 0 1.3rem 0; padding: 0; list-style: none;
}
.essay-body li {
  font-size: 1rem; line-height: 1.78; color: var(--mid);
  padding-left: 1.5rem; position: relative;
  margin-bottom: 0.55rem;
}
.essay-body li strong { color: var(--ink); font-weight: 400; }
.essay-body ul > li::before {
  content: '·'; color: var(--saffron);
  position: absolute; left: 0.5rem; top: -0.05em;
  font-size: 1.5em; font-weight: 600;
}
.essay-body ol { counter-reset: olc; }
.essay-body ol > li { counter-increment: olc; }
.essay-body ol > li::before {
  content: counter(olc) '.';
  color: var(--saffron); font-family: var(--serif);
  position: absolute; left: 0; top: 0; font-size: 0.95em;
}
.essay-body table {
  width: 100%; border-collapse: collapse;
  margin: 1.6rem 0 2rem; font-size: 0.92rem;
}
.essay-body th, .essay-body td {
  text-align: left; padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--rule); vertical-align: top;
}
.essay-body th {
  color: var(--ink); font-weight: 500;
  font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase;
}
.essay-body td { color: var(--mid); line-height: 1.6; }
.essay-body td strong { color: var(--ink); font-weight: 400; }

.essay-body figure {
  margin: 2.4rem 0;
}
.essay-body figure img {
  width: 100%; height: auto; display: block;
  border-radius: 2px; border: 1px solid var(--rule);
}
.essay-body figcaption {
  font-size: 0.78rem; color: var(--faint);
  letter-spacing: 0.04em; margin-top: 0.7rem;
  line-height: 1.6; text-align: center;
}

/* ═══ PULL QUOTE ═══ */
.pull {
  margin: 3rem 0;
  padding: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 2rem 0;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 500;
  line-height: 1.32;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.pull em { color: var(--saffron); font-style: normal; }

/* ═══ FAQ for AEO ═══ */
.faq {
  padding: 3.5rem 0 1rem;
  border-top: 1px solid var(--rule);
}
.faq-head { margin-bottom: 2.2rem; }
.faq-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 2.6vw, 2.2rem);
  font-weight: 500; letter-spacing: -0.008em;
  margin-bottom: 0.6rem;
}
.faq-item {
  padding: 1.6rem 0;
  border-top: 1px solid var(--rule);
}
.faq-item:last-child { border-bottom: 1px solid var(--rule); }
.faq-q {
  font-family: var(--serif);
  font-size: 1.18rem; font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.7rem;
  line-height: 1.35;
}
.faq-a {
  font-size: 0.98rem; line-height: 1.78; color: var(--mid);
}
.faq-a strong { color: var(--ink); font-weight: 400; }

/* ═══ RELATED ═══ */
.related {
  padding: 4rem 0 5rem;
  border-top: 1px solid var(--rule);
}
.related-head { margin-bottom: 1.8rem; }
.related-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 2.4vw, 2.05rem);
  font-weight: 500;
  letter-spacing: -0.008em;
  margin-bottom: 0.3rem;
}
.related-head p {
  font-size: 0.85rem; color: var(--faint); max-width: 50ch; line-height: 1.6;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.related-item {
  background: var(--bg);
  padding: 1.4rem 1.4rem 1.5rem;
  display: block;
  transition: background 0.2s;
}
.related-item:hover { background: rgba(201,115,34,0.04); }
.related-item .ri-label {
  font-size: 0.62rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--saffron);
  margin-bottom: 0.55rem;
}
.related-item .ri-name {
  font-family: var(--serif);
  font-size: 1.05rem; font-weight: 500;
  margin-bottom: 0.4rem; color: var(--ink);
  letter-spacing: 0.005em;
}
.related-item .ri-line {
  font-size: 0.82rem; color: var(--mid); line-height: 1.65;
}

/* ═══ ENGAGE BAND ═══ */
.engage-band {
  padding: 4.5rem 0;
  border-top: 1px solid var(--rule);
  background: rgba(237,232,223,0.015);
}
.engage-band-inner {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4rem; align-items: center;
}
.engage-band h2 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-weight: 500; line-height: 1.1;
  letter-spacing: -0.012em;
  margin-bottom: 0.9rem;
}
.engage-band p { font-size: 0.96rem; color: var(--mid); line-height: 1.75; max-width: 42ch; }
.engage-band .cta-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.3rem; }
.engage-band .cta-pri {
  background: var(--saffron); color: #fff;
  padding: 11px 22px; border-radius: 3px;
  font-size: 0.82rem; font-weight: 500; letter-spacing: 0.03em;
}
.engage-band .cta-pri:hover { opacity: 0.88; }
.engage-band .cta-sec {
  color: var(--ink); padding: 11px 22px; border-radius: 3px;
  border: 1px solid var(--rule);
  font-size: 0.82rem; letter-spacing: 0.03em;
  transition: border-color 0.2s, color 0.2s;
}
.engage-band .cta-sec:hover { border-color: var(--saffron); color: var(--saffron); }

/* ═══ FOOTER ═══ */
footer.site-footer {
  padding: 2.2rem 0;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.footer-copy {
  font-size: 0.7rem; color: var(--faint);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.footer-links { display: flex; gap: 1.6rem; }
.footer-links a {
  font-size: 0.72rem; color: var(--faint);
  letter-spacing: 0.04em; transition: color 0.2s;
}
.footer-links a:hover { color: var(--mid); }

/* ═══ CODEX (the index page itself) ═══ */
.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-top: 3rem;
}
.codex-card {
  background: var(--bg);
  padding: 2rem 2rem 2.2rem;
  display: block; position: relative;
  transition: background 0.2s;
}
.codex-card:hover { background: rgba(201,115,34,0.045); }
.codex-card-label {
  font-size: 0.65rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--saffron);
  margin-bottom: 0.9rem;
}
.codex-card-name {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 500; line-height: 1.08;
  letter-spacing: -0.008em;
  color: var(--ink); margin-bottom: 0.55rem;
}
.codex-card-name .sanskrit {
  display: block; font-size: 0.5em;
  color: var(--mid); margin-top: 0.3rem; letter-spacing: 0;
}
.codex-card-dek {
  font-family: var(--serif);
  font-style: italic; color: var(--mid);
  font-size: 1rem; line-height: 1.5; margin-bottom: 1rem;
  max-width: 36ch;
}
.codex-card-line {
  font-size: 0.85rem; line-height: 1.65; color: var(--mid);
}
.codex-card-cta {
  display: inline-block;
  margin-top: 1.2rem;
  font-size: 0.74rem; letter-spacing: 0.06em;
  color: var(--saffron);
  border-bottom: 1px solid rgba(201,115,34,0.4);
  padding-bottom: 2px;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
  .related-grid { grid-template-columns: 1fr; }
  .engage-band-inner { grid-template-columns: 1fr; gap: 1.8rem; }
  .codex-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .w, .w-narrow, .w-mid { padding: 0 1.25rem; }
  .essay-hero { padding: 3.5rem 0 3rem; }
  .site-nav .hide-sm { display: none; }
  .site-nav { gap: 1.1rem; }
}
