/* ============================================================
   MOTION (31 Oct, Sheikh: "every interaction should animate, even lightly")

   One layer for the whole app, beside motion.js. It only adds motion; it never moves anything for good, so a screen
   at rest is exactly the screen without this file. Transform and opacity only (the compositor runs them while the
   app works), from the feel framework's springs (.claude/skills/feel): the curves below are those springs written
   out as CSS linear() easings, so a CSS transition moves like Feel.Spring would. Never a new number per screen.

     snap    damping 1,    response .25   a press coming back, a pop, a small thing a tap changes
     move    damping 1,    response .40   something a tap brings in: a toast, a row, a screen
     sheet   damping .86,  response .32   a sheet rising

   Reduced motion: fades only. Calm mode (body.calm): nothing moves (index.html already zeroes CSS durations there;
   motion.js does the same for what it plays).
   ============================================================ */
:root{
  --m-snap:  cubic-bezier(.2,.8,.2,1);   --m-snap-ms: 340ms;
  --m-move:  cubic-bezier(.2,.8,.2,1);   --m-move-ms: 520ms;
  --m-sheet: cubic-bezier(.2,.9,.25,1);  --m-sheet-ms: 380ms;
  --m-exit:  cubic-bezier(.4,0,.8,.4);   --m-exit-ms: 200ms;   /* leaving is a little faster than arriving */
  --m-fade-ms: 200ms;
}
@supports (transition-timing-function: linear(0, 1)){
  :root{
    --m-snap:  linear(0, 0.104, 0.292, 0.477, 0.628, 0.743, 0.826, 0.883, 0.924, 0.95, 0.968, 0.979, 0.986, 0.991, 0.994, 0.996, 1);
    --m-move:  linear(0, 0.094, 0.277, 0.455, 0.605, 0.721, 0.809, 0.87, 0.912, 0.941, 0.961, 0.974, 0.983, 0.989, 0.993, 0.995, 1);
    --m-sheet: linear(0, 0.083, 0.25, 0.431, 0.6, 0.73, 0.827, 0.895, 0.941, 0.97, 0.987, 0.997, 1.002, 1.004, 1.004, 1.004, 1);
  }
}

/* ---------- screens: deeper slides in from its side (index.html), a tab only cross-fades, quickly ---------- */
.view.active.go-tab{ animation:mTab 160ms var(--ease, ease-out); }
@keyframes mTab{ from{ opacity:.25; } }

/* ---------- sheets: rise on the sheet spring, leave faster; the scrim fades ---------- */
#sheet{ transition:transform var(--m-exit-ms) var(--m-exit), padding .4s cubic-bezier(.4,0,.2,1); }
#sheet.show{ transition:transform var(--m-sheet-ms) var(--m-sheet), padding .4s cubic-bezier(.4,0,.2,1); }
#sheet.m-dragging, #sheet.m-settling{ transition:none !important; }
#sheetBack{ transition:opacity 160ms var(--ease, ease-out); }
#sheetBack.show{ transition:opacity var(--m-fade-ms) var(--ease, ease-out); }

/* ---------- toasts and the undo bar: spring in, fade out ---------- */
#toast, #undoBar{ transition:opacity 160ms var(--ease, ease-out), transform var(--m-exit-ms) var(--m-exit); }
#toast.show, #undoBar.show{ transition:opacity var(--m-fade-ms) var(--ease, ease-out), transform var(--m-move-ms) var(--m-move); }
#toast:not(.show), #undoBar:not(.show){ transform:translate(-50%, 14px); }

/* ---------- waiting: a calm shimmer (motion.js adds .m-wait only where nothing else draws on the thing) ---------- */
.m-wait{ position:relative; }
.m-wait::after{
  content:''; position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  background:linear-gradient(100deg, transparent 35%, color-mix(in srgb, currentColor 9%, transparent) 50%, transparent 65%);
  background-size:260% 100%; animation:mShimmer 1.8s linear infinite;
}
@keyframes mShimmer{ from{ background-position:130% 0; } to{ background-position:-30% 0; } }

/* ---------- clay icons (31 Oct, Sheikh: "we need animations for the icons as well") ----------
   Every clay picture in a button: it pops in the first time, tilts toward a finger or pointer, and squashes like soft
   clay when pressed. Transform only, on the picture, so the button's own press still runs. */
:where(button, [role="button"], .tab) img:where([src*="art/features/"], [src*="art/subjects/"], [src*="art/zen/"]){
  transition:transform var(--m-snap-ms) var(--spring, cubic-bezier(.2,.8,.2,1)); animation:mClayIn 460ms var(--m-move) backwards; }
:where(button, [role="button"], .tab):hover img:where([src*="art/features/"], [src*="art/subjects/"]){ transform:rotate(-7deg) scale(1.08); }
:where(button, [role="button"], .tab):active img:where([src*="art/features/"], [src*="art/subjects/"], [src*="art/zen/"]){ transform:scale(1.12, .86); transition-duration:90ms; }
.tab.on img[src*="art/"]{ animation:mClayHop 520ms cubic-bezier(.34,1.56,.64,1); }
@keyframes mClayIn{ from{ opacity:0; transform:scale(.6) rotate(-10deg); } }
@keyframes mClayHop{ 0%{ transform:translateY(0) scale(1); } 35%{ transform:translateY(-6px) scale(.94, 1.08); } 70%{ transform:translateY(0) scale(1.08, .92); } 100%{ transform:none; } }

/* ---------- serious screens stay calm (31 Oct, Sheikh: "less childish, Gizmo's fun with Save My Exams' calm") ----------
   Papers, a paper being sat or marked, and You: the clay icons keep their press but never hop, tilt or pop in. */
:is(#viewPast, #viewPaperRead, #viewPapers, #viewSettings, #psnPaper) img[src*="art/"]{ animation:none !important; }
@media (hover:hover){ :is(#viewPast, #viewPaperRead, #viewPapers, #viewSettings, #psnPaper) :is(button, [role="button"]):hover img[src*="art/"]{ transform:none; } }

/* ---------- people's settings ---------- */
@media (prefers-reduced-motion: reduce){
  .view.active.go-tab{ animation:none; }
  .m-wait::after{ animation:none; opacity:.6; }
  :is(button, [role="button"], .tab) img[src*="art/"], .tab.on img[src*="art/"]{ animation:none !important; transform:none !important; }
  /* a sheet fades in place instead of rising */
  #sheet:not(.show){ transform:none !important; opacity:0; visibility:hidden; pointer-events:none;
    transition:opacity 160ms ease-out, visibility 0s linear 160ms; }
  #sheet.show{ transform:none !important; opacity:1; visibility:visible; transition:opacity var(--m-fade-ms) ease-out; }
  #toast, #undoBar, #toast.show, #undoBar.show{ transition:opacity var(--m-fade-ms) ease-out; }
  #toast:not(.show), #undoBar:not(.show){ transform:translate(-50%, 0); }
}
body.calm .m-wait::after{ display:none; }
body.calm :is(button, [role="button"], .tab) img[src*="art/"]{ animation:none !important; transform:none !important; }
@media print{ .m-wait::after{ display:none; } }
