/* ===== King of Hearts auth-page avatar =====
 * Drops the existing geometric .auth-art-mark icon in favour of a circular
 * blinking King portrait. Pure CSS animation, no JS.
 * Wired in: app/templates/auth/_king_avatar.html  +  the four auth pages. */

.king {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #f3eee0, #e7dec3);
  box-shadow:
    0 26px 50px -20px rgba(0, 0, 0, 0.75),
    0 0 0 4px rgba(255, 215, 0, 0.18),
    0 0 0 5px var(--gold-deep, #c9a961),
    inset 0 -10px 30px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: kingFloat 6s ease-in-out infinite;
}

@keyframes kingFloat {
  0%, 100% { transform: translateY(0) rotate(-0.4deg); }
  50%      { transform: translateY(-6px) rotate(0.4deg); }
}

.king-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

/* Eyelids drawn over the portrait. The portrait is a 1:1 crop with eyes at
 * roughly y=58%, x=36%/62%. scaleY(0) keeps them open by default; the blink
 * keyframe flips to scaleY(1.05) for ~1 frame every 5.2s. */
.king .lid {
  position: absolute;
  width: 11%;
  height: 6%;
  transform-origin: 50% 0;
  transform: scaleY(0);
  background: linear-gradient(180deg, #efdcbf 0%, #d9bb95 70%, #b89876 100%);
  border-bottom: 1.4px solid #5a3a22;
  border-radius: 50% 50% 48% 48% / 95% 95% 22% 22%;
  box-shadow:
    inset 0 -1px 2px rgba(0, 0, 0, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.4);
  pointer-events: none;
  z-index: 3;
  animation: kingBlink 5.2s ease-in-out infinite;
}

.king .lid::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -3px;
  height: 4px;
  background:
    radial-gradient(circle at  8% 0, #3a2316 0 0.7px, transparent 1.2px),
    radial-gradient(circle at 25% 0, #3a2316 0 0.7px, transparent 1.2px),
    radial-gradient(circle at 42% 0, #3a2316 0 0.7px, transparent 1.2px),
    radial-gradient(circle at 58% 0, #3a2316 0 0.7px, transparent 1.2px),
    radial-gradient(circle at 75% 0, #3a2316 0 0.7px, transparent 1.2px),
    radial-gradient(circle at 92% 0, #3a2316 0 0.7px, transparent 1.2px);
  opacity: 0.6;
}

/* Eye positions retuned for the supplied portrait crop. Eyes sit at y≈52-58%,
 * iris centres at x≈38% (left) and x≈58% (right). Lid width 11%, half=5.5%,
 * so left edges land at 32.5% / 52.5%. */
.king .lid.left  { top: 52%; left: 32.5%; }
.king .lid.right { top: 52%; left: 52.5%; animation-delay: 30ms; }

@keyframes kingBlink {
  0%, 92%, 96%, 100% { transform: scaleY(0); }
  94%                { transform: scaleY(1.05); }
}

/* K♥ corner chip. inset-inline-end keeps it on the visually-leading edge
 * in RTL (which is the right side for our app since the layout flips). */
.king-chip {
  position: absolute;
  top: 8px;
  inset-inline-end: 12px;
  z-index: 4;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fffaf0;
  border: 1px solid var(--gold-deep, #c9a961);
  display: grid;
  place-items: center;
  font-family: 'Amiri', Georgia, serif;
  color: #c8243c;
  line-height: 1;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
  transform: rotate(-8deg);
}

.king-chip .r { font-size: 14px; font-weight: 800; }
.king-chip .s { font-size: 12px; margin-top: 1px; }

/* The original .auth-art-mark slot was a 96px geometric diamond. The King
 * needs more room, so collapse its outer margin and let the medallion own
 * the spacing instead. Only applies inside auth pages. */
.auth-art-content .king {
  margin-bottom: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .king,
  .king .lid { animation: none; }
}

@media (max-width: 480px) {
  .king {
    width: 160px;
    height: 160px;
  }
  .king-chip {
    width: 28px;
    height: 28px;
    top: 6px;
    inset-inline-end: 8px;
  }
  .king-chip .r { font-size: 12px; }
  .king-chip .s { font-size: 10px; }
}
