/* Tokens ------------------------------------------------------------------ */
:root {
  color-scheme: light;
  --paper: #fcfbf9;
  --ink: #23262b;
  --ink-2: #5b5f66;
  --ink-3: #8a8d94;
  --rule: #e3e1dc;
  --panel: #f1efea;
  --accent: #b4232c;
  --accent-soft: #f3d9d9;
  --s-a: #0f8f7c;            /* teal */
  --s-b: #b4232c;            /* crimson, the accent */
  --s-c: #2e6bb5;            /* blue */
  --s-d: #b8860b;            /* amber */
  --focus: #2e6bb5;

  --font: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --text: 1.1875rem;   /* 19px */
  --small: 0.9375rem;  /* 15px */
  --measure: 34rem;
  --gutter: 1rem;
  --page: 74rem;

  /* colour follows the entity, everywhere on the page */
  --m-sent: var(--s-b);      /* GARCH-LSTM + sentiment, the proposed model */
  --m-nn: var(--s-d);        /* GARCH-LSTM */
  --m-garch: var(--s-a);     /* GARCH */
  --m-garchx: var(--s-c);    /* GARCH + sentiment */
  --i-negtw: var(--s-b);     /* negative Twitter index */
  --i-postw: var(--s-c);     /* positive Twitter index */
  --i-negnews: var(--s-a);   /* negative news index */
  --i-posnews: var(--s-d);   /* positive news index */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #17181b;
    --ink: #eceae4;
    --ink-2: #a7a9ae;
    --ink-3: #75787f;
    --rule: #2c2e33;
    --panel: #1f2125;
    --accent: #d9575d;
    --accent-soft: #3a2224;
    --s-a: #2aa58f;
    --s-b: #d9575d;
    --s-c: #5e96dc;
    --s-d: #b39033;
    --focus: #5e96dc;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #17181b;
  --ink: #eceae4;
  --ink-2: #a7a9ae;
  --ink-3: #75787f;
  --rule: #2c2e33;
  --panel: #1f2125;
  --accent: #d9575d;
  --accent-soft: #3a2224;
  --s-a: #2aa58f;
  --s-b: #d9575d;
  --s-c: #5e96dc;
  --s-d: #b39033;
  --focus: #5e96dc;
}

/* Base ---------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.55;
  font-optical-sizing: auto;
  font-feature-settings: "kern", "liga", "onum" 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; text-decoration-color: var(--ink-3); }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-weight: 500; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
h1 { font-size: clamp(2rem, 1.2rem + 3.2vw, 3.4rem); font-weight: 400; max-width: 22ch; }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); margin-bottom: 1.1rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.45rem; }
p { margin: 0 0 1.05em; }
p:last-child { margin-bottom: 0; }
sub { font-size: 0.7em; line-height: 0; }
.var { font-style: italic; }
.num { font-variant-numeric: tabular-nums; }
.small, .hint, figcaption, .facts, .flip-note, .case-note, .readout-title, .var-verdict, .formula-note, .explorer-ticks, .foot, .cost, .affil, .venue {
  font-size: var(--small);
  color: var(--ink-2);
}
svg text { font-family: var(--font); }

/* Page grid ----------------------------------------------------------------- */
/* One grid for everything: [gutter] text column | side column [gutter]. */
.masthead, .section, .foot {
  display: grid;
  grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--measure)) minmax(0, 15rem) minmax(var(--gutter), 1fr);
  column-gap: 2.5rem;
  row-gap: 0;
  align-items: start;
}
.masthead > *, .section > *, .foot > * { grid-column: 2; }
.section > .side { grid-column: 3; }
.section > .wide, .masthead > .wide { grid-column: 2 / 4; }
@media (max-width: 62rem) {
  .masthead, .section, .foot { grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--measure)) minmax(var(--gutter), 1fr); column-gap: 0; }
  .section > .side { grid-column: 2; margin-top: 1.25rem; }
  .section > .wide, .masthead > .wide { grid-column: 2; }
}
.text { min-width: 0; }
.section { padding: 5.5rem 0 0; }
.section:first-of-type { padding-top: 4rem; }
main { padding-bottom: 5rem; }

/* Masthead ------------------------------------------------------------------ */
.masthead { padding: 4.5rem 0 0; }
.venue { margin-bottom: 1.4rem; }
.masthead h1 { margin-bottom: 1.6rem; }
.authors { margin-bottom: 1.1rem; line-height: 1.45; }
.affil { display: inline-block; margin-top: 0.2rem; }
.links { margin-bottom: 2.4rem; display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; }
.lede { font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.5rem); line-height: 1.42; max-width: 30em; font-style: italic; font-weight: 400; }

/* Side column ---------------------------------------------------------------- */
.side { padding-top: 0.35rem; }
.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 0.9rem; row-gap: 0.35rem; line-height: 1.4; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; color: var(--ink); }
.side-links { line-height: 1.7; }

/* Diagram -------------------------------------------------------------------- */
.diagram { margin: 2.2rem 0 0; }
.diagram figcaption { margin-top: 0.6rem; max-width: 52ch; }
.model-diagram { width: 100%; height: auto; max-width: 48rem; display: block; color: var(--ink); }
.d-accent-stroke { stroke: var(--accent); }
.d-accent-fill { fill: var(--accent); }
.d-muted { stroke: var(--ink-3); }
.d-small { fill: var(--ink-2); font-size: 12px; }

/* Charts ----------------------------------------------------------------------- */
.chart { margin: 1.3rem 0 0; }
.chart svg { display: block; width: 100%; height: auto; max-width: 40rem; overflow: visible; }
.chart figcaption { margin-top: 0.5rem; max-width: 52ch; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--ink-2); font-size: 12px; }
.chart .lab { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .lab.on { fill: var(--ink); font-weight: 500; }
.chart .baseline { stroke: var(--ink-3); stroke-width: 1; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.3rem; margin-bottom: 0.7rem; font-size: var(--small); color: var(--ink-2); }
.chart .legend span::before { content: ""; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.4em; background: var(--sw); vertical-align: -0.02em; }
.chart .guide { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .mark { stroke: var(--paper); stroke-width: 2; }
.chart .tip { fill: var(--ink); font-size: 12px; }

/* Formula ------------------------------------------------------------------------ */
.formula { margin: 1.4rem 0 1.4rem; padding: 1rem 1.2rem; background: var(--panel); border-radius: 3px; overflow-x: auto; }
.formula math { font-size: 1.15em; }
.formula-note { margin: 0.7rem 0 0; }

/* Explorer -------------------------------------------------------------------------- */
.explorer { margin: 1.4rem 0 2.4rem; display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); column-gap: 3rem; row-gap: 1.2rem; align-items: start; }
.explorer-control { grid-column: 1; }
.explorer-readout { grid-column: 1; }
.explorer .chart { grid-column: 2; grid-row: 1 / span 3; margin: 0; }
.explorer-cost { grid-column: 1; }
@media (max-width: 62rem) {
  .explorer { grid-template-columns: 1fr; }
  .explorer-control, .explorer-readout, .explorer .chart, .explorer-cost { grid-column: 1; grid-row: auto; }
}
.explorer-control label { display: block; margin-bottom: 0.5rem; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.explorer-ticks { display: flex; justify-content: space-between; padding: 0 0.3rem; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.readout { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr auto auto; column-gap: 1rem; row-gap: 0.3rem; align-items: baseline; }
.readout .k { color: var(--ink-2); }
.readout .v { font-variant-numeric: tabular-nums; font-size: 1.35rem; line-height: 1.1; }
.readout .d { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: var(--small); min-width: 5ch; text-align: right; }
.readout .d.up { color: var(--accent); }
.readout li { display: contents; }

/* BibTeX and footer ---------------------------------------------------------------- */
.bibtex { margin-top: 1.4rem; }
.bibtex summary { cursor: pointer; color: var(--ink-2); font-size: var(--small); }
.bibtex pre { font-size: 0.82rem; line-height: 1.45; background: var(--panel); padding: 0.9rem 1rem; border-radius: 3px; overflow-x: auto; margin: 0.6rem 0 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.cost { margin-top: 1.2rem; }
.foot { padding: 2rem 0 3rem; border-top: 1px solid var(--rule); }
.foot p { max-width: 60ch; }

/* Chip sets (shared by every widget) ------------------------------------------- */
.chipset { display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem; align-items: baseline; margin-bottom: 0.7rem; }
.chip {
  font: inherit; background: none; border: 0; padding: 0.1rem 0; cursor: pointer; color: var(--ink-2);
  border-bottom: 1.5px solid transparent; line-height: 1.3;
}
.chip:hover { color: var(--ink); }
.chip[aria-checked="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Granger explorer --------------------------------------------------------------- */
.granger .explorer-control { padding-top: 0.2rem; }
.granger .chart svg { max-width: 44rem; }
.granger .faint .series-line { opacity: 0.28; stroke-dasharray: 3 3; }
.readout-title { margin: 1rem 0 0.4rem; }
.readout .d { min-width: 8ch; }
.chart .axis-title { fill: var(--ink-3); font-size: 12px; }

/* VaR demo ------------------------------------------------------------------------ */
.vardemo { margin: 1.4rem 0 0; }
.vardemo .chart { margin: 0; }
.vardemo .chart svg { max-width: 44rem; }
.vardemo .ret { fill: var(--ink-2); opacity: 0.55; }
.vardemo .var-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.vardemo .hit { fill: var(--accent); stroke: var(--paper); stroke-width: 1.5; }
.var-verdict { margin-top: 0.9rem; max-width: 60ch; }
.var-count { color: var(--ink); font-size: var(--text); margin-bottom: 0.4rem; }

/* Criterion flip ------------------------------------------------------------------- */
.flipbox { margin: 1.4rem 0 2.2rem; }
.flip-scroll { overflow-x: auto; }
.flip-controls { display: flex; flex-wrap: wrap; gap: 0.2rem 2.4rem; align-items: baseline; }
.flip-grid { display: grid; grid-template-columns: minmax(9rem, 12rem) repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--rule); max-width: 46rem; }
.flip-row { display: contents; }
.flip-row > div { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--rule); min-width: 0; }
.flip-corner { color: var(--ink-3); font-size: var(--small); }
.flip-col, .flip-rowhead { font-size: var(--small); color: var(--ink-2); line-height: 1.3; }
.flip-col::before, .flip-rowhead::before { content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--sw); margin-right: 0.4em; vertical-align: 0; }
.flip-cell { font-variant-numeric: tabular-nums; color: var(--ink-2); position: relative; }
.flip-cell.good { color: var(--ink); background: color-mix(in oklab, var(--sw) calc(var(--k) * 34%), transparent); }
.flip-cell.empty { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--rule) 5px 6px); }
.flip-note { margin: 0.7rem 0 0.3rem; max-width: 60ch; }
.flip-rank { margin: 0; color: var(--ink-2); font-size: var(--small); }
.flip-rank .rank-item { white-space: nowrap; }
.flip-rank .rank-item::before { content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--sw); margin-right: 0.35em; }
@media (max-width: 40rem) {
  .flip-grid { min-width: 30rem; grid-template-columns: minmax(8rem, 10rem) repeat(4, minmax(0, 1fr)); font-size: var(--small); }
  .flip-row > div { padding: 0.5rem 0.4rem; }
}

/* Stock figure and case table ------------------------------------------------------- */
.lookbox { margin: 1.4rem 0 2.4rem; }
.look-figure { margin: 0; }
.look-figure img { display: block; width: 100%; max-width: 44rem; height: auto; aspect-ratio: 1100 / 916; border-radius: 3px; background: #fff; }
.look-figure figcaption { margin-top: 0.5rem; max-width: 60ch; }
.case { margin-top: 1.4rem; overflow-x: auto; }
.case table { border-collapse: collapse; font-size: var(--small); width: 100%; max-width: 44rem; }
.case th, .case td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.case thead th { color: var(--ink-2); font-weight: 400; line-height: 1.25; }
.case thead th[style]::before { content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--sw); margin-right: 0.4em; }
.case tbody th { font-weight: 400; color: var(--ink-2); }
.case tr.group th { padding-top: 0.9rem; color: var(--ink); font-style: italic; border-bottom: 0; }
.case td.num { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.case td.best { color: var(--ink); font-weight: 500; }
.case td.pass { color: var(--ink); }
.case td.fail { color: var(--ink-3); }
.case-note { margin: 0.6rem 0 0; }
