/* features/gaps-morph.css: the gaps language (Morph + hammer slam). Logic and rules: features/gaps-morph.js.
   Ships twice (landing/lib/gaps-morph.css is an identical copy, kept so by UAT). Motion: transform and opacity only,
   the house curve cubic-bezier(0.16, 1, 0.3, 1) written out (these elements can sit on <body>), BRAND §6 durations.
   Loops run only while .is-looping is set (a real wait). Reduced motion: still frames. */

.gm { position: relative; display: block; flex: none; pointer-events: none; -webkit-user-select: none; user-select: none; }
.gm-buy { width: 236px; height: 206px; }
.gm-rest { width: 220px; height: 200px; }
.gm-small { width: 78px; height: 70px; }
.gm picture, .gm img { display: block; -webkit-user-drag: none; }

/* The soft shadow the object floats over. Illustration colour (BRAND §3 allows it for brand art). */
.gm-floor { position: absolute; left: 18%; right: 18%; bottom: 2%; height: 9%; border-radius: 50%; transform-origin: center;
  background: radial-gradient(closest-side, rgb(58 34 16 / 0.34), transparent); }
html[data-theme="dark"] .gm-floor, :root:not([data-theme="light"]) .gm-floor { background: radial-gradient(closest-side, rgb(0 0 0 / 0.55), transparent); }
html[data-theme="light"] .gm-floor { background: radial-gradient(closest-side, rgb(58 34 16 / 0.34), transparent); }

.gm-float { position: absolute; inset: 0 0 8% 0; display: block; }
.gm-mf { position: absolute; inset: 0; display: block; transform-origin: 50% 88%; }
.gm-f { position: absolute; inset: 0; opacity: 0; transform-origin: 50% 88%; }
.gm-f img, .gm-steam img, .gm-ham img { width: 100%; height: 100%; object-fit: contain; }
.gm-f.is-vis { opacity: 1; }
.gm-f.is-in { animation: gm-in 160ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.gm-f.is-out { animation: gm-out 160ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.gm-mf.is-land { animation: gm-land 560ms cubic-bezier(0.16, 1, 0.3, 1); }
.gm-mf.is-bump { animation: gm-bump 560ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes gm-in { from { opacity: 0; transform: scale(1.04, 0.95); } to { opacity: 1; transform: none; } }
@keyframes gm-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.97, 1.05); } }
@keyframes gm-land { 0% { transform: none; } 25% { transform: scale(1.1, 0.88); } 55% { transform: scale(0.96, 1.05); } 100% { transform: none; } }
@keyframes gm-bump { 0% { transform: none; } 30% { transform: scale(1.12, 0.86); } 60% { transform: scale(0.96, 1.06); } 100% { transform: none; } }

/* Only while a real wait lasts: a slow float over a breathing shadow. */
.gm.is-looping .gm-float { animation: gm-float 2.8s cubic-bezier(0.16, 1, 0.3, 1) infinite alternate; }
.gm.is-looping .gm-floor { animation: gm-floor 2.8s cubic-bezier(0.16, 1, 0.3, 1) infinite alternate; }
@keyframes gm-float { from { transform: translateY(3%); } to { transform: translateY(-6%); } }
@keyframes gm-floor { from { transform: scaleX(1); opacity: 1; } to { transform: scaleX(0.78); opacity: 0.6; } }

/* At rest (Daily Review, all caught up): the mug and a still wisp of steam. Nothing loops. */
.gm-steam { position: absolute; left: 22%; width: 56%; top: -30%; height: 55%; opacity: 0.7; z-index: 2; }

/* The slam: the hammer strikes once when the wait really ends. Wind-up and fall, impact at 340 ms, settle. */
.gm-slam { position: absolute; inset: 0; z-index: 3; display: block; }
.gm-ham { position: absolute; width: 64%; aspect-ratio: 1312 / 1199; left: 44%; top: -32%; transform-origin: 82% 92%; opacity: 0; }
.gm-flash { position: absolute; left: 20%; top: 2%; width: 60%; aspect-ratio: 1; border-radius: 50%; opacity: 0;
  background: radial-gradient(closest-side, rgb(255 247 222 / 0.95), rgb(255 190 100 / 0.45) 45%, transparent); }
.gm-spk { position: absolute; left: 50%; top: 30%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; opacity: 0;
  background: radial-gradient(rgb(255 246 214), rgb(255 179 71) 60%, transparent 70%); }
.gm-small .gm-spk { width: 5px; height: 5px; margin: -2.5px; }
.gm.is-slam .gm-ham { animation: gm-ham-in 340ms both, gm-ham-out 380ms cubic-bezier(0.16, 1, 0.3, 1) 340ms forwards; }
.gm.is-slam .gm-mf { animation: gm-squash 380ms cubic-bezier(0.16, 1, 0.3, 1) 340ms both; }
.gm.is-slam .gm-float { animation: gm-shake 220ms linear 340ms both; }
.gm.is-slam .gm-flash { animation: gm-flash 340ms cubic-bezier(0.16, 1, 0.3, 1) 340ms both; }
.gm.is-slam .gm-spk { animation: gm-spk 540ms cubic-bezier(0.16, 1, 0.3, 1) calc(340ms + var(--d, 0ms)) both; }
@keyframes gm-ham-in {
  0% { opacity: 0; transform: rotate(36deg); animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
  62% { opacity: 1; transform: rotate(58deg); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  100% { opacity: 1; transform: rotate(-34deg); }
}
@keyframes gm-ham-out { 0% { opacity: 1; transform: rotate(-34deg); } 45% { opacity: 1; transform: rotate(-14deg); } 100% { opacity: 0; transform: rotate(-6deg); } }
@keyframes gm-squash { 0% { transform: scale(1.18, 0.76); } 35% { transform: scale(0.95, 1.07); } 70% { transform: scale(1.02, 0.99); } 100% { transform: none; } }
@keyframes gm-shake { 0% { transform: none; } 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } 100% { transform: none; } }
@keyframes gm-flash { 0% { opacity: 0; transform: scale(0.96); } 25% { opacity: 1; transform: scale(1.15); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes gm-spk {
  0% { opacity: 1; transform: translate(0, 0) scale(1.2); }
  40% { opacity: 1; transform: translate(calc(var(--x) * 0.6), calc(var(--y) * 0.6)); }
  100% { opacity: 0; transform: translate(var(--x), var(--dy)) scale(0.96); }
}

/* Captions under the object, one at a time, in step with each new shape. Decoration: the card's own text is read out. */
.gm-caps { display: grid; margin: 6px 0 14px; min-height: 20px; font-size: 14px; font-weight: 600; color: var(--accent-deep, var(--accent)); text-align: center; }
.gm-cap { grid-area: 1 / 1; opacity: 0; transform: translateY(5px); transition: opacity 360ms cubic-bezier(0.16, 1, 0.3, 1), transform 360ms cubic-bezier(0.16, 1, 0.3, 1); }
.gm-cap.is-on { opacity: 1; transform: none; transition-delay: 140ms; }
.gm-cap.is-off { opacity: 0; transform: translateY(-5px); transition-duration: 200ms; }

/* The 0.4 s rule: present, invisible, until the wait passes 400 ms. */
.gm-gate { opacity: 0; transform: translateY(8px); }
.gm-gate.is-shown { opacity: 1; transform: none; transition: opacity 360ms cubic-bezier(0.16, 1, 0.3, 1), transform 360ms cubic-bezier(0.16, 1, 0.3, 1); }

/* Offscreen or on a hidden tab: everything holds still. */
.gm.is-paused, .gm.is-paused * { animation-play-state: paused !important; }

/* Reduced motion: still frames. The slam shows one still pose of the hammer and the flash, then goes. */
@media (prefers-reduced-motion: reduce) {
  .gm, .gm * { animation: none !important; transition: none !important; }
  .gm.is-slam .gm-ham { opacity: 1; transform: rotate(-34deg); }
  .gm.is-slam .gm-flash { opacity: 0.55; }
  .gm-cap, .gm-gate { transform: none !important; }
  .gm-cap { transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1); }
  .gm-gate.is-shown { transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1); }
}
