/**
 * moments.css — the moments layer.
 *
 * Overlays that mark the things worth noticing in a morning: a task finished
 * under budget, a failure, the last minute, the whole thing done. Ported from
 * frontend/lab/08-moments.html.
 *
 * There is no out-the-door moment: tv.js already runs its own full-screen
 * celebration for that.
 *
 * Everything here is pointer-events:none and sits above the dashboard without
 * changing its layout. The only requirement of the page underneath is that
 * .child-column establishes a positioning context, set below.
 */

:root {
  --mo-bg: #0a0f0d;
  --mo-green: #22c55e;
  --mo-amber: #eab308;
  --mo-red: #ff5a5a;
  --mo-text: #e2e8f0;
  --mo-muted: #64748b;
  --mo-display: 'Rajdhani', sans-serif;
  --mo-mono: 'Share Tech Mono', monospace;
}

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

#moments-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 901;
}

/* The dashboard's columns host the per-child moments. */
.child-column { position: relative; }

/* ── Task complete: a rubber stamp on the child's column ────────── */

.mo-stamp {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%) rotate(-7deg);
  z-index: 5;
  pointer-events: none;
  padding: 1.4vh 1.4vw;
  border: .7vh solid var(--mo-sc, var(--mo-green));
  border-radius: 1.2vh;
  color: var(--mo-sc, var(--mo-green));
  text-align: center;
  font: 700 clamp(2.4vh, 1.8vw, 4.6vh)/1 var(--mo-display);
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 96%;
  box-shadow: inset 0 0 0 .3vh var(--mo-bg);
  background: rgba(10, 15, 13, .55);
  animation: mo-stamp-in .45s cubic-bezier(.15, 1.2, .3, 1) both;
}
.mo-stamp .sub {
  font: 1.7vh var(--mo-mono);
  letter-spacing: .18em;
  margin-top: .7vh;
  color: var(--mo-sub, var(--mo-green));
}
.mo-stamp.out { animation: mo-fade-out .6s ease-in both; }

@keyframes mo-stamp-in {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(-7deg) scale(2.4); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-7deg) scale(1); }
}
@keyframes mo-fade-out { to { opacity: 0; transform: translate(-50%, -60%) rotate(-7deg) scale(.9); } }

/* A short colour wash over the column that just changed. */
.mo-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--mo-cc, var(--mo-green));
  opacity: 0;
  border-radius: inherit;
}
.child-column.mo-flashing .mo-flash { animation: mo-flash .7s ease-out; }
@keyframes mo-flash { 0% { opacity: .45; } 100% { opacity: 0; } }

.child-column.mo-shake { animation: mo-shake .7s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes mo-shake {
  10%, 90% { transform: translate3d(-.3vw, 0, 0); }
  20%, 80% { transform: translate3d(.5vw, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-.8vw, .2vh, 0); }
  40%, 60% { transform: translate3d(.8vw, -.2vh, 0); }
}

/* ── Full-screen moments ────────────────────────────────────────── */

.mo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(ellipse at center, rgba(10, 15, 13, .82), rgba(10, 15, 13, .96));
  transition: opacity .45s ease;
}
.mo-overlay.on { opacity: 1; visibility: visible; }
.mo-overlay.bye { opacity: 0; }

/* Failure */
#mo-abort { background: radial-gradient(ellipse at center, rgba(60, 0, 0, .8), rgba(10, 15, 13, .96)); }
#mo-abort .tx {
  font: 700 11vh/1 var(--mo-display);
  color: var(--mo-red);
  text-transform: uppercase;
  letter-spacing: .04em;
  text-shadow: 0 0 5vh rgba(255, 90, 90, .6);
}
#mo-abort .who {
  font: 2.6vh var(--mo-mono);
  letter-spacing: .4em;
  color: var(--mo-red);
  text-transform: uppercase;
  opacity: .85;
}

/* Mission complete */
#mo-mission .hd {
  font: 700 12vh/1 var(--mo-display);
  color: var(--mo-amber);
  text-transform: uppercase;
  letter-spacing: .03em;
  text-shadow: 0 0 6vh rgba(234, 179, 8, .5);
}
#mo-mission .medals { display: flex; gap: 4vw; margin-top: 1vh; }
@keyframes mo-rise { from { opacity: 0; transform: translateY(6vh) scale(.9); } to { opacity: 1; transform: none; } }
#mo-mission .medal { text-align: center; animation: mo-rise .6s cubic-bezier(.2, 1.1, .3, 1) both; }
#mo-mission .medal:nth-child(2) { animation-delay: .12s; }
#mo-mission .medal:nth-child(3) { animation-delay: .24s; }
#mo-mission .disc {
  width: 9vh; height: 9vh; margin: 0 auto .8vh;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 700 4.4vh/1 var(--mo-display);
  color: var(--mo-bg);
  background: var(--mo-cc, var(--mo-muted));
  box-shadow: 0 0 3vh color-mix(in srgb, var(--mo-cc, #64748b) 55%, transparent);
}
#mo-mission .gold .disc   { background: #fde68a; }
#mo-mission .silver .disc { background: #cbd5e1; }
#mo-mission .bronze .disc { background: #d6a06a; }
#mo-mission .who { font: 700 3.2vh/1 var(--mo-display); color: var(--mo-cc, var(--mo-text)); text-transform: uppercase; }
#mo-mission .when { font: 2vh var(--mo-mono); color: var(--mo-muted); letter-spacing: .2em; margin-top: .4vh; }
#mo-mission .stats { display: flex; gap: 5vw; margin-top: 3vh; }
#mo-mission .st { text-align: center; }
#mo-mission .st .v { font: 700 5vh/1 var(--mo-display); color: var(--mo-text); }
#mo-mission .st .v.good { color: var(--mo-green); }
#mo-mission .st .v.bad  { color: var(--mo-red); }
#mo-mission .st .k { font: 1.7vh var(--mo-mono); letter-spacing: .3em; color: var(--mo-muted); text-transform: uppercase; margin-top: .6vh; }

/* Final minute */
#mo-minute {
  position: absolute;
  left: 0; right: 0; top: 0;
  padding: 1.2vh 0;
  display: flex; align-items: center; justify-content: center; gap: 1.5vw;
  background: linear-gradient(180deg, rgba(220, 38, 38, .95), rgba(220, 38, 38, 0));
  transform: translateY(-100%);
  transition: transform .5s cubic-bezier(.2, 1.1, .3, 1);
}
#mo-minute.on { transform: none; }
#mo-minute .lb {
  font: 2.4vh var(--mo-mono);
  letter-spacing: .5em;
  color: #fff;
  text-transform: uppercase;
}
#mo-minute .n {
  font: 700 5vh/1 var(--mo-display);
  color: #fff;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .mo-stamp, #mo-mission .medal { animation: none; }
  .child-column.mo-shake { animation: none; }
  .mo-overlay { transition: none; }
}
