/* ============================================================
   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.
   ============================================================ */

.vocab-library {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr 300px;
  gap: 24px;
  align-items: start;
  margin-top: 22px;   /* breathing room below the title banner */
}
/* Nudge the detail + ad columns down so their tops line up with the top of
   the word LIST (which sits below the ~39px search input + 10px margin). */
.vocab-details, .vocab-adrail { margin-top: 49px; }
/* Ad column: dedicated third column, sticky like the detail pane. */
.vocab-adrail { position: sticky; top: 16px; }

/* Below the widest layout, drop the dedicated ad column: it spans full
   width beneath the list + detail pair (centered), then everything stacks
   to a single column on phones. */
@media (max-width: 1024px) {
  .vocab-library { grid-template-columns: minmax(240px, 340px) 1fr; }
  .vocab-adrail { grid-column: 1 / -1; position: static; display: flex; justify-content: center; margin-top: 0; }
}
@media (max-width: 760px) {
  /* Single column. The second selector matches the store-promo rule's
     specificity (.vocab-library:not(:has(.store-promo)) in site.css) so it
     wins on phones instead of being overridden back to 2 columns. The
     detail bottom-sheet treatment lives at the END of this file (after the
     base .vocab-details rule) so its position:fixed wins. */
  .vocab-library,
  .vocab-library:not(:has(.store-promo)) { 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 */
}
