/* Echo Reapers game UI — animation layer (ER-0022). Loaded after every other stylesheet; overrides by order.
   Everything that moves sits inside prefers-reduced-motion: no-preference; er.css also kills animations globally for
   reduce, so the static state remains. Transforms and opacity only (a few tiny paint-only sweeps). */

/* canvases and counters (only exist when fx.js runs) */
:root {
  --motion-road-fade: 220ms; --motion-tile-hover: 240ms;
  --motion-panel-fade: 260ms; --motion-panel-slide: 460ms;
  --motion-tab-slide: 300ms; --motion-toast-enter: 380ms;
  --motion-ease-linear: linear;
  --motion-ease-out: ease-out; --motion-ease-panel: cubic-bezier(.2, .8, .2, 1);
  --motion-ease-tile: cubic-bezier(.2, .9, .3, 1.35);
  --motion-ease-tab: cubic-bezier(.3, .9, .3, 1.15);
  --motion-ease-tab-width: cubic-bezier(.3, .9, .3, 1);
  --motion-ease-toast: cubic-bezier(.2, .9, .3, 1.3);
  --motion-echo-cross: 44s; --motion-echo-idle: 6s; --motion-echo-reveal: 900ms;
  --motion-ease-idle: ease-in-out; --motion-ease-reveal: ease;
  --motion-echo-dim: .35s; --motion-ease-echo-dim: ease;
}
.fx-canvas { position: absolute; inset: 0; pointer-events: none; }
.fx-pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fx-login { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fx-hammer { display: none; }

@media (prefers-reduced-motion: no-preference) {

/* -- 1/4. counters ---------------------------------------------------------------------------------------- */
.fx-pop {
  position: absolute; transform: translate(-50%, -100%); padding: 3px 10px; border-radius: 4px; white-space: nowrap;
  background: var(--plaque, rgba(16, 14, 12, .82)); color: #f2ead8; font-size: 14px; line-height: 1.25;
  box-shadow: 0 0 0 1px var(--brass), 0 4px 10px rgba(0, 0, 0, .5);
  animation: fx-pop 3.2s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes fx-pop {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(.8); }
  10% { opacity: 1; transform: translate(-50%, -112%) scale(1.06); }
  18% { transform: translate(-50%, -104%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -128%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
.amber-chip.fx-bump { animation: fx-bump 520ms cubic-bezier(.2, .9, .3, 1.4); }
@keyframes fx-bump { 0% { transform: scale(1); } 35% { transform: scale(1.13); filter: brightness(1.35); } 100% { transform: scale(1); } }
.site-tile.fx-hit .tile-art { animation: fx-hit 460ms ease-out; }
@keyframes fx-hit { 0% { filter: brightness(1.6) saturate(1.3); } 100% { filter: none; } }

/* -- 1. roads --------------------------------------------------------------------------------------------- */
.fx-on .stage-roads .road-echo { opacity: .3; }          /* the static markers step back: real echoes walk the road now */
.stage-roads .road { transition: opacity var(--motion-road-fade); }
.stage-roads .road .road-dirt { transition: stroke var(--motion-road-fade); }
.stage-roads .road.hot .road-dirt { stroke: rgba(236, 196, 128, .92); }
.stage-roads .road.hot { opacity: 1; filter: drop-shadow(0 0 5px rgba(255, 210, 120, .55)); }
.stage-roads .road.faded.hot { opacity: .8; }

/* -- 2. idle life ------------------------------------------------------------------------------------------- */
.fx-on .stage-worksite { animation: fx-breathe 6.5s ease-in-out infinite; }
@keyframes fx-breathe { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -1.6px); } }

/* band crests and amber crystals: a slow shimmer */
.amber-chip .ico.amber, .plot-plaque .gem { animation: fx-shimmer 7s ease-in-out infinite; }
.plot-plaque .gem { animation-delay: -3s; }
@keyframes fx-shimmer { 0%, 78%, 100% { filter: brightness(1); } 88% { filter: brightness(1.55); } } /* brightness only: no animated drop-shadow (Aletheia 0.6.5 low finding) */

/* fallen-pip lanterns flicker faintly */
.pip.fallen { animation: fx-flicker 3.1s steps(1, end) infinite var(--fx-d2, 0s); }
@keyframes fx-flicker { 0% { opacity: .8; } 12% { opacity: 1; } 20% { opacity: .7; } 44% { opacity: .95; } 52% { opacity: .75; } 70% { opacity: 1; } 84% { opacity: .82; } 100% { opacity: .8; } }

/* grace tiles: a faint warm glow in the cracks */
.state-grace .tile-cracks path { animation: fx-crack 3.6s ease-in-out infinite var(--fx-d2, 0s); }
@keyframes fx-crack { 0%, 100% { stroke: rgba(0, 0, 0, .8); } 50% { stroke: rgba(255, 150, 60, .95); } }

/* pending flag waves slightly */
.tile-flag { transform-origin: 0 100%; animation: fx-wave 2.8s ease-in-out infinite var(--fx-d2, 0s); }
@keyframes fx-wave { 0%, 100% { transform: rotate(-1.6deg) skewY(0deg); } 50% { transform: rotate(1.4deg) skewY(-2.2deg); } }

/* the hourglass flips once a minute (120 s cycle: flip, hold a minute, flip again) */
.tick-chip .ico svg { animation: fx-flip 120s cubic-bezier(.5, 0, .2, 1) infinite; }
@keyframes fx-flip {
  0%, 0.2% { transform: rotate(0deg); } 1% { transform: rotate(180deg); }
  50% { transform: rotate(180deg); } 51% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }
}

/* scaffold hammer taps every ~2 s with a dust puff */
.fx-hammer { display: block; position: absolute; z-index: 3; left: 8%; bottom: 8%; width: 38%; max-width: 44px; aspect-ratio: 1; pointer-events: none; }
.fx-hammer svg, .fx-hammer img { width: 100%; height: 100%; display: block; object-fit: contain; transform-origin: 50% 92%; animation: fx-tap 2s ease-in infinite var(--fx-d2, 0s); filter: drop-shadow(0 1px 1px #000); }
@keyframes fx-tap { 0%, 62% { transform: rotate(-38deg); } 74% { transform: rotate(14deg); } 80% { transform: rotate(6deg); } 100% { transform: rotate(-38deg); } }
.fx-dust {
  position: absolute; left: 62%; bottom: -4%; width: 7px; height: 7px; border-radius: 50%; opacity: 0;
  background: rgba(220, 200, 160, .8); box-shadow: 8px -3px 0 -1px rgba(220, 200, 160, .6), -6px -2px 0 -1px rgba(220, 200, 160, .55);
  animation: fx-dust 2s ease-out infinite var(--fx-d2, 0s);
}
@keyframes fx-dust { 0%, 72% { opacity: 0; transform: scale(.3) translateY(0); } 76% { opacity: .85; } 100% { opacity: 0; transform: scale(2) translateY(-8px); } }

/* -- 3. interaction ---------------------------------------------------------------------------------------- */
.stage .site-tile { transform-origin: 50% 100%; transition: transform var(--motion-tile-hover) var(--motion-ease-tile); }
.stage .site-tile:hover { transform: translateY(-3px); }
.stage .site-tile:active { transform: translateY(0) scale(.975, .96); transition-duration: 90ms; }
.site-tile .tile-frame { transition: filter 200ms; }

.site-tile:hover .tile-frame { filter: var(--tint, brightness(1)) brightness(1.14); }
.site-tile.mine:hover .tile-frame { filter: var(--tint, brightness(1)) brightness(1.18); }
.state-empty:hover .tile-clearing { filter: brightness(1.12) drop-shadow(0 6px 5px rgba(15, 25, 8, .4)); }
.tile-plus { transition: transform 240ms cubic-bezier(.2, .9, .3, 1.5); }
.state-empty:hover .tile-plus { transform: scale(1.15); }

/* selected: the static ring stays; a slow amber ring pulses outward from it */
.site-tile.selected::after {
  content: ""; position: absolute; z-index: 5; inset: -4px -4px -2px; border: 3px solid var(--amber, #f0a020); border-radius: 8px; pointer-events: none;
  animation: fx-ring 2.8s ease-out infinite;
}
.state-empty.selected::after { inset: 0; }
@keyframes fx-ring { 0% { transform: scale(1); opacity: .75; } 70%, 100% { transform: scale(1.09); opacity: 0; } }

/* buttons press */
.icon-btn, .rail-btn, button.chip, .pick-tab, .tab { transition-property: transform, filter, background-color, border-color, color, box-shadow; }
.icon-btn:active, .rail-btn:active, button.chip:active { transform: scale(.97); transition-duration: 80ms; }

/* tabs: one underline that slides */
.fx-tabs { position: relative; }
.fx-tabs > [aria-selected="true"] { border-bottom-color: transparent; }
.fx-tab-line {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--amber, #f0a020); pointer-events: none;
  transition: transform var(--motion-tab-slide) var(--motion-ease-tab), width var(--motion-tab-slide) var(--motion-ease-tab-width);
}

/* panels: slide from their side with a little overshoot, backdrop fades; phone sheets rise with a spring */
.panel-layer { animation: fx-fade var(--motion-panel-fade) var(--motion-ease-out); }
@keyframes fx-fade { from { opacity: 0; } to { opacity: 1; } }
.panel-right { animation: fx-slide-r var(--motion-panel-slide) var(--motion-ease-panel) both; }
.panel-left { animation: fx-slide-l var(--motion-panel-slide) var(--motion-ease-panel) both; }
@keyframes fx-slide-r { 0% { transform: translateX(56px); opacity: 0; } 55% { transform: translateX(-7px); opacity: 1; } 80% { transform: translateX(2px); } 100% { transform: none; opacity: 1; } }
@keyframes fx-slide-l { 0% { transform: translateX(-56px); opacity: 0; } 55% { transform: translateX(7px); opacity: 1; } 80% { transform: translateX(-2px); } 100% { transform: none; opacity: 1; } }
@keyframes fx-rise { 0% { transform: translateY(100%); } 62% { transform: translateY(-2.4%); } 82% { transform: translateY(.8%); } 100% { transform: none; } }
@media (max-width: 600px) and (orientation: portrait) {
  .panel, .panel-wide { animation: fx-rise 560ms cubic-bezier(.2, .8, .2, 1) both; }
}

/* toasts slide and fade in */
.toast { animation: fx-toast var(--motion-toast-enter) var(--motion-ease-toast) both; }
@keyframes fx-toast { 0% { opacity: 0; transform: translateY(-16px) scale(.96); } 100% { opacity: 1; transform: none; } }

/* signing stepper: the check draws itself, the current step pulses */
.step-mark { position: relative; }
.step[data-state="done"] .step-mark { animation: fx-markpop 420ms cubic-bezier(.2, .9, .3, 1.5); }
.step[data-state="done"] .step-mark use { stroke-dasharray: 30; animation: fx-draw 460ms ease-out 120ms both; }
@keyframes fx-draw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
@keyframes fx-markpop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.step[data-state="done"]::before { transform-origin: 50% 0; animation: fx-line 420ms ease-out both; }
@keyframes fx-line { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.step[data-state="active"] .step-mark::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--amber, #f0a020); pointer-events: none;
  animation: fx-stepring 1.6s ease-out infinite;
}
@keyframes fx-stepring { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.7); opacity: 0; } }

/* -- 5. login ------------------------------------------------------------------------------------------------ */
.login-title { animation: fx-titleglow 2.8s ease-out .35s 1 both; }
@keyframes fx-titleglow {
  0% { text-shadow: 0 0 0 rgba(255, 210, 122, 0); }
  35% { text-shadow: 0 0 22px var(--amber-glow, #ffd27a), 0 0 4px var(--amber, #f0a020); }
  100% { text-shadow: 0 0 0 rgba(255, 210, 122, 0); }
}


}

/* Audit polish: toast text stays readable and clear of map plaques; all tile states share one plaque family. */
.boot { background: radial-gradient(ellipse at 50% 45%, #27231b, #0a0906 78%); }
/* toast position: hud.css (ER-1260) */
.toast { font-size: 14px; line-height: 1.4; }
.tile-plaque, html.kit-plaque-label .tile-plaque, html.kit-plaque-danger .tile-plaque.warn {
  box-sizing: border-box; width: max-content; max-width: min(175%, 220px); min-width: 0;
  padding: 5px 9px 4px; white-space: normal; overflow-wrap: normal; word-break: normal; text-wrap: balance;
  color: #f1e6d0; background: linear-gradient(180deg, rgba(38,35,29,.97), rgba(16,15,13,.97));
  border: 1px solid var(--brass, #b58b45); border-image: none; border-radius: 3px; box-shadow: 0 2px 5px #000b;
}
.tile-plaque.warn, html.kit-plaque-danger .tile-plaque.warn { color: #ffd6c9; }
.tile-plaque.mine { color: #ffdf9a; }
.tile-plaque.outpost { color: #f1e6d0; }
.fx-on .stage-roads .road-echo { opacity: .62; }
@media (max-width: 600px) {
  .tile-plaque, html.kit-plaque-label .tile-plaque { max-width: 150%; min-width: 0; padding: 4px 5px 3px; font-size: 12px; }
  .tile-plaque.warn { width: 118%; }
  .tile-plaque.outpost { width: 118%; }
}
html.kit-plaque-label.kit-panel-frame .sign-sheet .panel-head::before {
  top: 4px; left: auto; right: 68px; transform: none; z-index: 4;
}
/* Provisional task notes (ER map polish): replace placeholder scene summary cards with truthful data,
   make sparse plot cards readable, scale phone sites to the usable stage, ground the worksite, and
   negotiate art derivatives with Accept/Vary. This note is removed when the implementation lands. */
