/* Accasio — the ticker.
 *
 * A thin strip under the header that runs right to left. The movement is
 * one CSS animation on a duplicated list; nothing is measured, positioned
 * or stepped in JavaScript, so it cannot drift or stutter under load.
 */

/* Fixed, directly under the header.

   The header is `position: fixed`, so a strip after it in the DOM renders
   at the top of the viewport UNDERNEATH it — the first version was
   correct in every respect and completely invisible. Both numbers come
   from the script, which measures them: the header is 64px on this
   template today and that is not a figure worth writing into two files. */
.acc-tick {
  position: fixed;
  top: var(--acc-tick-top, 64px);
  left: 0;
  right: 0;
  z-index: 4990;

  display: flex;
  align-items: stretch;

  border-bottom: 1px solid var(--ac-gray-200, #e5e7eb);
  background: var(--ac-gray-50, #f9fafb);
  overflow: hidden;

  /* The same quarter-second and the same curve Artificer uses on the
     header, because the two have to leave together. See below. */
  transition: top 0.25s ease-in-out;
}

/* Away with the header, not hanging there after it.

   Artificer hides the header on a downward scroll by putting
   `bx-toolbar-up` on it, which is `translateY(-100%)`. The strip is a
   separate fixed element pinned under it, so it stayed exactly where it
   was and became a bar floating over the middle of the page with nothing
   above it.

   IT MOVES BY `top`, NOT BY A TRANSFORM. A transform is the usual tool
   and is the one this was written with first; on this element it does
   nothing at all. Measured, not assumed: an inline
   `transform: translateY(-50px)` on the strip leaves its rectangle
   exactly where it was, while the same declaration on a child of it
   moves that child, and setting `top` moves the strip. Something in the
   template claims `transform` on it with `!important`, which is this
   template's recurring trick. `top` is how the strip is already
   positioned, so it is the property known to work here.

   Its own height is the whole distance needed: at `top: -32px` a 32px
   strip has left the viewport. The number is the one the script
   measured, so a strip that wraps to two lines still clears.

   The class is mirrored from the header by the script rather than the
   strip being moved inside it: the header is a flex row and a full-width
   block child of it is a layout change in somebody else's markup, which
   is a bigger thing to own than one class name. */
.acc-tick.acc-tick-up {
  /* The script sets the actual offset inline, because it is the thing
     that measured it and because a rule here has to win against a
     template that overrides this element's transform with !important.
     This is left as the styling hook and as the answer for anything
     that reads the sheet rather than the element. */
  top: calc(-1 * var(--acc-tick-h, 32px));
  pointer-events: none;
}

/* And the page comes down by exactly the strip's height, so the ticker
   does not cover the first line of whatever is underneath it.

   THE TARGET IS ARTIFICER'S OWN SPACER, not the content element.

   Every page in this template clears the fixed header with one div,
   `.bx-menu-toolbar-padding.pt-16`, carrying 64px of padding. That is the
   single place the whole site already agrees the page begins, so adding
   the strip's height to it moves every page down by the right amount —
   the feed, the profile, Studio and the messenger, which has a full-height
   layout of its own and was the page where the overlap was impossible to
   miss.

   The first version padded `.bx-main > main` instead, and did nothing at
   all anywhere: Artificer is Tailwind built with `important: true`, so
   main's own `p-0` arrives as an important declaration and a plain rule
   cannot beat it however specific it is. It looked right on the activity
   page only because the first card there has a margin. Hence !important
   here, and hence reading the computed value rather than trusting the
   stylesheet — the same lesson this template has now taught three times.

   Both numbers are measured by the script: the header's real height and
   the strip's own, so a strip that wraps to two lines on a narrow window
   still pushes the page down by as much as it occupies. */
body.acc-has-tick .bx-menu-toolbar-padding {
  padding-top: calc(var(--acc-tick-top, 64px) + var(--acc-tick-h, 32px)) !important;
}

/* Hidden until the script has put it where it belongs.

   The strip is rendered into the page footer, because that is the only
   site-wide injection point UNA offers, and moved under the header on
   load. Showing it before the move would mean a strip appearing at the
   bottom of the page and jumping to the top — so it stays hidden until it
   is in place, and a page whose script never ran shows no ticker rather
   than a misplaced one. The links are in the document either way, which is
   what matters for a crawler. */
.acc-tick:not(.acc-tick-ready) {
  display: none;
}

.acc-tick-win {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;

  /* The ends fade rather than cutting off mid-word, so an item sliding out
     reads as leaving instead of being clipped. */
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    #000 48px,
    #000 calc(100% - 48px),
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 48px,
    #000 calc(100% - 48px),
    transparent
  );

  display: flex;
}

.acc-tick-run {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;

  /* One full pass of the first copy. The operator sets it on the ticker
     console and it arrives as an inline custom property on the strip, so
     changing the speed is a form field rather than a deploy. 60s is the
     default: slow enough to read a line without chasing it, and the
     duplicate directly behind makes the wrap seamless. */
  animation: acc-tick-run var(--acc-tick-secs, 60s) linear infinite;
  will-change: transform;
}

@keyframes acc-tick-run {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

/* Stopped: over the moving text, on keyboard focus inside it, and when
   the member has pressed pause.

   Focus matters as much as hover — a keyboard user tabbing into a moving
   strip cannot read the link they have just landed on, and hover-only
   would leave them chasing it.

   BOTH ARE SCOPED TO THE WINDOW, NOT THE WHOLE STRIP, and that is the
   whole point of the rule.

   The strip is a button, a hide control and then the window holding the
   list; only the window moves. Asking the strip about :focus-within
   therefore included the pause button itself — so pressing pause paused
   it, and pressing it again did NOT start it, because the button kept
   focus and went on answering the question. Measured on the live page:
   after the second press the class was gone and the stored preference
   was back to 0, while the computed animation-play-state was still
   paused, and moving the pointer away did not help. It restarted only
   when something else took focus, which is not a thing anybody would
   think to do.

   Scoped here, a link in the strip still pauses it on hover and on
   focus, which is what the rule is for, and the controls that sit beside
   the list no longer have an opinion about whether it moves. */
.acc-tick-win:hover .acc-tick-run,
.acc-tick-win:focus-within .acc-tick-run,
.acc-tick.acc-tick-off .acc-tick-run {
  animation-play-state: paused;
}

.acc-tick-i {
  flex: none;
  display: flex;
  align-items: center;
}

.acc-tick-i > a,
.acc-tick-i > .acc-tick-p {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;

  font-size: 0.84rem;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ac-gray-700, #374151);
}

.acc-tick-i > a:hover {
  background: var(--ac-white, #fff);
  color: var(--ac-gray-900, #111827);
  text-decoration: none;
}

/* A separator drawn rather than written, so there is no stray character
   for a screen reader to announce between every item. */
.acc-tick-i + .acc-tick-i::before {
  content: '';
  width: 1px;
  height: 14px;
  background: var(--ac-gray-200, #e5e7eb);
  flex: none;
}

/* What kind of thing it is, before the text. The colour is the second
   signal; the word is the first, so the strip still works in greyscale and
   for anybody who cannot separate these hues. */
.acc-tick-k {
  flex: none;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.acc-tick-k-join {
  background: #eff6ff;
  color: #1d4ed8;
}
.acc-tick-k-group {
  background: #f0fdf4;
  color: #166534;
}
.acc-tick-k-org {
  background: #f5f3ff;
  color: #5b21b6;
}
.acc-tick-k-event {
  background: #fffbeb;
  color: #92400e;
}
.acc-tick-k-talk {
  background: #fef2f2;
  color: #9f1239;
}
.acc-tick-k-launch {
  background: #ecfeff;
  color: #155e75;
}
.acc-tick-k-news {
  background: #f3f4f6;
  color: #374151;
}

/* Two more for the operator's own items: one that has to be noticed, and
   one for something being made a fuss of. */
.acc-tick-k-alert {
  background: #fee2e2;
  color: #b91c1c;
}
.acc-tick-k-gold {
  background: #fef3c7;
  color: #92400e;
}

.acc-tick-t {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44ch;
}

/* The pause control.

   A real button, not hover alone: hover does not exist on a phone, and a
   strip that cannot be stopped on the device most people are holding is a
   strip they cannot use. !important throughout because Artificer is
   Tailwind with important on and gives every button a filled blue pill. */
.acc-tick-stop {
  flex: none !important;
  width: 2rem !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;

  border: 0 !important;
  border-right: 1px solid var(--ac-gray-200, #e5e7eb) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;

  font-size: 0.6rem !important;
  line-height: 1 !important;
  color: var(--ac-gray-400, #9ca3af) !important;
  cursor: pointer;
}

.acc-tick-stop:hover {
  background: var(--ac-gray-100, #f3f4f6) !important;
  color: var(--ac-gray-700, #374151) !important;
}

.acc-tick-stop[aria-pressed='true'] {
  color: var(--ac-blue-700, #1d4ed8) !important;
}

/* Reduced motion: it does not move at all.

   Not "moves slower" — somebody who has asked for less motion has asked
   for none, and an animation that merely slows down is still the thing
   they turned off. The strip becomes a row they can scroll themselves,
   which loses nothing: every item is still there and still a link. */
@media (prefers-reduced-motion: reduce) {
  .acc-tick-run {
    animation: none;
  }

  /* Still gets out of the way with the header, just without sliding. */
  .acc-tick {
    transition: none;
  }

  .acc-tick-win {
    overflow-x: auto;
  }

  /* The duplicate exists only to make the loop seamless, and with no loop
     it is every item announced a second time. */
  .acc-tick-run[aria-hidden='true'] {
    display: none;
  }
}

/* On a narrow window the strip stays, because this is exactly where a
   quick glance at what is happening is worth most — but the text gets less
   room before it truncates. */
@media (max-width: 719px) {
  .acc-tick-t {
    max-width: 26ch;
  }

  .acc-tick-i > a,
  .acc-tick-i > .acc-tick-p {
    padding: 6px 12px;
  }
}

/* Nobody is looking at this tab. A strip animating behind a different
   window is a fan spinning for nothing. */
.acc-tick.acc-tick-hidden .acc-tick-run {
  animation-play-state: paused;
}
