/* ============================================================
   CODIFIDE.COM — Article Stylesheet
   Styles governance articles with Codifide brand design
   ============================================================ */

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.8;
  color: #1e2340;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
}

/* ─── Article Nav Bar ──────────────────────────────────────────── */
.article-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #001689;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.article-nav a {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.article-nav a:hover { opacity: 1; }

.article-nav .nav-logo {
  height: 44px;
  width: auto;
  filter: brightness(0) invert(1);
}

.article-nav .nav-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.article-nav .nav-back::before { content: "←"; }

/* ─── Content Container ────────────────────────────────────────── */
body > *:not(.article-nav) {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* ─── Typography ───────────────────────────────────────────────── */
h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #001689;
  line-height: 1.15;
  margin-top: 3rem;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.6rem;
  font-weight: 600;
  color: #001689;
  line-height: 1.3;
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid #e8f5fa;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e2340;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #4a5270;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1.1rem;
  font-size: 1.05rem;
  line-height: 1.8;
  color: #2d2d2d;
}

strong { font-weight: 600; color: #1e2340; }
em { font-style: italic; }

a { color: #0083AD; text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: #001689; }

.subtitle {
  font-size: 1.15rem;
  color: #4a5270;
  font-style: italic;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.meta {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.meta span { margin-right: 2rem; }

/* ─── Abstract / Lead ──────────────────────────────────────────── */
.abstract {
  background: #f8f9fc;
  border-left: 4px solid #4FA7C5;
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  border-radius: 0 10px 10px 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.abstract p {
  margin-bottom: 0;
  font-size: 1rem;
  color: #4a5270;
  line-height: 1.7;
}

/* ─── Stat Cards ───────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #dde1ef;
  border-radius: 10px;
  padding: 1.5rem 1.2rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.stat-card .number {
  font-size: 2.2rem;
  font-weight: 700;
  color: #001689;
  line-height: 1.2;
}

.stat-card .label {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* ─── Timeline ─────────────────────────────────────────────────── */
.timeline {
  position: relative;
  margin: 2.5rem 0;
  padding-left: 2.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, #4FA7C5, #001689);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.8rem;
  padding-left: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.55rem;
  top: 0.5rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4FA7C5;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px #4FA7C5;
}

.timeline-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4FA7C5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timeline-title {
  font-weight: 600;
  font-size: 1rem;
  color: #1e2340;
  margin: 0.2rem 0;
}

.timeline-desc {
  font-size: 0.92rem;
  color: #6b7280;
  line-height: 1.6;
}

/* ─── Diagrams ─────────────────────────────────────────────────── */
.diagram {
  background: #f8f9fc;
  border: 1px solid #dde1ef;
  border-radius: 12px;
  padding: 2rem;
  margin: 2.5rem 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.layer-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 600px;
  margin: 0 auto;
}

.layer {
  padding: 1.2rem 1.5rem;
  text-align: center;
  border: 2px solid;
  position: relative;
}

.layer-human { background: #fef3c7; border-color: #f59e0b; border-radius: 12px 12px 0 0; }
.layer-gate { background: #dbeafe; border-color: #3b82f6; }
.layer-loop { background: #d1fae5; border-color: #10b981; border-radius: 0 0 12px 12px; }

.layer-title { font-weight: 700; font-size: 1rem; margin-bottom: 0.3rem; color: #1e2340; }
.layer-detail { font-size: 0.85rem; color: #6b7280; }

.arrow-down { text-align: center; font-size: 1.5rem; color: #9099b8; margin: -2px 0; position: relative; z-index: 1; }

/* ─── Callouts ─────────────────────────────────────────────────── */
.callout {
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
}

.callout-info { background: #eff6ff; border-color: #3b82f6; }
.callout-warning { background: #fffbeb; border-color: #f59e0b; }
.callout-danger { background: #fef2f2; border-color: #dc2626; }

.callout-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.callout-info .callout-title { color: #1d4ed8; }
.callout-warning .callout-title { color: #b45309; }
.callout-danger .callout-title { color: #b91c1c; }

/* ─── Tier Cards ───────────────────────────────────────────────── */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.tier-card {
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid #dde1ef;
}

.tier-card.tier-1 { background: #fef2f2; border-color: #fca5a5; }
.tier-card.tier-2 { background: #fffbeb; border-color: #fcd34d; }
.tier-card.tier-3 { background: #f0fdf4; border-color: #86efac; }

.tier-label { font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.tier-pct { font-size: 2rem; font-weight: 700; color: #001689; }
.tier-desc { font-size: 0.85rem; color: #6b7280; margin-top: 0.5rem; line-height: 1.5; }

/* ─── Comparison Boxes ─────────────────────────────────────────── */
.compare-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
}

.compare-box {
  border-radius: 10px;
  padding: 1.5rem;
  border: 1px solid #dde1ef;
}

.compare-box.old { background: #fef2f2; border-color: #fca5a5; }
.compare-box.new { background: #f0fdf4; border-color: #86efac; }
.compare-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; color: #1e2340; }
.compare-arrow { font-size: 2rem; color: #9099b8; text-align: center; }

/* ─── Tables ───────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

th {
  background: #001689;
  color: #ffffff;
  padding: 0.85rem 1.2rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  line-height: 1.6;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fc; }

/* ─── Lists ────────────────────────────────────────────────────── */
ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2rem;
}

li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
  font-size: 1.02rem;
}

li::marker { color: #4FA7C5; }

/* ─── Code ─────────────────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  background: #f0f2f8;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  color: #5F54AD;
}

pre {
  background: #1e2340;
  color: #e0e4ef;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.85rem;
  line-height: 1.65;
}

pre code { background: transparent; color: inherit; padding: 0; }

/* ─── Blockquotes ──────────────────────────────────────────────── */
blockquote {
  border-left: 4px solid #4FA7C5;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: #f8f9fc;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #4a5270;
}

/* ─── SVG Diagrams ─────────────────────────────────────────────── */
.svg-diagram {
  margin: 2rem 0;
  text-align: center;
}

.svg-diagram svg {
  max-width: 100%;
  height: auto;
}

/* ─── References ───────────────────────────────────────────────── */
.references {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e8f5fa;
}

.references h2 { border-bottom: none; }

.references ol {
  font-size: 0.9rem;
  color: #4a5270;
}

/* ─── Hero (loop-engineering) ──────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #001689 0%, #0083AD 100%);
  color: #ffffff;
  padding: 4rem 2rem;
  margin: 0 -2rem;
  margin-top: 0;
  text-align: center;
}

.hero h1 { color: #ffffff; margin-top: 0; }
.hero .subtitle { color: rgba(255, 255, 255, 0.8); }
.hero p { color: rgba(255, 255, 255, 0.9); }

/* ─── Footer (whitepaper) ──────────────────────────────────────── */
.footer {
  margin-top: 4rem;
  padding: 2rem;
  background: #f8f9fc;
  border-top: 2px solid #e8f5fa;
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
}

/* ─── Container class (loop-engineering, whitepaper) ───────────── */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ─── Spacing at bottom ────────────────────────────────────────── */
body::after {
  content: "";
  display: block;
  height: 4rem;
}

/* ─── Print ────────────────────────────────────────────────────── */
@media print {
  .article-nav { display: none; }
  body { padding: 0; }
  body > *:not(.article-nav) { max-width: 100%; padding: 0 1rem; }
  h1 { margin-top: 0; }
  .stat-card, .tier-card, .callout, .diagram { break-inside: avoid; }
}

/* ─── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body > *:not(.article-nav) { padding-left: 1rem; padding-right: 1rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.35rem; }
  .article-nav { padding: 0.75rem 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tier-grid { grid-template-columns: 1fr; }
  .compare-flow { grid-template-columns: 1fr; }
  .compare-arrow { transform: rotate(90deg); }
  table { font-size: 0.82rem; }
  th, td { padding: 0.6rem 0.8rem; }
}
