/*
 * The TD sheets and exams of a theme (template: sheet or exam, with a
 * 'theme:' line): a white sheet on the paper of the theme, one exercise at a
 * time. Every colour and font comes from the variables of base.css and of
 * the theme (graphite.css).
 *
 * Besides the Markdown of the slides (**notion**, `code`, > à retenir,
 * ::: remark, ::: attention, ```{.console}...), a sheet knows:
 *   {.question} or ::: question     a numbered question
 *   ::: {.correction when="correction"}   a correction (also <aside>)
 *   ::: info                       something to know, a hint
 *   ::: danger                     a serious warning
 *   ::: example                    a worked example
 *   ::: remember                   what to remember
 */

.sheet {
  --sheet-width: 1124px;      /* as the home page (home.css) */
  margin: 0;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------- header */

.sheet-header {
  max-width: var(--sheet-width);
  margin: 0 auto;
  padding: 56px 16px 0;       /* as the header of the home page */
}

.sheet-home {
  position: fixed;
  left: 22px;
  bottom: 14px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.85;
}

.sheet-home:hover {
  color: var(--heading);
  opacity: 1;
}

.sheet-kicker {
  margin: 36px 0 6px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet h1 {
  margin: 0 0 28px;
  font-family: var(--font-heading);
  font-size: clamp(34px, 6vw, 56px);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  line-height: 1;
  color: var(--heading);
  text-wrap: balance;
}

.sheet h1::after {
  content: "";
  display: block;
  width: 1.2em;
  height: 0.08em;
  margin-top: 0.3em;
  background: var(--accent);
}

/* The exercises: tabs over the sheet. */
.sheet-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-margin-top: 12px;
}

.sheet-tabs a {
  flex: none;
  padding: 10px 18px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.sheet-tabs a:hover {
  color: var(--heading);
}

/* The exercise shown: light on dark, the colour of the questions. */
.sheet-tabs a[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ---------------------------------------------------------------- sheet */

.sheet-paper {
  max-width: var(--sheet-width);
  margin: 0 auto 64px;
  padding: 40px 56px 48px;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 0 10px 10px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.sheet-tab {
  counter-reset: question;
}

.sheet-tab-label {
  margin: 0 0 4px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet h2 {
  margin: 0 0 22px;
  font-family: var(--font-heading);
  font-size: 34px;
  font-weight: var(--heading-weight);
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--heading);
}

.sheet h3 {
  margin: 32px 0 12px;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--heading);
}

.sheet p {
  margin: 0 0 14px;
}

.sheet ul,
.sheet ol {
  margin: 0 0 14px;
  padding-left: 1.3em;
}

.sheet li {
  margin: 4px 0;
}

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

.sheet strong {
  font-weight: 650;
  color: var(--strong);
}

/* Links: dark violet, underlined. */
.sheet a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.sheet a:hover {
  text-decoration-thickness: 2px;
}

/* The header (Sommaire, the tabs) is navigation, not content: no link
   colours, underlined on hover only. */
.sheet .sheet-home,
.sheet .sheet-tabs a {
  color: var(--muted);
  text-decoration: none;
}

.sheet .sheet-home:hover,
.sheet .sheet-tabs a:hover {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.sheet .sheet-tabs a[aria-selected="true"],
.sheet .sheet-tabs a[aria-selected="true"]:hover {
  color: #ffffff;
}

/* A link on code (a file to download...): the code takes the link colours. */
.sheet a code,
.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside) a code {
  background: var(--link-soft);
  color: var(--link);
}

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

.sheet code,
.sheet kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-variant-ligatures: none;
}

.sheet code {
  padding: 0.08em 0.32em;
  border-radius: 4px;
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
}

.sheet kbd {
  padding: 0.05em 0.4em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #ffffff;
}

.sheet img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
  border-radius: 8px;
}

.sheet hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 28px 0;
}

.sheet table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 14px 0 18px;
  border-collapse: collapse;
  font-size: 15px;
}

.sheet th,
.sheet td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: baseline;
}

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

/* ------------------------------------------------------------ questions */

.sheet .question {
  position: relative;
  margin: 26px 0 14px;
  padding-left: 46px;
  counter-increment: question;
  font-weight: 400;
  color: var(--heading);
}

.sheet.sheet-td .question {
  color: #000000;
}

.sheet.sheet-td .question :is(strong, b) {
  color: inherit;
}

.sheet .question::before {
  content: counter(question);
  position: absolute;
  left: 0;
  top: 0.05em;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 30px;
  text-align: center;
}

.sheet div.question > p:last-child {
  margin-bottom: 0;
}

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

.sheet pre {
  margin: 14px 0 18px;
  padding: 14px 18px;
  overflow: auto;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.55;
  tab-size: 4;
  font-variant-ligatures: none;
}

.sheet pre.prettyprint {
  padding: 14px 18px;
  border: 1px solid var(--code-border);
}

.sheet pre mark {
  background: var(--code-mark);
}

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

.sheet pre.console::before {
  content: "Sortie";
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.55;
}

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

/* Line numbers (themed.html.j2 numbers every block of more than one line). */
.sheet pre ol.linenums {
  margin: 0;
  padding: 0 0 0 3em;
  list-style: decimal;
}

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

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

.sheet pre.single-line ol.linenums > li::marker {
  color: transparent;
}

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

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

.sheet blockquote {
  margin: 18px 0;
  padding: 12px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-weight: 600;
  color: var(--heading);
}

.sheet blockquote p:last-child {
  margin: 0;
}

.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside) {
  margin: 18px 0;
  padding: 12px 18px;
  border-left: 4px solid var(--box);
  border-radius: 0 8px 8px 0;
  background: var(--box-soft);
}

.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside)::before {
  content: var(--box-label);
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--box);
}

.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside) > :last-child {
  margin-bottom: 0;
}

.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside) :is(pre, code) {
  background: #ffffff;
}

.sheet :is(.attention, .danger, .info, .remark, .example, .remember, .correction, .answer, aside) pre.console {
  background: var(--console-bg);
}

.sheet .example { --box: var(--muted); --box-soft: var(--accent-soft); --box-label: "Exemple"; }
.sheet .remember { --box: var(--accent); --box-soft: var(--accent-soft); --box-label: "À retenir"; }
.sheet .attention { --box: var(--warn); --box-soft: var(--warn-soft); --box-label: "Attention"; }
.sheet .danger { --box: #b42318; --box-soft: #fdeeec; --box-label: "Danger"; }
.sheet .info { --box: var(--note); --box-soft: var(--note-soft); --box-label: "À savoir"; }
.sheet .remark { --box: var(--note); --box-soft: var(--note-soft); --box-label: "Remarque"; }
.sheet .answer { --box: var(--answer); --box-soft: var(--answer-soft); --box-label: "Réponse"; }
.sheet :is(.correction, aside) { --box: var(--answer); --box-soft: var(--answer-soft); --box-label: "Correction"; }

.sheet.sheet-td .info::before {
  display: none;
}

/* --------------------------------------------------------------- phones */

@media (max-width: 720px) {
  .sheet {
    font-size: 16px;
  }

  .sheet-header {
    padding-top: 32px;
  }

  .sheet-kicker {
    margin-top: 24px;
  }

  .sheet-paper {
    margin: 0 0 32px;
    padding: 24px 16px 28px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .sheet h2 {
    font-size: 28px;
  }

  .sheet .question {
    padding-left: 40px;
  }

  .sheet pre {
    font-size: 13px;
    padding: 12px 14px;
  }

  .sheet pre.linenums {
    background-image: linear-gradient(to right, var(--gutter) 0 calc(14px + 2.7em), transparent calc(14px + 2.7em));
  }
}

/* ---------------------------------------------------------------- print */

@media print {
  .sheet,
  body.sheet {
    background: #ffffff;
    font-size: 11pt;
  }

  .sheet-home,
  .sheet-tabs {
    display: none;
  }

  .sheet-paper {
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  /* Every exercise, one after the other. */
  .sheet-tab[hidden] {
    display: block;
  }

  .sheet-tab + .sheet-tab {
    break-before: page;
  }

  .sheet pre {
    white-space: pre-wrap;
    break-inside: avoid;
  }
}
