/* Badges (modules::badges, site/badges.rs): the small form on a profile, beside the flags,
   and the big one, brought forward in a dialog (components/badge-viewer.js) or on its own
   page. The art is the server's SVG; the depth is ours: the badge tilts toward the pointer,
   its shadow slides the other way, and a band of light crosses its surface. Transforms and
   one blurred shadow only, so it stays light on a phone. */

.profile-badges { display: inline-flex; gap: 0.375rem; margin-left: 0.5rem; vertical-align: middle; }
.profile-badge {
  display: inline-block;
  line-height: 0;
  border-radius: 2px;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.22));
  transition: transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.profile-badge svg { display: block; width: 1.5rem; height: 1.875rem; }
.profile-badge:hover { transform: translateY(-2px) rotate(-4deg); }
.profile-badge:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.profile-badge.is-lifted { visibility: hidden; }

.badge-tile-art { display: inline-block; vertical-align: -0.45em; margin-right: 0.375rem; line-height: 0; }
.badge-tile-art svg { width: 1.125rem; height: 1.4rem; }

/* Settings → Badges: which show on the profile, in what order. */
.badge-choices { display: flex; flex-direction: column; gap: 0.25rem; margin: 0; }
.badge-choice { display: flex; align-items: center; gap: 0.75rem; border-radius: 0.75rem; padding: 0.375rem 0.25rem 0.375rem 0.5rem; }
.badge-choice:hover { background: var(--surface-2); }
.badge-choice-art { flex-shrink: 0; line-height: 0; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.22)); }
.badge-choice-art img { width: 1.5rem; height: 1.875rem; }
.badge-choice-art:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.badge-choice-show { min-width: 0; flex: 1; }
.badge-choice-show span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-choice:has(input:not(:checked)) .badge-choice-art { opacity: 0.45; filter: grayscale(1); }
.badge-choice-move { display: inline-flex; flex-shrink: 0; gap: 0.125rem; }

/* ─── The big form ───────────────────────────────────────────────────────── */

.badge-card { display: grid; justify-items: center; gap: 1.75rem; padding: 1.5rem 0 2rem; }
.badge-stage { width: min(64vw, 18.5rem); perspective: 950px; }
.badge-object {
  position: relative;
  aspect-ratio: var(--badge-ratio);
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.badge-object.is-tracking { transition-duration: 0.12s; transition-timing-function: linear; }
.badge-art { position: relative; height: 100%; }
.badge-art svg { display: block; width: 100%; height: 100%; }
/* The shadow on the table: lower than the badge, sliding opposite its tilt. */
.badge-shadow {
  position: absolute;
  inset: 8% 6% 2%;
  border-radius: 6px;
  background: rgb(14 12 8 / 0.5);
  filter: blur(16px);
  transform: translate3d(var(--sx, 0px), calc(var(--sy, 0px) + 1.25rem), -40px);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.badge-object.is-tracking .badge-shadow { transition-duration: 0.12s; }
/* The light: a soft band across the paper and the ink, and a glint where the light hits. */
.badge-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: inset(1.5%);
  background:
    radial-gradient(circle at var(--gx, 35%) var(--gy, 25%), rgb(255 255 255 / calc(var(--badge-gloss, 0.3) * 1.7)), transparent 45%),
    linear-gradient(115deg, transparent 32%, rgb(255 255 255 / calc(var(--badge-gloss, 0.3) * 1.4)) 47%, transparent 60%);
  background-size: 100% 100%, 260% 260%;
  background-position: 0 0, var(--bx, 30%) var(--by, 30%);
  mix-blend-mode: soft-light;
  transform: translateZ(1px);
}
.badge-object.is-idle { animation: badge-sway 7s ease-in-out infinite; }
.badge-object.is-idle .badge-sheen { animation: badge-light 7s ease-in-out infinite; }
@keyframes badge-sway {
  0%, 100% { transform: rotateX(4deg) rotateY(-7deg); }
  50% { transform: rotateX(-3deg) rotateY(7deg); }
}
@keyframes badge-light {
  0%, 100% { background-position: 0 0, 15% 20%; }
  50% { background-position: 0 0, 85% 80%; }
}

.badge-words { max-width: 30rem; text-align: center; }
.badge-kicker { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.badge-name { margin-top: 0.25rem; font-family: var(--font-serif); font-size: 1.875rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); }
.badge-why { margin-top: 0.625rem; font-size: 1.0625rem; line-height: 1.5; color: var(--ink); }
.badge-about { margin-top: 0.5rem; font-size: 0.9375rem; line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.badge-back { margin-top: 1rem; }

/* ─── The dialog ─────────────────────────────────────────────────────────── */

.badge-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.badge-dialog::backdrop { background: rgb(12 10 8 / 0); transition: background 0.35s ease; }
.badge-dialog.is-open::backdrop { background: rgb(12 10 8 / 0.8); }
.badge-dialog-body { display: grid; place-items: center; min-height: 100%; padding: 3.5rem 1rem 2rem; }
.badge-dialog .badge-card { padding: 0; }
.badge-dialog .badge-back { display: none; }
.badge-dialog .badge-words {
  padding: 1.125rem 1.375rem 1.25rem;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.badge-dialog.is-open .badge-words { opacity: 1; transform: none; transition-delay: 0.22s; }
.badge-dialog.is-closing .badge-words { opacity: 0; transform: translateY(10px); transition-delay: 0s; transition-duration: 0.18s; }
.badge-dialog-close {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  color: #f4f0e6;
  background: rgb(255 255 255 / 0.1);
  opacity: 0;
  transition: opacity 0.3s;
}
.badge-dialog.is-open .badge-dialog-close { opacity: 1; }
.badge-dialog-close:hover { background: rgb(255 255 255 / 0.18); }
/* While it flies, the badge leaves the stage's light alone. */
.badge-flying .badge-sheen, .badge-flying .badge-shadow { opacity: 0; }
.badge-sheen, .badge-shadow { transition: opacity 0.4s ease; }

@media (prefers-reduced-motion: reduce) {
  .badge-object, .badge-object.is-idle, .badge-object.is-idle .badge-sheen { animation: none; transition: none; }
  .badge-dialog .badge-words { transition: opacity 0.2s; transform: none; }
  .profile-badge { transition: none; }
}
