/*
 * The only stylesheet a lesson needs to link. Prose styles live here; the
 * components import below.
 *
 * @import rather than four <link> tags in every lesson head, because a
 * lesson should not have to know which components it happens to use. The
 * serial-fetch cost that makes @import a bad idea on the web does not apply
 * to four local files.
 *
 * Tufte-influenced: warm paper, a narrow measure, generous air, restrained
 * rules. Prints cleanly on A4.
 */

@import url("drill.css");
@import url("audio.css");
@import url("panels.css");

:root {
  --paper: #fdfdfc;
  --ink: #1a1a19;
  --ink-soft: #55565a;
  --ink-faint: #8b8d93;
  --rule: #e4e4e2;
  --accent: #9c3428;
  --correct: #2f6b46;
  --correct-wash: #eaf3ed;
  --wrong: #a3352a;
  --wrong-wash: #fbeceb;
  --measure: 34rem;

  /* Gothic, not Mincho. Kana should read as clean shapes, not calligraphy —
   * the strokes are what is being learned. */
  --japanese: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium",
    "Yu Gothic", "Noto Sans JP", "Meiryo";

  /* Every Latin stack ends in the Japanese one. A Latin font has no kana
   * glyphs, so any Japanese character left unwrapped falls through to the
   * next family that does — and left to itself the browser picks Mincho,
   * which is exactly the ornate thing we do not want. Naming the fallback
   * explicitly means unwrapped Japanese is still correct, and the .kana
   * classes become about size and emphasis rather than rescuing glyphs. */
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    Arial, var(--japanese), sans-serif;
  --sans: var(--body);
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, var(--japanese),
    monospace;
  --kana: var(--japanese), sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16.5px;
}

body {
  margin: 0;
  padding: 4rem 1.5rem 8rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.02rem;
  line-height: 1.65;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Structure ---------- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
}

.page > * {
  margin-inline: 0;
}

/* Full-bleed elements escape the measure without leaving the column. */
.wide {
  max-width: calc(var(--measure) + 12rem);
  margin-inline: -6rem;
}

@media (max-width: 60rem) {
  .wide {
    max-width: 100%;
    margin-inline: 0;
  }
}

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

.eyebrow {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.9rem;
}

h1 {
  font-size: 2.35rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.028em;
  margin: 0 0 0.7rem;
}

.standfirst {
  font-size: 1.14rem;
  font-weight: 400;
  line-height: 1.52;
  letter-spacing: -0.008em;
  color: var(--ink-soft);
  margin: 0 0 2.5rem;
}

h2 {
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 3.5rem 0 1rem;
}

h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2.5rem 0 0.8rem;
}

p {
  margin: 0 0 1.2rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(138, 47, 36, 0.3);
}

a:hover {
  border-bottom-color: var(--accent);
}

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

strong {
  font-weight: 600;
}

/* ---------- Kana typography ---------- */

.kana {
  font-family: var(--kana);
  font-weight: 400;
  line-height: 1;
}

/* Japanese inside a sentence. The family is already inherited via the
 * fallback in --body; this exists because kana render optically smaller
 * than Latin at the same size and need a nudge to sit level. */
.kana-inline {
  font-family: var(--kana);
  font-size: 1.15em;
}

/* Marks the one moving part in a worked example — the shifting vowel in a
 * conjugation, the character under discussion in a pair. */
.vowel {
  color: var(--accent);
  font-weight: 500;
}

.romaji {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--ink-soft);
}

/* ---------- Character cards (the knowledge phase) ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin: 2rem 0 2.5rem;
  padding: 0;
  list-style: none;
}

/* One card introducing a single character — it should not stretch the width
 * of the measure just because it is alone in the grid. */
.cards.is-single {
  grid-template-columns: minmax(0, 21rem);
  margin: 1.5rem 0 2rem;
}

.card {
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.4rem 1.3rem;
  background: #fff;
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}

.card-glyph {
  font-family: var(--kana);
  font-size: 3.4rem;
  line-height: 0.85;
  flex: none;
}

.card-body {
  min-width: 0;
}

.card-reading {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.card-mnemonic {
  font-size: 0.94rem;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0;
}

/* Tofugu's mnemonic illustration, hotlinked from their CDN rather than
 * copied here. The picture is the mnemonic — the sentence beside it is a
 * caption for when the image does not load. Capped in height so a card
 * cannot outgrow its panel. */
.card {
  flex-wrap: wrap;
}

.card-image {
  flex-basis: 100%;
  width: 100%;
  max-height: 38dvh;
  object-fit: contain;
  object-position: left;
  margin-top: 0.4rem;
  border-radius: 3px;
}

/* How a character is built, and what it sounds like — sits under the card,
 * between meeting it and drilling it. */
.built-line {
  font-size: 0.98rem;
  color: var(--ink-soft);
  margin: -1.2rem 0 2rem;
}

/* ---------- Callouts ---------- */

.aside {
  border-left: 2px solid var(--rule);
  padding: 0.2rem 0 0.2rem 1.2rem;
  margin: 2rem 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.aside p:last-child {
  margin-bottom: 0;
}

.aside-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 0.4rem;
}

.warning {
  border-left-color: var(--accent);
}

/* ---------- Word list ---------- */

.words {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  border-top: 1px solid var(--rule);
}

.words li {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 0.85rem 0.2rem;
  border-bottom: 1px solid var(--rule);
}

.words .kana {
  font-size: 1.9rem;
  flex: none;
  min-width: 5.5rem;
}

.words .romaji {
  flex: none;
  min-width: 5rem;
}

.words .gloss {
  color: var(--ink-soft);
}

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

.lesson-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.lesson-footer h3 {
  margin-top: 0;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  margin-top: 2rem;
}

/* ---------- Print ---------- */

@media print {
  :root {
    --paper: #fff;
  }

  body {
    padding: 0;
    font-size: 11pt;
  }

  .nav-links {
    display: none;
  }

  .card {
    break-inside: avoid;
  }

  a {
    border-bottom: 0;
    color: var(--ink);
  }
}
