/* One grammar point or one word on its own page (/grammar/<locale>/<level>/<slug>/,
   build-library.py; /vocabulary/<locale>/<level>/<slug>/, build-words.py).
   Built on design.css, jlpt-pages.css and library.css: the head is a printed
   leaf like the level pages, small; the body is one column of ruled
   sections, the way a dictionary sets an entry. Japanese in the body is the
   reader's system Mincho (as on the level pages), so a page does not pull in
   the self-hosted Japanese font shards. */

.study-page main :lang(ja) {
  --display: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Source Han Serif JP", serif;
  --text: var(--display);
}
.study-page .gp-usage :lang(ja), .study-page .gp-meaning :lang(ja), .study-page .gp-ex-tr :lang(ja), .study-page .gp-note :lang(ja),
.study-page .gp-lead :lang(ja), .study-page .gp-rel-m :lang(ja), .study-page .gp-lessons :lang(ja), .study-page .wp-meaning :lang(ja),
.study-page .wp-sense :lang(ja), .study-page .wp-ex-tr :lang(ja), .study-page .crumbs :lang(ja) {
  --text: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans CJK JP", "Meiryo", sans-serif;
  --display: var(--text);
}

/* ---------------------------------------------------------------- the head */
/* The level page's leaf (library.css .lib-head): words, 版心, the level's
   glyph. The meaning is answered right under the heading. */
.gp-head .crumbs ol { margin-bottom: 22px; }
.gp-head .eyebrow { margin-bottom: 18px; }
.gp-h1 { display: grid; justify-items: start; gap: 6px; margin: 0; font-weight: 400; color: var(--ink); }
.gp-pattern { font-family: var(--display); font-size: clamp(40px, 5.2vw, 68px); line-height: 1.15; letter-spacing: .01em; overflow-wrap: anywhere; }
.gp-pattern:not(:lang(ja)) { font-size: clamp(34px, 4.4vw, 56px); letter-spacing: var(--display-tracking); }
.gp-h1-sub { font-family: var(--display); font-size: clamp(20px, 2.2vw, 28px); line-height: 1.3; color: #3A4640; }
.gp-h1-sub::first-letter { text-transform: uppercase; }
.gp-meaning { display: grid; gap: 6px; margin-top: clamp(24px, 3vw, 36px); max-width: 38em; }
.gp-kicker { margin: 0; font-family: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.gp-kicker:lang(zh), .gp-kicker:lang(ko) { font-size: 14px; letter-spacing: .08em; text-transform: none; }
.gp-meaning .g-meaning, .gp-meaning .g-senses { font-size: clamp(17px, 1.35vw, 20px); line-height: 1.7; color: #3A4640; }
.gp-also { margin: 14px 0 0; }
.gp-ledger { justify-items: center; }

/* ---------------------------------------------------------------- the body: ruled sections */
.gp-body { display: grid; gap: 0; margin-top: clamp(40px, 5vw, 72px); }
.gp-block { display: grid; grid-template-columns: 200px minmax(0, 760px); gap: 8px clamp(24px, 4vw, 64px); padding: 26px 0 30px; box-shadow: inset 0 1px var(--hairline); }
.gp-block:first-child { box-shadow: inset 0 2px var(--frame-ink), inset 0 6px var(--paper), inset 0 7px var(--frame-ink-2); padding-top: 32px; }
.gp-block > :not(.gp-h2) { grid-column: 2; }
.gp-h2 { grid-column: 1; grid-row: 1 / span 9; align-self: start; margin: 4px 0 0; font-family: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.gp-h2:lang(zh), .gp-h2:lang(ko), .gp-h2:lang(ja) { font-size: 14px; letter-spacing: .08em; text-transform: none; }

.gp-form { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.gp-form li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; font-size: 17px; line-height: 1.5; }
.gp-slot { display: inline-flex; align-items: center; min-height: 32px; padding: 3px 12px; border-radius: 999px; background: rgba(43, 76, 64, .08); color: var(--pine); font-size: 15px; font-weight: 600; }
.gp-ja { font-size: 20px; color: var(--ink); }
.gp-op { color: var(--muted); font-size: 15px; padding: 0 2px; }
.gp-or { color: var(--muted); font-size: 15px; padding: 0 4px; }
.gp-usage { max-width: 40em; margin: 0; font-size: 17px; line-height: 1.8; color: var(--ink); }

.gp-examples { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; counter-reset: gp-ex; }
.gp-ex { display: grid; gap: 4px; padding: 14px 0 16px 18px; box-shadow: inset 2px 0 var(--vermilion); counter-increment: gp-ex; }
.gp-ex + .gp-ex { margin-top: 14px; }
.gp-ex-line { display: flex; align-items: flex-start; gap: 14px; }
.gp-ex-ja { flex: 1; margin: 0; font-size: 20px; line-height: 1.75; color: var(--ink); }
.gp-ex-ja b { font-weight: 600; color: var(--vermilion-text); }
.gp-ex-tr { margin: 0; font-size: 15px; line-height: 1.65; color: #3A4640; }
.gp-note { max-width: 40em; margin: 18px 0 0; font-size: 15px; line-height: 1.7; color: #3A4640; }
.gp-note b { margin-right: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(43, 76, 64, .08); color: var(--pine); font-size: 12px; font-weight: 600; letter-spacing: .02em; }

.say {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  margin-top: 2px;
  border: 0;
  border-radius: 50%;
  background: rgba(43, 76, 64, .08);
  color: var(--pine);
  cursor: pointer;
  transition-property: background-color, transform;
  transition-duration: var(--t-small), var(--t-micro);
  transition-timing-function: var(--ease-enter);
}
.say .i { width: 16px; height: 16px; }
.say:hover { background: rgba(43, 76, 64, .15); }
.say:active { transform: scale(.94); }
.say:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 2px; }
.say.is-playing { background: var(--pine); color: var(--white); }
.no-speech .say:not([data-preview]) { display: none; }

.gp-related { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.gp-rel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  height: 100%;
  padding: 14px 16px;
  border-radius: var(--r-control);
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--ring);
  color: var(--ink);
  text-decoration: none;
  transition-property: box-shadow, transform;
  transition-duration: var(--t-small);
  transition-timing-function: var(--ease-enter);
}
.gp-rel:hover { box-shadow: inset 0 0 0 1px rgba(43, 76, 64, .28), var(--shadow); transform: translateY(-1px); }
.gp-rel:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 2px; }
.gp-rel-p { font-family: var(--display); font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.gp-rel-lv { align-self: start; padding: 2px 8px; border-radius: 999px; background: rgba(43, 76, 64, .08); color: var(--pine); font-size: 12px; font-weight: 600; }
.gp-rel-m { grid-column: 1 / -1; font-size: 14px; line-height: 1.6; color: #4A554F; }

.gp-lessons { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.gp-lessons li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; }
.gp-lessons li + li { box-shadow: inset 0 1px var(--hairline); }
.gp-lessons a { display: grid; gap: 2px; color: var(--ink); text-decoration: none; }
.gp-lessons a:hover .gp-lesson-t { color: var(--vermilion-text); }
.gp-lesson-c { font-size: 13px; color: var(--muted); }
.gp-lesson-t { font-size: 16px; line-height: 1.5; transition-property: color; transition-duration: var(--t-small); transition-timing-function: var(--ease-enter); }
.gp-badge { flex: none; padding: 3px 10px; border-radius: 999px; background: rgba(31, 42, 37, .06); color: var(--muted); font-size: 12px; font-weight: 600; }
.gp-badge.gp-free { background: rgba(43, 76, 64, .1); color: var(--pine); }

.gp-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 28px 0 0 calc(200px + clamp(24px, 4vw, 64px)); box-shadow: inset 0 1px var(--hairline); }

/* ---------------------------------------------------------------- turning the page */
.gp-turn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: clamp(56px, 6vw, 96px); box-shadow: inset 0 2px var(--frame-ink), inset 0 -1px var(--frame-ink-2); }
.gp-turn a { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 22px 4px; color: var(--ink); text-decoration: none; }
.gp-turn strong { font-family: var(--display); font-size: clamp(20px, 2vw, 26px); font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; transition-property: color; transition-duration: var(--t-small); transition-timing-function: var(--ease-enter); }
.gp-turn a:hover strong { color: var(--vermilion-text); }
.gp-turn a:focus-visible { outline: 2px solid var(--vermilion); outline-offset: -2px; }
.gp-prev { grid-column: 1; }
.gp-up { grid-column: 2; justify-items: center; text-align: center; }
.gp-next { grid-column: 3; justify-items: end; text-align: right; }

@media (max-width: 767px) {
  .gp-head .crumbs ol { margin-bottom: 16px; }
  .gp-pattern { font-size: clamp(34px, 10vw, 44px); }
  .gp-block { grid-template-columns: minmax(0, 1fr); padding: 22px 0 24px; }
  .gp-block > :not(.gp-h2) { grid-column: 1; }
  .gp-actions { padding-left: 0; }
  .gp-h2 { grid-row: auto; margin: 0 0 4px; }
  .gp-ex-ja { font-size: 18px; }
  .gp-ex { padding-left: 14px; }
  .gp-related { grid-template-columns: minmax(0, 1fr); }
  .gp-turn { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gp-up { grid-column: 1 / -1; grid-row: 2; box-shadow: inset 0 1px var(--hairline); }
  .gp-prev { grid-column: 1; grid-row: 1; }
  .gp-next { grid-column: 2; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .say, .gp-rel, .gp-lesson-t, .gp-turn strong { transition: none; }
  .gp-rel:hover { transform: none; }
}

/* ---------------------------------------------------------------- word pages */
.wp-read { display: grid; justify-items: start; gap: 10px; margin-top: clamp(24px, 3vw, 36px); }
.wp-reading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.wp-reading .wi-pitch { margin-top: 0; }
.wp-reading .wi-pitch .pitch { font-size: 26px; }
.wp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 0; }
.wp-chips .wi-class, .wp-class-line .wi-class { cursor: default; }
.wp-also { margin: 0; }
.wp-meaning, .wp-senses { max-width: 38em; margin: 0; font-size: clamp(17px, 1.35vw, 20px); line-height: 1.7; color: #3A4640; }
.wp-senses { display: grid; gap: 4px; padding-left: 1.4em; }
.wp-senses li::marker { color: var(--muted); font-size: 15px; }
.wp-figure { justify-items: center; padding-left: clamp(20px, 3vw, 48px); }
.wp-figure .pic { width: min(100%, 300px); }

.wp-note { max-width: 40em; margin: 0 0 14px; font-size: 15px; line-height: 1.7; color: #3A4640; }
.wp-class-line { margin: 18px 0 10px; }
.wp-class-line:first-child { margin-top: 0; }
.wp-table-wrap { overflow-x: auto; }
.wp-table { width: 100%; max-width: 760px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.wp-table col:first-child, .wp-table th[scope="col"]:first-child { width: 34%; }
.wp-table thead th { padding: 0 12px 10px 0; text-align: left; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.wp-table thead th:lang(en) { letter-spacing: .04em; text-transform: uppercase; font-size: 12px; }
.wp-table tbody th, .wp-table td { padding: 10px 12px 10px 0; text-align: left; vertical-align: top; box-shadow: inset 0 1px var(--hairline); }
.wp-table tbody th { font-weight: 400; }
.wp-table tbody th b { display: block; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.wp-table tbody th span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.wp-table .wp-group th { padding: 22px 0 8px; font-family: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--pine); box-shadow: none; }
.wp-table .wp-group:first-child th { padding-top: 6px; }
.wp-w { display: block; font-size: 18px; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; }
.wp-r { display: block; font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.wp-w em, .wp-r em { font-style: normal; color: var(--vermilion-text); }
.wp-none { color: var(--muted); }

.gp-ex-ja ruby rt { font-size: .5em; color: var(--muted); }
.gp-ex-ja b { font-weight: 600; color: var(--vermilion-text); }
.gp-ex-ja b rt { color: var(--vermilion-text); }

.wp-kanji { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.wp-kanji li { display: grid; grid-template-columns: minmax(0, 13em) auto minmax(0, 1fr); align-items: baseline; gap: 4px 14px; padding: 10px 0; }
.wp-kanji li + li { box-shadow: inset 0 1px var(--hairline); }
.wp-k { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; color: var(--ink); text-decoration: none; }
a.wp-k:hover .wp-k-w { color: var(--vermilion-text); }
a.wp-k .wp-k-w { text-decoration: underline; text-decoration-color: rgba(31, 42, 37, .25); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.wp-k-w { font-size: 20px; line-height: 1.35; transition-property: color; transition-duration: var(--t-small); transition-timing-function: var(--ease-enter); }
.wp-k-r { font-size: 14px; color: var(--muted); }
.wp-k-lv { align-self: center; padding: 2px 8px; border-radius: 999px; background: rgba(43, 76, 64, .08); color: var(--pine); font-size: 12px; font-weight: 600; }
.wp-k-m { font-size: 15px; line-height: 1.55; color: #3A4640; }
.wp-h3 { margin: 22px 0 4px; font-family: var(--text); font-size: 14px; font-weight: 600; color: var(--ink); }
.gp-foot { margin-top: 32px; }
.wp-credit { margin: 0 auto 8px; text-align: center; }
.wp-credit a { color: inherit; }

/* The level lists: word, reading, short meaning, one line each, in columns. */
.wl { columns: 2 22em; column-gap: clamp(24px, 4vw, 64px); margin: 0; padding: 18px 0 0; list-style: none; }
.wl li { break-inside: avoid; padding: 7px 0; font-size: 15px; line-height: 1.5; color: #3A4640; scroll-margin-top: 150px; }
.wl li b { font-family: var(--display); font-size: 19px; font-weight: 400; color: var(--ink); }
.wl li a { color: var(--ink); text-decoration: none; }
/* A word with its own page: an ink hairline under it, as on the home's level links. */
.wl li a b { text-decoration: underline 1px var(--frame-ink-2); text-underline-offset: 5px; }
.wl li a:hover b { color: var(--vermilion-text); text-decoration-color: currentColor; }
.wl li a:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 2px; border-radius: 4px; }
.wl li a span, .wl li > span[lang] { color: var(--muted); font-size: 14px; }
.wl li:target { animation: lib-mark 1.6s var(--ease-enter) both; }
.wl-group { content-visibility: auto; contain-intrinsic-size: auto 900px; }
.wl-group .lib-group-head span { font-size: clamp(40px, 4vw, 56px); }

@media (max-width: 767px) {
  .wp-reading .wi-pitch .pitch { font-size: 22px; }
  .wp-figure { padding: 24px 0 0; justify-items: start; }
  .wp-figure .pic { width: min(100%, 220px); }
  .wp-table { font-size: 14px; }
  .wp-table tbody th, .wp-table td { padding-right: 8px; }
  .wp-w { font-size: 16px; }
  .wp-kanji li { grid-template-columns: minmax(0, 1fr) auto; }
  .wp-k-m { grid-column: 1 / -1; }
  .wl { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .wp-k-w { transition: none; }
  .wl li:target { animation: none; background-color: rgba(198, 160, 102, .16); }
}

/* Long button labels on the vocabulary section and level pages wrap instead of
   pushing the leaf wider than a phone. */
.study-page .hero-actions .btn { white-space: normal; text-align: left; }
.study-page .hero-actions { max-width: 100%; }
