/* =========================================
   Lambdacus - Shared Styles
   Dark mode default, minimalistic theme toggle
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500&family=JetBrains+Mono:wght@400;500&family=Source+Sans+3:wght@400;500;600;700&display=swap');

/* Dark mode (default) */
:root {
  --bg: #1a1a1a;
  --fg: #e8e6e3;
  --accent: #d4a574;
  --accent2: #7cb87c;
  --muted: #9a9a9a;
  --border: #3d3d3d;
  --code-bg: #2d2d2d;
  --def-bg: #252525;
  --thm-bg: #2a2520;
  --thm-border: #c4713a;
  --prop-bg: #242a22;
  --prop-border: #5a8a50;
  --rem-bg: #252528;
  --rem-border: #7070a0;
  --cor-bg: #2a2520;
  --cor-border: #b08040;
}

/* Light mode */
body.theme-light {
  --bg: #faf8f4;
  --fg: #1a1a1a;
  --accent: #8b2500;
  --accent2: #2d5a27;
  --muted: #666;
  --border: #d4cfc7;
  --code-bg: #f0ece4;
  --def-bg: #f5f2eb;
  --thm-bg: #fdf6f0;
  --prop-bg: #f0f5ee;
  --rem-bg: #f0f0f8;
  --cor-bg: #fef8f0;
}

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

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 19px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(212, 165, 116, 0.25);
}

body.theme-light ::selection {
  background: rgba(139, 37, 0, 0.12);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--def-bg);
  color: var(--fg);
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}
.theme-toggle svg {
  width: 1.1em;
  height: 1.1em;
}
.theme-toggle:hover {
  background: var(--code-bg);
}

/* =========================================
   Landing Page
   ========================================= */

.landing {
  max-width: 640px;
  margin: 0 auto;
  padding: 140px 32px 120px;
}

.site-title {
  font-size: 2.6em;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 24px;
  color: var(--fg);
}

.site-desc {
  font-size: 1.05em;
  line-height: 1.78;
  color: var(--muted);
  margin-bottom: 60px;
  max-width: 540px;
}

.articles h2 {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
  border-bottom: none;
  padding-bottom: 0;
}

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

.articles li {
  margin-bottom: 14px;
  font-size: 1.02em;
  line-height: 1.6;
}

.articles li a {
  font-weight: 500;
  color: var(--fg);
}

.articles li a:hover {
  color: var(--accent);
}

.articles .desc {
  color: var(--muted);
  font-size: 0.92em;
}

.site-footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.82em;
  color: var(--muted);
  font-family: 'Source Sans 3', sans-serif;
}

.site-footer .email {
  margin-top: 8px;
}

.site-footer .email a {
  color: var(--muted);
  font-size: 0.95em;
}

.site-footer .email a:hover {
  color: var(--accent);
}

.paper .site-footer {
  margin-top: 60px;
}


/* =========================================
   Paper Layout (Articles)
   ========================================= */

.paper {
  max-width: 820px;
  margin: 0 auto;
  padding: 60px 40px 100px;
}

.paper h1 {
  font-size: 2em;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  text-align: center;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 50px;
  font-size: 1.05em;
}

.paper .back-link {
  display: inline-block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.78em;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 40px;
  letter-spacing: 0.02em;
}

.paper .back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

h2 {
  font-size: 1.45em;
  font-weight: 700;
  margin-top: 50px;
  margin-bottom: 18px;
  color: var(--accent);
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 6px;
}

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

h2 a:hover {
  text-decoration: none;
  border-bottom: none;
}

h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin-top: 30px;
  margin-bottom: 12px;
  color: var(--fg);
}

p { margin-bottom: 14px; }

ul, ol {
  margin: 8px 0 14px 24px;
}

li {
  margin: 3px 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}


/* =========================================
   Academic Blocks
   ========================================= */

.def, .thm, .prop, .rem, .cor, .lem, .ex {
  margin: 22px 0;
  padding: 16px 20px;
  border-left: 3.5px solid;
  border-radius: 0 4px 4px 0;
}

.def {
  background: var(--def-bg);
  border-color: var(--accent);
}

.thm {
  background: var(--thm-bg);
  border-color: var(--thm-border);
}

.prop {
  background: var(--prop-bg);
  border-color: var(--prop-border);
}

.rem {
  background: var(--rem-bg);
  border-color: var(--rem-border);
}

.cor {
  background: var(--cor-bg);
  border-color: var(--cor-border);
}

.lem {
  background: #2a2824;
  border-color: #a08060;
}

body.theme-light .lem {
  background: #f8f5f0;
}

.ex {
  background: #252a2d;
  border-color: #507090;
}

body.theme-light .ex {
  background: #f5f8fa;
}

.label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 6px;
}

.def .label { color: var(--accent); }
.thm .label { color: var(--thm-border); }
.prop .label { color: var(--prop-border); }
.rem .label { color: var(--rem-border); }
.cor .label { color: var(--cor-border); }
.lem .label { color: #a08060; }
.ex .label { color: #507090; }


/* =========================================
   Inline Formatting
   ========================================= */

.math {
  font-family: 'Crimson Pro', Georgia, serif;
  font-style: italic;
}

.cat {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 0.92em;
  font-style: normal;
}

.fn {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 500;
  font-size: 0.9em;
  font-style: normal;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
}

/* =========================================
   Diagrams (graphical, no ASCII)
   ========================================= */

.diagram {
  margin: 20px 0;
  padding: 18px;
  background: var(--def-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9em;
  line-height: 1.6;
}

.diagram-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diagram-box {
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 500;
}

.diagram-arrow {
  width: 20px;
  height: 2px;
  background: var(--muted);
  position: relative;
  flex-shrink: 0;
}
.diagram-arrow::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-left-color: var(--muted);
  border-right: none;
  margin-right: -4px;
}


/* =========================================
   Abstract and TOC
   ========================================= */

.abstract {
  margin: 0 0 40px;
  padding: 20px 24px;
  background: var(--def-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95em;
}

.abstract-title {
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.toc {
  margin: 30px 0 50px;
  padding: 20px 24px;
  background: var(--def-bg);
  border-radius: 4px;
}

.toc-title {
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 1.05em;
}

.toc ol {
  padding-left: 22px;
}

.toc li {
  margin: 4px 0;
  font-size: 0.95em;
}

.toc a {
  color: var(--accent);
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}


/* =========================================
   Flow Diagrams (image-style)
   ========================================= */

.flow-diagram {
  margin: 24px 0;
  padding: 24px 20px;
  background: var(--def-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
  font-size: 0.95em;
}

.flow-node {
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 0.85em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.flow-node.cat-node {
  background: #3d4045;
  color: #e8e6e3;
  border-color: #4d5055;
}

.flow-node.functor-node {
  background: #7a5a2a;
  color: #f5e6c8;
  border-color: #8a6a3a;
  font-style: italic;
  font-weight: 500;
}

.flow-node.result-node {
  background: #2d5a2d;
  color: #d4f0d4;
  border-color: #3d6a3d;
}

.flow-node.security-node,
.flow-node.lineage-node {
  background: #4a3a6a;
  color: #e8e0f0;
  border-color: #5a4a7a;
}

body.theme-light .flow-node.cat-node {
  background: #e8edf3;
  color: #2c3e50;
  border-color: #b0bec5;
}

body.theme-light .flow-node.functor-node {
  background: #fdf2e0;
  color: #7a5a10;
  border-color: #d4b060;
}

body.theme-light .flow-node.result-node {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #81c784;
}

body.theme-light .flow-node.security-node,
body.theme-light .flow-node.lineage-node {
  background: #f3e5f5;
  color: #6a1b9a;
  border-color: #b080c0;
}

.flow-arrow {
  width: 24px;
  height: 2px;
  background: var(--muted);
  position: relative;
  flex-shrink: 0;
}
.flow-arrow::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left-color: var(--muted);
  border-right: none;
  margin-right: -5px;
}

.flow-label {
  font-family: 'Crimson Pro', serif;
  font-size: 0.82em;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
  font-style: italic;
}

.flow-section {
  margin: 16px 0 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.flow-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.flow-section-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}


/* =========================================
   Tables
   ========================================= */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.92em;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

th {
  background: var(--def-bg);
  font-weight: 600;
}


/* =========================================
   Utility
   ========================================= */

.read-more {
  display: inline-block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.78em;
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: 0.02em;
}


/* =========================================
   Responsive
   ========================================= */

@media (max-width: 600px) {
  .landing {
    padding: 80px 24px 80px;
  }

  .site-title {
    font-size: 2em;
  }

  .paper {
    padding: 36px 20px 80px;
  }

  .paper h1 {
    font-size: 1.5em;
  }

  .flow-row {
    font-size: 0.82em;
    gap: 6px;
  }

  .flow-node {
    padding: 6px 12px;
    font-size: 0.8em;
  }

  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
}
