/*
 * Reusable components: buttons, cards, badges, tags, radio cards,
 * dialogs and toast.
 */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: var(--pill);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--ground); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #FFFFFF; }
.btn.primary:hover { background: var(--violet-ink); border-color: var(--violet-ink); }
.btn.primary svg { color: var(--lime); }
.btn.xs { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; margin-bottom: var(--gap); min-width: 0; }
.card.narrow { max-width: 680px; }
.card h3 { margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* Badges and pills */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.green { background: var(--lime-soft); color: var(--lime-ink); }
.badge.purple { background: var(--violet-soft); color: var(--violet-ink); }
.badge.gray { background: var(--gray-soft); color: var(--text-muted); }

/* Tags */
.tag-group + .tag-group { margin-top: 14px; }
.tag-group-head { display: flex; align-items: baseline; gap: 10px; }
.tag-group-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tag-group-count { font-size: 12px; font-weight: 600; color: var(--violet-ink); }
.tag-more { font-size: 12px; color: var(--text-muted); align-self: center; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
/*
 * Tags are flat labels, not rounded outlined chips: grey when free, solid
 * violet with a check mark when picked. Static ones (book cards, preview)
 * are smaller and never react to the pointer.
 */
.tag-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 6px;
  background: var(--ground); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
  transition: background .12s, color .12s;
}
.tag-pill:hover { background: var(--track); }
.tag-pill[aria-pressed="true"] { background: var(--violet); color: #FFFFFF; font-weight: 600; }
.tag-pill[aria-pressed="true"]::before { content: "✓"; font-weight: 700; }
.tag-pill:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tag-pill.static { cursor: default; min-height: 24px; padding: 0 8px; border-radius: 4px; font-size: 12px; }
.tag-pill.static:hover { background: var(--ground); }

/* Spice level as chili peppers */
.spice-meter { display: inline-flex; align-items: center; gap: 1px; }
.chili { width: 18px; height: 18px; fill: none; stroke: var(--line-strong); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chili.on { stroke: var(--chili); }
.chili.on .chili-body { fill: var(--chili); }
.chili.on .chili-stem { stroke: var(--lime-ink); }
.spice-label { margin-left: 8px; font-size: 13px; color: var(--text-muted); }

/* Choices (radio cards) */
.choice {
  display: flex; align-items: flex-start; gap: 12px; margin: 0;
  padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  color: var(--text); font-size: 14px; font-weight: 400; cursor: pointer;
}
.choice:hover { border-color: var(--lavender); }
.choice:has(input:checked) { border-color: var(--violet); background: var(--violet-soft); }
.choice:has(input:disabled) { cursor: default; }
.choice input { margin-top: 3px; }
.choice-body { flex: 1; }
.choice-strong { display: block; font-weight: 600; }
.choice-desc { display: block; font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Dialog */
dialog.modal { border: 0; border-radius: var(--radius-lg); width: min(640px, calc(100% - 32px)); padding: 28px; margin: 48px auto; color: var(--text); }
dialog.modal::backdrop { background: rgba(20, 20, 20, .45); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-close {
  width: var(--control-h); height: var(--control-h); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--ground); cursor: pointer; color: var(--text);
}
.modal-close svg { width: 16px; height: 16px; }

/* CGU acceptance at first sign-in */
.terms-gate { max-width: 520px; }
.terms-gate h2 { font-size: 24px; margin: 18px 0 8px; }
.terms-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.terms-brand .brand-mark { width: 32px; height: 32px; }
.terms-brand-sub { font-family: var(--font-body); font-weight: 400; font-size: 13px; color: var(--text-muted); }
.terms-docs { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.terms-docs a { color: var(--violet-ink); font-weight: 700; }
.terms-check {
  display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 14px 16px;
  border: 2px solid var(--violet); border-radius: var(--radius); color: var(--text); font-size: 14px; cursor: pointer;
}
.terms-check input { margin-top: 2px; width: 18px; height: 18px; flex: none; }
.terms-gate::backdrop { background: rgba(121, 60, 251, .25); backdrop-filter: blur(4px); }

/* Toast */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999; max-width: 360px;
  padding: 14px 18px; border-radius: var(--radius);
  background: var(--violet-ink); color: #FFFFFF; font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(20, 20, 20, .18);
}
#toast::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 4px; background: var(--lime); margin-right: 10px; vertical-align: 1px; }
#toast.err::before { background: #FF8A80; }

/* Fatal error screen (data source unavailable) */
.fatal { max-width: 560px; margin: 15vh auto; padding: 32px; background: var(--surface); border-radius: var(--radius-lg); }
.fatal h1 { font-size: 28px; margin-bottom: 8px; }

