/* ============================================================
   mastery-fx.css — next-gen motion & engagement layer
   Drop-in alongside mastery.css. Pair with mastery-fx.js.
   Everything degrades gracefully; honors prefers-reduced-motion.
   ============================================================ */

/* ── Reading progress bar ── */
#fx-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px; z-index: 1000; pointer-events: none;
}
#fx-progress .bar {
  height: 100%; width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--navy,#1B2A4A), var(--accent,#5B9E9B) 60%, var(--gold,#C9A84C));
}

/* ── Staggered reveal ── */
.fx-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s cubic-bezier(.2,.7,.3,1), transform .6s cubic-bezier(.2,.7,.3,1);
}
.fx-stagger.in-view > * { opacity: 1; transform: none; }
.fx-stagger.in-view > *:nth-child(1) { transition-delay: 0s; }
.fx-stagger.in-view > *:nth-child(2) { transition-delay: .12s; }
.fx-stagger.in-view > *:nth-child(3) { transition-delay: .24s; }
.fx-stagger.in-view > *:nth-child(4) { transition-delay: .36s; }
.fx-stagger.in-view > *:nth-child(5) { transition-delay: .48s; }
.fx-stagger.in-view > *:nth-child(6) { transition-delay: .6s; }

/* ── Resource engagement cards ── */
.fx-res {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: .75rem .875rem;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  text-decoration: none;
}
.fx-res:last-of-type { margin-bottom: 0; }
.fx-res:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(27,42,74,.09);
}
.fx-res .resource-icon { margin-top: 1px; }
.fx-res-body { flex: 1; min-width: 0; }
.fx-res-type {
  font-size: 9.5px; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 2px;
  display: flex; align-items: center; gap: 6px;
}
.fx-res-title { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.4; }
.fx-res-hook { font-size: 11.5px; color: var(--text-3); line-height: 1.5; margin-top: 3px; }
.fx-res-arrow {
  flex-shrink: 0; align-self: center;
  font-size: 14px; color: var(--text-3);
  opacity: .45;
  transition: transform .2s, opacity .2s, color .2s;
}
.fx-res:hover .fx-res-arrow { transform: translateX(3px); opacity: 1; color: var(--accent); }

/* unexplored cue: soft glint sweep */
.fx-res:not(.visited)::after {
  content: '';
  position: absolute; top: 0; bottom: 0;
  width: 55%; left: -60%;
  background: linear-gradient(105deg, transparent 0%, rgba(201,168,76,.10) 45%, rgba(201,168,76,.16) 50%, rgba(201,168,76,.10) 55%, transparent 100%);
  animation: fxGlint 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes fxGlint {
  0%, 62% { left: -60%; }
  82%, 100% { left: 110%; }
}
.fx-res:not(.visited) .fx-res-type::after {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  animation: fxPulseDot 2.2s ease-in-out infinite;
}
@keyframes fxPulseDot {
  0%, 100% { transform: scale(1); opacity: .9; }
  50%      { transform: scale(1.5); opacity: .35; }
}
/* explored state */
.fx-res.visited { border-color: rgba(91,158,155,.4); }
.fx-res-check {
  display: none;
  flex-shrink: 0; align-self: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  color: #fff; font-size: 10px;
  line-height: 18px;
  text-align: center;
}
.fx-res.visited .fx-res-check { display: block; animation: fxPop .3s cubic-bezier(.3,1.6,.5,1); }
.fx-res.visited .fx-res-arrow { display: none; }

/* resource meter */
.fx-res-meter { margin-top: .875rem; }
.fx-res-meter-track {
  height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.fx-res-meter-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent,#5B9E9B), var(--gold,#C9A84C));
  border-radius: 2px;
  transition: width .6s cubic-bezier(.2,.7,.3,1);
}
.fx-res-meter-label {
  font-size: 11px; color: var(--text-3);
  margin-top: 5px;
  display: flex; justify-content: space-between;
}
.fx-res-meter-label strong { color: var(--accent); font-weight: 500; }

/* ── Pop keyframe (used by resource check) ── */
@keyframes fxPop {
  0% { transform: scale(.75); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ── CTA shine ── */
.fx-shine { position: relative; overflow: hidden; }
.fx-shine::after {
  content: '';
  position: absolute; top: 0; bottom: 0;
  width: 40%; left: -50%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.25), transparent);
  animation: fxGlint 6s ease-in-out infinite;
  pointer-events: none;
}

/* ── Floating "next" pill ── */
#fx-next {
  position: fixed; right: 18px; bottom: 18px; z-index: 900;
  display: flex; align-items: center; gap: 8px;
  padding: .625rem 1.125rem;
  background: var(--navy);
  color: #fff; font-size: 13px; font-weight: 500;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(27,42,74,.28);
  text-decoration: none;
  opacity: 0; transform: translateY(80px);
  transition: opacity .35s, transform .35s cubic-bezier(.2,.7,.3,1);
}
#fx-next .fx-next-label { font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.5); }
#fx-next.show { opacity: 1; transform: none; }
#fx-next:hover { background: #24365c; }
@media (max-width: 700px) { #fx-next { right: 12px; bottom: 12px; } }

/* ── Animated science explainer ── */
.fx-explainer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.fx-explainer-head {
  padding: .875rem 1.5rem;
  background: #F4F1EC;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.fx-explainer-title { font-family: var(--serif, Georgia, serif); font-size: 16px; color: var(--navy); }
.fx-explainer-badge {
  font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(91,158,155,.12); color: var(--accent);
}
.fx-explainer-body { padding: 1rem 1.25rem .5rem; }
.fx-explainer svg { width: 100%; height: auto; display: block; }

/* ── Scene system: animation correlates with concept cards ── */
.fx-scene { opacity: 0; transition: opacity .45s ease; pointer-events: none; }
.fx-scene.active { opacity: 1; }

/* scene tabs */
.fx-scene-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: .875rem 1.25rem 0;
}
.fx-scene-tab {
  appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: var(--sans, sans-serif);
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .18s;
}
.fx-scene-tab:hover { border-color: var(--border-2); color: var(--text); }
.fx-scene-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* scene info line */
.fx-scene-infos { position: relative; min-height: 44px; margin: .25rem 0 .875rem; }
.fx-scene-info {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  opacity: 0; transform: translateY(5px);
  transition: opacity .4s ease, transform .4s ease;
  pointer-events: none;
}
.fx-scene-info.active { opacity: 1; transform: none; }
.fx-scene-info strong { font-size: 14px; font-weight: 500; color: var(--text); }
.fx-scene-info span { font-size: 12.5px; color: var(--text-3); margin-top: 1px; line-height: 1.5; }

/* concept cards linked to scenes */
[data-scene-link] { cursor: pointer; }
[data-scene-link].scene-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fx-cc-hint {
  display: inline-block;
  font-size: 11px; font-weight: 500;
  color: var(--accent);
  margin-top: .625rem;
  transition: transform .18s;
}
[data-scene-link]:hover .fx-cc-hint { transform: translateX(3px); }

/* scene 2: fat loss */
.fx-fat, .fx-flame, .fx-brain, .fx-hunger { transform-box: fill-box; transform-origin: center; }
.fx-scene.active .fx-fat { animation: fxFat 6s ease-in-out infinite; }
@keyframes fxFat {
  0%, 12%  { transform: scale(1); }
  62%, 82% { transform: scale(.76); }
  100%     { transform: scale(1); }
}
.fx-scene.active .fx-flame { animation: fxFlame 1.6s ease-in-out infinite; }
@keyframes fxFlame {
  0%, 100% { transform: scale(1); opacity: .9; }
  50%      { transform: scale(1.18) translateY(-2px); opacity: 1; }
}

/* scene 3: appetite */
.fx-scene.active .fx-brain { animation: fxBrain 2.8s ease-in-out infinite; }
@keyframes fxBrain {
  0%, 55%, 100% { transform: scale(1); }
  70%           { transform: scale(1.07); }
}
.fx-hunger { transform-origin: left center; }
.fx-scene.active .fx-hunger { animation: fxHunger 6s ease-in-out infinite; }
@keyframes fxHunger {
  0%, 10%  { transform: scaleX(1); }
  60%, 85% { transform: scaleX(.24); }
  100%     { transform: scaleX(1); }
}

/* svg element animations — all on a 9s master loop */
.fx-bolt { opacity: 0; animation: fxBolt 9s infinite; transform-origin: center; }
@keyframes fxBolt {
  0%   { opacity: 0; transform: scale(.6); }
  3%   { opacity: 1; transform: scale(1.15); }
  6%   { opacity: 1; transform: scale(1); }
  12%  { opacity: 0; transform: scale(.9); }
  100% { opacity: 0; }
}
.fx-band-break { animation: fxBand 9s infinite; }
@keyframes fxBand {
  0%       { opacity: .85; }
  5%       { opacity: .12; }
  48%      { opacity: .12; }
  62%      { opacity: .85; }
  100%     { opacity: .85; }
}
.fx-muscle-glow { animation: fxGlow 9s infinite; }
@keyframes fxGlow {
  0%, 66%  { stroke: var(--navy, #1B2A4A); stroke-width: 1.5; }
  74%, 84% { stroke: var(--accent, #5B9E9B); stroke-width: 2.5; }
  95%,100% { stroke: var(--navy, #1B2A4A); stroke-width: 1.5; }
}
/* ── Integrated "lab": concept cards ARE the controls for one shared stage ── */
.fx-lab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 22px rgba(27,42,74,.05);
}
.fx-lab-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .875rem 1.25rem;
  background: #F4F1EC;
  border-bottom: 1px solid var(--border);
}
.fx-lab-title { font-family: var(--serif, Georgia, serif); font-size: 16px; color: var(--navy); }
.fx-lab-badge {
  font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(91,158,155,.12); color: var(--accent);
}
.fx-lab-cards { padding: 1.25rem 1.25rem 1.75rem; }
/* the concept cards, now acting as tabs */
.fx-lab .concept-card { position: relative; cursor: pointer; }
.fx-lab .concept-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.fx-lab .concept-card.scene-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(91,158,155,.16);
  transform: translateY(-2px);
}
/* connector notch from active card down to the stage */
.fx-lab .concept-card.scene-active::after {
  content: ''; position: absolute; left: 50%; bottom: -17px; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 9px solid var(--accent);
}
/* multi-row card grids (4+ cards): the downward connector would point at another
   card rather than the stage, so suppress it and rely on the accent highlight */
.fx-lab.fx-lab-multirow .concept-card.scene-active::after { display: none; }
.fx-lab .concept-card .fx-cc-hint { opacity: .55; transition: opacity .18s, color .18s; }
.fx-lab .concept-card .fx-cc-hint::before { content: '▶ '; }
.fx-lab .concept-card:hover .fx-cc-hint,
.fx-lab .concept-card.scene-active .fx-cc-hint { opacity: 1; }
.fx-lab .concept-card.scene-active .fx-cc-hint { color: var(--accent); }
.fx-lab .concept-card.scene-active .fx-cc-hint::before { content: '● '; }
/* the shared animation stage */
.fx-lab-stage {
  margin: 0 1.25rem 1.25rem;
  background: linear-gradient(180deg, #FAF9F7, #F1EEE8);
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  padding: .875rem 1rem .25rem;
  box-shadow: inset 0 1px 4px rgba(27,42,74,.05);
}

/* ── Interactive tool: depth + pulse ── */
.tool-card { box-shadow: 0 4px 22px rgba(27,42,74,.06); transition: box-shadow .25s; }
.tool-card:hover { box-shadow: 0 8px 30px rgba(27,42,74,.10); }
/* result panel: depth + slow breathing halo */
.result-box { position: relative; overflow: hidden;
  background: radial-gradient(130% 130% at 0% 0%, #24365c 0%, var(--navy,#1B2A4A) 58%);
  box-shadow: 0 12px 32px rgba(27,42,74,.20);
}
.result-box::before {
  content: ''; position: absolute; right: -70px; top: -80px;
  width: 230px; height: 230px; border-radius: 50%;
  background: radial-gradient(circle, rgba(91,158,155,.38), rgba(91,158,155,0) 70%);
  animation: fxBreathe 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes fxBreathe {
  0%, 100% { transform: scale(1);    opacity: .45; }
  50%      { transform: scale(1.14); opacity: .8; }
}
.result-box > * { position: relative; }
/* the big number bumps whenever it changes (class toggled by JS) */
.result-number { transform-origin: left center; }
.result-number.fx-bump { animation: fxNumBump .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes fxNumBump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.09); }
  100% { transform: scale(1); }
}
/* slider thumbs: depth + glow on drag */
input[type=range]::-webkit-slider-thumb { box-shadow: 0 2px 6px rgba(27,42,74,.28); transition: box-shadow .15s; }
input[type=range]:hover::-webkit-slider-thumb  { box-shadow: 0 0 0 5px rgba(91,158,155,.12), 0 2px 6px rgba(27,42,74,.28); }
input[type=range]:active::-webkit-slider-thumb { box-shadow: 0 0 0 7px rgba(91,158,155,.20), 0 2px 6px rgba(27,42,74,.30); }
input[type=range]::-moz-range-thumb { box-shadow: 0 2px 6px rgba(27,42,74,.28); }
/* selected pills gain a little lift */
.sel-pill.active { box-shadow: 0 5px 14px rgba(27,42,74,.18); }
.diet-pill.active { box-shadow: 0 3px 10px rgba(27,42,74,.22); }

/* pause all fx animations until scrolled into view */
.fx-anim-gate *, .fx-anim-gate { animation-play-state: paused !important; }
.fx-anim-gate.in-view *, .fx-anim-gate.in-view { animation-play-state: running !important; }

/* ── Reduced motion: kill it all, show final states ── */
@media (prefers-reduced-motion: reduce) {
  .fx-stagger > * { opacity: 1; transform: none; transition: none; }
  .fx-res:not(.visited)::after,
  .fx-shine::after,
  .fx-res-type::after { animation: none !important; }
  .fx-bolt { animation: none; opacity: 0; }
  .fx-band-break { animation: none; opacity: .85; }
  .fx-muscle-glow { animation: none; }
  .fx-scene.active .fx-fat,
  .fx-scene.active .fx-flame,
  .fx-scene.active .fx-brain,
  .fx-scene.active .fx-hunger { animation: none; }
  .fx-scene, .fx-scene-info { transition: none; }
  #fx-next { transition: none; }
  #fx-progress .bar { transition: none; }
  .result-box::before { animation: none; opacity: .5; }
  .result-number.fx-bump { animation: none; }
  .fx-lab .concept-card { transition: none; }
}
