/* ===== 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. */

.tarneb-auth-mark {
  display: block;
  width: clamp(140px, 40vw, 200px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.35));
}

.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;
}

/* Each .lid is a transparent clip aligned to one eye in the 240px portrait.
 * Two panels move into that clip and meet in the middle, so the upper and
 * lower lids cover the iris together instead of stretching a flat patch over
 * it. The source drawing is asymmetric, so the clips are measured separately. */
.king .lid {
  position: absolute;
  display: block;
  overflow: hidden;
  border-radius: 50% / 46%;
  background: transparent;
  pointer-events: none;
  z-index: 3;
  isolation: isolate;
  contain: paint;
}

.king .lid::before,
.king .lid::after {
  content: "";
  position: absolute;
  left: -4%;
  width: 108%;
  height: 52%;
  will-change: transform;
}

.king .lid::before {
  top: 0;
  z-index: 2;
  transform: translateY(-110%);
  background: linear-gradient(180deg, #cbc7c1 0%, #d8d4cd 58%, #c7beb4 100%);
  border-bottom: 1.2px solid rgba(55, 42, 36, 0.9);
  box-shadow: inset 0 -1px 1px rgba(42, 30, 26, 0.28);
  animation: kingUpperBlink 5.4s cubic-bezier(.34, .03, .2, 1) infinite;
}

.king .lid::after {
  bottom: 0;
  z-index: 1;
  transform: translateY(110%);
  background: linear-gradient(0deg, #eeebe5 0%, #e2ddd5 58%, #cec7bd 100%);
  box-shadow: inset 0 1px 1px rgba(42, 30, 26, 0.18);
  animation: kingLowerBlink 5.4s cubic-bezier(.34, .03, .2, 1) infinite;
}

/* Measured visible-eye bounds in the source asset are x=69..98 / 121..155
 * and y=124..142. The clips include a 1-2px safety margin so antialiased eye
 * edges cannot peek through at the smallest rendered size. */
.king .lid.left  { top: 51.2%; left: 28%; width: 14%; height: 8.3%; }
.king .lid.right { top: 51.2%; left: 49.6%; width: 16%; height: 8.3%; }

@keyframes kingUpperBlink {
  0%, 87%, 94%, 100% { transform: translateY(-110%); }
  89.4%, 91.7%       { transform: translateY(0); }
}

@keyframes kingLowerBlink {
  0%, 87%, 94%, 100% { transform: translateY(110%); }
  89.4%, 91.7%       { transform: translateY(0); }
}

/* 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::before,
  .king .lid::after { 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; }
}
