/* MesoNotes website — the user guide (on top of style.css). The same page is printed into the PDF: see @media print. */
:root { --warn: #b45309; --tip: #0e7c66; --code-bg: #e8ecf2; }
@media (prefers-color-scheme: dark) { :root { --warn: #f1c21b; --tip: #42be9c; --code-bg: #262626; } }

html { scroll-behavior: smooth; scroll-padding-top: 20px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.langs a { font: 700 0.875rem/1 var(--text); color: var(--muted); text-decoration: none; border-radius: 999px; padding: 7px 12px; }
.langs a[aria-current='true'] { background: var(--ink); color: var(--bg); }

/* the title block */
.cover { padding-block: 28px 36px; border-bottom: 1px solid var(--line); }
.cover > img, .cover-name { display: none; }
.cover h1 { font: 800 clamp(2.4rem, 6vw, 4rem)/1 var(--display); font-stretch: 78%; letter-spacing: -0.01em; margin: 0 0 16px; }
.cover-lead { font-size: 1.1875rem; color: var(--muted); max-width: 40rem; margin: 0 0 14px; }
.cover-meta { color: var(--muted); font-size: 0.9375rem; margin: 0 0 20px; }
.cover-actions { margin: 0; }

/* contents on the left, text on the right */
.layout { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: 56px; align-items: start; padding-block: 32px 56px; }
.toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; font-size: 0.9375rem; padding-right: 4px; }
.toc summary { font: 700 0.8125rem/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; list-style: none; cursor: default; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc-list > li { margin-bottom: 2px; }
.toc a { display: flex; gap: 8px; padding: 5px 8px; border-radius: 7px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.toc a:hover { background: var(--surface); }
.toc .num { flex: none; width: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.toc ol ol { display: none; margin: 2px 0 6px calc(1.4em + 16px); border-left: 1px solid var(--line); }
.toc ol ol a { color: var(--muted); padding: 3px 10px; font-size: 0.875rem; }
.toc li.here > a { background: var(--surface); box-shadow: inset 2px 0 0 var(--link); font-weight: 700; }
.toc li.here > ol { display: block; }
.toc ol ol a.here { color: var(--ink); }

/* search (in the contents column): the results take the place of the contents while something is typed */
:root { --mark: #ffe27a; --mark-ink: #161616; }
@media (prefers-color-scheme: dark) { :root { --mark: #7a5c00; --mark-ink: #fff; } }
.gsearch { position: relative; margin-bottom: 18px; }
.gsearch input { width: 100%; box-sizing: border-box; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 36px 9px 12px; appearance: none; }
.gsearch input::-webkit-search-cancel-button { display: none; }
.gsearch input::placeholder { color: var(--muted); opacity: 1; }
.gsearch input:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.gs-key, .gs-clear { position: absolute; top: 8px; right: 8px; }
.gs-key { pointer-events: none; color: var(--muted); }
.gsearch input:focus ~ .gs-key { display: none; }
.gs-clear { width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--muted); font: 400 20px/1 var(--text); cursor: pointer; }
.gs-clear:hover { background: var(--line); color: var(--ink); }
.gsearch:has(.gs-clear:not([hidden])) .gs-key { display: none; }
.gs-status { margin: 12px 2px 6px; font-size: 0.8125rem; color: var(--muted); }
.gs-list { list-style: none; margin: 0; padding: 0; }
.gs-list li { margin-bottom: 2px; }
.gs-list a { display: block; padding: 7px 8px; border-radius: 7px; color: var(--ink); text-decoration: none; }
.gs-list a:hover, .gs-list a.sel { background: var(--surface); box-shadow: inset 2px 0 0 var(--link); }
.gs-where { display: block; font-weight: 700; font-size: 0.8438rem; line-height: 1.3; }
.gs-snip { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8438rem; line-height: 1.4; overflow-wrap: anywhere; }
.gs-list mark, mark.gs-mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 1px; }
.toc.searching details { display: none; }
.gs-hit { animation: gs-hit 2.4s ease-out; border-radius: 6px; }
@keyframes gs-hit { 0%, 35% { background: color-mix(in srgb, var(--mark) 45%, transparent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--mark) 45%, transparent); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .gs-hit { animation: none; outline: 2px solid var(--mark); outline-offset: 4px; } }

/* the text */
.doc-guide { min-width: 0; max-width: 50rem; }
.doc-guide p, .doc-guide li { line-height: 1.68; }
.doc-guide section.chapter { padding-block: 0 8px; border-top: 0; }
.doc-guide section.chapter + section.chapter { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line); }
.doc-guide h2 { display: flex; align-items: baseline; gap: 14px; margin: 0 0 18px; }
.doc-guide h2 .num { flex: none; font: 800 0.6em/1 var(--display); color: var(--link); border: 2px solid currentColor; border-radius: 9px; padding: 5px 9px; transform: translateY(-0.18em); font-variant-numeric: tabular-nums; }
.doc-guide h3 { font: 700 1.3125rem/1.25 var(--display); margin: 36px 0 10px; }
.doc-guide ul, .doc-guide ol { padding-left: 1.35em; }
.doc-guide li { margin-bottom: 6px; }
.doc-guide li > ul, .doc-guide li > ol { margin-top: 6px; }
.doc-guide code { background: var(--code-bg); border-color: transparent; overflow-wrap: anywhere; }
.doc-guide em { font-style: normal; font-weight: 700; color: var(--ink); } /* names of buttons and menus */
.doc-guide blockquote { margin: 16px 0; padding-left: 16px; border-left: 3px solid var(--line); color: var(--muted); }

.keys { white-space: nowrap; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; text-align: center;
  font: 700 0.8125em/1.5 ui-monospace, 'JetBrains Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
}

.callout { margin: 20px 0; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 8px; }
.callout > :last-child { margin-bottom: 0; }
.callout p { margin: 0 0 8px; }
.callout-title { font: 700 0.8125rem/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.callout.tip { border-left-color: var(--tip); }
.callout.tip .callout-title { color: var(--tip); }
.callout.warn { border-left-color: var(--warn); }
.callout.warn .callout-title { color: var(--warn); }

.table { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table table { border-collapse: collapse; width: 100%; font-size: 0.9688rem; }
.table th, .table td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--line); line-height: 1.5; }
.table th { font: 700 0.8125rem/1.3 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { white-space: nowrap; }
@media (max-width: 760px) { .table td:first-child { white-space: normal; } }

/* pictures: the app's own window, framed like on the front page */
figure { margin: 24px 0 28px; }
figure .zoom { display: block; width: 100%; padding: 4px; border: 0; border-radius: 14px; background: var(--ribbon); box-shadow: 0 24px 48px -30px var(--glow); cursor: zoom-in; }
figure .zoom img { width: 100%; border-radius: 10px; background: #161616; }
figcaption { margin-top: 10px; color: var(--muted); font-size: 0.9063rem; }

.back { margin-top: 48px; font-size: 0.9375rem; }

.lightbox { padding: 0; border: 0; background: none; max-width: 96vw; max-height: 96vh; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.82); }
.lightbox img { max-width: 96vw; max-height: 94vh; width: auto; height: auto; border-radius: 10px; cursor: zoom-out; }
.lightbox-close { position: fixed; top: 14px; right: 18px; width: 40px; height: 40px; border: 0; border-radius: 50%; font: 400 26px/1 var(--text); color: #fff; background: rgba(255, 255, 255, 0.16); cursor: pointer; }

@media screen and (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding-top: 20px; }
  .toc { position: static; max-height: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 12px 14px; }
  .toc summary { margin: 0; cursor: pointer; }
  .toc details[open] summary { margin-bottom: 12px; }
  .toc li.here > a { background: none; box-shadow: none; font-weight: 400; }
  .toc li.here > ol { display: none; }
  .gsearch { margin-bottom: 12px; }
  .gs-list { max-height: 55vh; overflow-y: auto; }
}

/* ---------- the PDF ---------- */
@page { size: A4; margin: 18mm 17mm 20mm; }
@media print {
  :root { --bg: #fff; --surface: #f4f6f9; --ink: #161616; --muted: #4a4a4a; --link: #0f62fe; --line: #d5dae1; --warn: #b45309; --tip: #0e7c66; --code-bg: #eceff4; color-scheme: light; }
  html { font-size: 10.5pt; }
  body { background: #fff; }
  .wrap { width: auto; }
  .top, .cover-actions, .back, .lightbox, .gsearch, footer p a[href^='privacy'] { display: none !important; }
  .toc.searching details { display: block; }
  a { color: inherit; text-decoration: none; }

  /* the first page */
  .cover { height: 245mm; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; border: 0; padding: 0; break-after: page; }
  .cover > img { display: block; width: 30mm; height: 30mm; margin-bottom: 6mm; }
  .cover-name { display: block; font: 800 20pt/1 var(--display); margin: 0 0 22mm; }
  .cover h1 { font-size: 40pt; margin-bottom: 8mm; }
  .cover-lead { font-size: 13pt; max-width: 130mm; }
  .cover-meta { font-size: 10.5pt; margin-top: 4mm; }

  /* the contents page */
  .layout { display: block; padding: 0; }
  .toc { position: static; max-height: none; overflow: visible; break-after: page; font-size: 10.5pt; }
  .toc summary { font-size: 20pt; letter-spacing: 0; text-transform: none; color: var(--ink); margin-bottom: 8mm; }
  .toc-list { columns: 2; column-gap: 12mm; }
  .toc-list > li { break-inside: avoid; margin-bottom: 2.5mm; }
  .toc a { padding: 1px 0; }
  .toc ol ol { display: block; border: 0; margin: 0 0 0 calc(1.4em + 8px); }
  .toc ol ol a { font-size: 9pt; padding: 0; }
  .toc li.here > a { background: none; box-shadow: none; font-weight: 400; }

  .doc-guide { max-width: none; }
  .doc-guide section.chapter + section.chapter { margin-top: 9mm; padding-top: 7mm; border-top: 0.3mm solid var(--line); }
  .doc-guide h2 { font-size: 22pt; margin-bottom: 6mm; }
  .doc-guide h3 { font-size: 13.5pt; margin-top: 7mm; break-after: avoid; }
  .doc-guide h2, .doc-guide h3 { break-after: avoid; }
  .doc-guide p, .doc-guide li { line-height: 1.5; orphans: 3; widows: 3; }
  .callout, .table, figure, tr { break-inside: avoid; }
  .table { overflow: visible; }
  .table td:first-child { white-space: normal; }
  figure { margin: 5mm 0 6mm; }
  figure .zoom { display: inline-block; width: auto; max-width: 100%; vertical-align: top; padding: 0; background: none; box-shadow: none; border: 0.3mm solid #c9ced6; border-radius: 2mm; overflow: hidden; }
  figure .zoom img { border-radius: 0; }
  figure.wide .zoom img { max-height: 118mm; width: auto; max-width: 100%; }
  figure.small { max-width: 120mm !important; }
  figure.small .zoom img { max-height: 105mm; width: auto; max-width: 100%; }
  footer { border: 0; padding: 6mm 0 0; font-size: 9pt; }
}
