/* The upvote: a soft pill with a solid triangle and a number. Blue once you have upvoted.
   Macros: templates/_upvote.html. Motion runs on click only, from static/js/upvote.js. */
.uv {
  --uv-bg: var(--field);
  position: relative; display: inline-flex; align-items: center; gap: 4px; flex: none; height: 22px; padding: 0 8px 0 6px;
  background: var(--uv-bg); border-radius: var(--r-pill); color: var(--text);
  font-size: var(--t-micro); font-weight: var(--w-strong); line-height: 1; white-space: nowrap; text-align: left;
  font-variant-numeric: tabular-nums; vertical-align: middle;
  transition: background .12s, border-color .12s, color .12s;
}
.uv-i { position: relative; z-index: 1; flex: none; display: block; width: 11px; height: 11px; fill: var(--accent); transition: fill .12s; }
.uv-n { position: relative; z-index: 1; display: inline-block; overflow: hidden; line-height: 1.3; }
.uv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.uv.is-on { --uv-on: var(--accent-text); background: var(--uv-on); color: var(--ink); }
.uv.is-on .uv-i { fill: currentColor; }

.uv-form { margin: 0; display: inline-flex; }
.uv-btn {
  --uv-bg: var(--panel);
  gap: 6px; height: 34px; padding: 0 13px 0 11px; border: 1px solid var(--border-2);
  font-family: inherit; font-size: var(--t-ui); cursor: pointer;
}
.uv-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.uv-btn.is-on { border-color: var(--uv-on); }
.uv-btn.is-on:hover { background: var(--uv-on); border-color: var(--uv-on); }
.uv-btn .uv-i { width: 13px; height: 13px; }
.uv-w { position: relative; z-index: 1; display: inline-grid; justify-items: center; }
.uv-w span { grid-area: 1 / 1; }
.uv-w span:last-child, .uv.is-on .uv-w span:first-child { visibility: hidden; }
.uv.is-on .uv-w span:last-child { visibility: visible; }
.uv-mock { cursor: default; pointer-events: none; }

/* The button at list size: the plain pill's looks, one size up so it reads as something to press.
   Its reach is wider than its paint, 44px on phones, so a small pill is still easy to hit. */
.uv-btn.uv-c { --uv-bg: var(--field); gap: 4px; height: 24px; padding: 0 8px 0 6px; border-color: transparent; font-size: var(--t-micro); }
.uv-btn.uv-c .uv-i { width: 11px; height: 11px; }
.uv-c::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 36px); height: 34px; translate: -50% -50%; }
.uv-btn.uv-c.is-on { border-color: var(--uv-on); }

/* Upvoting: the triangle hops once, one ring opens round the pill, the colour changes and the number
   rolls. The pill itself never moves, so it stays under the pointer. */
.uv-go .uv-i { animation: uvHop .38s cubic-bezier(.3, 1.5, .5, 1); }
.uv-go.is-on::after { content: ""; position: absolute; inset: -1px; border: 2px solid var(--accent); border-radius: inherit; pointer-events: none; animation: uvRing .42s ease-out forwards; }
.uv-back .uv-i { animation: uvSettle .24s ease-out; }

.uv-roll { display: block; animation: uvRollIn .24s ease-out both; }
.uv-roll-old { position: absolute; left: 0; top: 0; animation-name: uvRollOut; }
.uv-back .uv-roll { animation-name: uvRollInDown; }
.uv-back .uv-roll-old { animation-name: uvRollOutDown; }

@keyframes uvHop { 0% { transform: none; } 40% { transform: translateY(-3px) scale(1.22); } 100% { transform: none; } }
@keyframes uvRing { from { opacity: .55; transform: scale(1); } to { opacity: 0; transform: scale(1.14, 1.42); } }
@keyframes uvSettle { from { transform: translateY(-2px); } to { transform: none; } }
@keyframes uvRollIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes uvRollOut { from { transform: none; } to { transform: translateY(-100%); } }
@keyframes uvRollInDown { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes uvRollOutDown { from { transform: none; } to { transform: translateY(100%); } }

@media (max-width: 640px) { .uv-btn:not(.uv-mock, .uv-c) { height: 44px; padding-inline: 14px 16px; } }
@media (max-width: 640px), (pointer: coarse) { .uv-c::before { width: max(100%, 44px); height: 44px; } }
@media (prefers-reduced-motion: reduce) {
  .uv, .uv-i { transition: none; }
  .uv-go .uv-i, .uv-back .uv-i, .uv-roll { animation: none; }
  .uv-go.is-on::after, .uv-roll-old { display: none; }
}
