/* The Index / effects.css
 * Three small effects, taken from shahimim.com and shared by every page.
 *
 *   1 / Arrival. On load, blocks start blurred and a few pixels low, then
 *       rise and come into focus, one after another. Blocks below the fold
 *       do the same when they are first scrolled to.
 *   2 / Cards. On hover the outline darkens and the picture inside grows by
 *       about one and a half percent. The card itself stays where it is.
 *   3 / Scissors. A pair of blades snips along a dashed line, the line is cut
 *       away behind them, then it fades back in.
 *
 * All of it is off under prefers-reduced-motion. scripts/effects.js does the
 * timing; nothing here hides content unless that script has run.
 */

:root {
  --fx-ease: cubic-bezier(.22, 1, .36, 1);
  --fx-card: color-mix(in srgb, var(--ink) 30%, transparent);
}

/* ---- 1 / Arrival ---------------------------------------------------------
 * html.fx-pre is set by effects.js in the head, before the body paints, so
 * nothing flashes in and then disappears. It lasts until the blocks are
 * tagged. If the script fails part way, the fallback shows the page anyway.
 */
html.fx-pre main { opacity: 0; animation: fx-show 0s linear 1.6s forwards; }
@keyframes fx-show { to { opacity: 1; } }

[data-fx="wait"] { opacity: 0; }
[data-fx="in"] {
  animation: fx-settle 640ms var(--fx-ease) var(--fx-d, 0ms) both;
}
@keyframes fx-settle {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(var(--fx-b, 6px));
  }
  to { opacity: 1; transform: none; filter: blur(0); }
}

/* The home page has its own boot sequence; the blocks now arrive one by one,
   so the page-wide fade under them is not needed. */
html.fx-on[data-boot="in"] .page { animation: none; }

/* The case studies already rise on scroll. They gain the blur, so the whole
   site arrives the same way. */
html.fx-on [data-rise] {
  filter: blur(5px);
  transition: opacity 620ms var(--ease-expo), transform 620ms var(--ease-expo),
              filter 520ms var(--fx-ease);
  transition-delay: var(--rise-d, 0ms);
}
html.fx-on [data-rise="on"],
html.fx-on [data-rise="tilt"][data-on] { filter: none; }

/* ---- 2 / Cards -----------------------------------------------------------
 * Border to ink at 30% in 240ms, as on the reference. The media grows to
 * 1.04 in 400ms on cubic-bezier(.22, .8, .2, 1); the reference's 1.015 read
 * as no change at all. Uses the `scale` property, not transform, so it
 * stacks on top of whatever the media is already doing.
 */
.wk__card,
.record--grid .record__row,
.gd__card,
.offer {
  transition: border-color var(--dur-hover) ease, scale .12s var(--fx-ease);
}
.wk__card:hover,
.record--grid .record__row:hover,
.gd__card:hover,
.offer:hover {
  transform: none;
  border-color: var(--fx-card);
}
.wk__card:active,
.record--grid .record__row:active,
.gd__card:active { scale: .99; }

.wk__shot > *,
.record--grid .record__media > *,
.gd__shot > * {
  transition: scale 400ms cubic-bezier(.22, .8, .2, 1);
}
.wk__card:hover .wk__shot > *,
.record--grid .record__row:hover .record__media > *,
.gd__card:hover .gd__shot > * { scale: 1.04; }
.tile:hover .tile-media { transform: scale(1.04); }

/* The name of the work grows with it, from its left edge so the line does
   not slide sideways, and comes up to full ink. Kept to 4% so a long name
   still fits inside the card's padding. */
.gd__captxt { display: inline-block; }
.wk__name, .gd__title, .gd__captxt, .record__title, .offer-title, .tile-title {
  transform-origin: left center;
  transition: scale 360ms cubic-bezier(.22, .8, .2, 1), color var(--dur-hover) ease;
}
.tile--image .tile-title { transform-origin: left bottom; }
.wk__card:hover .wk__name,
.gd__card:hover .gd__title,
.gd__card:hover .gd__captxt,
.record--grid .record__row:hover .record__title,
.offer:hover .offer-title,
.tile:hover .tile-title { scale: 1.04; color: var(--ink); }
/* garden.css grew the print by 3%; the reference keeps it to 1.5. */
.gd__print:hover .gd__shot img,
.gd__print:hover .gd__shot video { transform: none; }

/* ---- 3 / Scissors --------------------------------------------------------
 * Two blades that rock open and shut, 14 degrees each way every 0.32s, the
 * timing on the reference.
 */
.snip-a, .snip-b { transform-box: view-box; transform-origin: 14.4px 12px; }
.snip-a { transform: rotate(6deg); }
.snip-b { transform: rotate(-6deg); }
.fx-snipping .snip-a { animation: fx-snip-a .32s ease-in-out infinite; }
.fx-snipping .snip-b { animation: fx-snip-b .32s ease-in-out infinite; }
@keyframes fx-snip-a { 0%, 100% { transform: rotate(14deg); }  50% { transform: rotate(-2deg); } }
@keyframes fx-snip-b { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(2deg); } }

/* The home cut: blades snip while a cut is being made, and the cursor
   scissors snip while the button is held over it. */
.cut[data-cutting="true"] .snip-a,
.cut.fx-snipping .snip-a,
.cursor[data-mode="cut"][data-press="true"] .snip-a { animation: fx-snip-a .32s ease-in-out infinite; }
.cut[data-cutting="true"] .snip-b,
.cut.fx-snipping .snip-b,
.cursor[data-mode="cut"][data-press="true"] .snip-b { animation: fx-snip-b .32s ease-in-out infinite; }

/* The demonstration pass on the home cut, once per visit. */
.cut.fx-snipping .cut-blades { opacity: 1; transition: none; }
.cut.fx-healing .cut-gap { opacity: 0; transition: opacity 700ms ease; }
.cut.fx-healing .cut-blades { opacity: 0; transition: opacity 260ms ease; }

/* A pass over any other dashed rule: an overlay laid on top of the rule,
   holding a strip of page colour that grows behind the blades. */
.fx-cutter {
  position: absolute;
  z-index: 5;
  height: 1px;
  pointer-events: none;
}
.fx-cutter__gap {
  position: absolute;
  left: 0; right: 0; top: -2px;
  height: 5px;
  background: var(--ground);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
}
.fx-cutter__blades {
  position: absolute;
  top: -9px; left: 0;
  width: 18px; height: 18px;
  color: var(--ink);
  translate: calc(var(--px, 0px) - 9px) 0;
}
.fx-cutter__blades svg { display: block; width: 100%; height: 100%; overflow: visible; }
.fx-cutter[data-heal="true"] .fx-cutter__gap { opacity: 0; transition: opacity 700ms ease; }
.fx-cutter[data-heal="true"] .fx-cutter__blades { opacity: 0; transition: opacity 260ms ease; }

/* ---- Quiet ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html.fx-pre main { opacity: 1; animation: none; }
  [data-fx] { opacity: 1; animation: none; }
  html.fx-on [data-rise] { filter: none; }
  .wk__card:active, .record--grid .record__row:active, .gd__card:active { scale: none; }
  .wk__card:hover .wk__shot > *,
  .record--grid .record__row:hover .record__media > *,
  .gd__card:hover .gd__shot > *,
  .wk__card:hover .wk__name, .gd__card:hover .gd__title, .gd__card:hover .gd__captxt,
  .record--grid .record__row:hover .record__title, .offer:hover .offer-title,
  .tile:hover .tile-title { scale: none; }
  .tile:hover .tile-media { transform: none; }
  .snip-a, .snip-b { animation: none !important; }
  .fx-cutter { display: none; }
}
