/*
 * 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: #fff;
  /* soft drop shadow so the white circle lifts off light images */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1d21; /* icon colour: the dark grey of the night-mode background */
  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: #eb8926;
  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: same white circle and dark grey trophy; a darker shadow, orange stars */
.night .award-badge {
  background: #fff;
  color: #1a1d21;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.night .award-stars i {
  color: #eb8926;
  text-shadow: 0 0 2px #000, 0 0 1px #000;
}

/* The rising stars use the starno star from the site title (as a mask, so they take the colour set above) */
.award-stars i {
  width: 9px;
  height: 9px;
  font-size: 0;
  text-shadow: none;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 17.5'%3E%3Cpath d='M0.3,8.8L0.3,8.8C0.2,8.8,0.1,8.7,0.1,8.6C0,8.4,0.1,8.1,0.3,8l5.1-2.1l1.1-5.4c0-0.1,0.1-0.4,0.3-0.4C7.1,0,7.2,0,7.4,0.2L11,4.4l5.5-0.6c0.2,0,0.4,0,0.5,0.2c0.1,0.1,0.1,0.4,0,0.6l-2.9,4.7c0,0,2.3,5,2.3,5.1c0.1,0.2,0,0.5-0.2,0.6c-0.1,0-0.2,0-0.3,0l0,0l-5.4-1.3l-4,3.7l0,0c0,0.1-0.3,0.3-0.6,0.1c-0.2-0.1-0.2-0.4-0.2-0.4l-0.5-5.5L0.3,8.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 17.5'%3E%3Cpath d='M0.3,8.8L0.3,8.8C0.2,8.8,0.1,8.7,0.1,8.6C0,8.4,0.1,8.1,0.3,8l5.1-2.1l1.1-5.4c0-0.1,0.1-0.4,0.3-0.4C7.1,0,7.2,0,7.4,0.2L11,4.4l5.5-0.6c0.2,0,0.4,0,0.5,0.2c0.1,0.1,0.1,0.4,0,0.6l-2.9,4.7c0,0,2.3,5,2.3,5.1c0.1,0.2,0,0.5-0.2,0.6c-0.1,0-0.2,0-0.3,0l0,0l-5.4-1.3l-4,3.7l0,0c0,0.1-0.3,0.3-0.6,0.1c-0.2-0.1-0.2-0.4-0.2-0.4l-0.5-5.5L0.3,8.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.award-stars i:nth-child(2) {
  width: 11px;
  height: 11px;
}

/*
 * Rollover / tap sequence: the dark grey trophy fades to starno orange first (0.25s),
 * then the badge shakes and the stars rise (everything below starts 0.2s later than before).
 */
.award-badge {
  transition: color 0.25s ease;
}
@media (hover: hover) {
  .grid-item:hover .award-badge {
    color: #eb8926;
  }
}
.grid-item.award-play .award-badge {
  color: #eb8926;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .grid-item:hover .award-badge {
    animation: award-shake 0.5s ease-in-out 0.2s;
  }
  .grid-item:hover .award-stars i:nth-child(1) { animation-delay: 0.35s; }
  .grid-item:hover .award-stars i:nth-child(2) { animation-delay: 0.25s; }
  .grid-item:hover .award-stars i:nth-child(3) { animation-delay: 0.45s; }
}
@media (prefers-reduced-motion: no-preference) {
  .grid-item.award-play .award-badge {
    animation: award-shake 0.5s ease-in-out 0.2s;
  }
  .grid-item.award-play .award-stars i:nth-child(1) { animation-delay: 0.35s; }
  .grid-item.award-play .award-stars i:nth-child(2) { animation-delay: 0.25s; }
  .grid-item.award-play .award-stars i:nth-child(3) { animation-delay: 0.45s; }
}

/*
 * The award badge in the Portfolio menu, to the left of "Award": the same badge scaled
 * to the menu text (a 14px trophy, no circle). Same rollover as the tiles: to orange,
 * then the shake and the rising starno stars.
 */
a[data-award] {
  white-space: nowrap; /* the badge never wraps away from the word */
}
.menu-award-mark {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: -2px 6px 0 0;
  vertical-align: middle;
}
.menu-award-mark .award-badge,
.menu-award-mark .award-stars {
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
}
/* in the menu: just the trophy, no circle or shadow, in the colour of the menu text */
.menu-award-mark .award-badge,
.night .menu-award-mark .award-badge {
  background: transparent;
  box-shadow: none;
  color: inherit;
}
.menu-award-mark .award-icon {
  width: 14px;
  height: 14px;
}
@media (hover: hover) {
  a[data-award]:hover .award-badge {
    color: #eb8926;
  }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  a[data-award]:hover .award-badge {
    animation: award-shake 0.5s ease-in-out 0.2s;
  }
  a[data-award]:hover .award-stars i:nth-child(1) { animation: award-star-left 0.9s ease-out 0.35s both; }
  a[data-award]:hover .award-stars i:nth-child(2) { animation: award-star-up 0.9s ease-out 0.25s both; }
  a[data-award]:hover .award-stars i:nth-child(3) { animation: award-star-right 0.9s ease-out 0.45s both; }
}

/* The trophy used in text in place of the 🏆 emoji (Client lists, Award title, award lines) */
.award-inline {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  vertical-align: -0.12em;
}
.award-inline svg {
  display: block;
  width: 100%;
  height: 100%;
}

/*
 * Inline trophies inside a link ("Award" under Client, the Clients + Friends list) play the
 * badge animation on rollover: the trophy shakes and the starno stars rise. The trophy
 * above award lines in post text is not a link, so it stays still.
 */
.award-inline {
  position: relative;
}
.award-inline .award-stars {
  top: 0;
  left: 0;
  right: auto;
  width: 100%;
  height: 100%;
}
@keyframes award-star-left-low {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% - 16px), calc(-50% - 9px)) scale(1) rotate(-30deg); }
}
@keyframes award-star-up-low {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 12px)) scale(1.1); }
}
@keyframes award-star-right-low {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + 16px), calc(-50% - 9px)) scale(1) rotate(30deg); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  a:hover .award-inline svg {
    animation: award-shake 0.5s ease-in-out 0.2s;
  }
  a:hover .award-inline .award-stars i:nth-child(1) { animation: award-star-left 0.9s ease-out 0.35s both; }
  a:hover .award-inline .award-stars i:nth-child(2) { animation: award-star-up 0.9s ease-out 0.25s both; }
  a:hover .award-inline .award-stars i:nth-child(3) { animation: award-star-right 0.9s ease-out 0.45s both; }
  /* in the Clients + Friends list (a scrolling box, Award at the top) the stars stay low enough to be seen */
  .dropdown-item:hover .award-inline .award-stars i:nth-child(1) { animation-name: award-star-left-low; }
  .dropdown-item:hover .award-inline .award-stars i:nth-child(2) { animation-name: award-star-up-low; }
  .dropdown-item:hover .award-inline .award-stars i:nth-child(3) { animation-name: award-star-right-low; }
}
/* the list highlights in orange on rollover, so the stars turn white there */
.dropdown-item:hover .award-inline .award-stars i,
.dropdown-item:focus .award-inline .award-stars i {
  color: #fff;
}
