/*
  notex.us: one stylesheet for every page (the home page adds hero.css, the
  chalkboard, generated by tools/site/hero-board). No web fonts, no external
  requests.
  Light is a sheet of ruled notebook paper (blue-black ink, a red margin line);
  dark is a blackboard (slate, chalk white, yellow and pink chalk).
  The red margin line is drawn once, by body::before, at --mx.
*/

:root {
  color-scheme: light dark;

  --paper: #fbfcfe;
  --ink: #18233f;
  --graphite: #4e586a;
  --pen: #2346a8;
  --red: #b4233f;
  --margin: #e0566e;
  --rule: #d6e1f1;
  --code: #f0f3f8;
  --note: #fdf0f2;

  /* The PDF sheet stays paper in both themes (specimen.svg's ink is black
     and #b4233f, AA on both). */
  --sheet: #ffffff;

  --serif: "Palatino Linotype", Palatino, "TeX Gyre Pagella", "URW Palladio L", P052, "Book Antiqua", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;

  /* Layout: one column; gutters left (clears the margin line) and right. */
  --col: 48rem;
  --gl: 1.75rem;
  --gr: 1rem;
  --mx: max(0.625rem, calc(50% - var(--col) / 2 - 0.75rem));
  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c2622;
    --ink: #e6ece7;
    --graphite: #a3b1a9;
    --pen: #f0d57a;
    --red: #f39aab;
    --margin: #e98a9c;
    --rule: #34433c;
    --code: #232f2a;
    --note: #2b2b2a;
    --sheet: #ecede7;
  }
}

@media (min-width: 60rem) {
  :root {
    --gl: 1rem;
    --mx: calc(50% - var(--col) / 2 - 2rem);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--sans);
  overflow-wrap: break-word;
}

/* The notebook's margin line. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--mx);
  width: 2px;
  background: var(--margin);
  pointer-events: none;
}

a { color: var(--pen); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: var(--gl);
  top: 0.5rem;
  z-index: 2;
  padding: 0.5rem 0.75rem;
  background: var(--paper);
  color: var(--pen);
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.wrap {
  max-width: calc(var(--col) + var(--gl) + var(--gr));
  margin-inline: auto;
  padding-left: var(--gl);
  padding-right: var(--gr);
}

/* ---- Site header and footer ------------------------------------------- */

.site-header { border-bottom: 1px solid var(--rule); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
  font: 700 1.625rem/1 var(--serif);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

/* The pen-nib N before the name: tools/brand/build.py writes its path (the
   small mark, bold enough for this size) into every page; it takes the
   text colour, so it follows the theme. Its foot sits on the baseline. */
.wordmark-mark {
  flex: none;
  width: auto;
  height: 1.2em;
  fill: currentColor;
}

.site-nav ul,
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding-block: 0.25rem;
  color: var(--ink);
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--margin);
  text-decoration-thickness: 2px;
}

/* Phones: the mark adds about 38 px to the wordmark; a smaller mark and
   tighter gaps keep the header on one line from 360 px up (also with
   Android's Noto Serif and Noto Sans). */
@media (max-width: 25rem) {
  .site-header .wrap { column-gap: 0.75rem; }
  .site-nav ul { column-gap: 0.875rem; }
  .wordmark { gap: 0.15em; }
  .wordmark-mark { height: 1em; }
}

.site-footer {
  margin-top: 5rem;
  border-top: 1px solid var(--rule);
  color: var(--graphite);
  font-size: 0.9375rem;
}
.site-footer .wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
.site-footer p { margin: 1rem 0 0; }
.site-footer a { color: var(--graphite); }
.site-footer a:hover { color: var(--ink); }

/* ---- Running text ------------------------------------------------------ */

main { display: block; }

main p,
main ul,
main ol,
main dl { max-width: var(--measure); }

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3rem); margin: 3rem 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem); margin: 3.5rem 0 0.75rem; }
h3 { font-family: var(--sans); font-size: 1.0625rem; line-height: 1.4; margin: 2rem 0 0.25rem; }

p { text-wrap: pretty; }

.lede {
  font: 1.3125rem/1.5 var(--serif);
  color: var(--ink);
  margin-top: 0;
}

.muted { color: var(--graphite); }

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

code,
kbd { font-family: var(--mono); font-size: 0.875em; }

main li + li { margin-top: 0.375rem; }

/* ---- Home: hero (the chalkboard is in hero.css) ------------------------- */

.hero h1 {
  font-size: clamp(2.5rem, 1.5rem + 4.2vw, 4.25rem);
  line-height: 1.04;
  margin: 3.5rem 0 1.25rem;
  max-width: 11em;
}

.hero .lede { max-width: 33rem; }

/* The LaTeX logo, set the way TeX sets it. */
.latex { white-space: nowrap; }
.latex .a {
  text-transform: uppercase;
  font-size: 0.72em;
  vertical-align: 0.26em;
  margin-left: -0.33em;
  margin-right: -0.13em;
}
.latex .e {
  text-transform: uppercase;
  vertical-align: -0.2em;
  margin-left: -0.15em;
  margin-right: -0.11em;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  margin: 1.75rem 0 0;
}
.status strong {
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.3rem 0.625rem;
  border: 1px solid var(--margin);
  border-radius: 1rem;
}

/* ---- About: the .tex / PDF specimen ------------------------------------- */

.specimen { margin: 2.25rem 0 1.75rem; }

.specimen-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}
@media (min-width: 44rem) {
  .specimen-panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

.pane-label {
  margin: 0 0 0.375rem;
  font-size: 0.875rem;
  color: var(--graphite);
}

.source {
  margin: 0;
  padding: 1rem 1.125rem;
  background: var(--code);
  border-radius: 6px;
  font: 0.8125rem/1.6 var(--mono);
  color: var(--ink);
  overflow-x: auto;
  tab-size: 2;
}
.source .c { color: var(--pen); }
.source .t { color: var(--red); }

/* A page of real pdflatex output (specimen.svg, black and red on a
   transparent page); the sheet is its paper. */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  /* A second sheet underneath. */
  box-shadow: 5px 5px 0 -1px var(--sheet), 5px 5px 0 0 var(--rule);
}
.sheet img {
  display: block;
  width: 100%;
  height: auto;
}

.specimen figcaption {
  margin-top: 1rem;
  max-width: var(--measure);
  color: var(--graphite);
  font-size: 0.9375rem;
}
.specimen figcaption code { color: var(--red); }

/* ---- Steps (numbers hang in the margin on wide screens) ---------------- */

.steps {
  list-style: none;
  counter-reset: step;
  margin: 1.5rem 0 0;
  padding: 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  margin-top: 1.75rem;
}
.steps > li::before {
  content: counter(step);
  font: 700 1.875rem/1 var(--serif);
  color: var(--red);
}
.steps h3 { margin: 0.125rem 0 0.25rem; }
.steps p { margin: 0; }
.steps > li > * { grid-column: 2; }

@media (min-width: 60rem) {
  .steps > li { display: block; }
  .steps > li::before {
    position: absolute;
    right: calc(100% + 2.75rem);
    top: 0;
  }
}

/* Home: the same steps, one line each. */
.steps-short > li {
  align-items: baseline;
  margin-top: 0.625rem;
}
.steps-short > li::before {
  font-size: 1.25rem;
  line-height: 1.36;
}
.steps-short p { margin: 0; }

.more { margin-top: 1.75rem; }

.facts { padding-left: 1.25rem; }
.facts li::marker { color: var(--red); }

/* ---- Support FAQ ------------------------------------------------------- */

.faq h3 { margin-top: 2rem; }
.faq h3 + p { margin-top: 0.25rem; }

/* ---- Legal pages (privacy, delete-account): existing markup ------------- */

main > header h1 { margin-bottom: 0.75rem; }

main > nav ol { padding-left: 1.5rem; columns: 2 14rem; column-gap: 2rem; }
main > nav li { break-inside: avoid; margin: 0 0 0.25rem; }

.note {
  background: var(--note);
  border-left: 3px solid var(--margin);
  padding: 0.75rem 1rem;
  border-radius: 0 4px 4px 0;
}

.table-wrap { overflow-x: auto; margin: 1rem 0; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
  line-height: 1.5;
}
th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.625rem 0.75rem 0.625rem 0;
  border-bottom: 1px solid var(--rule);
}
th { font-weight: 600; border-bottom-color: var(--graphite); }
td { overflow-wrap: break-word; }

/* Three-column tables become one block per row on narrow screens. */
@media (max-width: 35.99rem) {
  table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td { display: block; }
  table.stack tr { padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
  table.stack td { padding: 0.125rem 0; border: 0; }
  table.stack td:first-child { font-weight: 600; margin-bottom: 0.25rem; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--graphite); }
}

main > footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--graphite);
  font-size: 0.875rem;
}

/* ---- 404 ---------------------------------------------------------------- */

.notfound h1 { font-size: clamp(2.5rem, 1.5rem + 4.2vw, 4rem); }

/* ---- Motion and print ---------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media print {
  body::before,
  .skip,
  .site-nav { display: none; }
  body { background: #fff; color: #000; }
  a { color: inherit; }
}
