/* alohamc.com: the site's own motion (after site.css; the kit's motion.css is its buttons, links and
   menu). Motion here says something: where you are going, where you landed, that the address was
   copied, the order of the steps, how far the border moves. Nothing loops, and nothing moves only
   because the page scrolled, except the three things a player came for:

   1. between pages      the page cross-fades, the bar stays put, the current page's mark slides
   2. landing on a part  a link to #season-3 scrolls there; when it arrives its heading lights for a moment
   3. the home hero      the picture settles, the words' box rises (once, on load)
   4. the address        the page's one authored moment: "alohamc" strikes like the neon sign
   5. the steps to join  each rule draws and its number lights, in order: 1, 2, 3, 4 (the words are
                         always there: a player came to read them)
   6. copying            the button says so with a tick; the address on the page flickers back
   7. the border stages  a line under each stage, as long as the border is far, drawn in order
   8. the commands       the row under the pointer is marked, so a command and its line stay together
   9. the live count     arrives softly; its dot pings once when the number changes

   How 4, 5 and 7 start: head.js puts .fx on <html> (the armed, not-yet-seen states below apply only
   under it, and only on a screen: a printed page is simply there) and effects.js adds .is-in to each
   [data-inview] once it is on screen. If effects.js never runs, head.js takes .fx off again after three
   seconds, so nothing stays armed.

   Under prefers-reduced-motion nothing travels, scales or flickers: every armed state is skipped
   (the page is simply there), and what confirms an action stays as a change of colour or label. */

:root {
  --fx-ease: cubic-bezier(.16, 1, .3, 1);       /* arrivals: fast start, long soft landing */
  --fx-ease-io: cubic-bezier(.65, 0, .35, 1);   /* something travelling between two places */
}

/* 1. between pages (browsers without cross-document view transitions just load the page) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  /* smooth only once the page has loaded (.fx-ready, effects.js): a page opened at a part of itself
     is simply there, and does not scroll down its whole length after the cross-fade */
  :root.fx-ready { scroll-behavior: smooth; }
}
.nav { view-transition-name: site-bar; }
.nav__here { view-transition-name: site-here; }
/* the old page is gone before the new one shows: no moment with both on screen */
::view-transition-old(root) { animation: fx-page-out 100ms ease-out both; }
::view-transition-new(root) { animation: fx-page-in 320ms var(--fx-ease) 70ms both; }
::view-transition-group(site-here) { animation-duration: 380ms; animation-timing-function: var(--fx-ease-io); }
@keyframes fx-page-out { to { opacity: 0; } }
@keyframes fx-page-in { from { opacity: 0; transform: translateY(10px); } }

/* 2. landing on a part of a page: its heading holds the sign's cyan, then returns to the ink.
   effects.js marks the section when the scroll has arrived, so the cyan is not spent on the way */
main > section.is-landed :is(h1, h2) { animation: fx-land 1700ms ease-out; }
@keyframes fx-land { 12%, 34% { color: var(--sky); } }
/* under reduced motion the kit cuts every animation to nothing, so there the cyan is a state: held
   while effects.js keeps .is-landed on the section, then simply off */
@media (prefers-reduced-motion: reduce) { main > section.is-landed :is(h1, h2) { animation: none; color: var(--sky); } }

/* 6. copying: a tick before the label while the button says "Address copied" */
.btn[data-copy].is-done::before {
  content: ""; flex: none; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--fx-tick) center / contain no-repeat; mask: var(--fx-tick) center / contain no-repeat;
}
:root { --fx-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2.5 7.5 5.6 10.5 11.5 3.8' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
/* the address in a sentence (the hero's line) answers a copy by taking the cyan for a moment */
.mono[data-address] { transition: color 900ms ease-out; }
.mono[data-address].is-copied { color: var(--sky); transition-duration: 80ms; }

/* 5. the steps: each column's rule is drawn, not a border, so it can be drawn in */
.steps > li { position: relative; }
.steps > li::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; background: var(--line-strong); transform-origin: 0 50%; }
.steps > li:nth-child(1) { --i: 0; } .steps > li:nth-child(2) { --i: 1; }
.steps > li:nth-child(3) { --i: 2; } .steps > li:nth-child(4) { --i: 3; }

/* 7. the border stages: the line under each stage is as long as the border is far (of 1,700 blocks:
   650, 900, 1,200, 1,450, 1,700; change these with the list in servers/index.astro) */
.stages-list > li { position: relative; }
.stages-list > li::after { content: ""; position: absolute; left: 0; bottom: -1px; width: var(--w, 0%); height: 2px; background: var(--sky); transform-origin: 0 50%; }
.stages-list > li:nth-child(1) { --w: 38.24%; --i: 0; } .stages-list > li:nth-child(2) { --w: 52.94%; --i: 1; }
.stages-list > li:nth-child(3) { --w: 70.59%; --i: 2; } .stages-list > li:nth-child(4) { --w: 85.29%; --i: 3; }
.stages-list > li:nth-child(5) { --w: 100%; --i: 4; }

/* 8. the commands: the row under the pointer (a pointer only: a phone never keeps a stuck hover) */
@media (hover: hover) and (pointer: fine) {
  .commands > li { position: relative; isolation: isolate; }
  .commands > li::before {
    content: ""; position: absolute; inset: 0 calc(-1 * var(--s-3)); z-index: -1; border-radius: var(--r-sm);
    background: color-mix(in oklab, var(--ink) 7%, transparent); opacity: 0; transition: opacity 220ms ease-out;
  }
  .commands > li:hover::before { opacity: 1; transition-duration: 90ms; }
  .commands .rows__name { transition: color 220ms ease-out; }
  .commands > li:hover .rows__name { color: var(--sky); transition-duration: 90ms; }
}

@media screen and (prefers-reduced-motion: no-preference) {
  /* 3. the home hero, once on load; not when the page arrived through the cross-fade above (.vt-in,
     head.js), which is already its entrance */
  :root:not(.vt-in) .hero--photo > .hero__bg > img { animation: fx-settle 1300ms var(--fx-ease) backwards; }
  :root:not(.vt-in) .hero--photo .hero__text { animation: fx-rise 620ms var(--fx-ease) 90ms backwards; }

  /* 4. the address: an unlit tube until it is on screen, then it strikes (two false starts, on) */
  .fx .type-moment[data-inview]:not(.is-in) .hue { opacity: .26; }
  .fx .type-moment[data-inview].is-in .hue { animation: fx-strike 1050ms linear 120ms backwards; }

  /* 5. the steps, in order: the rule draws, the number holds the cyan and lets go. The words do
     not wait for either */
  .fx .steps[data-inview] > li { --d: calc(var(--i, 0) * 70ms + 180ms); }
  .fx .steps[data-inview] > li::after { transition: transform 720ms var(--fx-ease) var(--d); }
  .fx .steps[data-inview]:not(.is-in) > li::after { transform: scaleX(0); }
  .fx .steps[data-inview].is-in > li::before { animation: fx-count 1400ms ease-out calc(var(--d) + 320ms) backwards; }

  /* 6. copying: the tick pops in */
  .btn[data-copy].is-done::before { animation: fx-pop 320ms var(--fx-ease) backwards; }

  /* 7. the border stages, in order */
  .fx .stages-list[data-inview] > li::after { transition: transform 900ms var(--fx-ease) calc(var(--i, 0) * 120ms + 150ms); }
  .fx .stages-list[data-inview]:not(.is-in) > li::after { transform: scaleX(0); }

  /* 9. the live count */
  .netcount.is-fresh { animation: fx-rise-sm 480ms var(--fx-ease) backwards; }
  .netcount.is-fresh::before { animation: fx-ping 1300ms var(--fx-ease) 200ms; }
}

@keyframes fx-settle { from { transform: scale(1.045); } }
@keyframes fx-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fx-rise-sm { from { opacity: 0; transform: translateY(4px); } }
@keyframes fx-pop { from { opacity: 0; transform: scale(.4); } }
@keyframes fx-count { from { color: var(--sky); } }
@keyframes fx-ping { from { box-shadow: 0 0 0 0 color-mix(in oklab, var(--grass) 75%, transparent); } to { box-shadow: 0 0 0 9px transparent; } }
/* the strike: the glow belongs to the flicker and is gone when the word is on (a neon tube, the
   Discord icon's sign) */
@keyframes fx-strike {
  0%   { opacity: .26; text-shadow: none; }
  7%   { opacity: 1;   text-shadow: 0 0 .32em color-mix(in oklab, var(--sky) 65%, transparent); }
  13%  { opacity: .3;  text-shadow: none; }
  24%  { opacity: .3;  text-shadow: none; }
  30%  { opacity: 1;   text-shadow: 0 0 .32em color-mix(in oklab, var(--sky) 65%, transparent); }
  37%  { opacity: .5;  text-shadow: none; }
  46%  { opacity: 1;   text-shadow: 0 0 .42em color-mix(in oklab, var(--sky) 80%, transparent); }
  100% { opacity: 1;   text-shadow: 0 0 .42em transparent; }
}
