/* =====================================================================
   FX - the visual layer over components.css.
   Everything here is presentation: gradients, depth, motion and the
   celebration overlay. It changes no layout contract a view relies on,
   and every animation sits behind prefers-reduced-motion (tokens.css's
   blanket reduce rule then collapses anything left over).

   Colour stays inside the brand: Iris carries everything, and the nine
   cause hues below are used only as small accents (a dot, an icon tile,
   the top edge of a tile), never as surfaces, so purple stays the loudest
   voice as PRD section 5.1 asks.
   ===================================================================== */

:root {
  --fx-grad-brand: linear-gradient(135deg, #7d3aa8 0%, var(--iris-500) 45%, #4b1f70 100%);
  --fx-grad-brand-hover: linear-gradient(135deg, #8a45b6 0%, var(--iris-600) 50%, #3f1a5e 100%);
  --fx-grad-ink: radial-gradient(120% 140% at 0% 0%, #3a1a52 0%, var(--ink-900) 46%, #120f16 100%);
  --fx-glow: 0 0 0 1px rgba(141, 84, 189, 0.18), 0 18px 40px -12px rgba(106, 44, 145, 0.45);
  --fx-card-border: rgba(72, 28, 97, 0.07);
  --fx-shadow-card: 0 1px 0 rgba(255,255,255,0.8) inset, 0 1px 2px rgba(26,23,29,0.04), 0 8px 24px -12px rgba(54, 20, 73, 0.16);
  --fx-shadow-lift: 0 1px 0 rgba(255,255,255,0.8) inset, 0 2px 4px rgba(26,23,29,0.05), 0 22px 44px -18px rgba(54, 20, 73, 0.32);
  --fx-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Cause accents. Mid-saturation so they sit beside Iris without
     fighting it; each passes 3:1 on white for a dot or an icon. */
  --cause-environment: #2f8a6a;
  --cause-community:   #8d54bd;
  --cause-youth:       #c07a12;
  --cause-animals:     #c4583e;
  --cause-health:      #c2457a;
  --cause-arts:        #a23fae;
  --cause-justice:     #4b55b8;
  --cause-food:        #c9671b;
  --cause-shelter:     #2f6fa8;
}

/* ---------- Surface ---------- */
/* A soft wash of Iris behind every signed-in page, fixed so it does not
   scroll with long content. Paper-tinted stays the base colour. */
body.fx-surface,
body:has(> .app-bar) {
  background:
    radial-gradient(900px 520px at 100% -10%, rgba(173, 125, 207, 0.20), transparent 60%),
    radial-gradient(700px 480px at -10% 20%, rgba(230, 213, 240, 0.55), transparent 62%),
    radial-gradient(800px 600px at 50% 120%, rgba(244, 241, 234, 0.9), transparent 70%),
    var(--paper-tinted);
  background-attachment: fixed;
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--fx-card-border);
  box-shadow: var(--fx-shadow-card);
}
.card-hover, a.card {
  transition: transform var(--duration-slow) var(--ease-standard),
              box-shadow var(--duration-slow) var(--ease-standard),
              border-color var(--duration-slow) var(--ease-standard);
}
@media (hover: hover) {
  .card-hover:hover, a.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--fx-shadow-lift);
    border-color: rgba(106, 44, 145, 0.18);
  }
}

/* ---------- Buttons ---------- */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary {
  background: var(--fx-grad-brand);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 8px 18px -8px rgba(106, 44, 145, 0.7);
}
.btn-primary:hover { background: var(--fx-grad-brand-hover); }
.btn:active:not(:disabled) { transform: scale(0.975); }

/* The press ripple, injected by fx.js at the pointer position. The app's
   currency is called Ripples, so its buttons answer with one. */
.fx-press {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: 0.22;
  transform: scale(0);
  z-index: -1;
}
@media (prefers-reduced-motion: no-preference) {
  .fx-press { animation: fx-press 620ms var(--ease-out) forwards; }
}
@keyframes fx-press { to { transform: scale(1); opacity: 0; } }

/* ---------- Dark hero panels ---------- */
.fx-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--fx-grad-ink);
  color: var(--fg-on-inverse);
  border-radius: var(--radius-2xl);
  box-shadow: 0 30px 60px -30px rgba(34, 12, 46, 0.65);
}
.fx-hero::before,
.fx-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.fx-hero::before {
  width: 420px; height: 420px;
  right: -120px; top: -160px;
  background: radial-gradient(circle, rgba(173, 125, 207, 0.55), rgba(106, 44, 145, 0) 70%);
}
.fx-hero::after {
  width: 360px; height: 360px;
  left: 18%; bottom: -220px;
  background: radial-gradient(circle, rgba(47, 138, 106, 0.32), rgba(47, 138, 106, 0) 70%);
}
@media (prefers-reduced-motion: no-preference) {
  .fx-hero::before { animation: fx-drift 16s ease-in-out infinite alternate; }
  .fx-hero::after { animation: fx-drift 20s ease-in-out infinite alternate-reverse; }
}
@keyframes fx-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-40px, 30px) scale(1.12); }
}

/* Concentric water rings drawn behind hero content. */
.fx-rings {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
}
.fx-rings circle { fill: none; stroke: rgba(205, 169, 224, 0.16); stroke-width: 1; }
@media (prefers-reduced-motion: no-preference) {
  .fx-rings circle { animation: fx-ring-breathe 6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
  .fx-rings circle:nth-child(2) { animation-delay: -1.5s; }
  .fx-rings circle:nth-child(3) { animation-delay: -3s; }
  .fx-rings circle:nth-child(4) { animation-delay: -4.5s; }
}
@keyframes fx-ring-breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* A glass chip for stats laid over a dark hero. */
.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  font-size: var(--text-xs);
  color: rgba(247, 246, 248, 0.9);
  white-space: nowrap;
}
.fx-chip strong { font-family: var(--font-mono); font-weight: var(--weight-bold); color: #fff; }
.fx-chip svg { width: 15px; height: 15px; color: var(--iris-300); flex-shrink: 0; }

/* Gradient headline text. */
.fx-gradient-text {
  background: linear-gradient(92deg, #fff 0%, #e6d5f0 40%, #ad7dcf 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fx-gradient-text-brand {
  background: linear-gradient(92deg, var(--ink-900) 0%, var(--iris-700) 55%, var(--iris-400) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Avatars ---------- */
.avatar {
  --av-h: 280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--av-size, 36px);
  height: var(--av-size, 36px);
  border-radius: 50%;
  font-size: calc(var(--av-size, 36px) * 0.38);
  font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(140deg, hsl(var(--av-h) 52% 62%), hsl(calc(var(--av-h) + 28) 48% 38%));
  box-shadow: 0 0 0 2px var(--paper), 0 2px 6px rgba(26, 23, 29, 0.18);
  user-select: none;
}
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: calc(var(--av-size, 36px) * -0.3); }
.avatar-ring { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--iris-300); }

/* ---------- Cause dots and tags ---------- */
.cause-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cause, var(--iris-400));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cause, var(--iris-400)) 18%, transparent);
  flex-shrink: 0;
}
.cause-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cause, var(--iris-500)) 78%, var(--ink-900));
}

/* ---------- Progress rings and bars ---------- */
.fx-ring { display: block; }
.fx-ring .track { stroke: var(--ink-100); }
.fx-ring .value { stroke: url(#fx-ring-grad); stroke-linecap: round; }
@media (prefers-reduced-motion: no-preference) {
  .fx-ring .value { transition: stroke-dashoffset 1100ms var(--ease-out); }
}

.fx-bar { height: 8px; border-radius: var(--radius-pill); background: var(--ink-100); overflow: hidden; }
.fx-bar > span {
  display: block; height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--iris-300), var(--iris-500));
  box-shadow: 0 0 12px rgba(141, 84, 189, 0.45);
  transform-origin: left center;
}
@media (prefers-reduced-motion: no-preference) {
  .fx-reveal-ready .fx-bar > span { transform: scaleX(0); }
  .fx-bar.is-in > span { transform: scaleX(1); transition: transform 1000ms var(--ease-out); }
}

/* ---------- Seven-dot tier track ---------- */
.fx-dots { display: inline-flex; gap: 5px; align-items: center; }
.fx-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(141, 84, 189, 0.2);
}
.fx-dots i.on { background: var(--iris-400); box-shadow: 0 0 8px rgba(173, 125, 207, 0.8); }
.fx-dots i.now { width: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--iris-300), #fff); }

/* ---------- Load-in reveal ----------
   fx.js adds .fx-reveal-ready to <html> before first paint when motion is
   allowed, so with JS off or reduced motion everything is simply visible. */
.fx-reveal-ready [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
}
.fx-reveal-ready [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 560ms var(--ease-out), transform 640ms var(--fx-spring);
  transition-delay: var(--reveal-delay, 0ms);
}

/* ---------- Live pulse ---------- */
.fx-live {
  position: relative;
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #3fcf8e;
}
.fx-live::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: inherit;
}
@media (prefers-reduced-motion: no-preference) {
  .fx-live::after { animation: fx-live 1.8s var(--ease-out) infinite; }
}
@keyframes fx-live { from { transform: scale(1); opacity: 0.7; } to { transform: scale(3); opacity: 0; } }

/* ---------- Shine across earned things ---------- */
.fx-shine { position: relative; overflow: hidden; }
.fx-shine::after {
  content: "";
  position: absolute;
  inset: -50% auto -50% -60%;
  width: 40%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  pointer-events: none;
  opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .fx-shine::after { animation: fx-shine 5.5s ease-in-out infinite; animation-delay: var(--shine-delay, 1s); }
}
@keyframes fx-shine {
  0% { left: -60%; opacity: 0; }
  8% { opacity: 1; }
  22% { left: 130%; opacity: 0; }
  100% { left: 130%; opacity: 0; }
}

/* ---------- Tilt ---------- */
[data-tilt] { transform-style: preserve-3d; transition: transform 380ms var(--ease-out); will-change: transform; }

/* =====================================================================
   THE RIPPLE BURST - the celebration overlay.
   Expanding rings and rising bubbles from a point on screen. Fired by
   Fx.burst() at the moment success is known, never on a button press,
   and only where the organisation's gamification mode is Full. Purely
   decorative: aria-hidden, pointer-events none, gone in under 3s.
   ===================================================================== */
.fx-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}
.fx-burst .ring {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 3px solid var(--iris-300);
  opacity: 0;
  animation: fx-burst-ring 1700ms var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}
.fx-burst .ring.alt { border-color: rgba(63, 207, 142, 0.7); border-width: 2px; }
.fx-burst .bubble {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--s, 10px); height: var(--s, 10px);
  margin: calc(var(--s, 10px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,0.95), rgba(205,169,224,0.75) 40%, rgba(141,84,189,0.35) 70%);
  box-shadow: 0 0 10px rgba(173, 125, 207, 0.6);
  opacity: 0;
  animation: fx-burst-bubble var(--t, 1800ms) cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
  animation-delay: var(--d, 0ms);
}
.fx-burst .flash {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 520px; height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(205, 169, 224, 0.5), rgba(205, 169, 224, 0) 62%);
  animation: fx-burst-flash 900ms var(--ease-out) forwards;
}
@keyframes fx-burst-ring {
  0%   { opacity: 0.95; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(var(--r, 14)); }
}
@keyframes fx-burst-bubble {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -240px)) scale(1); }
}
@keyframes fx-burst-flash {
  0% { opacity: 0; transform: scale(0.3); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.2); }
}

/* Floating "+25" that rises out of a reward pill. */
.fx-float-points {
  position: absolute;
  left: 50%; top: 0;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--iris-300);
  text-shadow: 0 0 18px rgba(173, 125, 207, 0.8);
  pointer-events: none;
  opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .fx-float-points { animation: fx-float-up 1600ms var(--ease-out) 500ms forwards; }
}
@keyframes fx-float-up {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(1.1); }
}

/* ---------- Sparkline / area chart ---------- */
.fx-area path.line { fill: none; stroke: var(--iris-500); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fx-area path.fill { fill: url(#fx-area-grad); }
.fx-area circle.end { fill: #fff; stroke: var(--iris-500); stroke-width: 2.5; }
@media (prefers-reduced-motion: no-preference) {
  .fx-reveal-ready .fx-area path.line { stroke-dasharray: var(--len, 1000); stroke-dashoffset: var(--len, 1000); }
  .fx-area.is-in path.line { stroke-dashoffset: 0; transition: stroke-dashoffset 1400ms var(--ease-out); }
  .fx-reveal-ready .fx-area path.fill { opacity: 0; }
  .fx-area.is-in path.fill { opacity: 1; transition: opacity 900ms var(--ease-out) 500ms; }
}

/* ---------- Section headings ---------- */
.fx-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-10) 0 var(--space-4);
}
.fx-section-head h2 { margin: var(--space-1) 0 0; font-size: var(--text-xl); letter-spacing: -0.01em; }
.fx-section-head p { margin: var(--space-1) 0 0; color: var(--fg-muted); font-size: var(--text-sm); }
.fx-section-head a { font-size: var(--text-sm); font-weight: var(--weight-semibold); text-decoration: none; white-space: nowrap; }

/* ---------- Page title block ---------- */
.fx-title h1 {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: var(--text-5xl);
  line-height: 0.95;
  letter-spacing: 0.005em;
  margin: var(--space-2) 0 var(--space-3);
}
@media (max-width: 639px) {
  .fx-title h1 { font-size: var(--text-4xl); }
}

/* =====================================================================
   APP CHROME, refined
   ===================================================================== */
.app-bar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid rgba(72, 28, 97, 0.08);
}
.app-nav a { position: relative; border-radius: var(--radius-pill); padding: 0 var(--space-4); }
.app-nav a[aria-current="page"] {
  color: #fff;
  background: var(--fx-grad-brand);
  box-shadow: 0 6px 16px -6px rgba(106, 44, 145, 0.7);
}
.app-nav a[aria-current="page"] .nav-count { background: #fff; color: var(--iris-600); }
.app-nav .nav-count { box-shadow: 0 0 0 2px #fff; }
@media (prefers-reduced-motion: no-preference) {
  .app-nav .nav-count { animation: fx-count-pop 2.4s var(--fx-spring) 600ms 2; }
}
@keyframes fx-count-pop { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.25); } }
.app-brand .brand-seven {
  background: var(--fx-grad-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.app-user {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding-left: var(--space-4);
  border-left: 1px solid var(--border-subtle);
  font-size: var(--text-sm); color: var(--fg-muted); text-decoration: none;
}
@media (max-width: 1023px) { .app-user .app-user-name { display: none; } }
@media (max-width: 639px) {
  .app-bar { background: rgba(255, 255, 255, 0.88); }
  .app-user { display: none; }
  .app-nav a { border-radius: var(--radius-lg); padding: var(--space-2) var(--space-1); }
  .app-nav a[aria-current="page"] { background: transparent; box-shadow: none; color: var(--iris-600); }
  .app-nav a[aria-current="page"]::before {
    content: ""; position: absolute; top: -9px; left: 50%; width: 28px; height: 3px; margin-left: -14px;
    border-radius: 0 0 3px 3px; background: var(--fx-grad-brand);
  }
  .app-nav a[aria-current="page"] svg { filter: drop-shadow(0 3px 6px rgba(106, 44, 145, 0.45)); }
}

/* =====================================================================
   SHARED PAGE PIECES, lifted
   ===================================================================== */
.page-head h1 {
  font-size: var(--text-5xl);
  line-height: 0.95;
  letter-spacing: 0.005em;
  background: linear-gradient(92deg, var(--ink-900) 0%, var(--iris-800) 60%, var(--iris-500) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (max-width: 639px) { .page-head h1 { font-size: var(--text-4xl); } }
@media (prefers-reduced-motion: no-preference) {
  .page-head { animation: fx-rise 600ms var(--fx-spring) both; }
  .card-stack > *, .stat-grid > * { animation: fx-rise 560ms var(--fx-spring) both; }
  .card-stack > :nth-child(2), .stat-grid > :nth-child(2) { animation-delay: 60ms; }
  .card-stack > :nth-child(3), .stat-grid > :nth-child(3) { animation-delay: 120ms; }
  .card-stack > :nth-child(4), .stat-grid > :nth-child(4) { animation-delay: 180ms; }
  .card-stack > :nth-child(5), .stat-grid > :nth-child(5) { animation-delay: 240ms; }
  .card-stack > :nth-child(n+6) { animation-delay: 300ms; }
}
@keyframes fx-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.section-head h2 { font-size: var(--text-xl); letter-spacing: -0.01em; }

.card-link { transition: transform var(--duration-slow) var(--ease-standard), box-shadow var(--duration-slow) var(--ease-standard), border-color var(--duration-slow); }
.card-link:hover { transform: translateY(-3px); box-shadow: var(--fx-shadow-lift); border-color: rgba(106, 44, 145, 0.18); }

.stat-block { position: relative; overflow: hidden; }
.stat-block::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, rgba(173, 125, 207, 0.22), transparent 70%);
}
.stat-block .stat-value { font-size: var(--text-4xl); }

.pill-status { border: 1px solid transparent; }
.pill-status.is-good { border-color: rgba(47, 138, 78, 0.18); }
.pill-status.is-good::before, .pill-status.is-brand::before, .pill-status.is-info::before, .pill-status.is-warn::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.pill-status.is-brand { border-color: rgba(106, 44, 145, 0.18); }

.input:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--iris-400);
  box-shadow: 0 0 0 4px rgba(141, 84, 189, 0.16);
}
.input, .field input, .field select, .field textarea { border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.9); }

.choice { border-radius: var(--radius-xl); transition: border-color var(--duration-base), background var(--duration-base), transform var(--duration-slow) var(--fx-spring), box-shadow var(--duration-slow); }
.choice:hover { transform: translateY(-2px); box-shadow: var(--fx-shadow-card); }
.choice:has(input:checked) { box-shadow: 0 0 0 3px rgba(141, 84, 189, 0.18), var(--fx-shadow-card); }

.table th { background: linear-gradient(180deg, var(--bg-subtle), transparent); }
.table tbody tr { transition: background var(--duration-base); }
.table tbody tr:hover { background: rgba(245, 238, 249, 0.6); }

.notice-flash {
  background: linear-gradient(90deg, var(--iris-50), rgba(233, 245, 238, 0.7));
  border: 1px solid rgba(106, 44, 145, 0.12);
}

.meter-fill { background: linear-gradient(90deg, var(--iris-300), var(--iris-500)); box-shadow: 0 0 10px rgba(141, 84, 189, 0.4); }

.icon-tile { border-radius: var(--radius-lg); background: linear-gradient(140deg, var(--iris-50), var(--iris-100)); box-shadow: inset 0 1px 0 #fff; }

.mascot-empty { padding: var(--space-10) var(--space-5); }
