/* ═══════════════════════════════════════════
   THE STRUCTURE OF OBLIGATION
   Dark Editorial Theme
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Cinzel:wght@400;600;700&family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap');

:root {
  --bg-primary: #0e0c09;
  --bg-secondary: #181410;
  --bg-card: #1c1812;
  --bg-card-hover: #221e16;
  --bg-accent: #252015;

  --text-primary: #e8ddc4;
  --text-secondary: #c8b88a;
  --text-muted: #7a6e58;

  --accent-dark: #6b5418;
  --accent-mid: #b8952a;
  --accent-light: #d4b24e;
  --accent-glow: rgba(184, 149, 42, 0.1);
  --accent-border: rgba(184, 149, 42, 0.22);

  --gold: #b8952a;
  --gold-muted: rgba(184, 149, 42, 0.15);

  --font-display: 'Cinzel', 'Georgia', serif;
  --font-body: 'DM Sans', 'Segoe UI', sans-serif;

  --max-width: 820px;
  --nav-width: 260px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 40px;
  font-size: 16px;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--accent-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-mid); }

/* ── Background Texture ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(184, 149, 42, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(184, 149, 42, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════
   NAVIGATION
   ═══════════════════════════════════════════ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--accent-border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.nav-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--accent-border);
}

.nav-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.02em;
  line-height: 1.3;
  margin-top: 0;
}

.nav-header .nav-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 6px;
}

.nav-links {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-links a {
  display: block;
  padding: 10px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
  letter-spacing: 0.01em;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--accent-glow);
  border-left-color: var(--accent-mid);
}

.nav-links a.active {
  color: var(--accent-light);
  background: var(--accent-glow);
  border-left-color: var(--accent-light);
}

.nav-links .nav-section-label {
  padding: 16px 24px 6px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.nav-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--accent-border);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Mobile Nav Toggle ── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-border);
  color: var(--accent-light);
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */
.main-content {
  margin-left: var(--nav-width);
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.page {
  display: none;
  padding: 60px 60px 100px;
  max-width: calc(var(--max-width) + 120px);
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
}

.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════ */
.page-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1.15;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 40px;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-top: 56px;
  margin-bottom: 16px;
  line-height: 1.2;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent-mid);
  margin-top: 36px;
  margin-bottom: 12px;
  line-height: 1.3;
}

p {
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.75;
}

.lead {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

strong { color: #f0e6cc; font-weight: 600; }
em { color: var(--text-secondary); }
.cite { font-style: italic; color: var(--text-muted); font-size: 0.88rem; }

/* ── Dividers ── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-mid), transparent);
  margin: 48px 0;
  border: none;
}

.divider-thin {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-border), transparent);
  margin: 32px 0;
  border: none;
}

/* ── Blockquotes ── */
blockquote {
  margin: 24px 0;
  padding: 20px 28px;
  border-left: 3px solid var(--accent-mid);
  background: var(--accent-glow);
  border-radius: 0 6px 6px 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-primary);
  line-height: 1.7;
}

/* ── Lists ── */
ul.examples {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  columns: 2;
  column-gap: 32px;
}

ul.examples li {
  padding: 4px 0 4px 20px;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-secondary);
  break-inside: avoid;
}

ul.examples li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--accent-mid);
  font-weight: bold;
}

/* ═══════════════════════════════════════════
   CARDS & TABLES
   ═══════════════════════════════════════════ */
.tier-card {
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 28px 32px;
  margin: 24px 0;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.tier-card:hover {
  border-color: var(--accent-mid);
  background: var(--bg-card-hover);
}

.tier-card .tier-label {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.tier-card .tier-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
}

.tier-card p { font-size: 0.9rem; margin-bottom: 10px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.88rem;
}

thead th {
  background: var(--accent-dark);
  color: #f0e6cc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(184, 149, 42, 0.12);
  color: var(--text-primary);
  vertical-align: top;
}

tbody tr:nth-child(even) td { background: rgba(184, 149, 42, 0.04); }
tbody tr:hover td { background: var(--accent-glow); }

td:first-child { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }

/* ═══════════════════════════════════════════
   STRUCTURE DIAGRAM
   ═══════════════════════════════════════════ */
.structure-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 32px 0;
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
}

.flow-node {
  text-align: center;
  padding: 10px 24px;
}

.flow-node .flow-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-light);
}

.flow-node .flow-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.flow-arrow {
  color: var(--accent-mid);
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.6;
}

.flow-branches {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}

.flow-branch {
  text-align: center;
  padding: 12px 16px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  flex: 1;
  max-width: 200px;
}

.flow-branch .flow-label { font-size: 0.9rem; }
.flow-branch .flow-desc { font-size: 0.72rem; }

/* ═══════════════════════════════════════════
   HOME PAGE
   ═══════════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 36px 0 12px;
}

.hero .page-title {
  font-size: 3.4rem;
  margin-bottom: 8px;
}

.hero .page-subtitle {
  font-size: 1.35rem;
  margin-bottom: 12px;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 40px 0;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 28px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.doc-card:hover {
  border-color: var(--accent-light);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(184, 149, 42, 0.1);
}

.doc-card .doc-tier {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 8px;
}

.doc-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent-light);
  margin: 0 0 8px 0;
}

.doc-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ═══════════════════════════════════════════
   LEXICON
   ═══════════════════════════════════════════ */
.lex-entry {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(184, 149, 42, 0.08);
}

.lex-entry:last-child { border-bottom: none; }

.lex-term {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 6px;
}

.lex-def {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.75;
}

/* ═══════════════════════════════════════════
   DIAGNOSTIC STEPS
   ═══════════════════════════════════════════ */
.step-box {
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 24px 28px;
  margin: 20px 0;
}

.step-box .step-label {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.step-box .step-question {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.step-box .step-body { font-size: 0.9rem; }

.step-result {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-top: 8px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
  .main-content { margin-left: 0; }
  .site-nav { transform: translateX(-100%); }
  .site-nav.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,0.5); }
  .nav-toggle { display: flex; }
  .nav-overlay.open { display: block; }
  .page { padding: 60px 32px 80px; }
  .hero .page-title { font-size: 2.4rem; }
  .doc-grid { grid-template-columns: 1fr; }
  ul.examples { columns: 1; }
  .flow-branches { flex-direction: column; align-items: center; }
}

@media (max-width: 640px) {
  .page { padding: 50px 20px 60px; }
  .page-title { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .tier-card { padding: 20px; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 10px; }
}

/* ═══════════════════════════════════════════
   DIAGNOSTIC FLOWCHART
   ═══════════════════════════════════════════ */
.flowchart {
  margin: 32px 0;
  padding: 40px 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  overflow-x: auto;
}

.fc-trunk {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  min-width: 500px;
}

.fc-node {
  text-align: center;
  border-radius: 8px;
  position: relative;
  z-index: 2;
}

.fc-start {
  background: var(--accent-dark);
  border: 2px solid var(--accent-mid);
  color: #f0e6cc;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 32px;
}

.fc-question {
  background: var(--bg-accent);
  border: 2px solid var(--accent-mid);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 16px 22px;
  max-width: 320px;
  line-height: 1.5;
}

.fc-result-box {
  padding: 10px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  border: 2px solid;
  border-radius: 8px;
  text-align: center;
  max-width: 220px;
  line-height: 1.3;
}

.fc-result-justice {
  background: rgba(184, 149, 42, 0.12);
  border-color: var(--accent-light);
  color: var(--accent-light);
}

.fc-result-interpersonal {
  background: rgba(201, 168, 76, 0.1);
  border-color: var(--gold);
  color: var(--gold);
}

.fc-result-self {
  background: rgba(120, 160, 120, 0.1);
  border-color: #7a9e7a;
  color: #8fb88f;
}

.fc-result-none {
  background: rgba(160, 158, 147, 0.08);
  border-color: #6b6a63;
  color: #a09e93;
}

.fc-vline {
  width: 2px;
  height: 20px;
  background: var(--accent-mid);
  opacity: 0.5;
}

.fc-arrow-down {
  color: var(--accent-mid);
  font-size: 1rem;
  line-height: 1;
  opacity: 0.6;
  margin: -4px 0;
}

.fc-branch {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  position: relative;
  width: 100%;
  max-width: 620px;
}

.fc-branch-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.fc-branch-side {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 1 auto;
  padding-top: 0;
  min-width: 0;
}

.fc-branch-side-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.fc-hline {
  width: 24px;
  height: 2px;
  background: var(--accent-mid);
  opacity: 0.5;
  flex-shrink: 0;
}

.fc-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.fc-label-yes {
  color: #6abf6a;
  background: rgba(106, 191, 106, 0.12);
}

.fc-label-no {
  color: #d4795a;
  background: rgba(212, 121, 90, 0.12);
}

.fc-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  line-height: 1.4;
}

/* New flowchart step structure */
.fc-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 620px;
}

.fc-question-row {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  justify-content: center;
}

.fc-side-connector {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.fc-continuation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

@media (max-width: 640px) {
  .fc-branch { flex-direction: column; align-items: center; }
  .fc-branch-side { flex-direction: column; padding-top: 8px; }
  .fc-question-row { flex-direction: column; }
  .fc-side-connector { flex-direction: column; padding-top: 8px; }
  .fc-hline { width: 2px; height: 16px; }
  .fc-question { max-width: 280px; font-size: 0.8rem; padding: 14px 16px; }
  .fc-result-box { max-width: 200px; font-size: 0.82rem; }
  .fc-trunk { min-width: auto; }
}

/* ═══════════════════════════════════════════
   LEXICON TOOLTIPS
   ═══════════════════════════════════════════ */
.lex-tip {
  position: relative;
  color: var(--accent-light);
  border-bottom: 1px dotted var(--accent-mid);
  cursor: help;
  transition: color 0.2s ease;
}

.lex-tip:hover {
  color: #e8d48a;
}

.lex-tip-popup {
  display: none;
  position: fixed;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-mid);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 500;
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--text-primary);
  font-weight: 400;
  font-style: normal;
  text-align: left;
  pointer-events: none;
}

.lex-tip:hover .lex-tip-popup,
.lex-tip:focus .lex-tip-popup {
  display: block;
}

.lex-tip-popup .lex-tip-term {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-light);
  margin-bottom: 6px;
  display: block;
}

/* ═══ Content Links ═══ */
.main-content a {
  color: var(--accent-light);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-border);
  transition: color 0.2s, border-color 0.2s;
}
.main-content a:hover {
  color: var(--accent-mid);
  border-bottom-color: var(--accent-mid);
}
.main-content a:visited {
  color: var(--accent-light);
}

/* ═══ See Also Cross-References ═══ */
.see-also {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}
.see-also strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ═══ References Section ═══ */
.references-section {
  margin-top: 12px;
  padding-top: 8px;
}
.references-section h2 {
  font-size: 1.4rem;
  margin-top: 24px;
}
.references-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 10px;
}

/* ═══ Nav Search ═══ */
.nav-search {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--accent-border);
}

.nav-search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 0 10px;
  transition: border-color 0.2s ease;
}

.nav-search-input-wrap:focus-within {
  border-color: var(--accent-mid);
}

.search-icon {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 6px;
  flex-shrink: 0;
}

#siteSearch {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 8px 0;
  width: 100%;
}

#siteSearch::placeholder {
  color: var(--text-muted);
}

.search-results {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 8px;
}

.search-results:empty {
  display: none;
}

.search-result-item {
  display: block;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--bg-primary);
  border: 1px solid rgba(184, 149, 42, 0.1);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.search-result-item:hover {
  border-color: var(--accent-mid);
  background: var(--accent-glow);
}

.search-result-page {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 3px;
}

.search-result-snippet {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.search-result-snippet mark {
  background: transparent;
  color: var(--accent-light);
  font-weight: 600;
}

.search-no-results {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 4px;
  font-style: italic;
}
