/* The chats in the look of the book websites (skill book-websites): the book's fonts (Times as TeX Gyre Termes,
   the typewriter txtt in the bubbles), neuralmech blue, the top bar and the outline of the PDE catalogue */
@font-face { font-family: "Termes"; src: url(fonts/texgyretermes-regular.otf); }
@font-face { font-family: "Termes"; font-weight: 700; src: url(fonts/texgyretermes-bold.otf); }
@font-face { font-family: "Termes"; font-style: italic; src: url(fonts/texgyretermes-italic.otf); }
@font-face { font-family: "txtt"; src: url(fonts/txtt.otf); }
@font-face { font-family: "CMU Typewriter"; src: url(fonts/cmuntt.otf); }  /* for what txtt lacks (txtt is ASCII only) */
:root {
  --font-ui: "Termes", "Times New Roman", serif; --font-bubble: "txtt", "CMU Typewriter", monospace;
  --fs-ui: 17px; --fs-bubble: 15px; --lh-bubble: 1.45; --nav-w: 300px; --pad: 28px; --bubble-pad: 8px 12px; --gap: 8px;
  --bg: #ffffff; --ink: #141414; --muted: #6b6b6b; --rule: #d9d9d9; --link: #1f4e8c;
  --frame: #1f3f66; --tint: #e5edf5; --title: #ffffff; --user: #ececec; --code: rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --ink: #e6e6e6; --muted: #9a9a9a; --rule: #303030; --link: #8ab4ff;
    --frame: #3b5f88; --tint: #172029; --title: #f2f2f2; --user: #2a2a2a; --code: rgba(255, 255, 255, .06); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --ink: #e6e6e6; --muted: #9a9a9a; --rule: #303030; --link: #8ab4ff;
  --frame: #3b5f88; --tint: #172029; --title: #f2f2f2; --user: #2a2a2a; --code: rgba(255, 255, 255, .06); color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs-ui)/1.45 var(--font-ui); overflow-x: hidden; }
a { color: var(--link); }
button, select { font: inherit; color: inherit; }

/* top bar: the book's title, previous and next example, GitHub, light or dark */
.top { position: sticky; top: 0; z-index: 3; height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--bg); border-bottom: 1px solid var(--rule); }
.top .brand { color: inherit; text-decoration: none; font-size: 1.12em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .brand span { margin-left: .6em; font-weight: 400; color: var(--muted); }
.top .grow { flex: 1; }
.top .steps { display: flex; gap: 14px; font-size: .95em; white-space: nowrap; min-width: 0; }
.top .steps a { color: var(--link); text-decoration: none; overflow: hidden; text-overflow: ellipsis; max-width: 13em; }
.top .steps .prev::before { content: "\2190  "; }
.top .steps .next::after { content: "  \2192"; }
.top .gh { color: var(--muted); text-decoration: none; }
.top .gh:hover { color: var(--ink); }
.icon { background: none; border: 1px solid transparent; border-radius: 6px; width: 34px; height: 34px; padding: 0; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); }
.icon:hover { border-color: var(--rule); color: var(--ink); }

/* outline and content: the content fills the rest of the window */
.frame { display: flex; min-height: calc(100vh - 48px); }
#outline { flex: 0 0 var(--nav-w); width: var(--nav-w); background: var(--bg); border-right: 1px solid var(--rule);
  position: sticky; top: 48px; align-self: flex-start; height: calc(100vh - 48px); overflow-y: auto; padding: 14px 0 40px; }
body.nav-closed #outline { display: none; }
#outline .ch { padding: 14px 16px 6px; color: color-mix(in srgb, var(--frame) 60%, var(--ink)); font-weight: 700; line-height: 1.25; }
#outline .ch span { display: block; font-weight: 400; font-size: .78em; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
#outline .sec { display: flex; gap: .2em; padding: 8px 16px 2px; color: var(--muted); font-size: .92em; }
#outline .ex { display: flex; gap: .2em; padding: 4px 16px 4px 16px; color: var(--ink); text-decoration: none; font-size: .95em; line-height: 1.3; border-left: 3px solid transparent; }
#outline .ex:hover { background: var(--tint); }
#outline .ex.on { background: var(--tint); border-left-color: var(--link); font-weight: 600; }
#outline .n { flex: 0 0 3.6em; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
#main { flex: 1; min-width: 0; padding: 22px var(--pad) 60px; }

/* example: the title as a box title bar, the sets behind a switch, each set paged */
h1 { margin: 0 0 16px; padding: 7px 14px; border-radius: 8px; background: var(--frame); color: var(--title); font-size: 22px; font-weight: 700; line-height: 1.2; }
h1 .n { color: var(--title); opacity: .7; font-weight: 400; margin-right: .6em; }
h2 { font-size: 1.05em; margin: 0 0 8px; }
.switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.switch button { border: 0; background: none; padding: 2px 14px; cursor: pointer; }
.switch button + button { border-left: 1px solid var(--rule); }
.switch button[aria-selected="true"] { background: var(--frame); color: var(--title); }
.switch span { color: var(--muted); font-size: .85em; margin-left: .3em; }
.switch button[aria-selected="true"] span { color: var(--title); opacity: .75; }
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pager button { border: 1px solid var(--rule); background: var(--bg); border-radius: 6px; padding: 2px 12px; cursor: pointer; line-height: 1.5; }
.pager button:hover:not(:disabled) { border-color: var(--frame); }
.pager button:disabled { opacity: .35; cursor: default; }
.pager .count { font-variant-numeric: tabular-nums; min-width: 6em; text-align: center; color: var(--muted); }
.pager select { min-width: 0; max-width: 100%; flex: 1 1 260px; border: 1px solid var(--rule); background: var(--bg); border-radius: 6px; padding: 3px 6px; }
.pane { scroll-margin-top: 60px; min-width: 0; }
.panes.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.panes.two .pane.active h2 { color: var(--link); }
.panes.two .pane + .pane { border-left: 1px solid var(--rule); padding-left: 32px; }

/* bubbles, as in the book: prompt left, response right, 80 % wide; side-by-side responses in a row; one text size */
.msg { margin: var(--gap) 0; display: flex; flex-direction: column; }
.msg.user { align-items: flex-start; }
.msg.model { align-items: flex-end; }
.msg > * { width: min(80%, 100%); }
.msg.user .bubble { width: auto; max-width: 80%; }
.bubble { border-radius: 8px; padding: var(--bubble-pad); font: var(--fs-bubble)/var(--lh-bubble) var(--font-bubble); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { background: var(--user); }
.bubble.model { background: var(--tint); }
.bubble.ctx { color: var(--muted); }
.bubble img { display: block; max-width: min(260px, 100%); margin-bottom: 6px; border-radius: 4px; background: #fff; }
.think { color: var(--muted); border-bottom: 1px dashed var(--muted); padding-bottom: 6px; margin-bottom: 6px; }
pre.code { margin: 4px 0; padding: 6px 8px; background: var(--code); border-radius: 4px; white-space: pre; overflow-x: auto; font: inherit; }
.lab { display: flex; justify-content: space-between; gap: 8px; margin: 2px 0 2px; font-size: .92em; }
.lab span { color: var(--muted); font-size: .9em; }
.row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 12px; margin: var(--gap) 0; }
.source { text-align: right; color: var(--muted); font-size: .8em; margin: 2px 0 6px; }

/* links to code and data between two rules */
.links { margin-top: 28px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 8px 0; font-size: .88em; }
.links div { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 0; }
.links span { color: var(--muted); min-width: 3em; }
.links a { overflow-wrap: anywhere; }

/* phones: the outline opens over the content */
@media (max-width: 900px) {
  .top .brand span, .top .gh, .top .steps .t { display: none; }
  .top .steps { flex: none; gap: 8px; }
  #outline { position: fixed; top: 48px; left: 0; z-index: 2; width: min(85vw, var(--nav-w)); box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
  #main { padding: 16px 16px 48px; }
  .msg > *, .msg.user .bubble { width: 100%; max-width: 100%; }
  .msg.user .bubble { width: auto; max-width: 92%; }
  .msg.model > * { width: 92%; }
  .row { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 19px; }
}

/* the link to the legal notice, at the end of the outline */
#outline .legal { display: block; padding: 24px 16px 0; color: var(--muted); font-size: 14px; text-decoration: none; }
#outline .legal:hover { color: var(--ink); }
