/* ================= Плагін «Доручення мера» ================= */
.q-card, .q-list, .q-chest-box, .q-hist, .q-stat {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-edge), var(--glass-shadow);
}

/* --- Компактна картка на сторінці навчання --- */
.q-card { border-radius: 24px; padding: 8px 10px 10px; margin: 0 0 22px; }
.q-card.collapsed { padding-bottom: 8px; }
.q-card.has-ready { box-shadow: var(--glass-edge), inset 0 0 0 2px color-mix(in srgb, var(--green) 40%, transparent), var(--glass-shadow); }
.q-head { display: flex; align-items: center; gap: 6px; }
.q-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 4px; text-align: left; border-radius: 16px; }
.q-hic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(160deg, #7ab8ff, var(--accent)); box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 32%, transparent); }
.q-hic svg { width: 22px; height: 22px; }
.q-htxt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.q-htxt b { font-size: 16px; }
.q-htxt small { color: var(--label2); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-chev { color: var(--label3); width: 16px; height: 16px; flex: none; transform: rotate(90deg); transition: transform .3s var(--ease); }
.q-chev svg { width: 16px; height: 16px; }
.q-card.collapsed .q-chev { transform: rotate(0deg); }
.q-all { flex: none; font-size: 14px; font-weight: 600; color: var(--accent); padding: 7px 12px; border-radius: 99px; background: var(--accent-tint); }

.q-rows { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; animation: qIn .35s var(--ease); }
@keyframes qIn { from { opacity: 0; transform: translateY(-6px); } }

/* --- Рядок завдання --- */
.q-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 16px; position: relative; }
.q-ic { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center;
  color: var(--qc); background: color-mix(in srgb, var(--qc) 16%, transparent); }
.q-ic svg { width: 18px; height: 18px; }
.q-body { flex: 1; min-width: 0; }
.q-t { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.q-t b { font-size: 14px; font-weight: 600; line-height: 1.25; }
.q-bar { height: 6px; border-radius: 99px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.q-bar > div { height: 100%; border-radius: 99px; background: var(--qc); transition: width .6s var(--ease); }
.q-row.ready .q-bar > div, .q-row.claimed .q-bar > div { background: var(--green); }
.q-row.claimed { opacity: .62; }
.q-row.claimed .q-t b { text-decoration: line-through; text-decoration-color: var(--label3); }
.q-num { flex: none; min-width: 44px; text-align: right; font-size: 13px; font-weight: 600; color: var(--label2); font-variant-numeric: tabular-nums; }
.q-ok { flex: none; width: 28px; height: 28px; margin: 0 8px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--green); }
.q-ok svg { width: 14px; height: 14px; }
.q-claim { flex: none; height: 32px; padding: 0 14px; border-radius: 99px; font-size: 14px; font-weight: 700; color: #fff;
  background: var(--green); box-shadow: 0 4px 12px color-mix(in srgb, var(--green) 40%, transparent);
  animation: qPulse 1.6s ease-in-out infinite; transition: transform .2s var(--ease); }
.q-claim:active { transform: scale(.94); }
@keyframes qPulse { 50% { transform: scale(1.06); } }

.q-rw { display: inline-flex; gap: 6px; flex: none; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.q-gem { display: inline-flex; align-items: center; gap: 3px; color: var(--teal); }
.q-gem svg { width: 12px; height: 12px; }
.q-xp { color: var(--orange); }

.q-mini-chest { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 6px 2px; border-top: .5px solid var(--sep); font-size: 14px; font-weight: 600; }
.q-mini-chest > span:nth-child(2) { flex: 1; }
.q-mc-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #c9782f; background: rgba(201, 120, 47, .16); animation: qWiggle 2.4s ease-in-out infinite; }
.q-mc-ic svg { width: 20px; height: 20px; }

/* --- Сторінка «Завдання» --- */
.q-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.q-stat { border-radius: 22px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.q-stat > span svg { width: 24px; height: 24px; }
.q-stat b { font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.q-stat small { color: var(--label2); font-size: 12px; }
.q-list { border-radius: 26px; padding: 6px 8px; }
.q-row.full { padding: 12px 8px; }
.q-row.full + .q-row.full::before { content: ""; position: absolute; top: 0; left: 52px; right: 8px; border-top: .5px solid var(--sep); }
.q-row.full .q-ic { width: 38px; height: 38px; border-radius: 12px; }
.q-row.full .q-ic svg { width: 21px; height: 21px; }
.q-row.full .q-t b { font-size: 15px; }

/* --- Кошик з жолудями --- */
.q-chest-box { border-radius: 26px; padding: 16px; display: flex; align-items: center; gap: 14px; position: relative; overflow: hidden; }
.q-chest-box.ready { background: linear-gradient(135deg, color-mix(in srgb, var(--orange) 18%, var(--glass-bg)), var(--glass-bg)); }
.q-chest { width: 72px; height: 72px; flex: none; position: relative; display: grid; place-items: center; }
.q-chest-svg { width: 72px; height: 72px; overflow: visible; position: relative; z-index: 1; }
.q-chest-box.locked .q-chest-svg { filter: grayscale(.85); opacity: .55; }
.q-lock { position: absolute; right: 2px; bottom: 2px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg2); color: var(--label2); box-shadow: var(--shadow); }
.q-lock svg { width: 13px; height: 13px; }
.q-chest-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.q-chest-txt b { font-size: 17px; }
.q-chest-txt small { color: var(--label2); font-size: 14px; margin-top: 2px; line-height: 1.35; }
.q-open { height: 42px; padding: 0 18px; font-size: 15px; flex: none; background: linear-gradient(180deg, #ffb340, var(--orange)); }
.q-lid { transform-origin: 8px 31px; transform-box: view-box; transition: transform .5s var(--ease); }
.q-chest.open .q-lid { transform: translate(-4px, -10px) rotate(-28deg); }
.q-chest.wiggle { animation: qWiggle 2.4s ease-in-out infinite; }
@keyframes qWiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-8deg); } 82% { transform: rotate(7deg); } 88% { transform: rotate(-5deg); } 94% { transform: rotate(3deg); } }
.q-rays { position: absolute; inset: -22px; border-radius: 50%; z-index: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 204, 0, .45) 0 12deg, transparent 12deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: qSpin 12s linear infinite; }
@keyframes qSpin { to { transform: rotate(360deg); } }
.q-loot { display: flex; gap: 8px; margin-top: 8px; }
.q-loot > span { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; font-size: 14px; font-weight: 700; background: var(--fill); }
.q-loot .q-gem svg { width: 14px; height: 14px; }

/* Анімація відкриття: тремтіння → кришка злітає → промені → лут */
.q-chest-box.anim .q-chest { animation: qShake .6s ease-in-out both; }
.q-chest-box.anim .q-lid { animation: qLid .7s .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.q-chest-box.anim .q-rays { animation: qRays .7s .7s var(--ease) both, qSpin 12s 1.4s linear infinite; }
.q-chest-box.anim .q-chest-txt { animation: qPop .5s .9s var(--ease) both; }
.q-chest-box.anim .q-loot > span { animation: qPop .5s var(--ease) both; }
.q-chest-box.anim .q-loot > span:nth-child(1) { animation-delay: 1.05s; }
.q-chest-box.anim .q-loot > span:nth-child(2) { animation-delay: 1.2s; }
.q-chest-box.anim::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(circle at 52px 50%, rgba(255, 220, 120, .7), transparent 60%); animation: qFlash .9s .6s ease-out both; }
@keyframes qShake { 0% { transform: scale(1); } 20% { transform: scale(1.08) rotate(-7deg); } 40% { transform: scale(1.08) rotate(7deg); } 60% { transform: scale(1.1) rotate(-5deg); } 80% { transform: scale(1.12) rotate(4deg); } 100% { transform: scale(1); } }
@keyframes qLid { from { transform: none; } to { transform: translate(-4px, -10px) rotate(-28deg); } }
@keyframes qRays { from { opacity: 0; transform: scale(.3); } }
@keyframes qPop { from { opacity: 0; transform: translateY(8px) scale(.85); } }
@keyframes qFlash { from { opacity: 1; } to { opacity: 0; } }

/* --- Історія 7 днів --- */
.q-hist { border-radius: 26px; padding: 16px 12px 14px; }
.q-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.q-day { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.q-day small { font-size: 12px; color: var(--label2); }
.q-day.cur small { color: var(--accent); font-weight: 700; }
.q-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--label2);
  background: conic-gradient(var(--orange) var(--p), var(--fill) 0); position: relative; }
.q-dot::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--bg2); }
.q-dot > * { position: relative; }
.q-dot i { font-style: normal; }
.q-day.full .q-dot { background: var(--green); color: #fff; }
.q-day.full .q-dot::before { display: none; }
.q-dot svg { width: 15px; height: 15px; }
.q-dchest { position: absolute; top: -4px; right: calc(50% - 24px); color: #c9782f; }
.q-dchest svg { width: 14px; height: 14px; }
.q-note { margin: 14px 4px 0; font-size: 13px; color: var(--label2); line-height: 1.4; }

/* --- Вузькі екрани --- */
@media (max-width: 420px) {
  .q-card { padding: 6px 8px 8px; border-radius: 22px; }
  .q-row { gap: 10px; padding: 7px 4px; }
  .q-t { flex-direction: column; align-items: flex-start; gap: 2px; }
  .q-t b { font-size: 13.5px; }
  .q-claim { padding: 0 11px; font-size: 13px; }
  .q-chest-box { flex-wrap: wrap; padding: 14px; }
  .q-chest-box .q-open { width: 100%; }
  .q-chest, .q-chest-svg { width: 60px; height: 60px; }
  .q-dot { width: 32px; height: 32px; }
  .q-stat b { font-size: 19px; }
}

/* --- Менше руху --- */
@media (prefers-reduced-motion: reduce) {
  .q-claim, .q-chest.wiggle, .q-mc-ic, .q-rays, .q-rows { animation: none !important; }
  .q-chest-box.anim *, .q-chest-box.anim::after { animation: none !important; }
}
html.no-motion .q-claim, html.no-motion .q-chest.wiggle, html.no-motion .q-mc-ic, html.no-motion .q-rays,
html.no-motion .q-chest-box.anim *, html.no-motion .q-chest-box.anim::after { animation: none !important; }

/* ---------- Тема «Боброве містечко» (town): доручення мера ---------- */
html[data-theme="town"] .q-card, html[data-theme="town"] .q-list, html[data-theme="town"] .q-chest-box, html[data-theme="town"] .q-hist, html[data-theme="town"] .q-stat {
  -webkit-backdrop-filter: none; backdrop-filter: none; border: 1.5px solid rgba(90, 60, 30, .18); box-shadow: 0 2px 0 rgba(90, 60, 30, .08); border-radius: 22px; }
html[data-theme="town"] .q-card.has-ready { border-color: color-mix(in srgb, var(--green) 55%, transparent); box-shadow: 0 2px 0 rgba(90, 60, 30, .08); }
html[data-theme="town"] .q-hic { background: var(--accent); box-shadow: none; }
html[data-theme="town"] .q-chest-box.ready { background: color-mix(in srgb, #c9782f 12%, var(--glass-bg)); }
html[data-theme="town"] .q-open { background: #c9632f; box-shadow: none; }
html[data-theme="town"] .q-stat { border-radius: 18px; }
