/*
 * What every slide theme shares: the layout of a slide, and how each piece of
 * Markdown looks. A theme (graphite.css) loads its fonts, sets
 * the variables below, and adds its own touches.
 *
 * The Markdown of a deck says what a thing is, never which colour it is:
 *   **notion**          a key term, in the accent colour
 *   *insistance*        italic
 *   `code`              code in the text
 *   [texte]{.mark}      highlighted
 *   > phrase            what to remember
 *   ::: remark          a side note          ::: attention   a warning
 *   ::: answer          the answer to a question asked on the slide
 *   ::: remember        what to remember (as > phrase, with a label)
 *   ```{.console}       the output of a program
 *   # Titre             a cover or a section divider (the slide holds a h1)
 */

:root {
  --bg: #fff;
  --fg: #1f2328;
  --muted: #5b6470;
  --heading: #111;
  --accent: #2563eb;
  --accent-soft: #eef3ff;
  --strong: var(--accent);
  --rule: #e3e6ea;
  --warn: #c2410c;
  --warn-soft: #fff4ec;
  --note: #2f6fdb;
  --note-soft: #eef4fe;
  --answer: #2f7d4f;
  --answer-soft: #edf6f0;
  --mark: #fff1a8;
  --mark-fg: inherit;
  --link: var(--accent);
  --link-soft: var(--accent-soft);

  --font-body: system-ui, sans-serif;
  --font-heading: var(--font-body);
  --font-mono: ui-monospace, Consolas, monospace;
  --size: 28px;
  --line: 1.45;
  --heading-weight: 700;
  --heading-tracking: -0.015em;
  --h1: 2.4em;
  --h2: 1.45em;
  --radius: 8px;

  --code-bg: #f6f8fa;
  --code-fg: #1f2328;
  --code-border: #e3e6ea;
  --code-size: 0.7em;
  --code-mark: #fde68a;
  --inline-code-bg: #eff1f3;
  --inline-code-fg: inherit;
  --console-bg: #1f2328;
  --console-fg: #e6edf3;

  --tok-kwd: #cf222e;
  --tok-typ: #8250df;
  --tok-str: #0a3069;
  --tok-com: #6e7781;
  --tok-lit: #0550ae;
  --tok-pun: inherit;
  --tok-fun: #8250df;

  --img-bg: transparent;

  /* Mermaid diagrams: a group (a process...) holds nodes (threads...). */
  --diagram-group-bg: var(--accent-soft);
  --diagram-group-border: var(--muted);
  --diagram-node-bg: #ffffff;
  --diagram-node-border: var(--accent);
  --diagram-current: var(--note);
  --diagram-scale: 1.5;
  --line-number: #a3a9b0;
  --gutter: #f0f1f3;
  --footer: var(--muted);

  /* The tags Cours, TD, EXAM (.home-label, below). */
  --label-cours: #34506b;
  --label-td: #3b6150;
  --label-td-soft: #eef4f1;
  --label-exam: var(--warn);
}

/* reveal.js gives the page (.reveal-viewport) a white background. */
body,
body.reveal-viewport {
  background-color: var(--bg);
}

/* ------------------------------------------------------------------ tags */

/* Cours, TD, EXAM (the 'label' of the items in the session.yaml files and
   the plans), on the home page and in the results of the search: a small
   tag; lectures filled, TDs outlined, exams in orange. */
.home-label {
  --tag: var(--muted);
  justify-self: start;
  min-width: 44px;
  padding: 2px 7px;
  box-sizing: border-box;
  border: 1px solid var(--tag);
  border-radius: 5px;
  background: #ffffff;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  color: var(--tag);
  transition: background-color 0.12s, color 0.12s;
}

/* Each kind its colour: dark slate blue, dark slate green, the warning orange. */
.home-label[data-label="Cours"] { --tag: var(--label-cours); }
.home-label[data-label="TD"] { --tag: var(--label-td); }
.home-label[data-label="EXAM"] { --tag: var(--label-exam); }

/* ---------------------------------------------------------------- slide */

.reveal {
  font-family: var(--font-body);
  font-size: var(--size);
  line-height: var(--line);
  color: var(--fg);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.reveal ::selection {
  background: var(--accent-soft);
}

.reveal .slides {
  text-align: left;
}

/* Slides are shown as flex columns (display: 'flex' in Reveal.initialize). */
.reveal .slides > section,
.reveal .slides > section > section {
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 60px 84px 76px;
  line-height: var(--line);
}

/* The column never squeezes its content. A slide that is too long gets
   shorter images or scrolling code blocks (themed.html.j2). */
.reveal .slides > section > * {
  flex-shrink: 0;
}

/* A slide holding a h1 is a cover or a section divider: centred vertically. */
.reveal .slides > section:has(> h1) {
  justify-content: center;
}

/* ------------------------------------------------------------- headings */

.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4 {
  margin: 0 0 0.6em;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  line-height: 1.12;
  color: var(--heading);
  text-transform: none;
  text-shadow: none;
  word-wrap: break-word;
}

.reveal h1 { font-size: var(--h1); }
.reveal h2 { font-size: var(--h2); }
.reveal h3 { font-size: 1.1em; }
.reveal h4 { font-size: 1em; }

/* The subtitle under a cover title. */
.reveal h1 + h2 {
  font-size: 1.1em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.reveal h2 code,
.reveal h1 code {
  font-size: 0.9em;
  background: none;
  padding: 0;
  color: inherit;
}

/* ----------------------------------------------------------------- text */

.reveal p {
  margin: 0 0 0.65em;
  line-height: var(--line);
}

.reveal ul,
.reveal ol {
  display: block;
  margin: 0 0 0.65em;
  padding-left: 1.15em;
}

.reveal li {
  margin: 0.18em 0;
  padding-left: 0.15em;
}

.reveal li::marker {
  color: var(--accent);
}

.reveal ul ul,
.reveal ul ol,
.reveal ol ul,
.reveal ol ol {
  margin: 0.15em 0 0.2em;
  padding-left: 1.1em;
  font-size: 0.92em;
}

.reveal strong,
.reveal b {
  font-weight: 650;
  color: var(--strong);
}

.reveal em {
  font-style: italic;
}

.reveal a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

/* A link on code: the code takes the colours of links. */
.reveal a code {
  background: var(--link-soft);
  color: var(--link);
}

.reveal mark {
  background: var(--mark);
  color: var(--mark-fg);
  padding: 0 0.15em;
  border-radius: 3px;
}

.reveal code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  padding: 0.06em 0.3em;
  border-radius: 4px;
  font-variant-ligatures: none;
}

.reveal strong code {
  color: inherit;
}

/* --------------------------------------------------------------- blocks */

/* What to remember. */
.reveal blockquote {
  width: auto;
  margin: 0.8em 0;
  padding: 0.55em 0.9em;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  box-shadow: none;
  font-style: normal;
  font-weight: 600;
  color: var(--heading);
}

.reveal blockquote p {
  margin: 0;
}

.reveal .remark,
.reveal .attention,
.reveal .answer,
.reveal .remember {
  margin: 0.9em 0;
  padding: 0.55em 0.9em;
  border-radius: var(--radius);
  font-size: 0.8em;
}

.reveal .remark::before,
.reveal .attention::before,
.reveal .answer::before,
.reveal .remember::before {
  display: block;
  margin-bottom: 0.15em;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* A side note: built like a warning, in its own colour. */
.reveal .remark {
  background: var(--note-soft);
  border-left: 4px solid var(--note);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}

.reveal .remark::before {
  content: "Remarque";
  color: var(--note);
}

.reveal .attention {
  background: var(--warn-soft);
  border-left: 4px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}

.reveal .attention::before {
  content: "Attention";
  color: var(--warn);
}

.reveal .attention strong {
  color: var(--warn);
}

/* What to remember: built like a warning, in the colours of a quote (>). */
.reveal .remember {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}

.reveal .remember::before {
  content: "À retenir";
  color: var(--accent);
}

/* The answer to a question asked on the slide. */
.reveal .answer {
  background: var(--answer-soft);
  border-left: 4px solid var(--answer);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}

.reveal .answer::before {
  content: "Réponse";
  color: var(--answer);
}

.reveal .remark p,
.reveal .attention p,
.reveal .answer p,
.reveal .remember p {
  margin: 0;
}

/* ----------------------------------------------------------------- code */

.reveal pre {
  width: 100%;
  box-sizing: border-box;
  margin: 0.35em 0 0.7em;
  padding: 0.75em 1.05em;
  font-family: var(--font-mono);
  font-size: var(--code-size);
  line-height: 1.55;
  text-align: left;
  white-space: pre;
  tab-size: 4;
  -moz-tab-size: 4;
  overflow: auto;
  /* A block that would not fit becomes shorter and scrolls (themed.html.j2). */
  color: var(--code-fg);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  box-shadow: none;
  word-wrap: normal;
  font-variant-ligatures: none;
}

.reveal pre.prettyprint {
  padding: 0.8em 1.05em;
  border: 1px solid var(--code-border);
}

.reveal pre mark {
  background: var(--code-mark);
  color: inherit;
  padding: 0.05em 0.2em;
  border-radius: 3px;
}

.reveal pre.console {
  background: var(--console-bg);
  color: var(--console-fg);
  border-color: var(--console-bg);
}

.reveal pre.console::before {
  content: "Sortie";
  display: block;
  margin-bottom: 0.3em;
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}

.reveal pre .pln { color: var(--code-fg); }
.reveal pre .kwd { color: var(--tok-kwd); }
.reveal pre .typ { color: var(--tok-typ); }
.reveal pre .str { color: var(--tok-str); }
.reveal pre .com { color: var(--tok-com); font-style: italic; }
.reveal pre .lit { color: var(--tok-lit); }
.reveal pre .pun,
.reveal pre .opn,
.reveal pre .clo { color: var(--tok-pun); }
.reveal pre .fun,
.reveal pre .atn,
.reveal pre .dec { color: var(--tok-fun); }
.reveal pre.console span { color: inherit; }

/* Line numbers (themed.html.j2 numbers every code block). */
.reveal pre ol.linenums {
  margin: 0;
  padding: 0 0 0 3em;
  list-style: decimal;
}

.reveal pre ol.linenums > li {
  margin: 0;
  padding: 0 0 0 0.5em;
  list-style-type: decimal;
  background: none;
}

.reveal pre ol.linenums > li::marker {
  color: var(--line-number);
  font-size: 0.85em;
}

/* The numbers sit in a light grey column, as tall as the block (and moving
   with its content when it scrolls). */
.reveal pre.linenums {
  background-image: linear-gradient(to right, var(--gutter) 0 calc(1.05em + 2.7em), transparent calc(1.05em + 2.7em));
  background-attachment: local;
}

/* --------------------------------------------------------------- images */

.reveal section img {
  display: block;
  max-width: 100%;
  max-height: 400px;
  height: auto;
  margin: 0.3em auto 0.5em;
  border: 0;
  box-shadow: none;
  background: var(--img-bg);
  border-radius: var(--radius);
}

.reveal section img[height] {
  height: auto;
  max-height: 400px;
}

/* ------------------------------------------------------ mermaid diagrams */

/*
 * A ```mermaid block is replaced by its drawing when the page loads. Its
 * classes (`class P process`) pick the look of a group or a node:
 *   process   a group drawn as the container (a process, the heap...)
 *   thread    a group or node in the accent colour (a thread...)
 *   current   the line being executed: tinted, with a coloured edge
 *   ellipsis  "⋮" and the like: no box
 */
.reveal pre.mermaid {
  visibility: hidden;
}

.reveal .mermaid-measure {
  position: absolute;
  top: 0;
  left: -10000px;
  visibility: hidden;
}

.reveal .mermaid-figure {
  display: flex;
  justify-content: center;
  margin: 0.4em 0 0.8em;
}

.reveal .mermaid-figure svg {
  height: auto;
}

/* Mermaid makes the box of a label exactly as wide as its text, measured
   once: a text drawn a fraction of a pixel wider (rounding under the scale
   of the slide...) is not cut at its last letter. */
.reveal .mermaid-figure foreignObject {
  overflow: visible;
}

.reveal .mermaid-figure p,
.reveal .mermaid-measure p {
  margin: 0;
  line-height: 1.4;
}

.reveal .mermaid-figure code,
.reveal .mermaid-measure code {
  background: none;
  padding: 0;
  font-size: 0.95em;
  color: var(--fg);
}

.reveal .mermaid-figure .cluster.process > rect {
  fill: var(--diagram-group-bg) !important;
  stroke: var(--diagram-group-border) !important;
  stroke-width: 1.5px !important;
}

.reveal .mermaid-figure .cluster.process .cluster-label * {
  color: var(--muted) !important;
}

.reveal .mermaid-figure .cluster.thread > rect,
.reveal .mermaid-figure .node.thread > rect {
  fill: var(--diagram-node-bg) !important;
  stroke: var(--diagram-node-border) !important;
  stroke-width: 2.5px !important;
}

/* What changes the size of a label applies where it is measured too. */
.reveal .mermaid-figure .cluster.thread .cluster-label *,
.reveal .mermaid-figure .node.thread .label * {
  color: var(--strong) !important;
}

.reveal :is(.mermaid-figure, .mermaid-measure) :is(.cluster, .node).thread :is(.label, .cluster-label) * {
  font-weight: 650;
}

.reveal :is(.mermaid-figure, .mermaid-measure) .node.ellipsis .label * {
  font-size: 1.5em;
  line-height: 1;
}

.reveal .mermaid-figure .node.ellipsis > rect {
  fill: none !important;
  stroke: none !important;
}

.reveal .mermaid-figure .node.ellipsis .label * {
  color: var(--muted) !important;
}

.reveal .mermaid-figure .node.current > rect {
  fill: var(--note-soft) !important;
  stroke: var(--diagram-current) !important;
  stroke-width: 2px !important;
}

/* Producer/consumer diagrams: actors stay distinct without depending on the
   slide theme's exact palette. */
.reveal .mermaid-figure .node.producer > rect {
  fill: var(--note-soft) !important;
  stroke: var(--note) !important;
  stroke-width: 2px !important;
}

.reveal .mermaid-figure .node.consumer > rect {
  fill: var(--warn-soft) !important;
  stroke: var(--warn) !important;
  stroke-width: 2px !important;
}

.reveal .mermaid-figure .node.queue > rect {
  fill: var(--answer-soft) !important;
  stroke: var(--answer) !important;
  stroke-width: 2.5px !important;
}

/* Two successive diagrams can reserve the same room for labels while one of
   them keeps that information hidden. This prevents Mermaid from moving the
   corresponding nodes between the slides. */
.reveal :is(.mermaid-figure, .mermaid-measure) .diagram-overlay {
  display: grid;
  place-items: center;
}

.reveal :is(.mermaid-figure, .mermaid-measure) .diagram-overlay > span {
  grid-area: 1 / 1;
}

.reveal :is(.mermaid-figure, .mermaid-measure) .diagram-placeholder {
  visibility: hidden;
}

.reveal .mermaid-figure .node.unknown > rect {
  fill: none !important;
  stroke: none !important;
}

/* Enlarge the question mark without changing the shared diagram layout. */
.reveal .mermaid-figure .node.unknown .diagram-overlay > span:first-child {
  transform: scale(4);
  transform-origin: center;
}

.reveal .mermaid-figure .edgeLabel:has(.diagram-placeholder) {
  background: transparent !important;
}

.reveal :is(.mermaid-figure, .mermaid-measure) .node:is(.producer, .consumer, .queue) .label * {
  font-weight: 650;
}

/* The arrows of a line "%% arrows: a1 c1 b1" (the order the scheduler chose...). */
.reveal .mermaid-figure .extra-arrow {
  fill: none;
  stroke: var(--diagram-current);
  stroke-width: 3px;
  stroke-linecap: round;
}

.reveal .mermaid-figure .extra-arrow-head path {
  fill: var(--diagram-current);
}

/* --------------------------------------------------------------- tables */

.reveal table {
  margin: 0.4em 0 0.9em;
  border-collapse: collapse;
  font-size: 0.82em;
}

.reveal th,
.reveal td {
  padding: 0.4em 0.9em;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: baseline;
}

.reveal thead th {
  border-bottom: 2px solid var(--accent);
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--heading);
}

/* --------------------------------------------- older decks: .blue, .red... */

.reveal .blue { color: var(--accent); font-weight: 600; }
.reveal .red { color: var(--warn); font-weight: 600; }
.reveal .green { color: var(--muted); }

/* ------------------------------------------------- credits, footer, chrome */

.reveal .authorsList {
  display: block;
  margin-top: 1.6em;
  font-size: 0.62em;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.reveal .authorsList::before {
  content: "A. Carayol, C. Pivoteau et P. Rotondo";
}

.reveal .deck-footer {
  position: absolute;
  left: 22px;
  right: 130px;
  bottom: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1;
  color: var(--footer);
  letter-spacing: 0.02em;
}

.reveal .deck-home {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
  opacity: 0.85;
}

.reveal .deck-home:hover {
  color: var(--accent);
  opacity: 1;
}

.reveal .deck-title {
  flex: 1;
}

.reveal .deck-counter {
  font-variant-numeric: tabular-nums;
}

.reveal.on-cover .deck-title,
.reveal.on-cover .deck-counter {
  visibility: hidden;
}

.reveal .progress {
  height: 3px;
  color: var(--accent);
  background: transparent;
}

.reveal .controls {
  color: var(--accent);
}

.reveal .controls button {
  opacity: 0.55;
}

.reveal .controls button:hover {
  opacity: 1;
}

/* PDF export: no chrome. */
@media print {
  .reveal .deck-footer { display: none; }
}
