/* =========================
   Trust-State Unified CSS
   Institutional Version (2026)
   ========================= */

/* ---------- Root Variables ---------- */

:root {
  --ts-navy: #0A1F33;
  --ts-accent: #1E90FF;
  --ts-light: #F5F7FA;
  --ts-border: #E5E7EB;
  --ts-text: #1F2937;
  --ts-muted: #6B7280;
  --doc-width: 760px;
  --max-width: 1100px;
  --radius: 6px;

  /* Typography rhythm */
  --space-section: 2.2rem;
  --space-subsection: 1.2rem;
}

/* ---------- Base Reset ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--ts-light);
  color: var(--ts-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top Bar ---------- */

.ts-topbar {
  background: var(--ts-navy);
  color: white;
  font-size: 0.85rem;
  padding: 6px 12px;
  text-align: center;
}

/* ---------- Header / Navigation ---------- */

.ts-header {
  background: white;
  border-bottom: 1px solid var(--ts-border);
}

.ts-nav {
  max-width: var(--max-width);
  margin: auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ts-logo a {
  font-weight: 600;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ts-navy);
}

.ts-menu {
  display: flex;
  gap: 22px;
}

.ts-menu-item a {
  color: var(--ts-text);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 0;
}

.ts-menu-item a:hover {
  color: var(--ts-accent);
}

@media (max-width: 720px) {
  .ts-menu {
    display: none; /* We keep mobile simple, cleaner for standards pages */
  }
}

/* Sidebar list structure */
.ts-sidebar .ts-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ts-sidebar .ts-nav-list li {
  margin: 4px 0;
}

.ts-sidebar .ts-nav-list li a {
  display: block;
  padding: 6px 10px;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--ts-text);
  font-size: 0.95rem;
}

.ts-sidebar .ts-nav-list li a:hover {
  border-left-color: var(--ts-accent);
  color: var(--ts-accent);
}

.ts-sidebar .ts-nav-list li a.active {
  border-left-color: var(--ts-accent);
  font-weight: 600;
  color: var(--ts-navy);
}

/* =========================
   SIDEBAR LAYOUT RULES
   ========================= */

.ts-layout {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

/* Sidebar column */
.ts-sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 90px; /* keeps sidebar visible while scrolling */
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 10px;
}

/* Main content column */
.ts-doc {
  flex: 1;
  min-width: 0; /* prevents overflow */
}

/* ---------- Layout Containers ---------- */

.ts-container {
  max-width: var(--max-width);
  margin: auto;
  padding: 20px;
}

.ts-doc {
  max-width: var(--doc-width);
  margin: auto;
  padding-top: 20px;
}

/* ---------- Typography ---------- */

.ts-h1, h1 {
  font-size: 2rem;
  margin-bottom: 0.8rem;
  color: var(--ts-navy);
  font-weight: 700;
}

.ts-h2, h2 {
  margin-top: var(--space-section);
  margin-bottom: 0.6rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ts-navy);
}

.ts-h3, h3 {
  margin-top: var(--space-subsection);
  margin-bottom: 0.3rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ts-text);
}

.ts-h4, h4 {
  font-size: 1rem;
  margin-top: 0.6rem;
  font-weight: 600;
  color: var(--ts-text);
}

p {
  margin: 0 0 1rem 0;
}

ul, ol {
  margin: 0 0 1.2rem 1.3rem;
}

li {
  margin-bottom: 0.4rem;
}

/* ---------- Meta & Divider ---------- */

.ts-meta {
  color: var(--ts-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.ts-divider {
  border: 0;
  border-top: 1px solid var(--ts-border);
  margin: 1.6rem 0;
}

/* ---------- Code Blocks ---------- */

pre {
  background: white;
  border: 1px solid var(--ts-border);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f0f2f5;
  padding: 2px 5px;
  border-radius: 4px;
}

/* ---------- Footer ---------- */

.ts-footer {
  background: white;
  border-top: 1px solid var(--ts-border);
  padding: 24px 0;
  margin-top: 60px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ts-muted);
}

/* ---------- Section Spacing Fix (Requested) ---------- */

h2 + p,
h2 + ul,
h2 + pre {
  margin-top: 0.2rem !important; /* Tightens space under section titles */
}

h3 + p,
h3 + ul {
  margin-top: 0.1rem !important;
}

p + h2,
ul + h2,
pre + h2 {
  margin-top: var(--space-section) !important;
}

p + h3,
ul + h3,
pre + h3 {
  margin-top: var(--space-subsection) !important;
}

/* ---------- Mobile Doc Readability ---------- */

@media (max-width: 600px) {
  .ts-doc {
    padding: 10px;
    font-size: 0.97rem;
  }
  
  h1, .ts-h1 {
    font-size: 1.55rem;
  }

  h2, .ts-h2 {
    font-size: 1.3rem;
  }
}
