/* Reading Companion — one stylesheet for the whole site.
   Paper, blue-black ink, and a yellow highlighter that marks unknown words and nothing else. */

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/literata-roman-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/literata-roman-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/literata-italic-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #fdfdfb;
  --page: #ffffff;
  --ink: #1c2530;
  --ink-soft: #4f5b69;
  --rule: #d6dbe1;
  --tint: #f1f3f6;
  --link: #1f47a5;
  --marker: #f6e14b;
  --marker-ink: #1c2530;
  --focus: #1f47a5;

  --lv-a1-bg: #e6eef7; --lv-a1-fg: #1c2530;
  --lv-a2-bg: #d0dfef; --lv-a2-fg: #1c2530;
  --lv-b1-bg: #b2c9e5; --lv-b1-fg: #1c2530;
  --lv-b2-bg: #86a8d4; --lv-b2-fg: #0f1720;
  --lv-c1-bg: #4f77b0; --lv-c1-fg: #ffffff;
  --lv-c2-bg: #25497f; --lv-c2-fg: #ffffff;

  --serif: "Literata", "Iowan Old Style", Charter, Georgia, serif;
  /* One family for everything: Literata was drawn for e-book reading and has optical sizes for small text. */
  --sans: var(--serif);

  --text: 40rem;
  --notes: 15rem;
  --gap: 3rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181d;
    --page: #1a1f25;
    --ink: #e4e8ed;
    --ink-soft: #a5b0bd;
    --rule: #333c47;
    --tint: #1d232a;
    --link: #93b4ff;
    --marker: #d8c238;
    --marker-ink: #14181d;
    --focus: #93b4ff;

    --lv-a1-bg: #26313e; --lv-a1-fg: #e4e8ed;
    --lv-a2-bg: #2c3d52; --lv-a2-fg: #e4e8ed;
    --lv-b1-bg: #34506f; --lv-b1-fg: #ffffff;
    --lv-b2-bg: #41658f; --lv-b2-fg: #ffffff;
    --lv-c1-bg: #6f93c6; --lv-c1-fg: #0f1720;
    --lv-c2-bg: #a9c3e8; --lv-c2-fg: #0f1720;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

@media (min-width: 48rem) {
  body { font-size: 1.125rem; }
}

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

.skip {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 0.75rem; font-family: var(--sans); z-index: 10;
}
.skip:focus { top: 0.5rem; }

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

.site-header { border-bottom: 1px solid var(--rule); }
.header-inner {
  max-width: 62rem; margin: 0 auto; padding: 0.9rem 1rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 2rem;
}
.wordmark {
  font-family: var(--serif); font-weight: 650; font-size: 1.3rem;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
}
.site-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem;
  font-family: var(--sans); font-size: 0.9rem;
}
.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; }

.site-footer {
  margin-top: 5rem; border-top: 1px solid var(--rule); background: var(--tint);
  font-family: var(--sans); font-size: 0.92rem; line-height: 1.55; color: var(--ink-soft);
}
.footer-inner { max-width: 62rem; margin: 0 auto; padding: 2rem 1rem 3rem; }
.footer-inner p { max-width: 40rem; margin: 0 0 0.9rem; }
.footer-inner strong { color: var(--ink); }
.footer-links { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; }

/* ------------------------------------------------------------ the text column */

main { padding: 0 1rem; }

.prose {
  max-width: var(--text);
  margin: 2.5rem auto 0;
}

@media (min-width: 72rem) {
  .prose { margin-left: max(1rem, calc(50% - (var(--text) + var(--gap) + var(--notes)) / 2)); }
}

.prose h1 {
  font-size: 2.05rem; line-height: 1.14; font-weight: 640; letter-spacing: -0.015em;
  margin: 0 0 0.6rem; text-wrap: balance;
}
@media (min-width: 48rem) { .prose h1 { font-size: 2.75rem; } }

.prose h2 {
  font-size: 1.5rem; line-height: 1.25; font-weight: 620; letter-spacing: -0.01em;
  margin: 3rem 0 0.8rem; text-wrap: balance; scroll-margin-top: 1rem;
}
@media (min-width: 48rem) { .prose h2 { font-size: 1.7rem; } }

.prose h3 { font-size: 1.2rem; line-height: 1.3; font-weight: 620; margin: 2rem 0 0.5rem; }

.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose li { margin: 0 0 0.45rem; }
.prose li > ul, .prose li > ol { margin-top: 0.45rem; }

.meta { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 1.8rem; }

.lead { font-size: 1.2rem; line-height: 1.55; }
@media (min-width: 48rem) { .lead { font-size: 1.3rem; } }

/* Steps are a real sequence, so they get numbers. */
ol.steps { list-style: none; counter-reset: step; padding: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: 1.3rem; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05rem;
  width: 1.8rem; height: 1.8rem; border: 1.5px solid var(--ink); border-radius: 50%;
  font-family: var(--sans); font-weight: 700; font-size: 0.9rem; line-height: 1.7rem; text-align: center;
}
ol.steps > li > strong:first-child { display: block; }

blockquote { margin: 1.5rem 0; padding-left: 1.1rem; border-left: 3px solid var(--rule); color: var(--ink-soft); }

/* ------------------------------------------------------------ source notes in the margin */

.note {
  display: block;
  font-family: var(--sans); font-size: 0.85rem; line-height: 1.45; color: var(--ink-soft);
  border-left: 2px solid var(--rule); padding: 0.1rem 0 0.1rem 0.8rem; margin: -0.4rem 0 1.2rem;
}
.note a { color: inherit; }

@media (min-width: 72rem) {
  .with-note {
    display: grid; grid-template-columns: var(--text) var(--notes); column-gap: var(--gap); align-items: start;
    margin-right: calc(-1 * (var(--notes) + var(--gap)));
  }
  .with-note > .note { float: none; width: auto; margin: 0.3rem 0 0; }
}
@media (min-width: 72rem) {
  .note {
    float: right; clear: right;
    width: var(--notes); margin: 0.25rem calc(-1 * (var(--notes) + var(--gap))) 1rem 0;
    border-left: 0; padding: 0; border-top: 2px solid var(--rule); padding-top: 0.4rem;
  }
}

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; margin: 1.5rem 0 2rem; clear: right; }

/* Wide tables leave the text column: centred on tablets, into the notes margin on large screens. */
@media (min-width: 44rem) and (max-width: 71.99rem) {
  .wide { position: relative; left: 50%; width: min(calc(100vw - 3rem), 58rem); transform: translateX(-50%); }
}
@media (min-width: 72rem) {
  .wide { margin-right: calc(-1 * (var(--notes) + var(--gap))); }
}

table {
  border-collapse: collapse; width: 100%;
  font-family: var(--sans); font-size: 0.9rem; line-height: 1.4;
  font-variant-numeric: tabular-nums lining-nums;
}
caption {
  caption-side: top; text-align: left; color: var(--ink-soft);
  font-size: 0.85rem; padding-bottom: 0.6rem;
}
th, td { padding: 0.5rem 0.7rem 0.5rem 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
thead th { font-weight: 700; border-bottom: 1.5px solid var(--ink); vertical-align: bottom; }
tbody th { font-weight: 400; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot th, tfoot td { border-bottom: 0; border-top: 1.5px solid var(--ink); font-weight: 700; }

table.matrix td { text-align: right; }
table.matrix th[scope="col"]:not(:first-child) { text-align: right; }
table.matrix td.nil { color: var(--ink-soft); }
table.matrix td.total { font-weight: 700; }

.level {
  display: inline-block; min-width: 2.3em; padding: 0.05em 0.35em; border-radius: 3px;
  font-family: var(--sans); font-weight: 700; font-size: 0.82rem; text-align: center;
}
.level-a1 { background: var(--lv-a1-bg); color: var(--lv-a1-fg); }
.level-a2 { background: var(--lv-a2-bg); color: var(--lv-a2-fg); }
.level-b1 { background: var(--lv-b1-bg); color: var(--lv-b1-fg); }
.level-b2 { background: var(--lv-b2-bg); color: var(--lv-b2-fg); }
.level-c1 { background: var(--lv-c1-bg); color: var(--lv-c1-fg); }
.level-c2 { background: var(--lv-c2-bg); color: var(--lv-c2-fg); }

table.books th.book a { font-family: var(--serif); font-size: 1rem; font-weight: 600; }
table.books .by { display: block; color: var(--ink-soft); }
table.books td.form { color: var(--ink-soft); }
table.books tr { scroll-margin-top: 1rem; }

section.lang h2 .count { font-family: var(--sans); font-size: 0.95rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; margin-left: 0.4rem; }

/* On a phone each book becomes a short block instead of a seven-column row. */
@media (max-width: 40rem) {
  table.books, table.books tbody, table.books tr, table.books th, table.books td { display: block; }
  table.books thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.books caption, table.tools caption { display: block; }
  table.books tr {
    display: grid; grid-template-columns: auto auto auto; justify-content: start; gap: 0.35rem 1.4rem;
    padding: 0.9rem 0; border-bottom: 1px solid var(--rule);
  }
  table.books th, table.books td { border: 0; padding: 0; text-align: left; }
  table.books th.book, table.books td.form { grid-column: 1 / -1; }
  table.books td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.75rem; color: var(--ink-soft);
  }
  table.books td.form { margin-top: -0.3rem; font-style: italic; }
}

/* ------------------------------------------------------------ the known-words demo on the home page */

.demo { margin: 2rem 0 2.5rem; }
.demo input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.demo-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; font-family: var(--sans); }
.demo-controls .ask { flex-basis: 100%; font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 0.2rem; }
.demo-controls label {
  cursor: pointer; border: 1.5px solid var(--ink); border-radius: 4px;
  padding: 0.35rem 0.8rem; font-size: 0.95rem; background: var(--page); color: var(--ink);
}
.demo-controls label .sub { color: var(--ink-soft); }
#k98:checked ~ .demo-controls label[for="k98"],
#k95:checked ~ .demo-controls label[for="k95"],
#k90:checked ~ .demo-controls label[for="k90"] { background: var(--ink); color: var(--paper); }
#k98:checked ~ .demo-controls label[for="k98"] .sub,
#k95:checked ~ .demo-controls label[for="k95"] .sub,
#k90:checked ~ .demo-controls label[for="k90"] .sub { color: inherit; opacity: 0.8; }
#k98:focus-visible ~ .demo-controls label[for="k98"],
#k95:focus-visible ~ .demo-controls label[for="k95"],
#k90:focus-visible ~ .demo-controls label[for="k90"] { outline: 3px solid var(--focus); outline-offset: 2px; }

.demo-page {
  background: var(--page); border: 1px solid var(--rule); border-radius: 2px;
  padding: 1.4rem 1.5rem 1rem; box-shadow: 0 1px 0 var(--rule), 0 3px 0 -1px var(--page), 0 4px 0 -1px var(--rule);
}
.demo-page p { margin: 0; font-size: 1.12rem; line-height: 1.75; hyphens: auto; }
.demo-page .folio { margin-top: 0.8rem; text-align: center; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-soft); }

/* Without CSS the paragraph reads normally. With it, the chosen share of words is replaced by nonwords,
   the way Hu and Nation built their test texts. */
#k98:checked ~ .demo-page .t98 .rw,
#k95:checked ~ .demo-page :is(.t98, .t95) .rw,
#k90:checked ~ .demo-page .nw .rw { display: none; }

#k98:checked ~ .demo-page .t98::after,
#k95:checked ~ .demo-page :is(.t98, .t95)::after,
#k90:checked ~ .demo-page .nw::after {
  content: attr(data-nw);
  background: linear-gradient(to bottom, transparent 18%, var(--marker) 18%, var(--marker) 88%, transparent 88%);
  color: var(--marker-ink); padding: 0 0.1em; margin: 0 -0.1em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

.demo-caption { font-family: var(--sans); font-size: 0.92rem; color: var(--ink-soft); margin-top: 0.9rem; }
.demo-caption span { display: none; }
#k98:checked ~ .demo-caption .c98,
#k95:checked ~ .demo-caption .c95,
#k90:checked ~ .demo-caption .c90 { display: inline; }

/* Marked unknown words elsewhere, for example in the page test. */
mark.unknown {
  background: linear-gradient(to bottom, transparent 18%, var(--marker) 18%, var(--marker) 88%, transparent 88%);
  color: var(--marker-ink); padding: 0 0.1em;
}

/* ------------------------------------------------------------ reading-time calculator */

.calc {
  font-family: var(--sans); border: 1px solid var(--rule); background: var(--page);
  padding: 1.2rem 1.25rem; margin: 1.5rem 0 2rem; border-radius: 2px;
}
.calc h2 { margin-top: 0; font-family: var(--serif); }
.calc .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.9rem 1.2rem; }
.calc label { display: block; font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 0.25rem; }
.calc input {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 0.45rem 0.55rem;
  border: 1.5px solid var(--ink-soft); border-radius: 3px; background: var(--paper); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.calc output { display: block; margin-top: 1rem; font-size: 1.1rem; color: var(--ink); min-height: 1.6em; }
.calc .hint { font-size: 0.85rem; color: var(--ink-soft); margin: 0.8rem 0 0; }

/* ------------------------------------------------------------ misc */

.disclosure { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); }

.sources { margin-top: 3.5rem; border-top: 1px solid var(--rule); padding-top: 0.5rem; clear: both; }
.sources h2 { margin-top: 1rem; }
.sources ol { font-family: var(--sans); font-size: 0.9rem; line-height: 1.5; padding-left: 1.4rem; }
.sources li { margin-bottom: 0.6rem; scroll-margin-top: 1rem; }
.sources li:target { background: var(--tint); }

.see-also { font-family: var(--sans); font-size: 0.95rem; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

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

@media print {
  .site-header nav, .site-footer .footer-links, .demo-controls, .calc { display: none; }
  .note { float: none; width: auto; margin: 0 0 1rem; }
}

/* ------------------------------------------------------------ tools comparison */

table.tools .by { display: block; color: var(--ink-soft); font-size: 0.85rem; }
table.tools th[scope="row"] a { font-weight: 700; }

@media (max-width: 40rem) {
  table.tools, table.tools tbody, table.tools tr, table.tools th, table.tools td { display: block; }
  table.tools thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.tools tr { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
  table.tools th, table.tools td { border: 0; padding: 0.15rem 0; }
  table.tools td::before { display: block; font-size: 0.75rem; color: var(--ink-soft); }
  table.tools td:nth-of-type(1)::before { content: "Runs on"; }
  table.tools td:nth-of-type(2)::before { content: "What you read"; }
  table.tools td:nth-of-type(3)::before { content: "Looking up a word"; }
  table.tools td:nth-of-type(4)::before { content: "Saved words"; }
  table.tools td:nth-of-type(5)::before { content: "Price"; }
}
