/* Write-up pages for calgraham.com. Same system as the home page:
   Public Sans (Google Fonts), U.S. Web Design System colour tokens, a tinted brief
   column on the left and the document on the right.
   Contrast ratios are against #ffffff unless noted. */

:root {
  --ground: #ffffff;
  --ink:    #1b1b1b;  /* base-darkest   17.2:1 */
  --text-2: #3d4551;  /* base-darker     9.7:1  ledes, secondary text */
  --muted:  #565c65;  /* base-dark       6.7:1  labels, captions, footer */
  --link:   #005ea2;  /* blue-60v        6.7:1 */
  --link-2: #1a4480;  /* blue-warm-70v   9.6:1  hover */
  --rule:   #dfe1e2;  /* hairlines only, never text */
  --tint:   #e7f2f5;  /* blue-cool-5: brief column and notes. ink 15.1:1, muted 5.9:1, link 5.9:1 */
  --warn:   #faf3d1;  /* yellow-5: "watch out" notes. ink 15.4:1, link 6.0:1 */
  --code:   #f0f0f0;  /* base-lightest: code blocks */
  --ok:     #216e1f;  /* 6.3:1, "works" */
  --no:     #8b1303;  /* 9.6:1, "fails" */
  /* Syntax colours, all checked on --code: keyword 8.4, function 8.9, string 5.6,
     comment 5.9, number 8.4, variable 7.5 */
  --c-kw: #1a4480; --c-fn: #54278f; --c-str: #216e1f; --c-cm: #565c65; --c-num: #8b1303; --c-var: #7a3b07;
}

html { box-sizing: border-box; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover, a:active { color: var(--link-2); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }

/* ---------- Page frame: one column first ---------- */
.page { display: flex; flex-direction: column; max-width: 50rem; margin: 0 auto; padding: 0 1rem 3rem; }

/* Brief column: name, site links, contact, contents. On narrow screens a tinted band. */
.brief {
  background: var(--tint);
  box-shadow: 0 0 0 100vmax var(--tint);
  clip-path: inset(0 -100vmax);
  padding: 1.25rem 0 1rem;
  font-size: 0.9375rem;
}
.brief .home { font-size: 1.25rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.brief .home:hover { text-decoration: underline; }
.brief .tagline { margin-top: 0.15rem; color: var(--text-2); line-height: 1.35; }
.brief .site { margin-top: 0.75rem; line-height: 1.7; }
.brief .site a, .brief .contact a { white-space: nowrap; }
.brief .contact { margin-top: 0.25rem; }
.sep { color: var(--muted); }

.toc-box { margin-top: 0.9rem; }
.toc-box summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.toc { list-style: none; padding: 0; margin-top: 0.4rem; }
.toc li { margin: 0.15rem 0; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--link-2); text-decoration: underline; }
.toc a.active { color: var(--ink); font-weight: 600; }
.toc .toc { margin: 0.1rem 0 0.25rem 0.9rem; font-size: 0.9em; }

/* ---------- The document ---------- */
.doc { min-width: 0; }
.doc-header { padding: 2rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.doc-header h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.doc-header .lede { margin-top: 0.6rem; font-size: 1.125rem; color: var(--text-2); max-width: 62ch; line-height: 1.5; }
.meta { margin-top: 1.1rem; font-size: 0.9375rem; }

.row + .row { margin-top: 0.35rem; }
.row dt { display: inline; font-weight: 600; color: var(--muted); margin-right: 0.35em; }
.row dd { display: inline; }

.section { padding-top: 0.25rem; }
.section-anchor { display: block; height: 0; scroll-margin-top: 1rem; }
.doc h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; margin: 2.25rem 0 0.75rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.doc-header + .section h2 { border-top: 0; padding-top: 0; }
.doc h3 { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; margin: 1.5rem 0 0.5rem; }
.doc h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.doc p { margin: 0 0 0.85rem; max-width: 68ch; }
.doc li { max-width: 66ch; }
.doc b, .doc strong { font-weight: 600; }

/* Notes: a tinted block with a bold lead word in the text. No icons, no side stripes. */
.callout { background: var(--tint); padding: 0.85rem 1rem; margin: 1.1rem 0; max-width: 68ch; }
.callout.warn { background: var(--warn); }
.callout-body { line-height: 1.55; }

/* Code */
.code-wrap { margin: 1.1rem 0; }
.code-label { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.2rem; }
pre { background: var(--code); padding: 0.9rem 1rem; margin: 0; overflow-x: auto; font-size: 0.84rem; line-height: 1.55; }
code, .inline-code { font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; }
pre code { font-size: inherit; line-height: inherit; color: var(--ink); }
.inline-code { font-size: 0.88em; background: var(--code); padding: 0.05em 0.3em; color: var(--ink); }
.kw { color: var(--c-kw); }
.fn { color: var(--c-fn); }
.str, .val { color: var(--c-str); }
.cm { color: var(--c-cm); font-style: italic; }
.num { color: var(--c-num); }
.var { color: var(--c-var); }
.key { color: var(--c-kw); }
.op, .punct { color: var(--c-cm); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.1rem 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th { text-align: left; font-weight: 600; padding: 0.45rem 0.75rem 0.45rem 0; border-bottom: 2px solid var(--ink); vertical-align: bottom; }
td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.badge { font-weight: 600; white-space: nowrap; }
.badge.pass { color: var(--ok); }
.badge.fail { color: var(--no); }
.badge.neutral { color: var(--muted); }

/* Two-column comparisons, with no boxes */
.ref-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin: 1.1rem 0; }
.ref-list { list-style: none; padding: 0; }
.ref-list li { position: relative; padding-left: 1.3em; margin: 0.3rem 0; }
.ref-list li::before { content: "\2713"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.ref-list.no li::before { content: "\2717"; color: var(--no); }

/* Numbered steps: ordinary list numbers */
.steps { padding-left: 1.4em; margin: 1rem 0; }
.steps li { margin: 0.5rem 0; padding-left: 0.2em; }

.foot { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.875rem; color: var(--muted); }
.foot p + p { margin-top: 0.25rem; }

@media (min-width: 40em) {
  .row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); column-gap: 1.25rem; }
  .row dt, .row dd { display: block; margin: 0; }
  .ref-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .doc-header h1 { font-size: 2rem; }
}

/* ---------- Desktop: brief column stays put, tinted to the left edge ---------- */
@media (min-width: 64em) {
  .page { display: grid; grid-template-columns: 18rem minmax(0, 48rem); column-gap: 4rem; max-width: none; width: fit-content; padding: 0 2.5rem 0 0; }
  .page::before { content: ""; grid-column: 1; grid-row: 1; background: var(--tint);
                  box-shadow: 0 0 0 100vmax var(--tint); clip-path: inset(0 0 0 -100vmax); }
  .brief { grid-column: 1; grid-row: 1; position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto;
           scrollbar-width: thin; padding: 2.5rem 1.5rem 1.5rem 2.5rem; background: none; box-shadow: none; clip-path: none; font-size: 0.875rem; }
  .doc { grid-column: 2; grid-row: 1; }
  .doc-header { padding-top: 2.5rem; }
  .toc-box { margin-top: 1.25rem; }
  .toc-box summary { list-style: none; pointer-events: none; }
  .toc-box summary::-webkit-details-marker { display: none; }
  .foot { padding-bottom: 4rem; }
}
