/* ============================================================
   vocab-library.css — the standalone /vocabulary browser.

   Two panes: a virtualized word list (left) + a word-detail panel
   (right), stacking on narrow screens. Uses the shared theme tokens
   (css/theme.css) so light/dark track automatically.

   The promo rail is NOT part of this grid — it lives in the page-level
   .layout-with-rail (site.css) wrapping the library AND the editorial block,
   so it can stay stuck past this fixed-height pane.
   ============================================================ */

.vocab-library {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 22px;   /* breathing room below the title banner */
}
/* Nudge the detail column down so its top lines up with the top of the word
   LIST (which sits below the ~39px search input + 10px margin). */
.vocab-details { margin-top: 49px; }

/* Sit the library in the site's standard content card rather than bare on the
   page background — same tokens as .section in site.css, matching /decks. The
   blue .group-title kicker above it supplies the spacing, so no top margin. */
.vocab-page .vocab-library {
  margin-top: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
}

/* The shared rail stacks at 900px, but this page needs it earlier: two panes
   PLUS a 300px rail leaves the detail column too narrow below ~1024px. Drop
   the rail under the content at the same breakpoint the library reflows. */
@media (max-width: 1024px) {
  .vocab-library { grid-template-columns: minmax(240px, 340px) 1fr; }
  .vocab-page .layout-with-rail { grid-template-columns: 1fr; }
  .vocab-page .layout-with-rail__main,
  .vocab-page .layout-with-rail__rail { min-width: 0; }
  .vocab-page .layout-with-rail__rail { position: static; align-items: center; }
}
@media (max-width: 760px) {
  /* Single column. (The old duplicate :not(:has(.store-promo)) selector here
     existed only to out-specify a site.css rule that has since been removed
     along with the third ad column.) The detail bottom-sheet treatment lives
     at the END of this file so its position:fixed wins. */
  .vocab-library { grid-template-columns: 1fr; gap: 16px; }
}

/* ── Left pane: search + list ───────────────────────────── */
.vocab-browse { display: flex; flex-direction: column; min-width: 0; }

/* wrap so a longer count / decks-link in other languages drops to a second
   line instead of squeezing the input; min-width keeps the field usable. */
.vocab-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
#vocab-search-input {
  flex: 1 1 220px;
  min-width: 200px;
  font-family: inherit;
  font-size: 15px;
  padding: 9px 13px;
  border: 1.5px solid var(--container-border, #d9cdb4);
  border-radius: 10px;
  background: var(--bg, #fbf6ea);
  color: var(--text, #1f1a1a);
}
#vocab-search-input:focus {
  outline: none;
  border-color: var(--accent, #b32a2a);
  box-shadow: 0 0 0 3px var(--accent-bg, rgba(179, 42, 42, 0.07));
}
.vocab-count {
  font-size: 12px;
  color: var(--text-faint, #7a6260);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.vocab-list {
  height: clamp(360px, 62vh, 720px);
  overflow-y: auto;
  border: 1.5px solid var(--container-border, #d9cdb4);
  border-radius: 12px;
  background: var(--bg, #fbf6ea);
  -webkit-overflow-scrolling: touch;
}
.vocab-item {
  height: 56px;            /* MUST match ROW_H in library-page.js */
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line, rgba(31, 26, 26, 0.08));
  cursor: pointer;
}
.vocab-word-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
@media (hover: hover) {
  .vocab-item:hover { background: var(--accent-hover, rgba(179, 42, 42, 0.10)); }
}
.vocab-item.selected {
  background: var(--accent-bg, rgba(179, 42, 42, 0.07));
  box-shadow: inset 3px 0 0 var(--accent, #b32a2a);
}
.vocab-word {
  font-family: 'Klee One', 'Noto Sans JP', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #1f1a1a);
  line-height: 1.1;
}
.vocab-sub {
  font-size: 12px;
  color: var(--text-faint, #7a6260);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vocab-spacer { width: 100%; }

.vocab-loading, .vocab-empty, .vocab-error {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-faint, #7a6260);
  font-size: 14px;
}
.vocab-error { color: var(--accent, #b32a2a); }

/* ── Right pane: detail ─────────────────────────────────── */
.vocab-details {
  position: sticky;
  top: 16px;
  border: 1.5px solid var(--container-border, #d9cdb4);
  border-radius: 14px;
  background: var(--bg, #fbf6ea);
  padding: 22px 24px;
  min-height: 200px;
}
.vocab-details-empty {
  color: var(--text-faint, #7a6260);
  font-size: 14px;
  text-align: center;
  padding: 40px 8px;
}
.vocab-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.vocab-detail-headword {
  font-family: 'Klee One', 'Noto Sans JP', serif;
  font-size: 40px;
  font-weight: 700;
  color: var(--text, #1f1a1a);
  line-height: 1.1;
}
.vocab-detail-audio {
  border: 1.5px solid var(--container-border, #d9cdb4);
  background: var(--bg-outer, #f4ede0);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted, #54403a);
  flex: 0 0 auto;
}
@media (hover: hover) {
  .vocab-detail-audio:hover { border-color: var(--accent, #b32a2a); color: var(--accent, #b32a2a); }
}
.vocab-detail-reading {
  font-family: 'Klee One', 'Noto Sans JP', serif;
  font-size: 20px;
  color: var(--text-muted, #54403a);
  margin-top: 4px;
}
.vocab-detail-romaji {
  font-size: 14px;
  color: var(--text-faint, #7a6260);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.vocab-detail-meaning {
  font-size: 16px;
  color: var(--text, #1f1a1a);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line, rgba(31, 26, 26, 0.08));
}

/* ── Conjugation tables ─────────────────────────────────── */
.vocab-conj { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.vocab-conj-block { }
.vocab-conj-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent, #b32a2a);
  margin-bottom: 6px;
}
.vocab-conj-rows { display: flex; flex-direction: column; gap: 1px; }
.vocab-conj-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--line, rgba(31, 26, 26, 0.06));
}
.vocab-conj-row.no-kanji { grid-template-columns: 1.1fr 1fr; }
.vocab-conj-label { font-size: 12px; color: var(--text-faint, #7a6260); }
.vocab-conj-kanji,
.vocab-conj-reading {
  font-family: 'Klee One', 'Noto Sans JP', serif;
  font-size: 15px;
  color: var(--text, #1f1a1a);
}
.vocab-conj-reading { color: var(--text-muted, #54403a); }

/* ── Mobile detail = bottom sheet ───────────────────────────────────
   End-of-file (after the base .vocab-details rule) so position:fixed +
   close/backdrop reveal win on source order. On phones the list is
   full-width and tapping a word slides the detail up from the bottom;
   opened via the `vocab-detail-open` body class (library-page.js). */
.vocab-detail-close { display: none; }          /* shown only in sheet mode */
.vocab-sheet-backdrop { display: none; }

@media (max-width: 760px) {
  .vocab-details {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; margin: 0;
    z-index: 60; max-height: 82vh; overflow: auto;
    border-radius: 16px 16px 0 0; padding-top: 40px;
    transform: translateY(101%); transition: transform .28s ease;
    box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.22);
  }
  .vocab-details::before {                       /* grab handle */
    content: ""; position: absolute; top: 11px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px;
    background: var(--container-border, #d9cdb4);
  }
  body.vocab-detail-open .vocab-details { transform: translateY(0); }
  .vocab-detail-close {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; top: 6px; right: 10px; z-index: 2;
    width: 34px; height: 34px; padding: 0; border: none; border-radius: 8px;
    background: transparent; cursor: pointer; font-size: 17px; line-height: 1;
    color: var(--text-faint, #7a6260);
  }
  .vocab-sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0, 0, 0, 0.42); opacity: 0; pointer-events: none;
    transition: opacity .28s ease;
  }
  body.vocab-detail-open .vocab-sheet-backdrop { opacity: 1; pointer-events: auto; }
  body.vocab-detail-open { overflow: hidden; }   /* lock background scroll */
}
