/* THE RECEIPTS - paper and graphite pencil.
   Mobile-first, no JavaScript, dark-mode friendly.
   Fonts: Special Elite and Source Serif 4 from Google Fonts when allowed,
   otherwise the system fallbacks listed below. */

:root {
  --paper: #f6f0e0;
  --paper-2: #efe6cf;
  --ink: #2a2a2c;          /* graphite */
  --ink-soft: #4d4b48;
  --rule: #b9b09a;
  --accent: #b3261e;       /* red pencil */
  --accent-ink: #8f1d17;
  --on-accent: #fbf6e8;
  --shadow: rgba(42, 42, 44, 0.28);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "Special Elite", "Courier New", Courier, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1a18;
    --paper-2: #26231f;
    --ink: #ebe5d4;
    --ink-soft: #bfb8a6;
    --rule: #4c473d;
    --accent: #ff7a6b;
    --accent-ink: #ff9a8d;
    --on-accent: #1c1a18;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--paper);
  /* faint ruled-paper lines */
  background-image: repeating-linear-gradient(
    to bottom, transparent 0, transparent 1.74rem, rgba(120, 110, 90, 0.10) 1.74rem, rgba(120, 110, 90, 0.10) calc(1.74rem + 1px));
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.wrap { max-width: 46rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: .5rem .75rem; z-index: 10; }
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- header ---------- */
.site-header {
  background: var(--paper-2);
  border-bottom: 3px double var(--ink-soft);
  padding: .75rem 0 .65rem;
}
.header-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.brand {
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: .12em;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
}
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-family: var(--mono); font-size: .95rem; flex: 1 1 auto; }
.site-nav a { color: var(--ink-soft); text-decoration: none; padding: .15rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); border-bottom: 1px dashed var(--accent); }

.watch {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .85rem;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  padding: .45rem .8rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: 3px 3px 0 var(--shadow);
  white-space: nowrap;
}
.watch:hover { filter: brightness(1.08); }
.watch:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }

.draft-banner {
  margin: 0;
  padding: .45rem 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--accent-ink);
  border-bottom: 2px dashed var(--accent);
  background: var(--paper);
}

/* ---------- article ---------- */
main { padding-top: 1.25rem; padding-bottom: 3rem; }

article > .dateline {
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}

h1, h2, h3 { font-family: var(--mono); font-weight: 400; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.85rem; margin: .4rem 0 1rem; padding-bottom: .4rem; border-bottom: 3px solid var(--ink); }
h2 {
  font-size: 1.4rem;
  margin: 2.4rem 0 .8rem;
  padding-bottom: .3rem;
  border-bottom: 2px dashed var(--ink-soft);   /* receipt perforation */
}
h2::before { content: "\2736\00a0"; color: var(--accent); }
h3 { font-size: 1.15rem; margin: 1.8rem 0 .5rem; color: var(--accent-ink); }

h1, h2, h3 { scroll-margin-top: 1rem; }

p { margin: 0 0 1rem; }
strong { font-weight: 700; }

a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
a:focus-visible, .watch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

ul, ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
li { margin: 0 0 .55rem; }
li::marker { color: var(--accent); }

/* grade badges: letters carry the meaning, not color alone */
.grade {
  display: inline-block;
  font-family: var(--mono);
  font-size: .68em;
  line-height: 1;
  padding: .16em .36em;
  margin-left: .12em;
  border: 1px solid currentColor;
  vertical-align: super;
  color: var(--ink);
}
sup.grade { font-size: .66em; }
.g-A { background: var(--ink); color: var(--paper); }
.g-B { background: transparent; color: var(--ink); border-width: 1.5px; }
.g-C { background: transparent; color: var(--accent-ink); border-style: dashed; border-width: 1.5px; }

/* "on this page" box */
.toc {
  border: 1px dashed var(--ink-soft);
  background: var(--paper-2);
  padding: .6rem 1rem .4rem;
  margin: 0 0 1.5rem;
  font-size: .95rem;
}
.toc-title { font-family: var(--mono); margin: 0 0 .25rem; color: var(--ink-soft); }
.toc ol { margin: 0 0 .5rem; padding-left: 1.3rem; }
.toc li { margin: 0 0 .15rem; }

/* tables scroll inside their own box, never the page */
.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--rule); background: var(--paper-2); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--rule); }
th { font-family: var(--mono); font-weight: 400; background: var(--paper); border-bottom: 2px solid var(--ink-soft); white-space: nowrap; }
td:nth-child(1) { min-width: 11rem; }
td:nth-child(3) { min-width: 11rem; }

blockquote { margin: 0 0 1rem; padding: .25rem 1rem; border-left: 4px solid var(--accent); background: var(--paper-2); }
code { font-family: ui-monospace, "Courier New", monospace; font-size: .9em; }
hr { border: 0; border-top: 2px dashed var(--ink-soft); margin: 2rem 0; }

/* ---------- footer ---------- */
.site-footer {
  background: var(--paper-2);
  border-top: 3px double var(--ink-soft);
  padding: 1.25rem 0 2rem;
  font-size: .9rem;
  color: var(--ink-soft);
}
.site-footer p { margin: 0 0 .6rem; }
.legend { font-family: var(--mono); }
.legend .grade { vertical-align: baseline; font-size: .8em; padding: .12em .4em; }
.fine { font-size: .85rem; }

/* ---------- larger screens ---------- */
@media (min-width: 40rem) {
  body { font-size: 1.125rem; }
  .wrap { padding-left: 1.5rem; padding-right: 1.5rem; }
  h1 { font-size: 2.2rem; }
  .watch { margin-left: auto; }
}

@media (max-width: 30rem) {
  .watch { flex: 1 1 100%; text-align: center; }
  .brand { font-size: 1.15rem; }
}

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

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; background-image: none; font-size: 11pt; }
  .site-nav, .watch, .skip, .draft-banner { display: none; }
  h2 { page-break-after: avoid; }
}
