/* ============================================================
   all_articles.css — KinaQuest · All Articles (+ topic pages)
   Visual language matches books_styles.css (books_all.html):
   same tokens, gradient background, pill links, chips, cards,
   dark footer and quick-view dialog.
   Themes follow customize.js: data-theme on <html>, --accent-color.
   ============================================================ */
:root {
  --bq-accent: var(--accent-color, #5b3ef5);
  --bq-accent-2: #2f80ff;
  --bq-ink: #12102e;
  --bq-muted: #5d5b7a;
  --bq-surface: #ffffff;
  --bq-bg-1: #fcfbff;
  --bq-bg-2: #ecebff;
  --bq-blob: #aebfff;
  --bq-wave: #c9bcff;
  --bq-font: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bq-ease: cubic-bezier(.3, .7, .2, 1);
  --bq-line: color-mix(in srgb, var(--bq-accent) 13%, transparent);
  --bq-tint: color-mix(in srgb, var(--bq-accent) 6%, var(--bq-bg-1));
}
[data-theme="dark"], [data-theme="dracula"], [data-theme="midnight"] {
  --bq-ink: #f1f0ff; --bq-muted: #a9a7cf; --bq-surface: #1d1b3a;
  --bq-bg-1: #0f0e22; --bq-bg-2: #171540; --bq-blob: #2b3a8f; --bq-wave: #3a2a85;
}
[data-theme="rose"] { --bq-bg-1: #fffafc; --bq-bg-2: #ffe6f0; --bq-blob: #ffc2d9; --bq-wave: #f7b6d2; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; font-family: var(--bq-font); color: var(--bq-ink); background: var(--bq-bg-1); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--bq-accent); outline-offset: 3px; }

/* ---------- Background (same as .bq-bg) ---------- */
.aa-bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--bq-bg-image, none) center / cover no-repeat, linear-gradient(135deg, var(--bq-bg-1) 20%, var(--bq-bg-2));
}
.aa-bg::before, .aa-bg::after { content: ""; position: absolute; border-radius: 50%; }
.aa-bg::before { width: 80vw; aspect-ratio: 1; right: -28vw; top: -52vw; opacity: .8; background: linear-gradient(200deg, var(--bq-blob), transparent 70%); }
.aa-bg::after { width: 80vw; height: 50vw; left: -26vw; bottom: -30vw; opacity: .75; background: linear-gradient(20deg, var(--bq-wave), transparent 75%); }

/* ---------- Layout + header ---------- */
.aa-all { flex: 1; padding: clamp(20px, 4vw, 64px); width: 100%; max-width: 1320px; margin: 0 auto; }
.aa-wrap { max-width: 1200px; margin: 0 auto; }
.aa-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: clamp(24px, 4vw, 48px); }
.aa-logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: clamp(1.4rem, 2.2vw, 2rem); letter-spacing: -.02em; color: var(--bq-accent); }
.aa-logo svg { width: 1.6em; height: 1.6em; stroke-width: 5; }
.aa-logo span { color: var(--bq-ink); }
.aa-head__nav { display: flex; gap: 10px; flex-wrap: wrap; margin-right: auto; margin-left: 12px; }
.aa-head__actions { display: flex; gap: 10px; }
.aa-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 999px; white-space: nowrap; text-decoration: none;
  font-size: .85rem; font-weight: 600; color: var(--bq-accent); border: 1.5px solid var(--bq-accent); transition: background .2s, color .2s;
}
.aa-pill:hover, .aa-pill--current { background: var(--bq-accent); color: #fff; }
.aa-icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bq-surface); border: 1px solid var(--bq-line); box-shadow: 0 6px 18px -10px rgba(60, 50, 140, .35);
  transition: transform .2s var(--bq-ease), color .2s;
}
.aa-icon-btn:hover { transform: translateY(-2px); color: var(--bq-accent); }
.aa-icon-btn svg { width: 19px; height: 19px; }
.aa-icon-btn .ti--sun { display: none; }
[data-theme="dark"] .aa-icon-btn .ti--moon, [data-theme="dracula"] .aa-icon-btn .ti--moon, [data-theme="midnight"] .aa-icon-btn .ti--moon { display: none; }
[data-theme="dark"] .aa-icon-btn .ti--sun, [data-theme="dracula"] .aa-icon-btn .ti--sun, [data-theme="midnight"] .aa-icon-btn .ti--sun { display: block; }

/* ---------- Title + tools ---------- */
.aa-main { min-width: 0; }
.aa-title { margin: 0; font-size: clamp(2.2rem, 4.6vw, 3.8rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.aa-sub { margin: 10px 0 24px; color: var(--bq-muted); }
.aa-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; scroll-margin-top: 16px; }
.aa-input { padding: 12px 18px; border-radius: 999px; font: inherit; font-size: .92rem; color: var(--bq-ink); background: var(--bq-surface); border: 1px solid var(--bq-line); outline: 0; }
.aa-input:focus { border-color: var(--bq-accent); }
.aa-input::placeholder { color: var(--bq-muted); }
input.aa-input { flex: 1 1 260px; max-width: 380px; }
select.aa-input { cursor: pointer; }

/* ---------- Chips ---------- */
.aa-chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; margin-bottom: 16px; scrollbar-width: none; }
.aa-chips::-webkit-scrollbar { display: none; }
.aa-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
  font-weight: 600; font-size: .9rem; background: var(--bq-surface); border: 1px solid var(--bq-line); transition: background .2s, color .2s;
}
.aa-chip svg { width: 16px; height: 16px; }
.aa-chip:hover { border-color: var(--bq-accent); }
.aa-chip[aria-pressed="true"] { color: #fff; background: var(--bq-accent); border-color: var(--bq-accent); }

/* ---------- Footer (same as .bq-footer) ---------- */
.aa-footer { margin-top: 40px; padding: clamp(40px, 5vw, 72px) clamp(20px, 4vw, 64px) 28px; color: #d8d6f5; background: #14113a; }
.aa-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.aa-footer__brand { margin: 0 0 8px; font-size: 1.5rem; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.aa-footer__about { margin: 0 0 16px; max-width: 32ch; line-height: 1.55; }
.aa-footer h3 { margin: 0 0 12px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.aa-footer nav { display: flex; flex-direction: column; gap: 10px; }
.aa-footer a { color: inherit; text-decoration: none; opacity: .85; }
.aa-footer a:hover { opacity: 1; text-decoration: underline; }
.aa-footer__copy { margin: 40px 0 0; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .85rem; opacity: .7; }

/* ---------- customize.js popup ---------- */
.custom-popup {
  position: fixed; z-index: 1300; width: 250px; padding: 16px; color: var(--bq-ink); background: var(--bq-surface);
  border: 1px solid var(--bq-line); border-radius: 18px; box-shadow: 0 30px 60px -20px rgba(20, 10, 80, .55);
}
.cp-customize-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cp-customize-title { font-weight: 800; font-size: 1rem; }
.cp-close-btn { width: 28px; height: 28px; border-radius: 50%; color: var(--bq-muted); }
.cp-close-btn:hover { background: var(--bq-bg-2); color: var(--bq-ink); }
.cp-section + .cp-section { margin-top: 14px; }
.cp-section-label { display: block; margin-bottom: 8px; font-size: .78rem; font-weight: 600; color: var(--bq-muted); }
.cp-theme-row, .cp-accent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-theme-btn { width: 38px; height: 38px; border-radius: 11px; font-size: 1.1rem; border: 1.5px solid var(--bq-line); background: var(--bq-bg-1); }
.cp-theme-btn.active { border-color: var(--bq-accent); background: color-mix(in srgb, var(--bq-accent) 12%, var(--bq-surface)); }
.cp-accent-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--bq-line); }
.cp-accent-dot.active { box-shadow: 0 0 0 2px var(--bq-surface), 0 0 0 4px var(--bq-accent); }

/* ---------- Chip counter ---------- */
.aa-chip__n { font-size: .72rem; opacity: .7; }
.aa-chip[aria-current="page"] { pointer-events: none; }

/* ---------- Topic page header ---------- */
.aa-topichead { display: flex; align-items: center; gap: 18px; }
.aa-topichead__icon {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--a), var(--b)); box-shadow: 0 18px 30px -18px var(--a);
}
.aa-topichead__icon svg { width: 30px; height: 30px; }
.aa-topichead .aa-sub { margin-bottom: 0; }
.aa-blurb { max-width: 60ch; margin: 14px 0 0; color: var(--bq-muted); line-height: 1.55; }

/* ---------- Topic sections: rows × columns ---------- */
.aa-sections { margin-top: 8px; }
.aa-section { margin-top: clamp(32px, 4vw, 52px); }
.aa-section:first-child { margin-top: 16px; }
.aa-section__head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: clamp(18px, 2.5vw, 28px); }
.aa-section__head h2 {
  display: flex; align-items: center; gap: 12px; margin: 0; padding-left: 14px; border-left: 4px solid var(--bq-accent);
  font-size: clamp(1.25rem, 2vw, 1.6rem); font-weight: 800; letter-spacing: -.02em;
}
.aa-section__icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--a), var(--b)); }
.aa-section__icon svg { width: 18px; height: 18px; }
.aa-section__count { font-size: .85rem; color: var(--bq-muted); }
.aa-section__link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px; white-space: nowrap; text-decoration: none;
  font-size: .85rem; font-weight: 600; color: var(--bq-accent); border: 1.5px solid var(--bq-accent); transition: background .2s, color .2s;
}
.aa-section__link:hover { background: var(--bq-accent); color: #fff; }
.aa-section__link svg, .aa-more svg { width: 15px; height: 15px; }
.aa-more { margin: 16px 0 0; text-align: right; }
.aa-more a { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; color: var(--bq-accent); text-decoration: none; }
.aa-more a:hover { text-decoration: underline; }

.aa-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.aa-card {
  display: flex; flex-direction: column; overflow: hidden; border-radius: 18px; background: var(--bq-surface); border: 1px solid var(--bq-line);
  box-shadow: 0 10px 28px -20px rgba(60, 50, 140, .5); transition: transform .25s var(--bq-ease), box-shadow .25s;
}
.aa-card:hover { transform: translateY(-3px); box-shadow: 0 18px 34px -18px var(--bq-accent); }
.aa-card__thumb { position: relative; display: grid; place-items: center; height: 104px; overflow: hidden; color: #fff; background: linear-gradient(135deg, var(--a), var(--b)); }
.aa-card__thumb::before, .aa-card__thumb::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .16); filter: blur(2px); }
.aa-card__thumb::before { width: 60%; aspect-ratio: 1; left: -12%; top: -45%; }
.aa-card__thumb::after { width: 46%; aspect-ratio: 1; right: -8%; bottom: -40%; background: rgba(0, 0, 0, .14); }
.aa-card__thumb svg { position: relative; z-index: 1; width: 38px; height: 38px; stroke-width: 1.7; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .3)); }
.aa-card__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; }
.aa-card__body { display: flex; flex-direction: column; gap: 8px; flex: 1; padding: 14px 16px 16px; }
.aa-tag { align-self: flex-start; padding: 4px 10px; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bq-accent); background: color-mix(in srgb, var(--bq-accent) 12%, transparent); }
.aa-card h3 { margin: 0; font-size: .95rem; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
.aa-card h3 a { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-decoration: none; }
.aa-card h3 a:hover { color: var(--bq-accent); }
.aa-card p { margin: 0; font-size: .8rem; line-height: 1.45; color: var(--bq-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.aa-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: auto; padding-top: 4px; font-size: .72rem; color: var(--bq-muted); }
.aa-meta span { display: inline-flex; align-items: center; gap: 5px; }
.aa-meta svg { width: 13px; height: 13px; }
.aa-empty { padding: 60px 0; text-align: center; color: var(--bq-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) { .aa-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 980px)  { .aa-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px)  { .aa-head__nav { order: 3; width: 100%; margin-left: 0; } }
@media (max-width: 760px) {
  .aa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aa-footer__grid { grid-template-columns: 1fr 1fr; }
  .aa-footer__grid > div { grid-column: 1 / -1; }
  .aa-section__link { margin-left: 0; }
}
@media (max-width: 480px) { .aa-grid { grid-template-columns: 1fr; } .aa-topichead__icon { width: 52px; height: 52px; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
