/* ==========================================================================
   JORIE DAILY — badges.css · Phase 33.5 · The Golden Badge Collection ♡
   Badges page grid, locked silhouettes, hover shine, the detail dialog and
   the Today reveal. Everything is scoped to .bdg* classes; no existing
   selector, keyframe or animation is changed. Loaded just BEFORE
   design-system.css (Phase 33.2 rule: design-system.css stays last).
   Gold accents reuse the report's gold; everything else uses site tokens.
   ========================================================================== */
:root {
  --bdg-gold: #D9AE5F;
  --bdg-gold-soft: rgb(217 174 95 / 0.45);
  --bdg-lock-rim: color-mix(in srgb, var(--beige) 55%, var(--burgundy) 10%);
  --bdg-lock-face: color-mix(in srgb, var(--white) 70%, var(--beige));
  --bdg-lock-ink: rgb(var(--burgundy-rgb) / 0.32);
}
:root[data-theme="dark"] {
  --bdg-gold-soft: rgb(217 174 95 / 0.32);
  --bdg-lock-rim: rgb(var(--pink-rgb) / 0.16);
  --bdg-lock-face: rgb(var(--pink-rgb) / 0.07);
  --bdg-lock-ink: rgb(var(--pink-rgb) / 0.42);
}

/* ---------------------------------------------------------------- page */
.bdg-page { padding-bottom: clamp(28px, 5vw, 56px); }
.bdg-hero .page-hero__lede em { font-style: italic; }
#bdg-app { display: grid; gap: var(--gap, 18px); }
.bdg-summary {
  justify-self: start;
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--ink); font-size: var(--fs-sm); font-weight: 600;
}
.bdg-summary__num { font-family: var(--font-display); font-size: 1.35em; font-weight: 800; }
.bdg-loading, .bdg-empty { padding: 18px 20px; color: var(--ink-2); font-size: var(--fs-sm); }

.bdg-col { padding: clamp(16px, 2.6vw, 22px); }
.bdg-col__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.bdg-col__title {
  font-family: var(--font-display); font-size: clamp(1.15rem, 1.05rem + .5vw, 1.4rem);
  font-weight: 700; font-variation-settings: "SOFT" 100; letter-spacing: -0.01em;
}
.bdg-col__count { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; color: var(--ink-3); white-space: nowrap; }
.bdg-col--sub { padding: 0; }
.bdg-col--sub + .bdg-col--sub { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.bdg-col--sub .bdg-col__title { font-size: var(--fs-md); }

.bdg-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px 8px;
}
@media (max-width: 519px) { .bdg-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 2px 4px; } .bdg { padding: 6px 2px 8px; } .bdg__name { font-size: 11px; } }

/* ---------------------------------------------------------------- one medal */
.bdg-cell { display: contents; }
.bdg {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 4px;
  width: 100%; padding: 8px 4px 10px; border: 0; border-radius: 18px; background: none;
  color: var(--ink); font: inherit; text-align: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 300ms var(--ease-out), background-color 300ms ease;
}
.bdg__art { position: relative; display: block; width: 100%; max-width: 92px; aspect-ratio: 128 / 140; }
.bdg__img, .bdg__art > svg { display: block; width: 100%; height: 100%; transition: filter 300ms ease; }
.bdg__name { font-size: var(--fs-xs); font-weight: 600; line-height: 1.25; text-wrap: balance; }
.bdg__name--secret { color: var(--ink-3); font-weight: 500; font-style: italic; }
.bdg__new {
  position: absolute; top: 4px; right: 4px;
  padding: 2px 7px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--bg); font-size: 10px; font-weight: 700; letter-spacing: .04em;
}
/* the shine travels across the round medal only */
.bdg__shine {
  position: absolute; left: 6.25%; top: 2.86%; width: 87.5%; height: 80%;
  border-radius: 50%; overflow: hidden; pointer-events: none;
}
.bdg__shine::after {
  content: ""; position: absolute; inset: -10% auto -10% -60%; width: 45%;
  background: linear-gradient(105deg, transparent, rgb(255 255 255 / .55), transparent);
  transform: translateX(-40%) skewX(-12deg); opacity: 0;
}
.bdg:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; box-shadow: 0 0 0 6px var(--focus-halo); }
@media (hover: hover) and (pointer: fine) {
  .bdg:not(.bdg--locked):hover { transform: translateY(-3px) scale(1.03); }
  .bdg:not(.bdg--locked):hover .bdg__img { filter: drop-shadow(0 6px 12px var(--bdg-gold-soft)); }
  .bdg:not(.bdg--locked):hover .bdg__shine::after { opacity: 1; transform: translateX(330%) skewX(-12deg); transition: transform 700ms var(--ease-out), opacity 120ms ease; }
}
.bdg:not(.bdg--locked):active { transform: scale(.97); transition-duration: 120ms; }
.bdg.is-spotlit .bdg__img { filter: drop-shadow(0 0 14px var(--bdg-gold-soft)); }
.bdg.is-spotlit { background: var(--accent-soft); }

/* locked: an anonymous silhouette — no art, no name, no hint */
.bdg--locked { cursor: default; }
.bdg--locked .lk-tail { fill: var(--bdg-lock-rim); }
.bdg--locked .lk-rim { fill: var(--bdg-lock-rim); }
.bdg--locked .lk-face { fill: var(--bdg-lock-face); stroke: var(--bdg-lock-ink); stroke-width: 1; stroke-dasharray: 2 4; }
.bdg--locked .lk-dots { fill: none; stroke: none; }
.bdg--locked .lk-lock rect, .bdg--locked .lk-lock path { fill: none; stroke: var(--bdg-lock-ink); stroke-width: 2.4; stroke-linecap: round; }
.bdg--locked .lk-lock circle { fill: var(--bdg-lock-ink); }

/* Phase 42: anonymous progress under a locked Checklist badge (no name, no art) */
.bdg__meter {
  display: block; width: min(76%, 70px); height: 5px; margin-top: 1px;
  border-radius: var(--radius-pill); background: var(--bdg-lock-rim); overflow: hidden;
}
.bdg__meter-fill {
  display: block; width: var(--p, 0%); height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--bdg-gold-soft), var(--bdg-gold));
  transform-origin: left center; animation: bdgMeterIn 900ms var(--ease-out) 200ms both;
}
.bdg__count { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
@keyframes bdgMeterIn { from { transform: scaleX(0); } to { transform: none; } }

/* ---------------------------------------------------------------- detail dialog */
.bdg-detail .confirm__inner { gap: 10px; }
.bdg-detail__medal { display: block; width: min(176px, 52vw); }
.bdg-detail__img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 18px var(--bdg-gold-soft)); }
.bdg-detail__facts { display: grid; gap: 6px; margin: 4px 0 0; width: 100%; max-width: 34ch; font-size: var(--fs-sm); }
.bdg-detail__facts div { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px; text-align: left; }
.bdg-detail__facts dt { font-weight: 700; color: var(--ink-2); }
.bdg-detail__facts dd { margin: 0; }

/* ---------------------------------------------------------------- Today reveal */
.bdg-reveal .confirm__inner { gap: 8px; overflow: hidden; }
.bdg-reveal__stage { position: relative; display: grid; place-items: center; width: 168px; height: 176px; margin-bottom: 2px; }
.bdg-reveal__medal { position: relative; display: block; width: 150px; }
.bdg-reveal__img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 18px var(--bdg-gold-soft)); }
.bdg-reveal__shine { position: absolute; left: 6.25%; top: 2.86%; width: 87.5%; height: 80%; border-radius: 50%; overflow: hidden; }
.bdg-reveal__shine::after {
  content: ""; position: absolute; inset: -10% auto -10% -60%; width: 45%;
  background: linear-gradient(105deg, transparent, rgb(255 255 255 / .6), transparent);
  transform: translateX(-40%) skewX(-12deg); opacity: 0;
}
.bdg-reveal__burst { position: absolute; inset: 0; pointer-events: none; }
.bdg-reveal__burst i {
  position: absolute; left: 50%; top: 46%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: var(--bdg-gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: 0;
}
.bdg-reveal__burst i:nth-child(2n) { background: var(--pink); width: 7px; height: 7px; }
.bdg-reveal__kicker { color: var(--ink-2); }
.bdg-reveal__name { font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem); }
.bdg-reveal__count { font-size: var(--fs-xs); color: var(--ink-3); letter-spacing: .06em; }
.bdg-reveal__actions .btn { min-width: 9.5rem; justify-content: center; }

/* 1 sparkle → 2 medal scales in → 3 shine → 4 name → 5 message */
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__burst i { animation: bdgSpark 1100ms var(--ease-out) both; }
.bdg-reveal__burst i:nth-child(1) { --bx: 0px;    --by: -78px; }
.bdg-reveal__burst i:nth-child(2) { --bx: 58px;   --by: -56px; animation-delay: 40ms !important; }
.bdg-reveal__burst i:nth-child(3) { --bx: 80px;   --by: 0px;   animation-delay: 80ms !important; }
.bdg-reveal__burst i:nth-child(4) { --bx: 56px;   --by: 58px;  animation-delay: 120ms !important; }
.bdg-reveal__burst i:nth-child(5) { --bx: 0px;    --by: 80px;  animation-delay: 60ms !important; }
.bdg-reveal__burst i:nth-child(6) { --bx: -58px;  --by: 56px;  animation-delay: 100ms !important; }
.bdg-reveal__burst i:nth-child(7) { --bx: -80px;  --by: 0px;   animation-delay: 20ms !important; }
.bdg-reveal__burst i:nth-child(8) { --bx: -56px;  --by: -58px; animation-delay: 140ms !important; }
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__medal { animation: bdgMedalIn 900ms var(--ease-spring) 250ms both; }
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__shine::after { animation: bdgShine 900ms var(--ease-out) 1150ms both; }
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__kicker,
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__name { animation: bdgRise 600ms var(--ease-out) 1100ms both; }
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__text,
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__count,
.bdg-reveal[open]:not(.bdg-reveal--still) .bdg-reveal__actions { animation: bdgRise 600ms var(--ease-out) 1450ms both; }

@keyframes bdgSpark {
  0%   { opacity: 0; transform: translate(0, 0) scale(.3) rotate(0deg); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--bx), var(--by)) scale(1.1) rotate(70deg); }
}
@keyframes bdgMedalIn { 0% { opacity: 0; transform: scale(.55) rotate(-6deg); } 100% { opacity: 1; transform: none; } }
@keyframes bdgShine { 0% { opacity: 0; transform: translateX(-40%) skewX(-12deg); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateX(330%) skewX(-12deg); } }
@keyframes bdgRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 519px) {
  .bdg-reveal__stage { width: 140px; height: 148px; }
  .bdg-reveal__medal { width: 124px; }
  .bdg-reveal__actions .btn { flex: 1 1 100%; }
}

/* Reduced motion: no movement anywhere — the medal simply appears. */
@media (prefers-reduced-motion: reduce) {
  .bdg, .bdg__img { transition: none !important; }
  .bdg__meter-fill { animation: none !important; }
  .bdg:not(.bdg--locked):hover, .bdg:not(.bdg--locked):active { transform: none !important; }
  .bdg__shine::after, .bdg-reveal__shine::after, .bdg-reveal__burst i { display: none; }
  .bdg-reveal *, .bdg-reveal[open] .confirm__inner { animation: none !important; }
}
