/* davecbeck.com
   One plain column of Newsreader, with a commonplace-book margin to its left
   where dates and sidenotes hang in rubric red. */

@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-latin-standard-normal.woff2") format("woff2-variations"),
       url("/fonts/newsreader-latin-standard-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-latin-standard-italic.woff2") format("woff2-variations"),
       url("/fonts/newsreader-latin-standard-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #fdfdfb;
  --ink: #1c1b19;
  --ink-2: #5b574f;
  --ink-3: #8c867b;
  --rule: #e3e0d9;
  --wash: #f2f0eb;
  --rubric: #a52a1e;
  --focus: #1f4f99;

  --measure: 35rem;
  --margin: 10rem;
  --gap: 1.75rem;
  /* The right-hand picture column and the gap before it; none until 66rem. */
  --pw: 0rem;
  --gp: 0rem;
  --step: 1.6rem;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (min-width: 66rem) {
  :root { --pw: 13rem; --gp: 2.5rem; }
}
@media (min-width: 78rem) {
  :root { --pw: 18rem; --gp: 3rem; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171614;
    --ink: #ebe6dd;
    --ink-2: #aea79b;
    --ink-3: #847d71;
    --rule: #34312c;
    --wash: #201e1b;
    --rubric: #e8866f;
    --focus: #8fb4f0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #171614;
  --ink: #ebe6dd;
  --ink-2: #aea79b;
  --ink-3: #847d71;
  --rule: #34312c;
  --wash: #201e1b;
  --rubric: #e8866f;
  --focus: #8fb4f0;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.125rem, 1.05rem + 0.3vw, 1.25rem);
  line-height: 1.6;
  font-optical-sizing: auto;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent);
}
@media (hover: hover) {
  a:hover { color: var(--rubric); text-decoration-color: var(--rubric); }
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

img { max-width: 100%; height: auto; display: block; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.8rem;
  z-index: 10;
}
.skip:focus { top: 1rem; }

/* ---- Frame: margin column + text column ---- */

.page {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 4rem;
}
.frame {
  max-width: calc(var(--margin) + var(--gap) + var(--measure) + var(--gp) + var(--pw));
  margin-inline: auto;
  padding-left: calc(var(--margin) + var(--gap));
}
.frame > * { max-width: var(--measure); }

/* Anything with class "m" hangs in the margin, beside its line. */
.has-m { position: relative; }
.m {
  position: absolute;
  right: calc(100% + var(--gap));
  top: 0;
  width: var(--margin);
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---- Masthead ---- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 2.4rem 0;
  margin-bottom: 3.2rem;
}
.masthead .name {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
}
.masthead nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; font-size: 1.0625rem; }
.masthead nav a { text-decoration-color: transparent; }
.masthead nav a[aria-current="page"] { text-decoration-color: var(--rubric); text-decoration-thickness: 2px; }
@media (hover: hover) {
  .masthead nav a:hover { text-decoration-color: var(--rubric); }
}

/* ---- Type ---- */

h1, h2, h3 { font-weight: 500; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.6rem); letter-spacing: -0.01em; }
h2 {
  font-size: 1.3rem;
  font-style: italic;
  font-weight: 450;
  margin: 3.4rem 0 1.1rem;
}
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 1rem; text-wrap: pretty; }
.lede {
  font-size: clamp(1.55rem, 1.3rem + 1vw, 1.95rem);
  line-height: 1.28;
  font-weight: 400;
  letter-spacing: -0.008em;
  margin: 0 0 1.6rem;
}
.page-head { margin-bottom: 2.2rem; }
.page-head .lede { margin-top: 1rem; }

.prose > *:last-child { margin-bottom: 0; }
.prose h2 { margin-top: 2.6rem; }
.prose h3 { margin: 2rem 0 0.6rem; }
.prose ul, .prose ol { padding-left: 1.2em; margin: 0 0 1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose blockquote {
  margin: 1.4rem 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
}
.prose code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82em;
  background: var(--wash);
  padding: 0.08em 0.3em;
  border-radius: 3px;
}
.prose pre { overflow-x: auto; background: var(--wash); padding: 0.9rem 1rem; font-size: 0.85rem; line-height: 1.5; }
.prose pre code { background: none; padding: 0; }
.prose figure { margin: 1.8rem 0; }
.prose figcaption, .thumb figcaption {
  font-size: 0.875rem;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-2);
  margin-top: 0.5rem;
}
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4rem 0; }
.table-wrap { overflow-x: auto; margin: 1.4rem 0; }
.prose table { border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: lining-nums tabular-nums; }
.prose th, .prose td { text-align: left; padding: 0.4rem 0.9rem 0.4rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-weight: 600; }
.al-r { text-align: right !important; }
.al-c { text-align: center !important; }

/* ---- Sidenotes: in the margin when there is room, tap-to-open when not ---- */

.sn-ref {
  font-size: 0.68em;
  line-height: 0;
  vertical-align: 0.6em;
  color: var(--rubric);
  font-variant-numeric: lining-nums;
  padding: 0 0.08em 0 0.12em;
}
.sn-toggle { display: none; }
.sidenote {
  float: left;
  clear: left;
  width: var(--margin);
  margin-left: calc(-1 * (var(--margin) + var(--gap)));
  margin-top: 0.3rem;
  margin-bottom: 0.8rem;
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.42;
  color: var(--ink-2);
  font-variant-numeric: lining-nums;
}
.sn-num { color: var(--rubric); }

/* ---- Margin furniture ---- */

.date-m {
  font-size: 0.9rem;
  line-height: 1.6;
  padding-top: 0.12rem;
  color: var(--ink-2);
}
.mark-m {
  color: var(--rubric);
  font-size: 1.25rem;
  line-height: 1.25;
}

/* ---- Lists on Home ---- */

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li { margin: 0 0 1.05rem; }
.plain-list > li:last-child { margin-bottom: 0; }

.questions li { font-size: 1.125rem; line-height: 1.5; }

.more { margin-top: 1.4rem; font-size: 1rem; }

.made-list > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  align-items: flex-start;
  margin-bottom: 1.6rem;
}
.made-list .made-text { flex: 1 1 15rem; min-width: 0; }
.made-list .made-text a { font-size: 1.125rem; }
.made-list .made-text p { margin: 0.2rem 0 0; font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
.thumb { margin: 0; flex: 0 0 8.5rem; width: 8.5rem; }
.thumb img { border-radius: 2px; }

.now-row { display: flex; flex-wrap: wrap; gap: 0.8rem 1.5rem; align-items: flex-start; }
.now-row .prose { flex: 1 1 17rem; min-width: 0; }
.now-row .thumb { flex-basis: 10rem; width: 10rem; order: 2; }
@media (min-width: 66rem) {
  .now-row { display: block; }
  .now-row .thumb { float: right; width: var(--pw); margin: 0.35rem calc(-1 * (var(--pw) + var(--gp))) 1.5rem 0; }
}

/* ---- About ---- */

.portrait { float: right; width: 6.5rem; margin: 0.3rem 0 1rem 1.4rem; border-radius: 50%; }

/* ---- Side pictures: a small float beside the text, out in the right-hand
   column from 66rem. Clicking one shows an enlarged copy (.enlarged) ---- */

.side { float: right; clear: right; width: 8.5rem; margin: 0.3rem 0 0.6rem 1.25rem; cursor: zoom-in; }
.side img, .side video { display: block; width: 100%; height: auto; border-radius: 2px; }
.side-video { cursor: auto; }
@media (max-width: 65.99rem) {
  .prose p:has(> .side)::after, .prose li:has(> .side)::after { content: ""; display: block; clear: both; }
}
@media (min-width: 66rem) {
  .side { width: var(--pw); margin: 0.35rem calc(-1 * (var(--pw) + var(--gp))) 1.5rem 0; }
}

.enlarged { display: none; }
.enlarged:target {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  cursor: zoom-out;
}
.enlarged img {
  width: auto;
  max-width: min(100%, 720px);
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 0.5rem 2.5rem rgb(0 0 0 / 0.25);
}

/* ---- Charts drawn inline as SVG (used by drafts/ai-risk.md, not yet published) ---- */

.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--ink-3); stroke-width: 1; fill: none; }
.chart .area { fill: var(--rubric); fill-opacity: 0.12; stroke: none; }
.chart .curve { fill: none; stroke: var(--rubric); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .peak { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; }
.chart text { fill: var(--ink-2); font-family: var(--serif); font-size: 14px; font-style: italic; }
.chart .end { font-style: normal; fill: var(--ink); }

/* ---- Footer ---- */

.colophon {
  margin-top: 5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.colophon p { margin: 0 0 0.35rem; }
.colophon .contact { display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; color: var(--ink); font-size: 0.95rem; }

/* ---- Narrow screens: the margin folds into the column ---- */

@media (max-width: 52rem) {
  .frame { padding-left: 0; max-width: var(--measure); }
  .m {
    position: static;
    width: auto;
    text-align: left;
    display: block;
  }
  .date-m { padding: 0; font-size: 0.875rem; }
  .mark-m { display: none; }
  .questions li { padding-left: 1.1rem; position: relative; }
  .questions li::before { content: "\00B6"; position: absolute; left: 0; color: var(--rubric); }

  .sidenote { display: none; }
  .sn-ref {
    cursor: pointer;
    font-size: 0.75em;
    vertical-align: 0.5em;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    padding: 0.2em 0.2em;
  }
  .sn-toggle:checked + .sidenote {
    display: block;
    float: none;
    width: auto;
    margin: 0.5rem 0 0.7rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--rubric);
    text-align: left;
  }
  .sn-toggle { display: block; position: absolute; opacity: 0; width: 1px; height: 1px; }
  label.sn-ref:has(+ .sn-toggle:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
  .portrait { width: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .masthead nav, .skip { display: none; }
  .frame { padding-left: 0; }
  .m { position: static; width: auto; text-align: left; }
}
