/* ============================================================
   vocab-flashcards.css — the Printable Flashcard Maker (/vocabulary/flashcards).

   Screen: a picker card (library list | your cards), a print-options
   panel, and a live preview. The preview and the printout share ONE
   markup: every sheet dimension is `calc(var(--u) * <mm>)`, where --u is
   1mm when printing and "page width in px / paper width in mm" on screen
   (set by js/vocab/flashcards-page.js). So the preview is the print
   layout, scaled.

   Sheets are paper: they stay white with dark ink in dark mode too.
   ============================================================ */

.fc-page { width: 100%; }

/* ── Picker card ──────────────────────────────────────────── */
.fc-app {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 26px;
}
.fc-pick, .fc-build { display: flex; flex-direction: column; min-width: 0; }

.fc-search-row, .fc-deck-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
#fc-search {
  flex: 1 1 220px; min-width: 0;
  font: inherit; font-size: 15px;
  padding: 9px 13px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  background: var(--inset);
  color: var(--ink);
}
#fc-search:focus, .fc-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.fc-count { font-size: 13px; color: var(--faint); white-space: nowrap; }

.fc-deck-row__label { font-size: 13.5px; color: var(--muted); }
.fc-select {
  font: inherit; font-size: 14px;
  padding: 7px 10px;
  border: 1.5px solid var(--line-2);
  border-radius: 9px;
  background: var(--inset);
  color: var(--ink);
  max-width: 100%;
}
.fc-deck-row .fc-select { flex: 1 1 180px; min-width: 0; }
.fc-btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 16px;
  border-radius: 9px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.fc-btn:hover:not(:disabled) { background: var(--accent-bg); }
.fc-btn:disabled { opacity: .45; cursor: default; }

/* Virtualized list — row height must match ROW_H in the controller. */
.fc-list {
  height: 440px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--inset);
  overscroll-behavior: contain;
}
.fc-list:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.fc-list__msg { padding: 18px; color: var(--faint); font-size: 14px; }
.fc-item {
  height: 52px; box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 11em) minmax(0, 1fr) 30px;
  align-items: center; gap: 12px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.fc-item:hover { background: var(--accent-bg); }
.fc-item__jp {
  display: flex; flex-direction: column; min-width: 0;
  font-family: var(--font-kana); font-size: 17px; line-height: 1.15; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-item__reading { font-size: 11.5px; color: var(--faint); font-family: var(--font-ui); }
.fc-item__meaning {
  font-size: 13.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-item__tick {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--accent-line);
  color: var(--accent); font-weight: 700; font-size: 16px;
}
.fc-item.is-on { background: var(--accent-bg); }
.fc-item.is-on .fc-item__tick { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 14px; }

/* Themed thin scrollbars for the two scrolling panes — the default track
   stays bright white in dark mode. */
.fc-list, .fc-selected { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
html.dark .fc-list, html.dark .fc-selected { color-scheme: dark; }

/* ── Your cards ───────────────────────────────────────────── */
.fc-build__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 41px; margin-bottom: 10px;
}
.fc-build__title {
  margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 21px; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
}
.fc-badge {
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 700;
  min-width: 26px; padding: 2px 8px; border-radius: 999px; text-align: center;
  background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line);
}
.fc-link-btn {
  background: none; border: none; padding: 4px 2px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--faint); text-decoration: underline;
}
.fc-link-btn:hover { color: var(--red); }

.fc-selected {
  list-style: none; margin: 0; padding: 0;
  max-height: 491px; overflow-y: auto;
  counter-reset: fc;
}
.fc-selected:empty { display: none; }
.fc-sel {
  counter-increment: fc;
  display: grid;
  grid-template-columns: 2.2em minmax(0, auto) minmax(0, 1fr) 28px;
  align-items: center; gap: 10px;
  padding: 7px 4px 7px 0;
  border-bottom: 1px solid var(--line);
}
.fc-sel::before {
  content: counter(fc);
  font-size: 11.5px; font-weight: 700; color: var(--soft); text-align: right;
}
.fc-sel__jp { font-family: var(--font-kana); font-size: 16px; color: var(--ink); white-space: nowrap; }
.fc-sel__meaning { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-sel__x {
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: none;
  color: var(--faint); font-size: 18px; line-height: 1;
}
.fc-sel__x:hover { color: var(--red); border-color: var(--line-2); background: var(--inset); }
.fc-empty {
  margin: 0; padding: 26px 18px; text-align: center;
  font-size: 14px; color: var(--faint); line-height: 1.5;
  border: 1.5px dashed var(--line-2); border-radius: 12px;
}

/* ── Print panel ──────────────────────────────────────────── */
.fc-print-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 26px;
}
.fc-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px 24px;
  margin: 0 0 18px;
}
.fc-opt { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fc-opt__label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint);
}
.fc-seg {
  display: inline-flex; align-self: flex-start;
  border: 1.5px solid var(--line-2); border-radius: 10px;
  background: var(--inset); padding: 3px; gap: 3px;
}
.fc-seg__opt { position: relative; cursor: pointer; }
.fc-seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.fc-seg__opt span {
  display: block; padding: 6px 14px; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.fc-seg__opt:hover span { color: var(--accent); }
.fc-seg__opt input:checked + span { background: var(--accent); color: #fff; }
.fc-seg__opt input:focus-visible + span { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.fc-opt .fc-select { align-self: flex-start; min-width: 180px; }

.fc-checks { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
.fc-check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink); cursor: pointer; }
.fc-check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.fc-check.is-off { opacity: .45; }

.fc-print-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.fc-print-btn:disabled { opacity: .45; cursor: default; transform: none; }
.fc-print-bar .btn--ghost { border-width: 1px; }
.fc-summary { font-size: 14px; color: var(--muted); }
.fc-hint { margin: 12px 0 0; font-size: 13px; line-height: 1.55; color: var(--faint); max-width: 72ch; }

/* ── Preview ──────────────────────────────────────────────── */
.fc-preview { --u: 2px; }
.fc-preview__empty {
  padding: 38px 20px; text-align: center; font-size: 14px; color: var(--faint);
  border: 1.5px dashed var(--line-2); border-radius: 16px;
}
.fc-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  margin-bottom: 22px;
}
.fc-pv { margin: 0; min-width: 0; }
.fc-pv figcaption {
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 7px;
}
.fc-preview .fc-sheet {
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 22px rgba(40,50,70,.10);
  border-radius: 2px;
}
.fc-preview__more { text-align: center; font-size: 13.5px; color: var(--faint); margin: 0 0 8px; }

/* ── The sheet (shared by preview + print) ────────────────── */
.fc-sheet {
  position: relative;
  background: #fff;
  color: #232026;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.fc-grid { position: absolute; display: grid; }
.fc-c {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 0 calc(var(--u) * 4);
  min-width: 0; min-height: 0;
  overflow: hidden;
}
/* Cut lines on the FRONT only: a back side printed a millimetre off would
   put its dashes visibly beside the fronts'. Each cell draws its right and
   bottom edge; the grid draws the outer top/left. */
.fc-sheet--front .fc-grid {
  border-top: calc(var(--u) * .3) dashed #b9ad97;
  border-left: calc(var(--u) * .3) dashed #b9ad97;
}
.fc-sheet--front .fc-c {
  border-right: calc(var(--u) * .3) dashed #b9ad97;
  border-bottom: calc(var(--u) * .3) dashed #b9ad97;
}
.fc-c__jp {
  font-family: var(--font-kana); font-weight: 500;
  line-height: 1.15; white-space: nowrap; color: #1d2a3a;
}
.fc-c__reading {
  font-family: var(--font-kana); color: #5d5852; line-height: 1.3;
  margin-top: calc(var(--u) * 1.5); white-space: nowrap;
}
.fc-c__meaning {
  font-weight: 600; line-height: 1.25; color: #232026;
  overflow-wrap: anywhere;
}
.fc-c__sub {
  display: flex; flex-direction: column; align-items: center;
  margin-top: calc(var(--u) * 2.5);
  gap: calc(var(--u) * .8);
}
.fc-c--back .fc-c__sub .fc-c__reading { margin-top: 0; }
.fc-c__romaji { color: #8a8175; letter-spacing: .04em; white-space: nowrap; margin-top: calc(var(--u) * 1.2); }
.fc-c__sub .fc-c__romaji { margin-top: 0; }
/* Kanji maker (js/kanji/flashcards-page.js) — picker rows show the glyph
   large with its readings; backs carry 音/訓 reading lines + a JLPT tag. */
.fc-item--kanji .fc-item__glyph { font-size: 22px; line-height: 1; }
.fc-item--kanji .fc-item__jp { flex-direction: row; align-items: baseline; gap: 10px; }
.fc-item__tag {
  display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
  color: var(--muted); background: var(--inset); border: 1px solid var(--line);
}
.fc-c__kanji { font-family: var(--font-kana); font-weight: 400; }
.fc-c__readings {
  display: flex; flex-direction: column; align-items: center;
  margin-top: calc(var(--u) * 2.5); gap: calc(var(--u) * .6);
  font-family: var(--font-kana); color: #3f4a5a; line-height: 1.35;
}
.fc-c__rline { display: block; white-space: normal; text-align: center; }
.fc-c__r { display: inline-block; white-space: nowrap; }
/* "ON" / "KUN" title at the head of each reading line — so a learner can
   tell which readings are on'yomi and which are kun'yomi at a glance. */
.fc-c__rlabel {
  display: inline-block; margin-right: .55em; padding: .05em .4em; border-radius: .3em;
  font-family: var(--font-ui); font-size: .62em; font-weight: 700; letter-spacing: .12em;
  color: #fff; background: #7a8391; vertical-align: .12em;
}
.fc-c__jlpt {
  position: absolute; top: calc(var(--u) * 2.4); right: calc(var(--u) * 3);
  color: #b3aa9c; font-weight: 600; letter-spacing: .04em;
}
.fc-c__num {
  position: absolute; left: calc(var(--u) * 3); bottom: calc(var(--u) * 2.4);
  color: #b3aa9c; font-weight: 600;
}
.fc-c--back .fc-c__num { left: auto; right: calc(var(--u) * 3); }
.fc-c__mark {
  position: absolute; left: calc(var(--u) * 3); bottom: calc(var(--u) * 2.4);
  color: #c9c1b3; letter-spacing: .06em;
}
.fc-foot {
  position: absolute;
  display: flex; justify-content: space-between; align-items: center;
  color: #938b80; letter-spacing: .08em; text-transform: uppercase;
}
.fc-foot__brand { font-weight: 700; color: #20507e; }

/* ── Print ────────────────────────────────────────────────── */
#fc-print-root { display: none; }
@media print {
  #fc-print-root { display: block; --u: 1mm; }
  body > *:not(#fc-print-root) { display: none !important; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  :root { padding: 0 !important; }
  #fc-print-root .fc-sheet { break-after: page; page-break-after: always; }
  #fc-print-root .fc-sheet:last-child { break-after: auto; page-break-after: auto; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .fc-page .layout-with-rail { grid-template-columns: 1fr; }
  .fc-page .layout-with-rail__main,
  .fc-page .layout-with-rail__rail { min-width: 0; }
  .fc-page .layout-with-rail__rail { position: static; align-items: center; }
}
@media (max-width: 760px) {
  .fc-app { grid-template-columns: 1fr; padding: 18px 16px; gap: 20px; }
  .fc-print-panel { padding: 18px 16px; }
  .fc-list { height: 360px; }
  .fc-selected { max-height: 320px; }
  .fc-item { grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr) 30px; }
  .fc-pair { grid-template-columns: 1fr; gap: 14px; }
}
