/* cardbase.css: the flashcards page as a card database (cardbase.js).
 * Uses the style.css tokens; every flex and grid child that holds text gets
 * min-width:0 so long words never push the page sideways on a phone. */

.cb { margin: 18px 0 0; font-family: 'Inter', system-ui, sans-serif; }
.cb * { min-width: 0; }
.cb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* toolbar */
.cb-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  padding: 14px; background: var(--bg-2); border: 1px solid var(--rule); border-radius: 10px;
}
.cb-search { flex: 1 1 280px; display: block; }
.cb-search input {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .95rem;
  color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 8px;
}
.cb-search input::placeholder { color: var(--ink-3); }
.cb-field { display: flex; flex-direction: column; gap: 3px; flex: 0 1 auto; max-width: 100%; }
.cb-lbl { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cb-field select {
  max-width: 100%; width: 100%; padding: 9px 10px; font: inherit; font-size: .88rem;
  color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 8px;
}
#cb-unit { max-width: 340px; }
.cb-check { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; color: var(--ink-2); padding: 9px 0; cursor: pointer; }
.cb-check input { width: 17px; height: 17px; accent-color: var(--accent, var(--amber)); }
.cb-views { display: inline-flex; gap: 0; }
.cb-views .btn { border-radius: 0; padding: 8px 14px; }
.cb-views .btn:first-child { border-radius: 8px 0 0 8px; }
.cb-views .btn:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.cb .btn.on { background: var(--accent, var(--amber)); color: #14110a; border-color: transparent; font-weight: 600; }
.cb .btn { padding: 8px 14px; }

.cb-status { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin: 12px 2px 8px; font-size: .85rem; color: var(--ink-2); }
#cb-count { font-family: 'JetBrains Mono', monospace; font-size: .8rem; }
#cb-note { color: var(--rose); }

/* visible focus everywhere in the viewer */
.cb a:focus-visible, .cb button:focus-visible, .cb input:focus-visible,
.cb select:focus-visible, .cb [tabindex]:focus-visible {
  outline: 2px solid var(--accent, var(--amber)); outline-offset: 2px;
}

mark { background: rgba(230,168,92,.34); color: inherit; border-radius: 2px; padding: 0 1px; }

/* table view */
.cb-head, .cb-sum {
  display: grid;
  grid-template-columns: 3rem minmax(0, 9.5rem) minmax(0, 1.1fr) minmax(0, 1.5fr) 80px 4.5rem;
  gap: 12px; align-items: start;
}
.cb-head {
  padding: 8px 12px; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--rule);
}
.cb-row { border-bottom: 1px solid var(--rule); }
.cb-sum { padding: 11px 12px; cursor: pointer; border-radius: 6px; }
.cb-sum:hover { background: var(--bg-2); }
.cb-row.open { background: var(--bg-2); }
.cb-n { font-family: 'JetBrains Mono', monospace; font-size: .76rem; color: var(--ink-3); padding-top: 2px; }
/* the # cell is the row's open/close button: looks like the number, behaves like a button */
.cb-toggle { font: inherit; font-family: 'JetBrains Mono', monospace; font-size: .76rem; line-height: 1.3; text-align: left;
  color: var(--ink-3); background: none; border: 0; border-radius: 4px; padding: 2px 4px 0 0; cursor: pointer; }
.cb-toggle:hover { color: var(--ink); }
.cb-row { position: relative; }
.cb-unit { font-size: .76rem; line-height: 1.35; color: var(--ink-3); overflow-wrap: anywhere; }
.cb-q { font-size: .95rem; line-height: 1.4; color: var(--ink); overflow-wrap: break-word; }
.cb-a { font-size: .9rem; line-height: 1.4; color: var(--ink-2); }
.cb-a .cb-atext { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-row.open .cb-a .cb-atext, .cb-a .cb-atext.full { white-space: normal; overflow: visible; overflow-wrap: break-word; color: var(--ink); }
.cb-th { display: block; }
.cb-thumb {
  display: block; width: 72px; height: 45px; object-fit: contain;
  background: #fff; border: 1px solid var(--rule); border-radius: 4px;
}
.cb-srccell { font-size: .82rem; }
.cb-src { white-space: nowrap; }

.cb-detail { padding: 2px 12px 16px calc(3rem + 24px); }
.cb-detail .cf-fig { margin-top: 6px; }
.cb-detail .cf-fig img, .cb-card .cf-fig img { background: #fff; }
.cb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; font-size: .85rem; }
.cb-src-full { overflow-wrap: anywhere; }

/* hide answers */
.cb-cover {
  display: block; width: 100%; text-align: left; padding: 5px 10px; font: inherit; font-size: .84rem;
  color: var(--ink-3); background: repeating-linear-gradient(135deg, var(--bg-3), var(--bg-3) 6px, var(--bg-2) 6px, var(--bg-2) 12px);
  border: 1px dashed var(--rule); border-radius: 6px; cursor: pointer;
}
.cb-cover:hover { color: var(--ink); border-color: var(--accent, var(--amber)); }

/* cards view */
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.cb-card {
  display: flex; flex-direction: column; gap: 8px; padding: 16px;
  background: var(--bg-2); border: 1px solid var(--rule); border-radius: 10px;
}
.cb-card.target { border-color: var(--accent, var(--amber)); box-shadow: 0 0 0 2px var(--accent-soft, rgba(230,168,92,.2)); }
.cb-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.cb-pill { font-size: .72rem; line-height: 1.35; color: var(--ink-3); overflow-wrap: anywhere; }
.cb-card-q { margin: 0; font-size: 1.02rem; line-height: 1.35; color: var(--ink); overflow-wrap: break-word; }
.cb-card-a { font-size: .9rem; line-height: 1.45; color: var(--ink-2); overflow-wrap: break-word; }
.cb-card .cf-fig { margin: 4px 0 0; }
.cb-card .cb-actions { margin-top: auto; padding-top: 6px; }

.cb-empty { padding: 34px 18px; text-align: center; border: 1px dashed var(--rule); border-radius: 10px; }
.cb-empty h3 { margin-top: 0; }
.cb-empty p { color: var(--ink-2); overflow-wrap: anywhere; }
.cb-loading { color: var(--ink-3); padding: 20px 4px; }
#cb-sentinel { height: 1px; }

/* phones and narrow windows: stacked rows, no sideways scroll */
@media (max-width: 760px) {
  .cb-toolbar { padding: 12px; gap: 8px 12px; }
  .cb-search { flex-basis: 100%; }
  .cb-field { flex: 1 1 140px; }
  #cb-unit { max-width: 100%; }
  .cb-head { display: none; }
  .cb-sum {
    grid-template-columns: minmax(0, 1fr) 76px;
    grid-template-areas: "unit th" "q th" "a a" "src src";
    gap: 4px 10px;
  }
  /* phones: the row is tapped directly; the number button stays for screen readers and appears when focused */
  .cb-n { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cb-toggle:focus-visible { position: static; width: auto; height: auto; clip: auto; grid-area: unit; justify-self: end; }
  .cb-unit { grid-area: unit; }
  .cb-q { grid-area: q; }
  .cb-a { grid-area: a; }
  .cb-th { grid-area: th; }
  .cb-srccell { grid-area: src; }
  .cb-detail { padding: 2px 12px 14px; }
  .cb-grid { grid-template-columns: minmax(0, 1fr); }
}
