/* Bonfire Night: a starry night with a moon, fireworks bursting over the town, a bonfire glowing at the bottom
   with sparks drifting up, and buttons and title that glow like embers. Colours are in theme-flat.css. */

/* ---- the scene behind everything (built by buildScene() in app.js) ---- */
[data-theme="bonfire"] #stage-bg { background:
  radial-gradient(120% 55% at 50% 108%, rgba(255, 110, 30, .45), transparent 60%),
  linear-gradient(#060918 0%, #0d1330 45%, #1c1a3f 75%, #3a1f33 100%); }
.scene { position: absolute; inset: 0; overflow: hidden; }
.scene .stars { position: absolute; inset: 0 0 35% 0; }
.scene .stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: .7;
  animation: twinkle-star 3s ease-in-out infinite; }
@keyframes twinkle-star { 50% { opacity: .15; } }
.scene .moon { position: absolute; top: max(.5rem, env(safe-area-inset-top)); right: 1.2rem; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffdf2, #f3e6c4 60%, #d9c79c);
  box-shadow: 0 0 40px 10px rgba(255, 244, 214, .25); }
.scene .moon::after { content: ''; position: absolute; width: 22%; height: 22%; left: 52%; top: 40%; border-radius: 50%; background: rgba(160, 140, 100, .25);
  box-shadow: -1.2rem -.6rem 0 -.15rem rgba(160, 140, 100, .2), -.4rem .9rem 0 -.25rem rgba(160, 140, 100, .2); }

/* fireworks: a rising trail, then a burst of sparks that fades */
.scene .fw { position: absolute; width: 0; height: 0; }
.scene .fw .trail { position: absolute; left: -1px; width: 2px; height: 3.5rem; bottom: 0;
  background: linear-gradient(transparent, var(--fc)); opacity: 0; animation: fw-trail var(--d) ease-out infinite; animation-delay: var(--t); }
.scene .fw .p { position: absolute; width: 4px; height: 4px; left: -2px; top: -2px; border-radius: 50%; background: var(--fc);
  box-shadow: 0 0 6px 1px var(--fc); opacity: 0; animation: fw-burst var(--d) ease-out infinite; animation-delay: var(--t); }
@keyframes fw-trail { 0% { transform: translateY(40vh); opacity: 0; } 4% { opacity: .9; } 18% { transform: translateY(0); opacity: .9; } 20%, 100% { opacity: 0; } }
@keyframes fw-burst {
  0%, 19% { transform: rotate(var(--a)) translateY(0) scale(1); opacity: 0; }
  20% { opacity: 1; }
  45% { transform: rotate(var(--a)) translateY(var(--r)) scale(.9); opacity: .9; }
  60%, 100% { transform: rotate(var(--a)) translateY(calc(var(--r) + 1.2rem)) scale(.3); opacity: 0; } }

/* the bonfire: a dark crowd and hills, logs, flickering flames and rising embers */
.scene .ground { position: absolute; left: 0; right: 0; bottom: 0; height: 22vh; }
.scene .ground svg { position: absolute; inset: auto 0 0 0; width: 100%; height: 100%; }
.scene .fire { position: absolute; bottom: 9vh; left: 50%; width: 9rem; height: 9rem; transform: translateX(-50%); }
.scene .fire .glow { position: absolute; inset: -4rem; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 140, 40, .45), transparent 65%); animation: glow 2.2s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .7; transform: scale(.94); } }
.scene .fire .flame { position: absolute; bottom: 1.4rem; left: 50%; width: var(--w); height: var(--h); margin-left: calc(var(--w) / -2 + var(--x));
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%; background: radial-gradient(ellipse at 50% 85%, #fff3b0, var(--fcol) 55%, transparent 72%);
  filter: blur(1px); transform-origin: 50% 100%; animation: flick var(--s) ease-in-out infinite alternate; mix-blend-mode: screen; }
@keyframes flick { from { transform: scaleY(1) skewX(-3deg); } to { transform: scaleY(1.18) skewX(4deg); } }
.scene .fire .logs { position: absolute; bottom: .6rem; left: 50%; width: 6.5rem; height: 1.6rem; transform: translateX(-50%); }
.scene .fire .logs::before, .scene .fire .logs::after { content: ''; position: absolute; left: 0; right: 0; top: .4rem; height: .8rem; border-radius: .4rem;
  background: linear-gradient(#3b2416, #1d120b); transform: rotate(12deg); }
.scene .fire .logs::after { transform: rotate(-12deg); }
.scene .ember { position: absolute; bottom: 14vh; width: 3px; height: 3px; border-radius: 50%; background: #ffb347;
  box-shadow: 0 0 6px 2px rgba(255, 140, 40, .8); opacity: 0; animation: ember var(--d) linear infinite; animation-delay: var(--t); }
@keyframes ember {
  0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; }
  100% { transform: translate(var(--dx), -55vh); opacity: 0; } }

/* ---- the app itself, glowing like embers ---- */
[data-theme="bonfire"] .logo .l2 {
  background: linear-gradient(180deg, #ffe08a, #ff9a2e 55%, #ff5a36); -webkit-background-clip: text; background-clip: text;
  color: transparent; filter: drop-shadow(0 0 10px rgba(255, 120, 40, .55)); animation: firelight 2.6s ease-in-out infinite; }
@keyframes firelight { 50% { filter: drop-shadow(0 0 4px rgba(255, 120, 40, .35)); } }
[data-theme="bonfire"] .btn:not(.ghost) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--hot) 75%, #ffe08a), var(--hot));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--hot) 60%, black), 0 0 18px color-mix(in srgb, var(--hot) 45%, transparent); }
[data-theme="bonfire"] .btn.alt { --on-hot: #1b1405; }
/* a row of glowing sparks along the top edge of every main button */
[data-theme="bonfire"] .btn:not(.ghost):not(.small) { position: relative; overflow: visible; }
[data-theme="bonfire"] .btn:not(.ghost):not(.small)::after { content: ''; position: absolute; left: 12%; right: 12%; top: -3px; height: 6px; pointer-events: none;
  background: radial-gradient(circle, #fff3b0 0 1.5px, transparent 2px) 0 0 / 18px 6px repeat-x;
  filter: drop-shadow(0 0 3px #ffb347); opacity: .85; animation: sparks 1.6s ease-in-out infinite; }
@keyframes sparks { 50% { opacity: .35; transform: translateY(-1px); } }
[data-theme="bonfire"] .panel { backdrop-filter: blur(6px); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 170, 90, .18); }
/* Head to Head tiles: night-glass cards lit warmly from below, each subject's icon glowing in its own colour */
[data-theme="bonfire"] .topic {
  background: linear-gradient(180deg, rgba(28, 34, 72, .92), rgba(46, 30, 52, .92));
  border: 1px solid rgba(255, 170, 90, .25); color: var(--ink);
  box-shadow: inset 0 -14px 24px -12px rgba(255, 120, 40, .35), 0 4px 14px rgba(0, 0, 0, .35); }
[data-theme="bonfire"] .topic .ic { width: 2.4rem; height: 2.4rem; padding: .45rem; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--sc) 85%, white), var(--sc));
  box-shadow: 0 0 14px color-mix(in srgb, var(--sc) 70%, transparent); }
[data-theme="bonfire"] .topic small { color: var(--ink-dim); }
[data-theme="bonfire"] .topic:active { transform: translateY(2px); }
[data-theme="bonfire"] :is(.title, .tag, .home .dim) { text-shadow: 0 2px 10px rgba(0, 0, 0, .7); }

@media (prefers-reduced-motion: reduce) {
  .scene *, .scene *::before, .scene *::after, [data-theme="bonfire"] .logo .l2, [data-theme="bonfire"] .btn::after { animation: none !important; }
  .scene .fw, .scene .ember { display: none; }
}
