/* === Fonts === */
@font-face {
  font-family: 'ET Book';
  src: url('/fonts/etbookot-roman-webfont.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'ET Book';
  src: url('/fonts/etbookot-bold-webfont.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'ET Book';
  src: url('/fonts/etbookot-italic-webfont.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* === Variables === */
:root {
  --font-body: 'ET Book', 'Iowan Old Style', Palatino, Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --font-size-body: 19px;
  --font-size-mono: 0.92em;
  --font-size-small: 0.85em;
  --leading: 1.55;
  --leading-heading: 1.2;
}

/* === Colour: Light (default) === */
:root, .theme-light {
  --bg: #fffff8;
  --fg: #111111;
  --muted: #5a5a52;
  --accent: #c5454a;
  --rule: #c8c8c0;
  --code-bg: rgba(0,0,0,0.04);
  --code-rule: #d0d0c8;
}

/* === Colour: Dark === */
.theme-dark {
  --bg: #1a1a1a;
  --fg: #e8e8e3;
  --muted: #8a8a82;
  --accent: #e85d62;
  --rule: #353530;
  --code-bg: rgba(255,255,255,0.04);
  --code-rule: #383830;
}

/* === Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Layout === */
main {
  max-width: 38rem;
  margin: 4rem auto 6rem;
  padding: 0 1.5rem;
  padding-top: 36px;
}

/* === Headings === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  line-height: var(--leading-heading);
}
h1 { font-size: 2.2em;  font-weight: 400; margin: 0    0 0.5em 0; }
h2 { font-size: 1.7em;  font-weight: 400; margin: 2em  0 0.5em 0; }
h3 { font-size: 1.35em; font-weight: 400; font-style: italic; margin: 1.7em 0 0.4em 0; }
h4 { font-size: 1.1em;  font-weight: 600; margin: 1.4em 0 0.3em 0; }
h5 { font-size: 1em;    font-weight: 600; font-variant: small-caps; letter-spacing: 0.05em; margin: 1.4em 0 0.3em 0; }
h6 { font-size: 1em;    font-weight: 400; font-style: italic; margin: 1.4em 0 0.3em 0; }

/* === Vertical rhythm === */
p, ul, ol, blockquote, pre, table, figure { margin: 0 0 1.2em 0; }

/* === Links === */
a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
a:hover {
  background: var(--accent);
  color: var(--bg);
}

/* === Code: inline === */
code {
  font-family: var(--font-mono);
  font-size: var(--font-size-mono);
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

/* === Code: block === */
pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-mono);
  line-height: 1.5;
  padding: 0.4em 0 0.4em 1em;
  border-left: 2px solid var(--code-rule);
  background: transparent !important;
  overflow-x: auto;
}
pre code {
  background: none;
  padding: 0;
}

/* Shiki dual-theme: light by default, dark when toggled */
pre span { color: var(--shiki-light); }
.theme-dark pre span { color: var(--shiki-dark); }

/* === Blockquotes === */
blockquote {
  margin-left: 0;
  padding-left: 1.5em;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}
blockquote p { margin: 0.5em 0; }

/* === Lists === */
ul, ol { padding-left: 1.5em; }
li { margin: 0.3em 0; }
li > p:first-child { margin-top: 0; }
li > p:last-child  { margin-bottom: 0; }

/* Task lists */
.task-list-item { list-style: none; margin-left: -1.5em; }
.task-list-item input { margin-right: 0.5em; }

/* === Tables === */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95em;
}
th, td {
  text-align: left;
  padding: 0.4em 0.8em 0.4em 0;
  border-bottom: 1px solid var(--rule);
}
th { font-weight: 600; border-bottom: 2px solid var(--fg); }

/* === Horizontal rule === */
hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5em auto;
  width: 50%;
}

/* === Images === */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
}
figcaption {
  text-align: center;
  font-style: italic;
  font-size: 0.9em;
  color: var(--muted);
  margin-top: 0.5em;
}

/* === Footnotes === */
.footnote-ref a {
  border: none;
  font-size: 0.7em;
  vertical-align: super;
  color: var(--accent);
}
.footnotes {
  margin-top: 4em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
  font-size: 0.9em;
  color: var(--muted);
}
.footnotes ol { padding-left: 1.5em; }

/* === Selection === */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* === Toolbar === */
.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  background: var(--bg);
  font-size: 0.85em;
  color: var(--muted);
  z-index: 10;
}
.toolbar button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1em;
  padding: 0.2em 0.5em;
  cursor: pointer;
  opacity: 0.5;
}
.toolbar button:hover { opacity: 1; }
.toolbar .file-name { font-family: var(--font-mono); }
.toolbar .spacer { flex: 1; }
.toolbar .connection { color: var(--accent); }
.toolbar .connection.disconnected { color: var(--muted); }

/* === Viewer dots === */
.viewer-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 8px;
}
.viewer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 150ms, box-shadow 150ms;
}
.viewer-dot:hover { opacity: 1; }
.viewer-dot.self { opacity: 1; cursor: default; }
.viewer-dot.following {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor;
}

/* === Definition lists === */
dt { font-weight: 600; margin-top: 0.8em; }
dd { margin-left: 1.5em; margin-bottom: 0.5em; }

/* === Math === */
.katex-display {
  margin: 1.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2em 0;
}
.katex-display > .katex { text-align: left; }

/* === Remote cursor === */
#remote-cursor {
  position: absolute;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
  transition: top 100ms ease-out, left 100ms ease-out;
}
#remote-cursor.pulsing {
  animation: cursor-pulse 0.4s ease-out;
}
@keyframes cursor-pulse {
  0%   { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(2); opacity: 0.8; }
}

/* === Remote selection (presenter highlight) === */
.remote-selection {
  position: absolute;
  pointer-events: none;
  border-radius: 2px;
  mix-blend-mode: multiply;
  opacity: 0.22;
  z-index: 4;
}
.theme-dark .remote-selection {
  mix-blend-mode: screen;
  opacity: 0.15;
}

/* === Viewer highlights (watercolor blending) === */
.viewer-highlight {
  position: absolute;
  pointer-events: none;
  border-radius: 2px;
  mix-blend-mode: multiply;
  opacity: 0.18;
  z-index: 3;
}
.theme-dark .viewer-highlight {
  mix-blend-mode: screen;
  opacity: 0.12;
}
