/* mentat.hr motion layer (2026-11-05). motion.js sets html.motion when reduced motion is off;
   without it every rule below that is scoped to html.motion is inert and the page is static. */
:root { --ease-expo: cubic-bezier(0.16, 1, 0.3, 1); --ease-quart: cubic-bezier(0.25, 1, 0.5, 1); --slat: #161412; }

/* hero: each word rises from behind its own baseline */
html.motion .hero .headline.split .w {
  display: inline-block; animation: wrise 0.95s var(--ease-expo) both;
  animation-delay: calc(140ms + var(--i) * 70ms);
}
@keyframes wrise {
  from { transform: translateY(1.1em); clip-path: inset(-0.3em -0.15em 1.1em -0.15em); }
  to   { transform: none;              clip-path: inset(-0.3em -0.15em -0.3em -0.15em); }
}

/* diagram: wires draw on arrival, then amber pulses run source -> gate -> output */
html.motion .wiring .wire path { stroke-dasharray: 260; stroke-dashoffset: 260; }
html.motion .wiring.in .wire path { animation: draw 1.6s var(--ease) forwards; }
html.motion .wiring.in .wire path:nth-child(n+5) { animation-delay: 0.9s; }
.wiring .pulses circle { fill: var(--amber); }

/* before -> after rows: label, an arrow whose amber dot runs to the phrase, the phrase on flaps */
.swap li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25em 0.55em; }
.swap b { font-weight: 600; }
.arr { position: relative; display: inline-block; width: 1.6em; height: 2px; background: rgba(194, 168, 120, 0.35); }
.arr::after {
  content: ''; position: absolute; right: -3px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border-radius: 50%; background: var(--amber);
}
html.motion .arr::after { right: auto; left: -2px; opacity: 0; transition: transform 0.42s var(--ease-quart), opacity 0.15s linear; }
html.motion .swap li.in .arr::after { opacity: 1; transform: translateX(calc(1.6em - 4px)); }

/* split-flap cells: a recessed slat with a lit top edge and the seam the mechanism leaves.
   Cells only exist when motion.js built them. */
.word { display: inline-block; white-space: nowrap; }
.flap {
  position: relative; display: inline-block; overflow: hidden;
  height: 1.4em; line-height: 1.4em; min-width: 0.72em; padding: 0 0.06em; margin-right: 2px;
  vertical-align: bottom; text-align: center; background: var(--slat); border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 -1px 0 rgba(0, 0, 0, 0.55);
  color: rgba(232, 220, 200, 0.3); transition: color 0.3s linear;
}
.flap::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
/* each slat must be its own 1.4em block, or the strip lays out inline and slides out of the window */
.flap .strip { display: block; }
.flap .strip > span { display: block; height: 1.4em; line-height: 1.4em; }
/* 6 slats per cell (motion.js DEPTH): the resting one is 5 x 1.4em down */
.flap.go { color: var(--bone); transition-delay: var(--wait); }
.flap.go .strip { transform: translateY(-7em); transition: transform 0.55s cubic-bezier(0.16, 0.84, 0.3, 1) var(--wait); }
.big .flap { color: rgba(217, 121, 4, 0.35); }
.big .flap.go { color: var(--amber); }

/* three beats, one after another; the last one lands in amber */
html.motion .beats span {
  display: inline-block; opacity: 0; transform: translateY(0.45em); filter: blur(6px);
  transition: opacity 0.6s var(--ease-expo), transform 0.8s var(--ease-expo), filter 0.6s var(--ease-expo);
}
html.motion .beats.in span { opacity: 1; transform: none; filter: none; }
html.motion .beats.in span:nth-child(2) { transition-delay: 0.5s; }
html.motion .beats.in span:nth-child(3) { transition-delay: 1s; color: var(--amber); }

/* form: amber line draws under the field in use, a check draws when a field is valid,
   the hint ticks once e-mail or phone is filled, the button gives under the finger */
.form label { position: relative; transition: color 0.2s linear; }
.form label:focus-within { color: var(--bone); }
.form input, .form textarea { caret-color: var(--amber); padding-right: 42px; }
.form label:has(> input, > textarea, > select)::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 0 0 3px 3px;
  background: var(--amber); transform: scaleX(0); transform-origin: left; pointer-events: none;
  transition: transform 0.3s var(--ease-quart);
}
.form label:focus-within::after { transform: scaleX(1); }
.form label:has(> input:user-valid:not(:placeholder-shown), > textarea:user-valid:not(:placeholder-shown))::before {
  content: ''; position: absolute; right: 15px; bottom: 17px; width: 16px; height: 12px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Cpath d='M1.5 6.5l4 4L14.5 1.5' fill='none' stroke='%23D97904' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
  animation: tick 0.35s var(--ease-quart) both;
}
@keyframes tick { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.form .pair:has(input:not(:placeholder-shown)) + .hint::before { content: '\2713\00a0'; color: var(--amber); }
.btn:active { transform: scale(0.97); transition-duration: 0.1s; }
.btn.sending { position: relative; overflow: hidden; }
.btn.sending::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 40%; height: 2px; background: var(--void);
  animation: run 1s linear infinite;
}
@keyframes run { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* thank-you page: the ring from behind the form draws itself closed, then the tick */
.ring { display: block; width: 72px; height: 72px; margin-bottom: 1.4rem; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ring circle { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 164; transform: rotate(-90deg); transform-box: fill-box; transform-origin: center; }
.ring path { stroke: var(--bone); stroke-width: 2.5; stroke-dasharray: 31; }

@media (prefers-reduced-motion: no-preference) {
  .ring circle { animation: ringdraw 1.1s var(--ease-expo) 0.15s both; }
  .ring path { animation: tickdraw 0.5s var(--ease-quart) 1.05s both; }
}
@keyframes ringdraw { from { stroke-dashoffset: 164; } }
@keyframes tickdraw { from { stroke-dashoffset: 31; } }

@media (prefers-reduced-motion: reduce) {
  .form label::after, .form label::before, .btn.sending::after { transition: none; animation: none; }
}

/* the slats are wider than bare glyphs; give the board row the full main width */
.band:has(.swap) { max-width: none; }

/* board columns: labels, arrows and phrases line up like a departure board (wide screens) */
@media (min-width: 760px) {
  .swap { display: grid; grid-template-columns: max-content 1.6em max-content; column-gap: 0.55em; }
  .swap li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; }
}

/* before -> after phrases: scattered sand that drifts together and settles into the word */
html.motion .sand .g {
  display: inline-block; opacity: 0; color: var(--sand);
  transform: translate(var(--x), var(--y)) rotate(var(--r)); filter: blur(3px);
  transition: transform 1.1s var(--ease-expo), opacity 0.5s linear, filter 1s var(--ease-expo), color 1.2s linear;
  transition-delay: var(--d);
}
html.motion .swap li.in .sand .g { opacity: 1; transform: none; filter: none; color: var(--bone); }

/* phones: every row stacks the same way, label / arrow pointing down / phrase */
@media (max-width: 759px) {
  .swap li { flex-direction: column; gap: 0.2em; padding: 0.6em 0; }
  .arr { width: 2px; height: 1em; }
  .arr::after { right: auto; left: 50%; top: auto; bottom: -3px; margin: 0 0 0 -4px; }
  html.motion .arr::after { left: 50%; top: -2px; bottom: auto; }
  html.motion .swap li.in .arr::after { transform: translateY(calc(1em - 4px)); }
}

/* diagram boxes: the same recessed slat as the price cells, an indicator light, connector ports */
.center .diagram .wiring { max-width: 760px; }
.wiring .boxes rect { fill: var(--slat); stroke: rgba(232, 220, 200, 0.16); stroke-width: 1; }
.wiring .boxes .out rect { stroke: rgba(217, 121, 4, 0.45); }
.wiring .boxes .lip { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; fill: none; }
.wiring .boxes text { letter-spacing: 0.02em; }
.wiring .boxes .src .led { fill: var(--sand); opacity: 0.75; }
.wiring .boxes .out .led { fill: var(--amber); }
.wiring .boxes .out text { font-weight: 600; }
.wiring .ports circle { fill: var(--void); stroke: var(--sand); stroke-width: 1.5; }
.wiring .cols text { fill: var(--sand); letter-spacing: 0.24em; }
html.motion .wiring.in .boxes .out .led { animation: led 3.2s steps(1) 2.2s infinite; }
@keyframes led { 0%, 49% { opacity: 0.35; } 50%, 100% { opacity: 1; } }

/* diagram: wide version on desktop, a portrait version on phones (the wide one shrinks to 7px text) */
.wiring svg.v { display: none; }
@media (max-width: 759px) {
  .wiring svg.h { display: none; }
  .wiring svg.v { display: block; max-width: 420px; margin: 0 auto; }
}
