/* Literata: made for reading e-books (OFL, from @fontsource, latin subset) */
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/literata-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/literata-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/literata-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f6f1e7;           /* paper */
  --box: #fbf8f1;
  --text: #2b2722;         /* ink */
  --muted: #6f675c;
  --line: #ddd3c2;
  --accent: #9c4a2c;       /* terracotta */
  --accent-soft: #efe1d1;
  --ok: #4d7536;
  --bad: #a8321f;
  --page: #fffdf8;         /* the book page stays light: formulas are black on white */
  --sketch-paper: #fffdf8;
  --sketch-line: #c9bba6;
  --sketch-ink: #4a423a;
  --sketch-device: #3b3530;
  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a17;
    --box: #23201c;
    --text: #ebe4d6;
    --muted: #a59c8d;
    --line: #3a352e;
    --accent: #e3916b;
    --accent-soft: #3a2a20;
    --ok: #9cc27f;
    --bad: #f0a097;
    --page: #f6f1e7;
    --sketch-paper: #ece4d5;
    --sketch-line: #a89a86;
    --sketch-ink: #4a423a;
    --sketch-device: #4a433b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1a17;
  --box: #23201c;
  --text: #ebe4d6;
  --muted: #a59c8d;
  --line: #3a352e;
  --accent: #e3916b;
  --accent-soft: #3a2a20;
  --ok: #9cc27f;
  --bad: #f0a097;
  --page: #f6f1e7;
  --sketch-paper: #ece4d5;
  --sketch-line: #a89a86;
  --sketch-ink: #4a423a;
  --sketch-device: #4a433b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18.5px/1.65 var(--serif);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
button:disabled { opacity: .4; cursor: default; }

.page { max-width: 680px; margin: 0 auto; padding: 48px 24px 40px; }

.masthead { margin-bottom: 52px; }
.masthead .name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  letter-spacing: .04em;
  font-variant: small-caps;
  color: var(--text);
  text-decoration: none;
}
.masthead img { border-radius: 6px; }
.fleuron { color: var(--accent); }

.kicker { margin: 0 0 10px; font-size: 16px; letter-spacing: .06em; font-variant: small-caps; color: var(--accent); }
h1 { margin: 0; font-size: 40px; line-height: 1.14; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h2 { margin: 0 0 14px; font-size: 24px; font-weight: 600; }
h3 { margin: 26px 0 6px; font-size: 19px; font-weight: 600; }
.intro p { margin: 0 0 14px; }
.intro .quiet { color: var(--muted); font-style: italic; }

/* the little drawing: a two-column PDF page becomes an e-reader page */
.sketch { display: block; width: 100%; max-width: 520px; height: auto; margin: 30px auto 28px; }
.sketch * { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sketch .s-paper { fill: var(--sketch-paper); stroke: var(--sketch-line); stroke-width: 1.5; }
.sketch .s-fold { fill: var(--bg); stroke: var(--sketch-line); stroke-width: 1.5; }
.sketch .s-line { stroke: var(--sketch-line); stroke-width: 2.2; }
.sketch .s-fig { fill: color-mix(in srgb, var(--sketch-line) 35%, transparent); stroke: var(--sketch-line); stroke-width: 1.5; }
.sketch .s-ink { stroke: var(--sketch-ink); stroke-width: 4; }
.sketch .s-faint { stroke: var(--sketch-line); stroke-width: 2.5; }
.sketch .s-arrow { stroke: var(--accent); stroke-width: 2.6; }
.sketch .s-device { fill: var(--sketch-device); }
.sketch .s-screen { fill: var(--sketch-paper); }
.sketch .s-line2 { stroke: #9b8f7f; stroke-width: 3; }
.sketch .s-math { stroke: var(--accent); stroke-width: 3; }

.divider { margin: 52px 0 40px; text-align: center; color: var(--accent); font-size: 22px; line-height: 1; }

/* ── drop zone ───────────────────────────────────────── */
.convert { margin-top: 36px; }
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 34px 20px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--box);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-main { font-size: 20px; }
.drop-main u { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.drop-sub { font-size: 15px; color: var(--muted); max-width: 30em; }

/* ── jobs: one quiet line each ───────────────────────── */
.jobs { list-style: none; margin: 18px 0 0; padding: 0; }
.job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.job:first-child { border-top: 1px solid var(--line); }
.job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job.current .job-name { font-style: italic; }
.job-status { grid-column: 1; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.job[data-state="done"] .job-status { color: var(--ok); }
.job[data-state="failed"] .job-status, .job[data-state="expired"] .job-status { color: var(--bad); }
.job-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 14px; align-items: baseline; font-size: 16px; }
.job-actions .btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.job-actions .btn.icon { color: var(--muted); text-decoration: none; }
.job-bar { grid-column: 1 / -1; height: 2px; background: var(--line); overflow: hidden; margin-top: 6px; }
.job-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.job:not([data-state="uploading"]):not([data-state="queued"]):not([data-state="checking"]):not([data-state="converting"]) .job-bar { display: none; }
.job[data-state="queued"] .job-bar span,
.job[data-state="checking"] .job-bar span,
.job[data-state="converting"] .job-bar span { width: 30%; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .job-bar span { animation: none !important; width: 100% !important; opacity: .5; }
}

/* ── reader: a little wider than the text column ─────── */
.workspace { margin: 36px -110px 0; scroll-margin-top: 16px; }
.reader {
  display: flex;
  flex-direction: column;
  height: min(86vh, 920px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--box);
  overflow: hidden;
}
.reader-bar { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 16px; }
.reader-bar select {
  flex: 1;
  min-width: 0;
  max-width: 460px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.tools { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.tool {
  border: 0;
  background: none;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.tool:hover:not(:disabled) { background: var(--accent-soft); }
.stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: stretch; padding: 14px 4px; }
.viewer {
  flex: 1;
  min-width: 0;
  max-width: 760px;
  margin: 0 auto;
  background: var(--page);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .12), 0 6px 18px -10px rgba(60, 40, 20, .25);
}
.turn {
  flex: none;
  width: 42px;
  border: 0;
  background: none;
  font-size: 30px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
@media (hover: hover) {
  .turn:hover:not(:disabled) { color: var(--accent); }
}
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.reader[data-state="open"] .placeholder { display: none; }
.reader:not([data-state="open"]) .viewer { visibility: hidden; }
.reader[data-state="error"] .placeholder { color: var(--bad); }
.reader-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
#book-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
#where { flex: none; }
.thanks { margin: 12px 0 0; text-align: center; font-size: 16px; font-style: italic; color: var(--muted); }
.reader:not([data-state="open"]) ~ .thanks { display: none; }  /* only once the book is open */

/* ── notes ───────────────────────────────────────────── */
.faq h3:first-of-type { margin-top: 8px; }
.notes ul { margin: 0; padding: 0; list-style: none; }
.notes li { position: relative; padding-left: 1.3em; margin-bottom: 6px; }
.notes li::before { content: "–"; position: absolute; left: 0; color: var(--accent); }
.notes p { margin: 0 0 14px; }

.colophon { margin-top: 64px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 16px; color: var(--muted); }
.colophon p { margin: 0; }

/* ── ad slots: collapsed until filled (or ?ads=preview) ─ */
.ad-slot { display: none; }
.ad-slot.filled, .ads-preview .ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 40px 0;
  overflow: hidden;
}
.ads-preview .ad-slot:not(.filled) { border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; }
.ads-preview .ad-slot:not(.filled)::before { content: "ad slot · " attr(data-ad); }
.ad-slot.filled { flex-direction: column; gap: 6px; align-items: stretch; }
.ad-slot.filled::before { content: "advertisement"; font-size: 13px; letter-spacing: .06em; font-variant: small-caps; color: var(--muted); text-align: center; }
.ad-slot ins.adsbygoogle { display: block; width: 100%; }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }  /* AdSense had nothing to show */

/* ── the privacy page ─────────────────────────────────── */
.prose h1 { margin-bottom: 6px; }
.prose h2 { margin-top: 34px; }
.prose p { margin: 0 0 14px; }
.prose .quiet { color: var(--muted); font-style: italic; }

@media (max-width: 940px) {
  .workspace { margin-left: 0; margin-right: 0; }
}
@media (max-width: 600px) {
  body { font-size: 17.5px; }
  .page { padding: 28px 16px 32px; }
  .masthead .name { margin-bottom: 32px; }
  h1 { font-size: 31px; }
  .sketch { margin: 22px auto 20px; }
  .drop { padding: 26px 14px; }
  .workspace { margin: 28px -10px 0; }
  .reader { height: 84vh; }
  .reader-bar { gap: 6px; padding: 6px 8px; }
  .tool { padding: 4px 5px; }
  .turn { width: 26px; }
  .stage { padding: 8px 2px; }
}
