/* LISEL: animation kit for the website (lisel-motion 1.1, 14 Nov 2026)

   One stylesheet and one script (lisel-motion.js, loaded in <head>). You switch a move on with an
   attribute or a class; demo.html shows every move and README.md has the snippets.

   The idea: the page is drawn the way an interior designer works. First the plan: the walls are
   drawn and the door swings open. Then the room fills in, calmly. The terracotta dot comes last,
   like the full stop in the logo.

   - Every move plays once and ends on the page exactly as designed. Nothing loops.
   - The hidden "before" states only exist once the script has switched motion on (the class lm-on
     on <html>). No script, a script error or a visitor who has asked for reduced motion: everything
     simply shows, still.
   - Moves can be combined on one element: data-lm="stagger draw". */

:root {
  --lm-out: cubic-bezier(.19, 1, .22, 1);       /* arriving and settling */
  --lm-inout: cubic-bezier(.65, 0, .35, 1);     /* lines being drawn, a door swinging */
  --lm-soft: cubic-bezier(.34, 1.4, .64, 1);    /* the dot landing */
  --lm-rise: 22px;                              /* how far a block rises as it fades in */
  --lm-step: 90ms;                              /* the gap between items in a row */
  --lm-terracotta: #B65E3A;
}


/* 1. THE LOGO: classes on the inline logo SVGs from logo/ ------------------------------------
   lm-plan    the full logo (or the plan line alone): the walls are drawn, the door swings open,
              LISEL settles in letter by letter, the dot lands, then the service line and tagline
   lm-name    the name alone (header): the letters settle in, the dot lands
   lm-arches  the small mark: the front arch is drawn, the one behind slides out
   lm-nod     the dot gives a little nod when the link around the logo is hovered */

.lm-logo { overflow: visible; }
.lm-logo :is(.lm-letter, .lm-dot, .lm-sub, .lm-tag, .lm-door, .lm-arch-front, .lm-arch-back) { transform-box: fill-box; transform-origin: 50% 50%; }
.lm-logo .lm-door { transform-origin: 50% 0; } /* the hinge */

/* Plan, 2.8 s */
.lm-plan.lm-play .lm-wall { stroke-dasharray: 1 2; animation: lm-line 1.3s var(--lm-inout) both; }
.lm-plan.lm-play .lm-swing { stroke-dasharray: 1 2; animation: lm-line .9s var(--lm-inout) .55s both; }
.lm-plan.lm-play .lm-door { animation: lm-door .9s var(--lm-inout) .55s both; }
.lm-plan.lm-play .lm-letter { animation: lm-letter .9s var(--lm-out) both; animation-delay: calc(.75s + var(--i, 0) * 80ms); }
.lm-plan.lm-play .lm-dot { animation: lm-dot .7s var(--lm-soft) 1.4s both; }
.lm-plan.lm-play .lm-sub { animation: lm-rise .9s var(--lm-out) 1.55s both; }
.lm-plan.lm-play .lm-rule { stroke-dasharray: 1 2; animation: lm-line .7s var(--lm-inout) 1.75s both; }
.lm-plan.lm-play .lm-tag { animation: lm-slide .9s var(--lm-out) 1.95s both; }

/* Name, 1.2 s */
.lm-name.lm-play .lm-letter { animation: lm-letter .8s var(--lm-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
.lm-name.lm-play .lm-dot { animation: lm-dot .6s var(--lm-soft) .5s both; }

/* Arches, 1.5 s */
.lm-arches.lm-play .lm-arch-front { stroke-dasharray: 1 2; animation: lm-line 1s var(--lm-inout) both, lm-fill .5s ease .65s both; }
.lm-arches.lm-play .lm-arch-back { animation: lm-behind .8s var(--lm-out) .75s both; }

/* Nod, on hover, 0.6 s */
.lm-nodding .lm-dot { animation: lm-nod .6s var(--lm-out); }

@keyframes lm-line { from { stroke-dashoffset: 1.01; } to { stroke-dashoffset: 0; } }
@keyframes lm-door { 0% { transform: rotate(-90deg) scaleY(.87); opacity: 0; } 12% { opacity: 1; } }
@keyframes lm-letter { from { opacity: 0; transform: translateY(14%); } }
@keyframes lm-dot { from { transform: scale(0); } }
@keyframes lm-rise { from { opacity: 0; transform: translateY(40%); } }
@keyframes lm-slide { from { opacity: 0; transform: translateX(-3%); } }
@keyframes lm-fill { from { fill-opacity: 0; } }
@keyframes lm-behind { from { opacity: 0; transform: translateX(-16%); } }
@keyframes lm-nod { 30% { transform: translateY(-40%); } 62% { transform: translateY(6%); } }

/* A logo waits, invisible, until the script plays it, so the still logo never flashes up first.
   lm-done marks a logo that has played (or won't). */
@media screen {
  .lm-on :is(.lm-plan, .lm-name, .lm-arches):not(.lm-play):not(.lm-done) { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) { .lm-logo, .lm-logo * { animation: none !important; } }


/* 2. AS THINGS COME INTO VIEW: data-lm="…" (or the class lm-…) ---------------------------------
   The script adds lm-set once an element is ready, lm-in when it scrolls into view and lm-done when
   the move is over (from then on the kit leaves the element alone, so its own hover transitions work
   as normal). --lm-d is the element's delay, --lm-i an item's place in a row. */

@media screen {
  /* Waiting for the script to prepare it (split the words, measure the lines) */
  .lm-on [data-lm]:not(.lm-set),
  .lm-on :is(.lm-up, .lm-words, .lm-photo, .lm-stagger, .lm-draw, .lm-line):not(.lm-set) { opacity: 0; }

  /* up: fades in and rises a little. Text, buttons, cards. */
  .lm-on [data-lm~="up"]:not(.lm-in) { opacity: 0; translate: 0 var(--lm-rise); }
  .lm-on [data-lm~="up"].lm-in:not(.lm-done) { transition: opacity .9s ease, translate 1.2s var(--lm-out); transition-delay: var(--lm-d, 0ms); }

  /* words: each word rises out of its own line. Headings. */
  .lm-w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 .08em .18em; margin: 0 -.08em -.18em; }
  .lm-w > span { display: inline-block; }
  .lm-on [data-lm~="words"]:not(.lm-in) .lm-w > span { translate: 0 calc(100% + .3em); }
  .lm-on [data-lm~="words"].lm-in:not(.lm-done) .lm-w > span { transition: translate 1.1s var(--lm-out); transition-delay: calc(var(--lm-d, 0ms) + var(--lm-i, 0) * 60ms); }

  /* photo: the picture fades in softly and settles from a slight zoom, like a room coming into focus.
     Put it on the box around the <img> (or on the <img> itself for the fade alone). */
  .lm-on [data-lm~="photo"] { overflow: hidden; }
  .lm-on [data-lm~="photo"]:not(.lm-in) img, .lm-on img[data-lm~="photo"]:not(.lm-in) { opacity: 0; }
  .lm-on [data-lm~="photo"]:not(.lm-in) img { scale: 1.08; }
  .lm-on [data-lm~="photo"].lm-in:not(.lm-done) img { transition: opacity 1.2s ease, scale 2.2s var(--lm-out); transition-delay: var(--lm-d, 0ms); }
  .lm-on img[data-lm~="photo"].lm-in:not(.lm-done) { transition: opacity 1.2s ease var(--lm-d, 0ms); }

  /* stagger: on a list or a row. The items come in one after another. */
  .lm-on [data-lm~="stagger"]:not(.lm-in) > * { opacity: 0; translate: 0 calc(var(--lm-rise) * .8); }
  .lm-on [data-lm~="stagger"].lm-in:not(.lm-done) > * { transition: opacity .8s ease, translate 1.1s var(--lm-out); transition-delay: calc(var(--lm-d, 0ms) + var(--lm-i, 0) * var(--lm-step)); }

  /* draw: line icons and line drawings draw themselves, one after another, like a sketch.
     Lines with their own dashes keep them and simply show. */
  .lm-on [data-lm~="draw"].lm-set:not(.lm-in) svg, .lm-on svg[data-lm~="draw"].lm-set:not(.lm-in) { stroke-dasharray: 1 2; stroke-dashoffset: 1.01; }
  .lm-on [data-lm~="draw"].lm-in:not(.lm-done) svg, .lm-on svg[data-lm~="draw"].lm-in:not(.lm-done) {
    stroke-dasharray: 1 2; stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.1s var(--lm-inout); transition-delay: calc(var(--lm-d, 0ms) + 150ms + var(--lm-i, 0) * var(--lm-step));
  }

  /* A sketch (an SVG with the class lm-sketch, like the icons in icons/): its lines take turns, the way
     a hand draws it. On each line --lm-at says when it starts and --lm-for how long it takes. Fills with
     the class lm-tint wash in and dots with the class lm-pop land, also at their --lm-at. */
  .lm-on [data-lm~="draw"].lm-set:not(.lm-in) .lm-sketch :is(path, line, polyline, polygon, circle, ellipse, rect),
  .lm-on .lm-sketch[data-lm~="draw"].lm-set:not(.lm-in) :is(path, line, polyline, polygon, circle, ellipse, rect) { stroke-dashoffset: 1.01; }
  .lm-on [data-lm~="draw"]:not(.lm-in) .lm-sketch .lm-tint, .lm-on .lm-sketch[data-lm~="draw"]:not(.lm-in) .lm-tint { fill-opacity: 0; }
  .lm-on [data-lm~="draw"]:not(.lm-in) .lm-sketch .lm-pop, .lm-on .lm-sketch[data-lm~="draw"]:not(.lm-in) .lm-pop { scale: 0; }
  .lm-on [data-lm~="draw"].lm-in:not(.lm-done) .lm-sketch, .lm-on .lm-sketch[data-lm~="draw"].lm-in:not(.lm-done) {
    --lm-start: calc(var(--lm-d, 0ms) + 150ms + var(--lm-i, 0) * var(--lm-step));
    transition: none;
  }
  .lm-on [data-lm~="draw"].lm-in:not(.lm-done) .lm-sketch :is(path, line, polyline, polygon, circle, ellipse, rect),
  .lm-on .lm-sketch[data-lm~="draw"].lm-in:not(.lm-done) :is(path, line, polyline, polygon, circle, ellipse, rect) {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset var(--lm-for, 1s) var(--lm-inout) calc(var(--lm-start) + var(--lm-at, 0s));
  }
  .lm-on [data-lm~="draw"].lm-in:not(.lm-done) .lm-sketch .lm-tint, .lm-on .lm-sketch[data-lm~="draw"].lm-in:not(.lm-done) .lm-tint {
    transition: fill-opacity var(--lm-for, .7s) ease calc(var(--lm-start) + var(--lm-at, 0s));
  }
  .lm-on [data-lm~="draw"].lm-in:not(.lm-done) .lm-sketch .lm-pop, .lm-on .lm-sketch[data-lm~="draw"].lm-in:not(.lm-done) .lm-pop {
    transition: scale var(--lm-for, .6s) var(--lm-soft) calc(var(--lm-start) + var(--lm-at, 0s));
  }

  /* line: draws from left to right. The short terracotta rule of the logo (class lm-hr), or any line. */
  .lm-on [data-lm~="line"]:not(.lm-in) { scale: 0 1; transform-origin: 0 50%; }
  .lm-on [data-lm~="line"].lm-in:not(.lm-done) { transform-origin: 0 50%; transition: scale .9s var(--lm-inout) var(--lm-d, 0ms); }
}

/* A sketch's dots land from their own centre */
.lm-sketch .lm-pop { transform-box: fill-box; transform-origin: 50% 50%; }

/* The logo's short terracotta line, ready to use */
.lm-hr { display: block; width: 64px; height: 2px; border: 0; margin: 0; background: var(--lm-terracotta); }


/* 3. UNDER THE POINTER: classes ----------------------------------------------------------------*/

/* lm-btn: on hover the button fills up from the bottom, like a room. Set the colour it fills with
   in --lm-fill (default: charcoal). It gives a little when pressed. */
.lm-btn {
  background-image: linear-gradient(var(--lm-fill, #2B2B2B), var(--lm-fill, #2B2B2B));
  background-repeat: no-repeat; background-position: 50% 100%; background-size: 100% 0;
  transition: background-size .55s var(--lm-out), scale .16s var(--lm-out);
}
.lm-btn:hover, .lm-btn:focus-visible { background-size: 100% 100%; }
.lm-btn:active { scale: .98; }

/* lm-link: a terracotta underline draws in from the left on hover and leaves to the right. Menus. */
.lm-link {
  text-decoration: none;
  background-image: linear-gradient(var(--lm-terracotta), var(--lm-terracotta));
  background-repeat: no-repeat; background-position: 100% 100%; background-size: 0 1px;
  transition: background-size .45s var(--lm-out);
}
.lm-link:hover, .lm-link:focus-visible, .lm-link[aria-current="page"] { background-position: 0 100%; background-size: 100% 1px; }

/* lm-zoom: the photo leans in slowly on hover. Portfolio pictures. */
.lm-zoom { overflow: hidden; }
.lm-zoom img { transition: transform 1.4s var(--lm-out); }
@media (hover: hover) { .lm-zoom:hover img { transform: scale(1.05); } }


/* Reduced motion: nothing moves. (The script also leaves lm-on off, so nothing is hidden.) */
@media (prefers-reduced-motion: reduce) {
  .lm-btn, .lm-link, .lm-zoom img { transition: none; }
  .lm-zoom:hover img, .lm-btn:active { transform: none; scale: none; }
}
