/* ─────────────────────────────────────────────────────────────────────
   While you wait: the mask from a high-school doodle (the right-hand one on
   assets/img/works/high-school-doodles.jpg?v=f6e1ad2fb0), cast as a small metal tag,
   platinum on one face and blue gold on the other (the classes keep their old
   names, .tag-gold and .tag-silver). It turns a little in the light, flips,
   turns a little, flips back. The silhouette is assets/img/mask-tag.svg?v=bf723cb693
   (traced by _source/tools/trace_mask.py).
   Markup:
     <span class="tag" aria-hidden="true"><span class="tag-coin">
       <i class="tag-gold"></i><i></i><i></i><i></i><i></i><i></i><i class="tag-silver"></i>
     </span></span>
   Size it with --tag-h on the tag or any parent.
   The light (a filter) is on .tag and the turn on .tag-coin: a filter on the
   turning element itself would flatten its faces into one.
   ───────────────────────────────────────────────────────────────────── */
.tag {
  --tag-h: 60px;
  position: relative; display: inline-block; vertical-align: middle;
  width: calc(var(--tag-h) * 0.7573); height: var(--tag-h);
  perspective: calc(var(--tag-h) * 6);
  animation: tag-light 4.4s infinite;
}
.tag-coin {
  --tag-t: calc(var(--tag-h) * 0.07);          /* how thick the metal is */
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  animation: tag-turn 4.4s infinite;
}
.tag-coin i {
  position: absolute; inset: 0;
  -webkit-mask: url("../img/mask-tag.svg") center / contain no-repeat;
  mask: url("../img/mask-tag.svg") center / contain no-repeat;
}
/* the faces: metal is dark in its hollows and hot where the light sits; the light slides as it turns */
.tag-coin .tag-gold, .tag-coin .tag-silver {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background-size: 260% 100%; animation: tag-sheen 4.4s infinite linear;
}
.tag-coin .tag-gold {
  transform: translateZ(calc(var(--tag-t) / 2));
  /* platinum: white gold, cool, very bright where the light sits */
  background-image: linear-gradient(115deg, #8a9198 0%, #c2c8cf 16%, #ecf0f3 30%, #ffffff 37%, #dce1e6 44%, #959ca4 60%, #cfd5db 74%, #f7f9fb 84%, #9ea5ad 100%);
}
.tag-coin .tag-silver {
  transform: rotateY(180deg) translateZ(calc(var(--tag-t) / 2));
  /* blue gold: a deep anodised blue with pale gold in its highlights */
  background-image: linear-gradient(115deg, #142545 0%, #2f5592 16%, #6f9ad6 30%, #f3e7c4 37%, #7fa5dc 44%, #1d3866 60%, #4d77b8 74%, #dcd2b0 84%, #1a3160 100%);
}
/* the edge: five sheets between the faces, gold going to silver, so it has a body when it is side-on */
.tag-coin i:nth-child(2) { transform: translateZ(calc(var(--tag-t) * 0.33)); background: #8d939a; }
.tag-coin i:nth-child(3) { transform: translateZ(calc(var(--tag-t) * 0.17)); background: #767d86; }
.tag-coin i:nth-child(4) { transform: translateZ(0); background: #4e5c72; }
.tag-coin i:nth-child(5) { transform: translateZ(calc(var(--tag-t) * -0.17)); background: #2f4a75; }
.tag-coin i:nth-child(6) { transform: translateZ(calc(var(--tag-t) * -0.33)); background: #24406c; }

/* a slow turn showing the gold, a flip, a slow turn showing the silver, a flip back */
@keyframes tag-turn {
  0%   { transform: rotateY(-20deg); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  34%  { transform: rotateY(20deg);  animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
  50%  { transform: rotateY(160deg); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  84%  { transform: rotateY(200deg); animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
  100% { transform: rotateY(340deg); }
}
/* side-on it catches less light; a soft shadow under it, as on the old castings */
@keyframes tag-light {
  0%, 34%, 50%, 84%, 100% { filter: brightness(1) drop-shadow(0 1px 0.5px rgba(28, 36, 52, 0.4)) drop-shadow(0 5px 9px rgba(28, 36, 52, 0.22)); }
  42%, 92% { filter: brightness(0.72) drop-shadow(0 1px 0.5px rgba(28, 36, 52, 0.3)) drop-shadow(0 4px 7px rgba(28, 36, 52, 0.16)); }
}
@keyframes tag-sheen {
  0%   { background-position: 100% 0; }
  34%  { background-position: 30% 0; }
  50%  { background-position: 100% 0; }
  84%  { background-position: 30% 0; }
  100% { background-position: 100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tag, .tag-coin, .tag-coin .tag-gold, .tag-coin .tag-silver { animation: none; }
  .tag { filter: drop-shadow(0 1px 0.5px rgba(28, 36, 52, 0.4)) drop-shadow(0 5px 9px rgba(28, 36, 52, 0.22)); }
}
