/* Shared styles for the kanji study pages (KIC, finance, news, books).
   Loaded site-wide via config.toml [extra] custom_css. Pages used to embed
   a copy of this block; the page generators should no longer emit one. */

.kic-page {
  font-family: system-ui, -apple-system, "Helvetica Neue", "Hiragino Sans", "Noto Sans CJK JP", sans-serif;
  /* Text size = base for the screen width × the reader's A−/A+ setting
     (--kic-scale, set on <html> by kic.js, remembered per device). */
  --kic-base: 15px;
  font-size: calc(var(--kic-base) * var(--kic-scale, 1));
  line-height: 1.7;
  max-width: 760px;
  margin: 0 auto;
  padding: 1em 1em 4em 1em;
}
.kic-page ruby { ruby-align: center; }
.kic-page rt {
  font-size: max(0.55em, 10px); /* furigana never smaller than 10px */
  opacity: 0.85;
  letter-spacing: 0.05em;
}
body.hide-furigana .kic-page ruby rt { visibility: hidden; }
.kic-page table { border-collapse: collapse; margin: 1em 0; min-width: 100%; }
.kic-page th, .kic-page td {
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  padding: 0.4em 0.7em;
  text-align: left;
  vertical-align: top;
}
.kic-page th { background: color-mix(in srgb, currentColor 6%, transparent); }
.kic-page .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1em 0; }
.kic-page img { max-width: 100%; height: auto; display: inline-block; border-radius: 6px; }
/* News-track image credit: the italic *写真：…* paragraph right after an image. */
.kic-page p:has(> img) { margin-bottom: 0.3em; }
.kic-page p:has(> img) + p > em { font-size: 0.82em; opacity: 0.7; }
.kic-page details {
  margin: 1em 0;
  padding: 0.5em 0.9em;
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  border-radius: 6px;
}
.kic-page details summary { cursor: pointer; font-weight: 600; }
.kic-page blockquote {
  border-left: 3px solid color-mix(in srgb, currentColor 30%, transparent);
  padding-left: 1em;
  margin: 1em 0;
  opacity: 0.92;
}
.kic-furigana-toggle {
  display: inline-block;
  margin: 0.6em 0 1.4em 0;
  padding: 0.4em 0.9em;
  font: inherit;
  font-size: 0.95em;
  cursor: pointer;
  background: transparent;
  color: inherit;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 999px;
}
.kic-furigana-toggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
/* News track: NHK-Easy-style proper-noun highlighting. The nw-* classes are
   only emitted by scripts/build-news.nu; harmless on chapter/article pages. */
.kic-page .nw-place  { color: #2e7dd1; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 0.2em; }
.kic-page .nw-person { color: #2e9e5b; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 0.2em; }
.kic-page .nw-org    { color: #c05621; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 0.2em; }
.kic-page .nw-event  { color: #7a4fc9; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 0.2em; }
body.hide-names .kic-page .nw-place,
body.hide-names .kic-page .nw-person,
body.hide-names .kic-page .nw-org,
body.hide-names .kic-page .nw-event {
  color: inherit; font-weight: inherit; text-decoration: none;
}
.kic-names-toggle {
  display: inline-block;
  margin: 0.6em 0 1.4em 0.5em;
  padding: 0.4em 0.9em;
  font: inherit;
  font-size: 0.95em;
  cursor: pointer;
  background: transparent;
  color: inherit;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 999px;
}
.kic-names-toggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.kic-furigana-toggle--inline {
  display: block;
  margin: -0.4em 0 1em 0;
  padding: 0.15em 0.7em;
  font-size: 0.78em;
  opacity: 0.65;
}
.kic-furigana-toggle--inline:hover { opacity: 1; }
/* A− / 100% / A+ text-size stepper (injected by kic.js next to the toggles). */
.kic-textsize {
  color: inherit; /* the theme greys out every <span>; keep the page's text colour */
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
  margin: 0.6em 0 1.4em 0.5em;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 999px;
  overflow: hidden;
  font-size: 0.95em;
}
.kic-textsize button {
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0.4em 0.8em;
  min-width: 2.6em;
}
.kic-textsize button + button { border-left: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
.kic-textsize button:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.kic-textsize button:disabled { opacity: 0.35; cursor: default; background: transparent; }
.kic-textsize .kic-textsize-level { font-variant-numeric: tabular-nums; opacity: 0.8; }

/* Book workbook pages (読書ノート). */
.kic-page details.book-part { margin: 0.6em 0; padding: 0.4em 0.9em; border: 1px solid rgba(128,128,128,0.35); border-radius: 6px; }
.kic-page details.book-part > summary { cursor: pointer; font-weight: 700; }
.kic-page .book-unread { margin: 0.6em 0; padding: 0.4em 0.9em; border: 1px dashed rgba(128,128,128,0.35); border-radius: 6px; opacity: 0.6; }
.kic-page details.book-unread > summary { cursor: pointer; }
.kic-page details.book-part details { margin: 0.4em 0 0; opacity: 0.8; }
.kic-page details.book-part details > summary { cursor: pointer; font-size: 0.9em; }
.kic-page .book-bar { display: inline-block; height: 0.75em; background: #2e7dd1; border-radius: 2px; vertical-align: baseline; }
.kic-page .book-progress { height: 0.8em; background: rgba(128,128,128,0.25); border-radius: 4px; overflow: hidden; max-width: 420px; }
.kic-page .book-progress > span { display: block; height: 100%; background: #2e7dd1; }

/* ---- Tablet and phone ------------------------------------------------
   Selectors below are prefixed with `body` on purpose: a page regenerated by
   an old generator still embeds the legacy style block *after* this file in
   document order, and its phone rules (`.kic-page rt { font-size: 0.5em }`,
   `.kic-page { padding: ... }`) would otherwise win on equal specificity.
   Pages are mostly read on a phone or iPad, so Japanese text steps up as the
   screen gets smaller; furigana keeps a 10px floor (see .kic-page rt above).
   Phone rules also reclaim the three stacked side margins (theme body margin,
   .content padding, .kic-page padding) and tame the shared theme's oversized
   table headers so vocabulary tables fit without sideways scrolling. */
@media (max-width: 1100px) {
  body .kic-page { --kic-base: 17px; }
}
@media (max-width: 600px) {
  body { margin: 0; }
  body .content { padding: 0 12px; }
  body .kic-page { padding: 0.5em 0 3em 0; --kic-base: 19px; line-height: 1.75; }
  body .kic-page rt { font-size: max(0.6em, 10px); }

  /* Tables: body-sized headers, tighter cells, short Japanese headers kept whole. */
  body .kic-page table { font-size: 0.85em; }
  body .kic-page table th { font-size: inherit; word-break: keep-all; hyphens: auto; }
  body .kic-page th, body .kic-page td { padding: 0.3em 0.45em; }

  /* Less chrome above the first article: hide the date / read-time line and
     fit the top toggle buttons on one row. */
  body article .title .meta { display: none; }
  body .kic-page > .kic-furigana-toggle:not(.kic-furigana-toggle--inline),
  body .kic-page > .kic-names-toggle {
    margin: 0.3em 0.4em 0.9em 0;
    padding: 0.3em 0.75em;
    font-size: 0.8em;
  }
  body .kic-page > .kic-textsize { margin: 0.3em 0.4em 0.9em 0; font-size: 0.8em; }
  body .kic-page > .kic-textsize button { padding: 0.3em 0.65em; }
}
