/* Amnalith icons (seat V). Usage and the list of ids: work/ICONS.md.
   <svg class="ico" aria-hidden="true"><use href="#i-accounts"/></svg>
   The sprite (src/partials/icons.html) is included once, right after <body>.

   Line weight: 1.5px on screen at every size. It is done by scaling stroke-width with the size, not with
   vector-effect: non-scaling-stroke (Chrome measures the dashes of a non-scaling stroke in screen space while
   pathLength stays in user space, so the draw-in breaks into dashes at 40px and above). The symbols are drawn
   on the 24 grid and written in a 240-unit user space, hence 240 below. --ico is the size in px, unitless:
   any size works with style="--ico: 64". A heavier line: --ico-stroke: 2. */
.ico {
  --ico: 24;
  width: calc(var(--ico) * 1px);
  height: calc(var(--ico) * 1px);
  flex: none;
  display: inline-block;
  vertical-align: middle;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: calc(var(--ico-stroke, 1.5) * 240 / var(--ico));
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico--sm { --ico: 20; }
.ico--lg { --ico: 40; }
.ico--xl { --ico: 96; }

.ico--ice { color: var(--ice-700); }
.on-dark .ico--ice, .ico--ice.on-dark { color: var(--ice-300); }

/* Draw-in. Every element in the sprite has pathLength="1". The dash is 1.05 long (a hair over the whole line,
   so no curve can end short) with a gap of 2: an offset of 1.06 hides every line, round caps included, and 0
   shows it whole. Dash properties inherit from the <svg> into the <use> shadow tree.
   Without .motion nothing here applies and every icon is simply drawn. */
.motion [data-reveal] .ico:not(.ico--still) {
  stroke-dasharray: 1.05 2;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--t-draw, 1200ms) var(--ease-out, cubic-bezier(.16, 1, .3, 1))
    calc(var(--i, 0) * var(--stagger, 70ms) + var(--ico-delay, 120ms));
}
.motion [data-reveal]:not(.is-in) .ico:not(.ico--still) {
  stroke-dashoffset: 1.06;
  transition: none;
}

/* Redraw once on hover or keyboard focus of the nearest link, button, list item, table row or card. */
@keyframes ico-redraw {
  from { stroke-dasharray: 1.05 2; stroke-dashoffset: 1.06; }
  to { stroke-dasharray: 1.05 2; stroke-dashoffset: 0; }
}
.motion :is(a, button, li, tr):hover .ico--redraw:not(.ico--still),
.motion :is(a, button):focus-visible .ico--redraw:not(.ico--still),
.motion :is(li, tr):focus-within .ico--redraw:not(.ico--still) {
  animation: ico-redraw 700ms var(--ease-out, cubic-bezier(.16, 1, .3, 1)) backwards;
}
