/*
 * Display names, Messenger Plus! style (see app/models/display_name.rb).
 * Shared by profiles and the app. Everything is a class: profiles' Content
 * Security Policy doesn't allow style attributes, so a name can only ever use
 * the colours, gradients, animations and delays listed here.
 */
.display-name {
  --plus-0: #ffffff; /* white */
  --plus-1: #000000; /* black */
  --plus-2: #00007f; /* navy */
  --plus-3: #009300; /* green */
  --plus-4: #ff0000; /* red */
  --plus-5: #7f0000; /* maroon */
  --plus-6: #9c009c; /* purple */
  --plus-7: #fc7f00; /* orange */
  --plus-8: #ffff00; /* yellow */
  --plus-9: #00fc00; /* lime */
  --plus-10: #009393; /* teal */
  --plus-11: #00ffff; /* aqua */
  --plus-12: #0000fc; /* blue */
  --plus-13: #ff00ff; /* pink */
  --plus-14: #7f7f7f; /* grey */
  --plus-15: #d2d2d2; /* silver */
}

/* [b] [i] [u] [s] */
.dn-b { font-weight: 700; }
.dn-i { font-style: italic; }
.dn-u { text-decoration: underline; }
.dn-s { text-decoration: line-through; }

/* [c=4] */
.dn-c0 { color: var(--plus-0); }
.dn-c1 { color: var(--plus-1); }
.dn-c2 { color: var(--plus-2); }
.dn-c3 { color: var(--plus-3); }
.dn-c4 { color: var(--plus-4); }
.dn-c5 { color: var(--plus-5); }
.dn-c6 { color: var(--plus-6); }
.dn-c7 { color: var(--plus-7); }
.dn-c8 { color: var(--plus-8); }
.dn-c9 { color: var(--plus-9); }
.dn-c10 { color: var(--plus-10); }
.dn-c11 { color: var(--plus-11); }
.dn-c12 { color: var(--plus-12); }
.dn-c13 { color: var(--plus-13); }
.dn-c14 { color: var(--plus-14); }
.dn-c15 { color: var(--plus-15); }

/* [c=4]…[/c=12]: one rule for every gradient, with the two ends set by classes. */
.dn-gradient {
  background: linear-gradient(90deg, var(--from), var(--to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* A glow inside a gradient glows in the gradient's end colour. */
  --glow: var(--to);
}
/*
 * Letters that move on their own ([wave] inside a gradient) can't share one
 * background, so each one is coloured by mixing the two ends: dn-t-0 is the
 * start, dn-t-20 the end, in 5% steps.
 */
.dn-gradient.dn-split { background: none; color: inherit; }
.dn-gradient.dn-split .dn-ch { color: color-mix(in oklab, var(--from), var(--to) var(--t, 0%)); }
.dn-t-0 { --t: 0%; }
.dn-t-1 { --t: 5%; }
.dn-t-2 { --t: 10%; }
.dn-t-3 { --t: 15%; }
.dn-t-4 { --t: 20%; }
.dn-t-5 { --t: 25%; }
.dn-t-6 { --t: 30%; }
.dn-t-7 { --t: 35%; }
.dn-t-8 { --t: 40%; }
.dn-t-9 { --t: 45%; }
.dn-t-10 { --t: 50%; }
.dn-t-11 { --t: 55%; }
.dn-t-12 { --t: 60%; }
.dn-t-13 { --t: 65%; }
.dn-t-14 { --t: 70%; }
.dn-t-15 { --t: 75%; }
.dn-t-16 { --t: 80%; }
.dn-t-17 { --t: 85%; }
.dn-t-18 { --t: 90%; }
.dn-t-19 { --t: 95%; }
.dn-t-20 { --t: 100%; }

.dn-from-0 { --from: var(--plus-0); }
.dn-from-1 { --from: var(--plus-1); }
.dn-from-2 { --from: var(--plus-2); }
.dn-from-3 { --from: var(--plus-3); }
.dn-from-4 { --from: var(--plus-4); }
.dn-from-5 { --from: var(--plus-5); }
.dn-from-6 { --from: var(--plus-6); }
.dn-from-7 { --from: var(--plus-7); }
.dn-from-8 { --from: var(--plus-8); }
.dn-from-9 { --from: var(--plus-9); }
.dn-from-10 { --from: var(--plus-10); }
.dn-from-11 { --from: var(--plus-11); }
.dn-from-12 { --from: var(--plus-12); }
.dn-from-13 { --from: var(--plus-13); }
.dn-from-14 { --from: var(--plus-14); }
.dn-from-15 { --from: var(--plus-15); }
.dn-to-0 { --to: var(--plus-0); }
.dn-to-1 { --to: var(--plus-1); }
.dn-to-2 { --to: var(--plus-2); }
.dn-to-3 { --to: var(--plus-3); }
.dn-to-4 { --to: var(--plus-4); }
.dn-to-5 { --to: var(--plus-5); }
.dn-to-6 { --to: var(--plus-6); }
.dn-to-7 { --to: var(--plus-7); }
.dn-to-8 { --to: var(--plus-8); }
.dn-to-9 { --to: var(--plus-9); }
.dn-to-10 { --to: var(--plus-10); }
.dn-to-11 { --to: var(--plus-11); }
.dn-to-12 { --to: var(--plus-12); }
.dn-to-13 { --to: var(--plus-13); }
.dn-to-14 { --to: var(--plus-14); }
.dn-to-15 { --to: var(--plus-15); }

/*
 * Animations. Each one starts after its delay ([wave=5] is 0.5s), and
 * per-letter ones ([wave], [rainbow]) stagger their letters by position.
 * Their lengths all fit into 4 seconds, so a name with several of them still
 * repeats cleanly.
 * Codes inside a delayed one, with no delay of their own, wait for it too.
 */
.dn-anim { display: inline-block; animation-delay: var(--delay, 0s); }
.dn-ch { display: inline-block; white-space: pre; }
.dn-wave .dn-ch { animation: dn-wave 1s ease-in-out infinite; }
.dn-rainbow .dn-ch { animation: dn-rainbow 4s linear infinite; }
.dn-wave .dn-rainbow .dn-ch, .dn-rainbow .dn-wave .dn-ch {
  animation: dn-wave 1s ease-in-out infinite, dn-rainbow 4s linear infinite; /* both at once */
}
.dn-wave .dn-ch, .dn-rainbow .dn-ch { animation-delay: calc(var(--delay, 0s) + var(--ch) * 0.08s); }
.dn-glow { animation: dn-glow 2s ease-in-out infinite var(--delay, 0s); }
.dn-bounce { animation: dn-bounce 2s ease-in-out infinite var(--delay, 0s); }
.dn-shake { animation: dn-shake 4s linear infinite var(--delay, 0s); }
/* Slow on purpose: nothing here flashes more than three times a second. */
.dn-blink { animation: dn-blink 2s ease-in-out infinite var(--delay, 0s); }

.dn-delay-1 { --delay: 0.1s; }
.dn-delay-2 { --delay: 0.2s; }
.dn-delay-3 { --delay: 0.3s; }
.dn-delay-4 { --delay: 0.4s; }
.dn-delay-5 { --delay: 0.5s; }
.dn-delay-6 { --delay: 0.6s; }
.dn-delay-7 { --delay: 0.7s; }
.dn-delay-8 { --delay: 0.8s; }
.dn-delay-9 { --delay: 0.9s; }
.dn-delay-10 { --delay: 1s; }
.dn-delay-11 { --delay: 1.1s; }
.dn-delay-12 { --delay: 1.2s; }
.dn-delay-13 { --delay: 1.3s; }
.dn-delay-14 { --delay: 1.4s; }
.dn-delay-15 { --delay: 1.5s; }
.dn-delay-16 { --delay: 1.6s; }
.dn-delay-17 { --delay: 1.7s; }
.dn-delay-18 { --delay: 1.8s; }
.dn-delay-19 { --delay: 1.9s; }
.dn-delay-20 { --delay: 2s; }

.dn-ch-0 { --ch: 0; }
.dn-ch-1 { --ch: 1; }
.dn-ch-2 { --ch: 2; }
.dn-ch-3 { --ch: 3; }
.dn-ch-4 { --ch: 4; }
.dn-ch-5 { --ch: 5; }
.dn-ch-6 { --ch: 6; }
.dn-ch-7 { --ch: 7; }
.dn-ch-8 { --ch: 8; }
.dn-ch-9 { --ch: 9; }
.dn-ch-10 { --ch: 10; }
.dn-ch-11 { --ch: 11; }
.dn-ch-12 { --ch: 12; }
.dn-ch-13 { --ch: 13; }
.dn-ch-14 { --ch: 14; }
.dn-ch-15 { --ch: 15; }
.dn-ch-16 { --ch: 16; }
.dn-ch-17 { --ch: 17; }
.dn-ch-18 { --ch: 18; }
.dn-ch-19 { --ch: 19; }
.dn-ch-20 { --ch: 20; }
.dn-ch-21 { --ch: 21; }
.dn-ch-22 { --ch: 22; }
.dn-ch-23 { --ch: 23; }
.dn-ch-24 { --ch: 24; }
.dn-ch-25 { --ch: 25; }
.dn-ch-26 { --ch: 26; }
.dn-ch-27 { --ch: 27; }
.dn-ch-28 { --ch: 28; }
.dn-ch-29 { --ch: 29; }
.dn-ch-30 { --ch: 30; }
.dn-ch-31 { --ch: 31; }
.dn-ch-32 { --ch: 32; }
.dn-ch-33 { --ch: 33; }
.dn-ch-34 { --ch: 34; }
.dn-ch-35 { --ch: 35; }
.dn-ch-36 { --ch: 36; }
.dn-ch-37 { --ch: 37; }
.dn-ch-38 { --ch: 38; }
.dn-ch-39 { --ch: 39; }

@keyframes dn-wave { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-0.25em); } }
@keyframes dn-rainbow {
  0%, 100% { color: var(--plus-4); }
  17% { color: var(--plus-7); }
  33% { color: var(--plus-8); }
  50% { color: var(--plus-9); }
  67% { color: var(--plus-11); }
  83% { color: var(--plus-13); }
}
@keyframes dn-glow {
  0%, 100% { filter: drop-shadow(0 0 0.05em var(--glow, currentColor)); }
  50% { filter: drop-shadow(0 0 0.35em var(--glow, currentColor)); }
}
@keyframes dn-bounce { 0%, 50%, 100% { transform: translateY(0); } 25% { transform: translateY(-0.3em); } }
@keyframes dn-shake {
  0%, 84%, 100% { transform: translateX(0); }
  86%, 90%, 94% { transform: translateX(-0.06em) rotate(-2deg); }
  88%, 92%, 96% { transform: translateX(0.06em) rotate(2deg); }
}
@keyframes dn-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

@media (prefers-reduced-motion: reduce) {
  .dn-anim, .dn-ch { animation: none !important; }
}

/* The plain name, for screen readers, when the letters have been split up. */
.dn-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
