/* ========================================
   BLUEPRINT EDITORIAL — BASE STYLES
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.65;
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 400;
  background-color: #f5f3f0;
  color: #1c1917;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* CSS Variables */
:root {
  --substrate: #f5f3f0;
  --ink: #1c1917;
  --interpreted: #78716c;
  --boundary: #e7e5e4;
  --enforced: #9C033B;
  --structural-blue: #3B82F6;

  --font-serif: "Instrument Serif", serif;
  --font-sans: "IBM Plex Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 20px;
  --space-xl: 32px;
  --space-2xl: 40px;
  --space-3xl: 60px;

  --container-width: 760px;
  --article-width: 640px;
}

/* Typography */
.display {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
}

h1 {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}

h2 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
}

h3 {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}

h4 {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

p {
  color: var(--ink);
}

.text-secondary {
  color: var(--interpreted);
}

.label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--interpreted);
  margin-bottom: var(--space-md);
}

.description {
  color: var(--interpreted);
  margin-top: var(--space-md);
}

.description a {
  color: var(--enforced);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--enforced);
  transition: opacity 0.2s ease;
}

.description a:hover {
  opacity: 0.7;
}

.description a:hover {
  color: var(--enforced);
  text-decoration-color: var(--enforced);
}

.caption {
  font-size: 13px;
  color: var(--interpreted);
}

.system-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--interpreted);
}

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: 14px;
}

/* Layout */
.page-wrapper {
  position: relative;
  overflow-x: clip;
}

/* Dot-grid background */
.page-wrapper::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--ink) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

/* Crop marks on prose (article pages only) */
.prose {
  position: relative;
}

.prose::before,
.prose::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  opacity: 0.25;
  pointer-events: none;
  top: 0;
}

.prose::before {
  left: 0;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}

.prose::after {
  right: 0;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
}

/* Links */
a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--enforced);
}

/* Navigation */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--boundary);
  position: sticky;
  top: 0;
  background-color: var(--substrate);
  z-index: 10;
}

.nav-brand {
  display: flex;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  padding: 0;
}

.nav-links li {
  margin: 0;
}

.nav-links a {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-links a .nav-knot {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-links a .nav-knot path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 0.4s ease, opacity 0.2s ease;
  opacity: 0;
}

.nav-links a:hover .nav-knot path,
.nav-links a.knot-tap .nav-knot path {
  stroke-dashoffset: 0;
  opacity: 1;
}

/* Tags */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--boundary);
  color: var(--interpreted);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tag:hover {
  color: var(--enforced);
  border-color: var(--enforced);
}

.tag--active {
  color: var(--enforced);
  border-color: var(--enforced);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* Headshot */
.headshot {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--boundary);
}

/* Header */
header {
  padding: var(--space-3xl) 0;
}

/* Sections */
section {
  padding: var(--space-3xl) 0;
}

section + section {
  border-top: 1px solid var(--boundary);
}

/* Cards */
.card {
  border: 1px solid var(--boundary);
  border-top: 2px solid transparent;
  padding: var(--space-lg);
  background: transparent;
  transition: border-top-color 0.2s ease;
}

.card:hover {
  border-top-color: var(--enforced);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--boundary);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  color: var(--enforced);
  border-color: var(--enforced);
}

/* Lists */
ul, ol {
  padding-left: var(--space-lg);
}

li {
  margin-bottom: var(--space-sm);
}

li::marker {
  color: var(--interpreted);
}

/* Post List */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--boundary);
}

.post-item:first-child {
  padding-top: 0;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.post-date {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--interpreted);
}

.post-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: var(--space-xs);
}

.post-title a {
  color: var(--ink);
  text-decoration: none;
  position: relative;
}

.post-title .nav-knot {
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
}

.post-title .nav-knot path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 0.4s ease, opacity 0.2s ease;
  opacity: 0;
}

.post-title a:hover .nav-knot path,
.post-title a.knot-tap .nav-knot path {
  stroke-dashoffset: 0;
  opacity: 1;
}

.post-title a:hover,
.post-title a.knot-tap {
  color: var(--enforced);
}

.post-subtitle {
  color: var(--interpreted);
  font-size: 15px;
  line-height: 1.4;
  margin-top: var(--space-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Article Header */
.article-header {
  padding: var(--space-3xl) 0 var(--space-2xl);
  max-width: var(--article-width);
  margin: 0 auto;
}

.article-header .tag-list {
  margin-bottom: var(--space-lg);
}

.article-header h1 {
  margin-bottom: var(--space-lg);
}

.article-subtitle {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 20px;
  color: var(--interpreted);
  line-height: 1.4;
  margin-bottom: var(--space-lg);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--interpreted);
}

.meta-separator {
  color: var(--boundary);
}

/* Prose Styles */
.prose {
  max-width: var(--article-width);
  margin: 0 auto;
  padding-top: 10px;
}

.prose p {
  margin-bottom: 1.5em;
}

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

.prose h2 {
  margin-top: 2.5em;
  margin-bottom: 0.75em;
}

.prose h3 {
  margin-top: 2em;
  margin-bottom: 0.5em;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
}

.prose h3:first-child {
  margin-top: 0;
}

.prose strong {
  font-weight: 700;
}

.prose a {
  text-decoration: underline;
  text-decoration-color: var(--boundary);
  text-underline-offset: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.prose a:hover {
  color: var(--enforced);
  text-decoration-color: var(--enforced);
}

.prose blockquote {
  border-left: 2px solid var(--boundary);
  padding-left: var(--space-lg);
  margin: 1.5em 0;
  color: var(--interpreted);
  font-style: normal;
}

.prose pre {
  border: 1px solid var(--boundary);
  padding: var(--space-lg);
  overflow-x: auto;
  margin: 1.5em 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  background: transparent;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 2px 6px;
  border: 1px solid var(--boundary);
  background: transparent;
}

.prose pre code {
  padding: 0;
  border: none;
  font-size: inherit;
}

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--boundary);
  margin: 1.5em 0;
}

.prose figure {
  margin: 1.5em 0;
}

.prose figcaption {
  font-size: 13px;
  color: var(--interpreted);
  margin-top: var(--space-sm);
}

.prose ul,
.prose ol {
  margin: 1.5em 0;
  padding-left: var(--space-xl);
}

.prose ol {
  list-style: none;
  counter-reset: ol-counter;
  padding-left: var(--space-lg);
}

.prose ol > li {
  counter-increment: ol-counter;
  padding-left: var(--space-lg);
  position: relative;
}

.prose ol > li::before {
  content: counter(ol-counter) ".";
  position: absolute;
  left: 0;
  color: var(--interpreted);
  font-family: var(--font-mono);
  font-size: 13px;
  top: 3px;
}

.prose li {
  margin-bottom: var(--space-sm);
}

.prose li::marker {
  color: var(--interpreted);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--boundary);
  margin: 2.5em 0;
}

/* Dropdown Accordion */
.dropdowns {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 1.5em 0;
}

.dropdown {
  background: rgba(0, 0, 0, 0.03);
  border-left: 3px solid var(--boundary);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropdown[open] {
  border-left-color: var(--enforced);
  background: rgba(0, 0, 0, 0.04);
}

.dropdown summary {
  padding: var(--space-lg);
  padding-right: calc(var(--space-lg) + 24px);
  cursor: pointer;
  list-style: none;
  display: block;
  position: relative;
  transition: color 0.2s ease;
}

.dropdown-title {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--interpreted);
  line-height: 1.2;
}

.dropdown-subtitle {
  display: block;
  font-size: 16px;
  font-weight: 600;
  font-style: normal;
  color: var(--ink);
  line-height: 1.4;
  margin-top: var(--space-xs);
}

.dropdown summary::-webkit-details-marker {
  display: none;
}

.dropdown summary::marker {
  content: "";
  display: none;
}

.dropdown summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--interpreted);
  position: absolute;
  right: var(--space-lg);
  top: var(--space-lg);
  transition: color 0.2s ease;
}

.dropdown[open] summary::after {
  content: "\2212";
  color: var(--enforced);
}

.dropdown summary:hover {
  color: var(--enforced);
}

.dropdown > *:not(summary) {
  padding: 0 var(--space-lg) var(--space-lg);
}

.dropdown[open] summary {
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-xl);
  position: relative;
}

.dropdown[open] summary::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.dropdown p,
.dropdown ul,
.dropdown ol {
  margin-bottom: 0.75em;
}

.dropdown ul,
.dropdown ol {
  padding-left: calc(var(--space-lg) + var(--space-lg));
}

.dropdown p:last-child,
.dropdown ul:last-child,
.dropdown ol:last-child {
  margin-bottom: 0;
}

/* Footnotes */
.footnotes {
  border-top: 1px solid var(--boundary);
  margin-top: var(--space-3xl);
  padding-top: var(--space-lg);
  max-width: var(--article-width);
  margin-left: auto;
  margin-right: auto;
}

.footnotes-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--interpreted);
  margin-bottom: var(--space-md);
}

.footnotes-list {
  padding-left: var(--space-lg);
  font-size: 13px;
  color: var(--interpreted);
  line-height: 1.5;
}

.footnotes-list li {
  margin-bottom: var(--space-sm);
}

.footnote-ref {
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: none;
  color: var(--interpreted);
}

.footnote-ref:hover {
  color: var(--enforced);
}

.footnote-backref {
  text-decoration: none;
  color: var(--interpreted);
  margin-left: var(--space-xs);
}

.footnote-backref:hover {
  color: var(--enforced);
}

/* Footer */
footer {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--boundary);
  margin-top: var(--space-3xl);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2xl);
}

.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin: 0;
}

.footer-links a {
  font-size: 14px;
}

.copyright {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--interpreted);
}

/* Utility Classes */
.mt-sm { margin-top: var(--space-md); }
.mt-md { margin-top: var(--space-lg); }
.mt-lg { margin-top: var(--space-2xl); }

.accent {
  color: var(--enforced);
}

.highlight {
  background-color: rgba(156, 3, 59, 0.08);
  border-bottom: 2px solid var(--enforced);
  padding-bottom: 1px;
}

/* Article Wrapper (for TOC positioning) */
.article-wrapper {
  position: relative;
  max-width: var(--article-width);
  margin: 0 auto;
}

.article-wrapper .article-header {
  max-width: none;
  margin: 0;
}

.article-wrapper .prose {
  max-width: none;
  margin: 0;
}

/* Table of Contents — Left Rail */
.toc-rail {
  display: none;
  position: absolute;
  left: calc(-1 * ((100vw - var(--article-width)) / 2));
  top: var(--space-3xl);
  bottom: 0;
  width: calc((100vw - var(--article-width)) / 2);
}

.toc {
  position: sticky;
  top: var(--space-2xl);
  display: block;
  border-bottom: none;
  padding: 0 var(--space-lg);
  margin: 0 auto;
  max-width: 240px;
  text-align: left;
}

.toc-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--interpreted);
  margin-bottom: var(--space-md);
}

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

.toc-list li {
  margin-bottom: var(--space-sm);
}

.toc-list a {
  font-size: 13px;
  color: var(--interpreted);
  text-decoration: none;
  line-height: 1.4;
  display: block;
  position: relative;
  transition: color 0.2s ease;
}

.toc-list a .nav-knot {
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
}

.toc-list a .nav-knot path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 0.4s ease, opacity 0.2s ease;
  opacity: 0;
}

.toc-list a:hover .nav-knot path,
.toc-list a.knot-tap .nav-knot path {
  stroke-dashoffset: 0;
  opacity: 1;
}

.toc-list a:hover,
.toc-list a.knot-tap {
  color: var(--enforced);
}

.toc-list a.active {
  color: var(--ink);
}

@media (min-width: 1140px) {
  .toc-rail {
    display: block;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-lg);
  }

  h1 {
    font-size: 28px;
  }

  .display {
    font-size: 36px;
  }

  h2 {
    font-size: 20px;
  }

  .article-header {
    padding: var(--space-2xl) 0 var(--space-lg);
  }

  .footer-content {
    flex-direction: column;
  }

  nav {
    flex-direction: column;
    gap: 16px;
  }

  .post-title .nav-knot {
    display: none;
  }
}
