/* viyan.live — built to be read.
 *
 * The reference is Medium, and the parts of Medium worth copying are not the
 * branding: a serif body at 20-21px, a line height near 1.6, a measure around
 * 680px, and a lot of air between paragraphs. That combination is what makes
 * a 1500-word piece feel finishable.
 *
 * NO WEB FONTS. A font file is 100-300KB fetched from someone else's server on
 * every first visit, and it blocks text from appearing while it arrives.
 * Charter ships with macOS and iOS, Sitka with Windows, and Georgia with
 * everything - so the serif stack below lands on a real book face almost
 * everywhere, instantly, with no request at all.
 */

:root {
  --ink: #1a1a19;        /* not black: pure black on white is harsh at length */
  --soft: #5f5f5a;
  --faint: #8a8a84;
  --line: #e6e4de;
  --bg: #ffffff;
  --panel: #f7f7f4;
  --accent: #2f6f4f;

  /* Medium sets its article column at 680px. Long-form prose is read at
   * 65-75 characters a line, and at 21px that is what 680px gives. */
  --measure: 42.5rem;

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9e7e0;
    --soft: #a7a59c;
    --faint: #78766e;
    --line: #2b2b28;
    --bg: #111110;
    --panel: #1a1a18;
    --accent: #7fbd9a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.5rem 5rem;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

main, .top, footer { max-width: var(--measure); margin: 0 auto; }

a { color: inherit; }

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

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.top nav { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.top nav a { color: var(--soft); text-decoration: none; font-size: 0.9rem; }
.top nav a:hover { color: var(--accent); }

/* --- index and channel lists ------------------------------------------ */

.lede { padding: 3rem 0 1.5rem; }
.lede h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.022em;
  margin: 0 0 0.5rem;
}
.lede p { color: var(--soft); margin: 0; font-size: 1.05rem; }

.pieces { list-style: none; padding: 0; margin: 0; }
.pieces li { padding: 1.75rem 0; border-top: 1px solid var(--line); }
.pieces h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 0.3rem 0 0.45rem;
}
.pieces h2 a { text-decoration: none; }
.pieces h2 a:hover { color: var(--accent); }
.pieces p { margin: 0 0 0.6rem; color: var(--soft); }

.ch { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
      color: var(--faint); }
.ch a { color: inherit; text-decoration: none; }
.ch a:hover { color: var(--accent); }

time { font-size: 0.85rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.empty { color: var(--soft); padding: 2.5rem 0; }

/* --- the article ------------------------------------------------------- */

article { padding: 3rem 0 0; }

article h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 7vw, 2.9rem);
  line-height: 1.14;
  letter-spacing: -0.024em;
  font-weight: 700;
  margin: 0.5rem 0 0.7rem;
}

.summary {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--soft);
  margin: 0 0 1.4rem;
}

/* Channel · date · reading time, the one line Medium puts under every title.
 * The reading time is the part that earns its place: these pieces run
 * 900-2000 words, so "how long is this" is a real question. */
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--faint);
}
.byline .dot { opacity: 0.5; }

/* The body, and the whole point of the file. */
.body {
  font-family: var(--serif);
  font-size: 1.3rem;          /* ~21px */
  line-height: 1.62;
  letter-spacing: -0.003em;
  margin-top: 2.25rem;
}

.body p { margin: 0 0 1.6rem; }

/* Headings go SANS against a serif body. The contrast is what makes them read
 * as structure at a glance rather than as a slightly bigger sentence. */
.body h2 {
  font-family: var(--sans);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 3rem 0 0.9rem;
}
.body h3 {
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2.25rem 0 0.7rem;
}

/* Underlined, in the text colour: a link in the middle of a paragraph should
 * be findable without recolouring the sentence around it. */
.body a { color: inherit; text-decoration: underline; text-underline-offset: 3px;
          text-decoration-thickness: 1px; text-decoration-color: var(--faint); }
.body a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.body ul, .body ol { padding-left: 1.4rem; margin: 0 0 1.6rem; }
.body li { margin-bottom: 0.65rem; }

.body blockquote {
  margin: 2rem 0;
  padding-left: 1.4rem;
  border-left: 3px solid var(--ink);
  font-style: italic;
  color: var(--soft);
}
.body blockquote p:last-child { margin-bottom: 0; }

.body hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

.body strong { font-weight: 700; }

/* Code and tables drop back to sans/mono at a smaller size: they are not
 * prose, and setting them in the reading face at reading size makes a page of
 * numbers look like a page of argument. */
.body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--panel);
  padding: 0.12em 0.36em;
  border-radius: 4px;
}

.body pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem;
  /* Code, tables and diagrams are the only things allowed wider than the
   * measure, and they scroll inside themselves so the PAGE never does. */
  overflow-x: auto;
  font-size: 0.95rem;
}
.body pre code { background: none; padding: 0; font-size: 0.88rem; }

.body table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
  margin: 2rem 0;
  display: block;
  overflow-x: auto;
}
.body th, .body td { border: 1px solid var(--line); padding: 0.6rem 0.8rem; text-align: left; }
.body th { background: var(--panel); font-weight: 600; }

.body img { max-width: 100%; height: auto; border-radius: 6px; }

/* --- diagrams ---------------------------------------------------------- */
/* Mermaid, unrendered on purpose - see `_diagram_fence`. Framed and labelled
 * so it reads as a diagram in source form rather than as a page that failed to
 * load something. */

.body .diagram {
  margin: 2.25rem 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.body .diagram figcaption {
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.body .diagram pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* --- sources and footer ------------------------------------------------ */

.sources {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.95rem;
}
.sources h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin: 0 0 0.8rem;
  font-weight: 600;
}
.sources ul { padding-left: 1.2rem; margin: 0; }
.sources li { margin-bottom: 0.4rem; }
.sources a { color: var(--accent); }

footer {
  margin-top: 4.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.88rem;
}
footer p { margin: 0 0 0.5rem; }
footer a { color: var(--accent); }

/* --- the apex: a way in, not a second copy of the channels -------------- */

.channels { list-style: none; padding: 0; margin: 2rem 0 3.5rem; display: grid; gap: 0.75rem; }
.channels a {
  display: block;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color .12s ease;
}
.channels a:hover { border-color: var(--accent); }
.channels h2 { font-family: var(--serif); font-size: 1.25rem; margin: 0 0 0.15rem;
               letter-spacing: -0.012em; }
.channels p { margin: 0; color: var(--faint); font-size: 0.88rem; }

h2.section {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.top nav a.on { color: var(--ink); font-weight: 600; }
