:root { color-scheme: light; }
/* Wiki Views — house stylesheet
   Shared by index.html and every views/*.html page.
   House standard: 1024px page width (Tailwind max-w-5xl), content-dense layout.
   Light/dark aware. Chart colours live here as CSS variables so every
   view draws with the same palette (read them in JS via getComputedStyle). */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1d1d1f;
  --text-muted: #5f5e5a;
  --border: #e2dfd8;
  --accent: #2f5fb3;
  --accent-soft: #e6edf9;

  /* callouts */
  --warn: #9a5b00;   --warn-bg: #fdf3e2;
  --ok: #2e7d4f;     --ok-bg: #e7f4ec;
  --info: #2f5fb3;   --info-bg: #e6edf9;
  --q: #6b4fa8;      --q-bg: #efeaf8;

  /* chart palette: bright categorical (see-through fills, solid outlines),
     then signed (gain / pain). Draw charts with assets/charts.js. */
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #e0569a;
  --c5: #6250d6;
  --c-pos: #1a9e5c;
  --c-neg: #e34948;
  --c-grid: #dcd8cf;
  --c-axis: #8a877f;
  --c-zero: #3a3936;

  /* category colours (index groups + group badges) */
  --cat-randy: #6b4fa8;       --cat-randy-bg: #efeaf8;
  --cat-project: #b86a00;     --cat-project-bg: #fdf0dc;
  --cat-established: #2f5fb3; --cat-established-bg: #e6edf9;
  --cat-ai: #0f7c7a;          --cat-ai-bg: #e0f3f1;

  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 1024px;   /* house standard: Tailwind max-w-5xl (64rem @ 16px) */
  --gap: 1.5rem;       /* column gutter */
  --radius: 8px;
}

@media not all /* dark mode off on io.world */ {
  :root {
    --bg: #17171a;
    --surface: #1f1f23;
    --surface-2: #26262b;
    --text: #ececec;
    --text-muted: #a5a39d;
    --border: #34343a;
    --accent: #8fb0ee;
    --accent-soft: #23304a;

    --warn: #f0b765;   --warn-bg: #33281a;
    --ok: #7fcf9d;     --ok-bg: #1b2e23;
    --info: #8fb0ee;   --info-bg: #1f2a3f;
    --q: #b9a3ea;      --q-bg: #2a2438;

    --c1: #4b93ec;
    --c2: #f07a4a;
    --c3: #2fc28c;
    --c4: #ec7fb3;
    --c5: #9085e9;
    --c-pos: #3fbf7a;
    --c-neg: #ef6d6c;
    --c-grid: #3a3a40;
    --c-axis: #8d8b85;
    --c-zero: #d6d4ce;

    --cat-randy: #b9a3ea;       --cat-randy-bg: #2a2438;
    --cat-project: #f0b765;     --cat-project-bg: #33281a;
    --cat-established: #8fb0ee; --cat-established-bg: #1f2a3f;
    --cat-ai: #5fd0c8;          --cat-ai-bg: #183230;
  }
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem 24px 3.5rem;
}

/* ---------- typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-ui);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.85rem; margin: .25rem 0 .35rem; }
h2 {
  font-size: 1.2rem;
  margin: 2rem 0 .65rem;
  padding-top: .9rem;
  border-top: 1px solid var(--border);
}
h3 { font-size: .98rem; margin: 1.1rem 0 .4rem; }
h4 { font-size: .9rem; margin: 0 0 .35rem; }
p, ul, ol { margin: 0 0 .75rem; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: .2rem; }
a { color: var(--accent); text-underline-offset: 2px; }
strong { font-weight: 650; }
code, .mono { font-family: var(--font-mono); font-size: .86em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--text-muted); }
.small { font-size: .88rem; }
.lede { font-size: 1.08rem; }

/* wiki cross-references: shown, not linked (views never link into the vault) */
.wikiref {
  font-family: var(--font-ui);
  font-size: .82em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .05em .4em;
  border-radius: 4px;
  white-space: nowrap;
}

/* ---------- top nav + standard header ---------- */
.topnav {
  font-family: var(--font-ui);
  font-size: .82rem;
  margin-bottom: 1rem;
}
.topnav a { text-decoration: none; }
.topnav a:hover { text-decoration: underline; }

.view-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 25rem;
  gap: .75rem 2rem;
  align-items: end;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--text);
}
.view-header .purpose {
  font-size: 1.02rem;
  color: var(--text-muted);
  margin: 0;
}
.meta {
  font-family: var(--font-ui);
  font-size: .76rem;
  color: var(--text-muted);
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .15rem .75rem;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
}
.meta dt { font-weight: 600; }
.meta dd { margin: 0; }
.meta ul { list-style: none; padding: 0; margin: 0; }
.meta li { margin: 0; font-family: var(--font-mono); font-size: .9em; }

.badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: .66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .12em .55em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  vertical-align: middle;
}

/* ---------- layout utilities ---------- */
.cols-2, .cols-3, .cols-2-1, .cols-1-2 {
  display: grid;
  gap: var(--gap);
  align-items: start;
}
.cols-2   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3   { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.cols-2 > *, .cols-3 > *, .cols-2-1 > *, .cols-1-2 > * { min-width: 0; }
.cols-2 > div > :first-child, .cols-3 > div > :first-child,
.cols-2-1 > div > :first-child, .cols-1-2 > div > :first-child { margin-top: 0; }

/* stat strip: key numbers at a glance */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: .5rem;
  margin: 0 0 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .75rem;
}
.stat b {
  display: block;
  font-family: var(--font-ui);
  font-size: 1.2rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-family: var(--font-ui);
  font-size: .74rem;
  color: var(--text-muted);
}

/* ---------- callouts (mirror Obsidian callout types) ---------- */
.callout {
  border-left: 4px solid var(--info);
  background: var(--info-bg);
  padding: .6rem .9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: .75rem 0;
  font-size: .95rem;
}
.callout > :last-child { margin-bottom: 0; }
.callout ul { margin-bottom: 0; }
.callout-title {
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: .84rem;
  margin-bottom: .25rem;
}
.callout.warning  { border-color: var(--warn); background: var(--warn-bg); }
.callout.warning  .callout-title { color: var(--warn); }
.callout.success  { border-color: var(--ok);   background: var(--ok-bg); }
.callout.success  .callout-title { color: var(--ok); }
.callout.question { border-color: var(--q);    background: var(--q-bg); }
.callout.question .callout-title { color: var(--q); }
.callout.info     .callout-title { color: var(--info); }

/* ---------- key formula / principle ---------- */
.principle {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  padding: .8rem 1rem;
  margin: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.formula {
  font-family: var(--font-mono);
  font-size: .86rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .75rem;
  margin: .4rem 0 .75rem;
  overflow-x: auto;
}

/* ---------- cards / grids ---------- */
.grid-2, .grid-3, .grid-4 {
  display: grid;
  gap: .75rem;
  margin: .5rem 0 1rem;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  font-size: .95rem;
}
.card h3, .card h4 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.accent { border-top: 3px solid var(--accent); }

/* numbered steps */
ol.steps { counter-reset: step; list-style: none; padding: 0; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 .35rem 2.1rem;
  margin-bottom: .35rem;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: .05rem;
  width: 1.45rem; height: 1.45rem;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: .83rem;
  margin: .4rem 0 1rem;
}
th, td {
  text-align: left;
  padding: .38rem .5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.c, th.c { text-align: center; }
tr.total td { font-weight: 700; border-top: 2px solid var(--text-muted); }
.pos { color: var(--c-pos); font-weight: 600; }
.neg { color: var(--c-neg); font-weight: 600; }

/* ---------- charts ---------- */
figure.chart {
  margin: .5rem 0 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
}
figure.chart svg { display: block; width: 100%; height: auto; }
figure.chart figcaption {
  font-family: var(--font-ui);
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: .45rem;
}
.chart-text { font-family: var(--font-ui); fill: var(--text); font-size: 12px; }
.chart-label { font-family: var(--font-ui); fill: var(--text-muted); font-size: 11px; }
.chart-grid { stroke: var(--c-grid); stroke-width: 1; fill: none; }
.chart-axis { stroke: var(--c-axis); stroke-width: 1; }
.chart-zero { stroke: var(--c-zero); stroke-width: 2; fill: none; }

.legend {
  display: flex; flex-wrap: wrap; gap: .3rem 1rem;
  font-family: var(--font-ui); font-size: .76rem; color: var(--text-muted);
  margin-top: .4rem;
}
.legend span::before {
  content: ""; display: inline-block; width: .7rem; height: .7rem;
  border-radius: 3px; margin-right: .35rem; vertical-align: -1px;
  background: var(--swatch);
}
/* see-through swatch with a solid outline, matching the chart marks */
.legend span.fill::before {
  background: color-mix(in srgb, var(--swatch) 22%, transparent);
  border: 1.5px solid var(--swatch);
}
/* line swatch: a short stroke (solid, dashed or dotted) for line and radar series */
.legend span.line::before { display: none; }
figure.chart .legend span.line svg, .legend span.line svg { display: inline-block; width: 1.6rem; height: .7rem; margin-right: .35rem; vertical-align: 0; overflow: visible; }

/* ---------- index page ---------- */
.index-group { margin-top: 1.75rem; }
.index-group h2 { margin-top: 0; display: flex; align-items: center; gap: .5rem; }
.index-group h2::before {
  content: ""; width: .7rem; height: .7rem; border-radius: 3px;
  background: var(--cat, var(--accent)); flex: none;
}

/* ---------- category colours ---------- */
.cat-randy       { --cat: var(--cat-randy);       --cat-bg: var(--cat-randy-bg); }
.cat-project     { --cat: var(--cat-project);     --cat-bg: var(--cat-project-bg); }
.cat-established { --cat: var(--cat-established); --cat-bg: var(--cat-established-bg); }
.cat-ai          { --cat: var(--cat-ai);          --cat-bg: var(--cat-ai-bg); }
.badge.cat-randy, .badge.cat-project, .badge.cat-established, .badge.cat-ai {
  background: var(--cat-bg); color: var(--cat);
  border-color: color-mix(in srgb, var(--cat) 40%, transparent);
}
.index-kind {
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: .9rem 0 .45rem;
}
.view-list {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: .75rem;
}
.view-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--cat, var(--accent));
  border-radius: var(--radius);
  padding: .75rem .9rem;
  margin: 0;
  display: flex; flex-direction: column;
}
.view-list a.title {
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: .98rem;
  text-decoration: none;
}
.view-list a.title:hover { text-decoration: underline; }
.view-list .purpose { margin: .25rem 0 .5rem; font-size: .92rem; flex: 1; }
.view-list .stamp { font-family: var(--font-ui); font-size: .72rem; color: var(--text-muted); }
.empty {
  font-family: var(--font-ui);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

footer.page-foot {
  margin-top: 2.5rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: .76rem;
  color: var(--text-muted);
}

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .view-header, .cols-2, .cols-3, .cols-2-1, .cols-1-2, .grid-3 { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  figure.chart, .card, .stat, .view-list li { break-inside: avoid; }
}
