/* Juice: floating numbers, sparks, shake, banners, toasts, modals.
   Everything here is decoration — `prefers-reduced-motion` strips it and the
   game stays completely playable. */

#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

/* ---------- Floating numbers ---------- */

.float {
  position: absolute;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ember-soft);
  text-shadow: 0 2px 5px rgb(0 0 0 / 0.85);
  white-space: nowrap;
  will-change: transform, opacity;
  animation: float-up 1000ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.float.gold { color: var(--gold); font-size: 19px; }
.float.power { color: var(--power); }
.float.loss { color: var(--danger); }
.float.big { font-size: 27px; }

@keyframes float-up {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  18% { transform: translate(-50%, -12px) scale(1.12); opacity: 1; }
  100% { transform: translate(-50%, -74px) scale(0.95); opacity: 0; }
}

/* ---------- Sparks ---------- */

.spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 6px var(--ember);
  will-change: transform, opacity;
  animation: spark-fly 620ms ease-out forwards;
}

@keyframes spark-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* ---------- Screen shake ---------- */

.shake-sm { animation: shake 220ms ease-in-out; }
.shake-lg { animation: shake-hard 420ms ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -1px); }
}

@keyframes shake-hard {
  0%, 100% { transform: translate(0, 0); }
  12% { transform: translate(-7px, 3px) rotate(-0.35deg); }
  28% { transform: translate(6px, -3px) rotate(0.3deg); }
  46% { transform: translate(-5px, -2px) rotate(-0.2deg); }
  64% { transform: translate(4px, 3px) rotate(0.2deg); }
  82% { transform: translate(-2px, -1px); }
}

/* ---------- The "they're coming" banner ---------- */

#banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 34%;
  z-index: 70;
  display: none;
  padding: 16px 20px;
  text-align: center;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(20 6 4 / 0.94) 12%, rgb(20 6 4 / 0.94) 88%, transparent);
  border-top: 1px solid rgb(255 90 60 / 0.5);
  border-bottom: 1px solid rgb(255 90 60 / 0.5);
}

#banner.show {
  display: block;
  animation: banner-in 2600ms ease-out forwards;
}

#banner-title {
  font-size: clamp(21px, 6.5vw, 38px);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffd6c4;
  text-shadow: 0 0 26px rgb(255 70 40 / 0.85), 0 3px 6px #000;
  line-height: 1.1;
}

#banner-sub {
  margin-top: 5px;
  font-size: clamp(12px, 3.2vw, 15px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ff9a7a;
}

@keyframes banner-in {
  0% { opacity: 0; transform: scale(1.14); }
  10% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.97); }
}

/* ---------- Toasts ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 600;
  background: rgb(24 26 33 / 0.97);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ember);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: toast-in 200ms ease-out, toast-out 320ms ease-in forwards;
  animation-delay: 0s, var(--hold, 2.6s);
}

.toast .toast-icon {
  font-size: 17px;
  flex: none;
}

.toast.achievement { border-left-color: var(--gold); }
.toast.relic { border-left-color: var(--valor); }
.toast.warn { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Modals ---------- */

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(4 5 8 / 0.82);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

#modal-root.open {
  display: flex;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1b1e26, #14161c);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms cubic-bezier(0.2, 0.8, 0.3, 1);
  overflow: hidden;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.modal-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
}

.modal-body {
  padding: 15px 18px;
  overflow-y: auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: rgb(0 0 0 / 0.2);
}

.modal-foot .btn {
  flex: 1;
}

.modal.danger .modal-head {
  background: linear-gradient(180deg, rgb(60 18 12 / 0.75), transparent);
}

.modal.valor .modal-head {
  background: linear-gradient(180deg, rgb(50 24 70 / 0.75), transparent);
}

/* Relic pick-1-of-3 */
.relic-choices {
  display: grid;
  gap: 8px;
}

.relic-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: transform 110ms, border-color 140ms, background 140ms;
}

.relic-card:hover {
  transform: translateY(-2px);
  background: var(--panel-2);
}

.relic-card .relic-icon {
  font-size: 32px;
  text-align: center;
  line-height: 1;
}

.relic-card .relic-name {
  font-size: 15px;
  font-weight: 750;
}

.relic-card .relic-effect {
  font-size: 12px;
  font-weight: 650;
  margin-top: 1px;
}

/* Offline report figures */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.report-cell {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.report-cell .report-label {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.report-cell .report-value {
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* ---------- Reduced motion: strip decoration, keep the game ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  /* Banner and toast use `forwards` fade-outs to hide themselves. With
     animations stripped they would blink out instantly, so pin them visible
     and let the JS timeouts in fx.js do the removing. */
  #banner.show,
  .toast {
    animation: none !important;
    opacity: 1;
  }

  #banner.show {
    display: block;
  }

  .float,
  .spark {
    display: none;
  }
}


/* ---------- Emberfall ---------- */

.ember {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  /* Generous hit area on top of the visual, because this is a moving target
     and missing it because your thumb was 4px off is miserable. */
  padding: 10px;
  filter: drop-shadow(0 0 14px var(--ember)) drop-shadow(0 0 30px rgb(255 122 47 / 0.65));
  animation: ember-pulse 1.15s ease-in-out infinite;
  will-change: transform, opacity;
  z-index: 65;
}

.ember:hover {
  filter: drop-shadow(0 0 22px var(--gold)) drop-shadow(0 0 44px rgb(255 200 60 / 0.8));
}

@keyframes ember-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.14; }
}

/* Active blessings, shown in the siege HUD */
#buffs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

#buffs:empty {
  display: none;
}

.buff-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 99px;
  color: #ffe0c0;
  background: linear-gradient(90deg, rgb(255 122 47 / 0.3), rgb(255 122 47 / 0.12));
  border: 1px solid var(--ember);
  font-variant-numeric: tabular-nums;
  animation: buff-glow 1.6s ease-in-out infinite;
}

.buff-pill.tap { color: #fff0c0; border-color: var(--gold); }
.buff-pill.power { color: #cfe4ff; border-color: var(--power); }

@keyframes buff-glow {
  0%, 100% { box-shadow: 0 0 0 rgb(255 122 47 / 0); }
  50% { box-shadow: 0 0 12px rgb(255 122 47 / 0.5); }
}

@media (prefers-reduced-motion: reduce) {
  .ember { animation: none !important; }
  .buff-pill { animation: none !important; }
}
