/*
 * Award badge: a small trophy in a circle, top corner of a post's tile.
 * Turned on per post with the "Award winner" switch in the editor sidebar.
 */
.grid-item {
  position: relative;
}
.award-badge {
  position: absolute;
  /* pops out of the image's top-right corner: 6px above, 6px to the right
     (the tile has a 9px gutter, so 9 - 6 = 3px from the tile edge) */
  top: -6px;
  right: 3px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff; /* icon colour */
  line-height: 1;
  pointer-events: none; /* clicks go through to the tile */
}
.award-icon {
  display: block;
  width: 15px;
  height: 15px;
}
@media (min-width: 992px) {
  .award-icon {
    width: 15px;
    height: 15px;
  }
}
.grid-item.open .award-badge {
  display: none; /* hidden while the tile's inline preview is open */
}
@media (min-width: 992px) {
  .award-badge {
    top: -6px;
    right: 3px;
    width: 30px;
    height: 30px;
  }
}

/* Rollover: the badge shakes and three little stars rise from its top and fade */
.award-stars {
  position: absolute;
  top: -6px;
  right: 3px;
  z-index: 3;
  width: 30px;
  height: 30px;
  pointer-events: none;
}
.award-stars i {
  position: absolute;
  left: 50%;
  top: 30%;
  font-style: normal;
  font-size: 10px;
  line-height: 1;
  color: #000;
  text-shadow: 0 0 2px #fff, 0 0 1px #fff;
  opacity: 0;
  transform: translate(-50%, -50%);
}
.award-stars i:nth-child(2) { font-size: 12px; }
.grid-item.open .award-stars { display: none; }

@keyframes award-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg); }
  40% { transform: rotate(12deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(5deg); }
}
@keyframes award-star-left {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% - 16px), calc(-50% - 24px)) scale(1) rotate(-30deg); }
}
@keyframes award-star-up {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 32px)) scale(1.1); }
}
@keyframes award-star-right {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + 16px), calc(-50% - 22px)) scale(1) rotate(30deg); }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .grid-item:hover .award-badge {
    animation: award-shake 0.5s ease-in-out;
  }
  .grid-item:hover .award-stars i:nth-child(1) { animation: award-star-left 0.9s ease-out 0.15s both; }
  .grid-item:hover .award-stars i:nth-child(2) { animation: award-star-up 0.9s ease-out 0.05s both; }
  .grid-item:hover .award-stars i:nth-child(3) { animation: award-star-right 0.9s ease-out 0.25s both; }
}

/* Touch screens: awards.js adds .award-play on tap, plays the same animation, then opens the tile */
@media (prefers-reduced-motion: no-preference) {
  .grid-item.award-play .award-badge {
    animation: award-shake 0.5s ease-in-out;
  }
  .grid-item.award-play .award-stars i:nth-child(1) { animation: award-star-left 0.9s ease-out 0.15s both; }
  .grid-item.award-play .award-stars i:nth-child(2) { animation: award-star-up 0.9s ease-out 0.05s both; }
  .grid-item.award-play .award-stars i:nth-child(3) { animation: award-star-right 0.9s ease-out 0.25s both; }
}

/* Night mode: white circle, black trophy, white stars */
.night .award-badge {
  background: #fff;
  color: #000;
}
.night .award-stars i {
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 1px #000;
}
