/* the palette of dmeoli.github.io */
:root {
  --ground: #e8e2f3; --ink: #2e2040; --ink-soft: #5f4b76; --rule: #d4c9e6;
  --accent: #7338a8; --accent-2: #9363be; --lilac: #d4b9eb; --gold: #6c5920;
  --panel: #f2edf8;
}
/* dark with the system, unless the reader chose a theme on the site (theme.js
   copies that choice into data-theme, since the pages share its origin) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #262235; --ink: #f6effc; --ink-soft: #c9bdd7; --rule: #4a4463;
    --accent: #d4b9eb; --accent-2: #b98ee6; --lilac: #4e2c72; --gold: #b59a45;
    --panel: #302c44;
  }
}
:root[data-theme="dark"] {
  --ground: #262235; --ink: #f6effc; --ink-soft: #c9bdd7; --rule: #4a4463;
  --accent: #d4b9eb; --accent-2: #b98ee6; --lilac: #4e2c72; --gold: #b59a45;
  --panel: #302c44;
}
* { box-sizing: border-box; }
body {
  margin: 0 auto; max-width: 1080px; padding: 24px 16px 40px;
  background: var(--ground); color: var(--ink);
  font: 17px/1.5 Spectral, Georgia, serif;
}
h1 { font-weight: 600; margin: 0 0 6px; color: var(--accent); }
.lede { margin: 0 0 18px; color: var(--ink-soft); max-width: 72ch; }
/* the control bar of every scene: the parameters (.settings) on the left, in
   the order of the page, wrapping among themselves; at the right end the
   transport, always Reset, Step, Play (Pause while running), with the counter
   of the iterations before the buttons; a secondary action (Regenerate, New
   weights, Export trace) sits next to the parameter it acts on, and a .row is
   a full line under the bar */
.controls {
  display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: end;
  font: 13px/1.3 'IBM Plex Mono', monospace; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px;
}
.settings { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: end; flex: 1 1 0; min-width: 0; }
.controls label { display: grid; gap: 4px; min-width: 0; max-width: 100%; }
.controls select { max-width: 100%; min-width: 0; }
/* a slider with its value: the value on the right of the slider, as in .params */
.controls label:has(> input[type=range]) { grid-template-columns: auto auto; align-items: center; column-gap: 8px; justify-content: start; }
.controls label:has(> input[type=range]) > span { grid-column: 1 / -1; }
.controls label > output { min-width: 3.5ch; }
.transport { display: flex; flex-wrap: nowrap; gap: 8px; align-items: end; margin-left: auto; flex: none; }
.transport #play { min-width: 5.2em; }
.counter { margin-right: 6px; }
.counter output { font: 500 18px/1.2 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; min-width: 4ch; }
.controls > .row { flex-basis: 100%; }
@media (max-width: 640px) { .settings { flex-basis: 100%; } }
.inline { display: flex; gap: 8px; align-items: end; }
.controls span { text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-size: 11px; }
.params { display: flex; gap: 18px; flex-wrap: wrap; }
.params label { grid-template-columns: auto auto; align-items: center; column-gap: 8px; }
.params span { grid-column: 1 / -1; }
select, button {
  font: inherit; color: var(--ink); background: var(--ground);
  border: 1px solid var(--rule); border-radius: 6px; padding: 5px 9px;
}
button { cursor: pointer; }
input[type=file] { font: inherit; color: var(--ink-soft); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; color: var(--ink); background: var(--ground); cursor: pointer;
  border: 1px solid var(--rule); border-radius: 6px; padding: 5px 9px; margin-right: 8px;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }
button:hover { border-color: var(--accent); color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 120px; }
.explain { color: var(--ink-soft); font-style: italic; margin: 12px 0; min-height: 3em; }
main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
main > * { min-width: 0; }
@media (max-width: 860px) { main { grid-template-columns: 1fr; } }
figure { margin: 0; }
figcaption { font-size: 14px; color: var(--ink-soft); margin-bottom: 6px; min-height: 5.5em; }
svg { width: 100%; height: auto; display: block; }
.stats { display: flex; gap: 22px; font: 13px 'IBM Plex Mono', monospace; margin: 8px 0 0; }
.stats dt { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stats dd { margin: 0; }
footer { margin-top: 28px; font: 12px 'IBM Plex Mono', monospace; color: var(--ink-soft); }
.k { display: inline-block; width: 10px; height: 10px; vertical-align: middle; }
.k.dw { border-radius: 50%; background: var(--gold); }
.k.opt { transform: rotate(45deg); border: 2px solid var(--accent); }

/* drawing */
.grid { stroke: var(--rule); stroke-width: 1; }
.axis { stroke: var(--ink-soft); stroke-width: 1; }
.tick, .lab { font: 11px 'IBM Plex Mono', monospace; fill: var(--ink-soft); }
.tick { text-anchor: middle; }
.end { text-anchor: end; }
.infeasible { fill: var(--ink); opacity: .07; }
.coupling { stroke: var(--gold); stroke-width: 2; }
.relaxation { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; stroke-dasharray: 5 4; }
.inthull { fill: var(--lilac); opacity: .45; stroke: var(--accent-2); stroke-width: 1; }
.colhull { fill: var(--accent); opacity: .22; stroke: var(--accent); stroke-width: 2; }
.colseg { stroke: var(--accent); stroke-width: 3; opacity: .5; }
.ipt { fill: var(--ink-soft); }
.col { fill: var(--accent); stroke: var(--ground); stroke-width: 2; }
.col.hot { fill: var(--gold); }
.arrow, .tipfill { stroke: var(--ink-soft); fill: var(--ink-soft); stroke-width: 1.5; }
.opt { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.dw { fill: var(--gold); stroke: var(--ground); stroke-width: 2; }
.cut { stroke: var(--accent-2); stroke-width: 1; opacity: .35; }
.truef { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; stroke-dasharray: 4 4; }
.model { fill: none; stroke: var(--accent); stroke-width: 3; }
.prox { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 2 3; }
.center { fill: none; stroke: var(--gold); stroke-width: 2.5; }
.iter circle { fill: var(--accent); stroke: var(--ground); stroke-width: 2; cursor: pointer; }
.iter.null circle { fill: var(--ground); stroke: var(--accent); }
.iter.hot circle { fill: var(--gold); }
.gapline { fill: none; stroke: var(--accent); stroke-width: 2; }

/* the map of the multipliers: a canvas under an SVG with the same frame */
.dualbox { position: relative; }
.dualbox canvas { position: absolute; image-rendering: pixelated; border-radius: 2px; }
.dualbox svg { position: relative; }
.mapframe { fill: none; stroke: var(--rule); }
.path { fill: none; stroke: var(--ink); stroke-width: 1.5; opacity: .7; }
.star { fill: var(--gold); stroke: var(--ground); stroke-width: 1; }
.onmap { fill: var(--ink); font-weight: 500; paint-order: stroke; stroke: var(--ground); stroke-width: 3px; }
.dualbox canvas.gl { position: static; width: 100%; height: auto; cursor: grab; border-radius: 6px; }

/* the race: a second row with the primal and the dual of the second algorithm */
body:not(.racing) .race-only { display: none; }
.runname { grid-column: 1 / -1; margin: 6px 0 -10px; font: 500 13px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.runname:empty { display: none; }
.runname.b, .explain.b { color: var(--gold); }
.explain.b:empty { display: none; }
figure.wide { grid-column: 1 / -1; max-width: 640px; }
.gapline.b { stroke: var(--gold); }
.check { grid-template-columns: auto; justify-items: start; }
.params.b span { color: var(--gold); }
[hidden] { display: none !important; }
.lpregion { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 1 3; }
.lpopt { fill: none; stroke: var(--ink); stroke-width: 2; }
.ipopt { fill: var(--ink); stroke: var(--ground); stroke-width: 1.5; }
.k.lpk { border-radius: 50%; border: 2px solid var(--ink); }
.k.ipk { background: var(--ink); }
/* pages and the single stage of the polarity scene */
nav.pages { font: 12px 'IBM Plex Mono', monospace; color: var(--ink-soft); margin-bottom: 10px; }
a { color: var(--accent); }
nav.pages a { color: var(--ink-soft); text-decoration: none; }
nav.pages a[aria-current] { color: var(--accent); border-bottom: 1px solid var(--accent); }
nav.pages .group { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-right: 6px; }
nav.pages { line-height: 1.8; }
/* inside the site the overlay bar already names the scene and closes it */
.embedded nav.pages { display: none; }
/* on a phone each group stays on one line that scrolls sideways */
@media (max-width: 46rem) {
  nav.pages { white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
}
main.single { grid-template-columns: 1fr; }
.stage canvas { width: 100%; height: auto; display: block; cursor: grab; }
/* the learning scene */
#map, #curves { width: 100%; height: auto; display: block; border-radius: 6px; cursor: crosshair; }
#curves { cursor: default; }
.algos { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.algo { display: flex !important; align-items: center; gap: 6px; font-size: 12px; }
.algo i, .legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; }
.legend { list-style: none; padding: 0; margin: 8px 0; font: 12px 'IBM Plex Mono', monospace; columns: 2; }
@media (max-width: 640px) { .legend { columns: 1; } }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { font-weight: 500; margin-left: auto; padding-right: 12px; }
/* the network scene, laid out as the TensorFlow Playground: data and features,
   the network with the controls of its layers above it, the output */
body.wide { max-width: 1360px; }
.nnlayout { grid-template-columns: 220px minmax(0, 1fr) 260px; grid-template-areas: "data net out"; align-items: start; margin-top: 18px; }
.nndata { grid-area: data; } .nnmid { grid-area: net; } .nnout { grid-area: out; }
@media (max-width: 1100px) { .nnlayout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "net net" "data out"; } }
@media (max-width: 640px) { .nnlayout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "data" "net" "out"; } }
.side { display: grid; gap: 8px; align-content: start; font: 12px 'IBM Plex Mono', monospace; }
.side h3, .nethead h3 { margin: 6px 0 0; font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.side h3:first-child { margin-top: 0; }
.side label { display: grid; gap: 3px; }
.side label span { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.side input[type=range] { width: 100%; }
.side .check { display: flex; align-items: center; gap: 6px; }
.datas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 260px; }
.datas button { padding: 2px; line-height: 0; border-width: 2px; border-color: transparent; background: none; }
.datas button[aria-checked="true"] { border-color: var(--accent); }
.datas canvas { width: 100%; height: auto; border-radius: 3px; }
.feats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nethead { display: flex; align-items: center; justify-content: center; gap: 10px; }
.nethead h3 { margin: 0; }
.pm { display: inline-flex; gap: 4px; }
.pm button { padding: 0 7px; font-size: 13px; line-height: 1.4; }
.colheads { position: relative; height: 46px; margin-top: 6px; font: 11px 'IBM Plex Mono', monospace; color: var(--ink-soft); }
.colhead { position: absolute; top: 0; transform: translateX(-50%); display: grid; justify-items: center; gap: 2px; white-space: nowrap; }
.netname { margin: 4px 0 0; font: 500 12px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.netname.b, .stats.b dt { color: var(--gold); }
canvas.neuron { width: 34px; height: 34px; border-radius: 4px; border: 1px solid var(--rule); display: block; cursor: default; }
#out, #outB { width: 100%; max-width: 320px; height: auto; border-radius: 6px; }
#loss { width: 100%; max-width: 320px; height: auto; }
.nnout .stats { margin: 0; }
.placeholder { margin: 0; padding: 10px; border: 1px dashed var(--rule); border-radius: 6px; color: var(--ink-soft); font: italic 13px/1.4 Spectral, Georgia, serif; }
.big { font: 500 20px 'IBM Plex Mono', monospace; }
.mid svg { width: 100%; height: auto; }
#plane { width: 100%; height: auto; border-radius: 6px; display: block; }
/* the integer scene */
.bbopen { fill: var(--lilac); opacity: .35; stroke: var(--accent-2); stroke-dasharray: 3 3; }
.treeedge { stroke: var(--rule); stroke-width: 1.5; }
.small { font-size: 9px; }
.tnode circle { fill: var(--accent); stroke: var(--ground); stroke-width: 2; cursor: pointer; }
.tnode.integer circle { fill: var(--gold); }
.tnode.pruned circle, .tnode.infeasible circle { fill: var(--ink-soft); opacity: .5; }
.tnode.branched circle { fill: var(--accent-2); }
.tnode.hot circle { stroke: var(--ink); stroke-width: 3; }
.tval { font: 9px 'IBM Plex Mono', monospace; fill: #fff; text-anchor: middle; pointer-events: none; }
.trbox { fill: var(--gold); opacity: .08; }
#land { width: 100%; max-width: 320px; height: auto; border-radius: 6px; }
.linkhit { cursor: pointer; }
.wedit { position: absolute; z-index: 10; background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; padding: 3px; }
.wedit input { width: 80px; font: 12px 'IBM Plex Mono', monospace; }

/* components.html: the dual function and the four methods */
.dualfn { fill: none; stroke: var(--ink); stroke-width: 2; }
:root { --m1: var(--accent); --m2: var(--gold); --m3: var(--accent-2); --m4: var(--ink-soft); }

/* manifolds.html: the two planes */
#input, #hidden { width: 100%; height: auto; display: block; border-radius: 6px; }
#arrows, #gram, #bars { width: 100%; height: auto; display: block; border-radius: 6px; }
#bars { margin-top: 8px; }
/* the formulas (MathJax) keep their letters inside the uppercase labels */
mjx-container { text-transform: none; letter-spacing: normal; }
mjx-container[display="true"] { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.stats dt mjx-container, .controls span mjx-container, .side label span mjx-container { font-size: 125%; }

/* two languages, as on the site: the text not of the language chosen is hidden
   (theme.js sets data-lang from the choice made on dmeoli.github.io) */
:root:not([data-lang="it"]) [data-l="it"], :root[data-lang="it"] [data-l="en"] { display: none !important; }
/* the bar of a scene opened on its own: back to the site, language, theme */
.scenebar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin: -8px 0 8px;
  font: 12px 'IBM Plex Mono', monospace; color: var(--ink-soft); }
.scenebar .home { margin-right: auto; color: var(--ink-soft); text-decoration: none; }
.scenebar .home:hover { color: var(--accent); }
.scenebar button { font: inherit; color: var(--ink-soft); background: none; border: 0; border-bottom: 1px solid transparent; border-radius: 0; padding: 2px 3px; cursor: pointer; }
.scenebar button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.scenebar button:hover { color: var(--accent); }
.scenebar .theme { font-size: 14px; margin-left: 6px; }
/* bilingual text inside a button of the bar keeps the look of the button */
.controls button span { text-transform: none; letter-spacing: normal; font-size: inherit; color: inherit; }
