/* ==========================================================================
   components.css — the ask box, book cards with drawn covers, subject tiles,
   filters, collections, how-it-works steps, library card, toasts.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Ask box — the hero's centrepiece. Same component works on night and paper.
   -------------------------------------------------------------------------- */
.askbox {
  display: flex; align-items: center; gap: var(--s3);
  background: #fff; border-radius: var(--r-pill); padding: 9px 9px 9px var(--s5);
  box-shadow: var(--shadow-night); margin-top: var(--s6);
}
.askbox-icon { color: var(--ink-faint); flex: none; }
.askbox input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font-size: var(--t-md); color: var(--ink); padding: 8px 0;
}
.askbox input::placeholder { color: var(--ink-faint); }
.askbox-mic {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--page-2); color: var(--ink-soft); display: grid; place-items: center;
  transition: all .15s;
}
.askbox-mic:hover { background: var(--marigold-lo); color: var(--ink); }
.askbox-mic.is-live { background: var(--coral); color: #fff; animation: mic 1.1s infinite; }
@keyframes mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,78,114,.55); }
  50%      { box-shadow: 0 0 0 11px rgba(239,78,114,0); }
}
.askbox-go {
  flex: none; height: 46px; padding: 0 22px; border-radius: var(--r-pill); border: none;
  background: var(--marigold); color: #2B1B02; font-family: var(--display);
  font-weight: 700; font-size: var(--t-sm);
}
.askbox-go:hover { background: #FFB53C; }

.try-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); align-items: center; }
.try-label { font-size: var(--t-xs); color: var(--night-soft); margin-right: var(--s1); }
.try {
  border: 1.5px solid rgba(255,255,255,.22); background: rgba(255,255,255,.07);
  color: var(--night-ink); border-radius: var(--r-pill); padding: 7px 14px;
  font-size: var(--t-xs); font-weight: 500; transition: all .15s;
}
.try:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.45); }

/* --------------------------------------------------------------------------
   Answer card — proves the promise: an answer that shows its page.
   -------------------------------------------------------------------------- */
.answer {
  background: var(--night-2); border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-night);
  width: 100%; max-width: 480px;
}
.answer-top { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.answer-avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none; background: var(--marigold);
  color: #2B1B02; display: grid; place-items: center; font-family: var(--display);
  font-weight: 800; font-size: 13px;
}
.answer-top b { color: #fff; font-family: var(--display); font-size: var(--t-sm); display: block; }
.answer-top span { color: var(--night-soft); font-size: var(--t-xs); }
.answer-q { color: var(--night-soft); font-size: var(--t-sm); margin-bottom: var(--s3); }
.answer-body { color: var(--night-ink); font-size: var(--t-md); line-height: 1.6; }
.answer-body strong { color: var(--marigold); }
.answer-cite {
  display: inline-flex; align-items: center; gap: var(--s2); margin-top: var(--s4);
  background: rgba(0,163,140,.18); border: 1px solid rgba(0,163,140,.45);
  color: #6FE3CD; border-radius: var(--r-pill); padding: 7px 14px;
  font-size: var(--t-xs); font-weight: 600;
}
.answer-cite:hover { background: rgba(0,163,140,.3); }
.answer-dots { display: flex; gap: 5px; padding: var(--s2) 0; }
.answer-dots i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--night-soft);
  animation: blink 1.2s infinite;
}
.answer-dots i:nth-child(2) { animation-delay: .15s; }
.answer-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,60%,100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* --------------------------------------------------------------------------
   Subject tiles
   -------------------------------------------------------------------------- */
.subjects { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s4); }
.subject {
  position: relative; overflow: hidden; text-align: left;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: var(--s5) var(--s4) var(--s4); display: flex; flex-direction: column; gap: var(--s3);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.subject:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--c); }
.subject-art { width: 62px; height: 62px; border-radius: var(--r-sm); background: var(--c-lo); padding: 9px; }
.subject h3 { font-size: var(--t-md); }
.subject .ta { font-size: var(--t-xs); color: var(--ink-faint); margin-top: -4px; }
.subject .n { font-size: var(--t-xs); color: var(--c); font-weight: 700; margin-top: auto; }
.subject::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--c);
  transform: scaleX(0); transform-origin: left; transition: transform .22s var(--ease);
}
.subject:hover::after { transform: scaleX(1); }

/* --------------------------------------------------------------------------
   Catalogue: filter rail + book grid
   -------------------------------------------------------------------------- */
.catalogue { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--s7); }
.filters { position: sticky; top: calc(var(--nav-h) + var(--s4)); align-self: start; }
.filter-group + .filter-group { margin-top: var(--s5); }
.filter-group h4 {
  font-family: var(--display); font-size: var(--t-xs); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: var(--s3);
}
.filter-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.filter {
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-soft);
  border-radius: var(--r-pill); padding: 7px 14px; font-size: var(--t-xs); font-weight: 500;
  transition: all .15s;
}
.filter:hover { border-color: var(--ink-faint); color: var(--ink); }
.filter.is-on { background: var(--ink); border-color: var(--ink); color: var(--page); font-weight: 600; }
.filter-reset {
  margin-top: var(--s5); background: none; border: none; padding: 0;
  color: var(--coral); font-size: var(--t-sm); font-weight: 600; text-decoration: underline;
}

.results-bar { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; }
.results-bar h3 { font-size: var(--t-lg); }
.results-bar .count { color: var(--ink-faint); font-size: var(--t-sm); margin-left: auto; font-variant-numeric: tabular-nums; }

.books { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }

.book {
  display: flex; flex-direction: column; text-align: left; background: var(--paper);
  border: 1.5px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.book:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--c); }
.book-cover { position: relative; aspect-ratio: 4 / 3; background: var(--c); overflow: hidden; }
.book-cover svg.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.book-kind {
  position: absolute; top: 11px; right: 11px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.94); color: var(--ink); border-radius: var(--r-pill);
  padding: 4px 10px; font-size: 11px; font-weight: 700; font-family: var(--display);
  text-transform: uppercase; letter-spacing: .04em;
}
.book-save {
  position: absolute; top: 9px; left: 9px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.92); color: var(--ink-soft);
  display: grid; place-items: center; opacity: 0; transform: translateY(-4px);
  transition: opacity .18s, transform .18s, color .15s;
}
.book:hover .book-save, .book-save.is-saved, .book-save:focus-visible { opacity: 1; transform: translateY(0); }
.book-save.is-saved { color: var(--coral); }
.book-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); flex: 1; }
.book-meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.book h3 { font-size: var(--t-md); line-height: 1.25; }
.book-blurb { font-size: var(--t-sm); color: var(--ink-faint); }
.book-foot {
  margin-top: auto; padding-top: var(--s3); display: flex; align-items: center; gap: var(--s3);
  font-size: var(--t-xs); color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.book-foot span { display: inline-flex; align-items: center; gap: 5px; }
.book-foot .open { margin-left: auto; color: var(--c); font-weight: 700; font-family: var(--display); }

.empty {
  grid-column: 1 / -1; text-align: center; padding: var(--s8) var(--s4);
  border: 2px dashed var(--line); border-radius: var(--r-md); color: var(--ink-faint);
}
.empty svg { margin: 0 auto var(--s3); color: var(--ink-faint); }
.empty b { color: var(--ink); display: block; margin-bottom: var(--s1); font-size: var(--t-md); }

/* --------------------------------------------------------------------------
   How it works
   -------------------------------------------------------------------------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
.step {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3);
}
.step-art { width: 100%; height: 132px; border-radius: var(--r-sm); background: var(--page-2); padding: var(--s3); }
.step-n {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--page);
  display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: var(--t-xs);
}
.step h3 { font-size: var(--t-md); }
.step p { color: var(--ink-soft); font-size: var(--t-sm); }

/* --------------------------------------------------------------------------
   Collections
   -------------------------------------------------------------------------- */
.collections { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s5); }
.collection {
  position: relative; overflow: hidden; text-align: left; border: none; border-radius: var(--r-lg);
  background: var(--c); color: #fff; padding: var(--s6); min-height: 190px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s2);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.collection:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.collection svg.art { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .95; }
.collection > * { position: relative; z-index: 1; }
.collection h3 { color: #fff; font-size: var(--t-xl); }
.collection .ta { font-size: var(--t-sm); opacity: .9; }
.collection .n {
  align-self: flex-start; margin-top: var(--s3); background: rgba(0,0,0,.28);
  border-radius: var(--r-pill); padding: 5px 13px; font-size: var(--t-xs); font-weight: 700;
}

/* --------------------------------------------------------------------------
   Library card & stamps
   -------------------------------------------------------------------------- */
.libcard {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-md);
}
.libcard-top {
  padding: var(--s5) var(--s6); background: var(--night); color: #fff;
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
}
.libcard-top h3 { color: #fff; font-size: var(--t-lg); letter-spacing: .04em; }
.libcard-top p { color: var(--night-soft); font-size: var(--t-xs); }
.libcard-top .no {
  margin-left: auto; font-family: var(--display); font-weight: 700; font-size: var(--t-sm);
  color: var(--marigold); font-variant-numeric: tabular-nums;
}
.stamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); padding: var(--s5); }
.stamp {
  border: 2px dashed var(--line); border-radius: var(--r-md); padding: var(--s4);
  display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center;
}
.stamp-seal {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  border: 2px dotted var(--line); color: var(--ink-faint); opacity: .55;
}
.stamp h4 { font-size: var(--t-sm); }
.stamp p { font-size: var(--t-xs); color: var(--ink-faint); line-height: 1.4; }
.stamp .prog { font-size: 11.5px; font-weight: 700; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.stamp.is-earned { border-style: solid; border-color: var(--marigold); background: var(--marigold-lo); }
.stamp.is-earned .stamp-seal {
  border: 3px solid var(--coral); color: var(--coral); opacity: 1; transform: rotate(-8deg);
}
.stamp.is-earned h4, .stamp.is-earned .prog { color: var(--coral); }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--s5);
  z-index: 95; display: flex; flex-direction: column; align-items: center; gap: var(--s2);
}
.toast {
  background: var(--night); color: #fff; border-radius: var(--r-pill);
  padding: 12px 22px; font-size: var(--t-sm); font-weight: 600; font-family: var(--display);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: var(--s2);
  animation: toast .3s var(--pop);
}
.toast svg { color: var(--marigold); flex: none; }
@keyframes toast { from { transform: translateY(14px) scale(.94); opacity: 0; } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .subjects { grid-template-columns: repeat(3, 1fr); }
  .books { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .catalogue { grid-template-columns: 1fr; gap: var(--s5); }
  .filters { position: static; }
  .steps { grid-template-columns: 1fr; }
  .stamps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .collections { grid-template-columns: 1fr; }
  .askbox { flex-wrap: wrap; border-radius: var(--r-lg); padding: var(--s3); }
  .askbox input { order: 1; flex-basis: 60%; padding-left: var(--s2); }
  .askbox-go { order: 3; flex: 1; }
}
@media (max-width: 560px) {
  .subjects { grid-template-columns: repeat(2, 1fr); }
  .books { grid-template-columns: 1fr; }
  .stamps { grid-template-columns: 1fr; }
}
