/* =========================================================================
   The profile: a dashboard at the top (streak, today's goal, the next
   award), the achievements cabinet with its 3D medals and unlock ceremony,
   and Apple-Settings-style preferences. Loaded by /progress only.
   js/achievements.js draws the medals; js/progress.js lays out the rest.
   ========================================================================= */

:root {
  --pf-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --pf-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pf-flame-a: #f7a6e5;
  --pf-flame-b: #df44bf;
  --pf-ring-a: #178a4a;
  --pf-ring-b: #2cc56f;
  --pf-tile-pad: clamp(1.1rem, 2.2vw, 1.6rem);
}
[data-theme="dark"] {
  --pf-ring-a: #2fbf6c;
  --pf-ring-b: #74d9a0;
}

/* ------------------------------------------------------------ identity --- */

/* The site's generic section padding is for page bands, not these. */
.progress-page .pg-identity, .progress-page .pf-dash { padding: 0; margin: 0; }

.pg-identity .pf-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.pf-hero .pg-identity-avatar { width: 56px; height: 56px; }
.pf-hero-copy { display: grid; gap: 0.1rem; min-width: 0; }
.pf-hero-copy b { font-size: 1.15rem; letter-spacing: -0.015em; font-weight: 600; }
.pf-hero-copy small { color: var(--ink-faint); font-size: 0.84rem; }
.pf-hero-jump {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  transition: background 0.3s var(--pf-ease), color 0.3s var(--pf-ease);
}
.pf-hero-jump:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.pf-hero-jump svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.6s var(--pf-ease); }
.pf-hero-jump:hover svg { transform: rotate(60deg); }

/* ------------------------------------------------------------- dashboard -- */

.pf-dash {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 14px;
}
.pf-tile {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: var(--pf-tile-pad);
  border-radius: var(--radius-lg);
  background: var(--glass-fill);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-hi), var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  transition: transform 0.6s var(--pf-ease), box-shadow 0.6s var(--pf-ease);
}
.pf-tile:hover { transform: translateY(-2px); }
.pf-tile-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-faint);
}
.pf-tile-label i {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

/* --- the streak ---------------------------------------------------------- */

.pf-streak { grid-row: span 2; display: grid; grid-template-rows: auto 1fr auto auto; }
.pf-streak::before {
  /* The warmth the flame throws on the glass, stronger the longer the run. */
  content: "";
  position: absolute;
  inset: -30% -20% auto auto;
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--pf-flame-a) calc(var(--heat, 0) * 34%), transparent), transparent 66%);
  z-index: -1;
  transition: opacity 1s;
  animation: pfBreathe 5s ease-in-out infinite;
}
@keyframes pfBreathe { 50% { transform: scale(1.12); opacity: 0.75; } }

.pf-streak-main { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2rem); }
.pf-flame {
  position: relative;
  width: clamp(92px, 11vw, 128px);
  aspect-ratio: 0.8;
  flex: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pf-flame svg { width: 100%; height: 100%; overflow: visible; }
.pf-flame path { transform-box: fill-box; transform-origin: 50% 100%; }
.pf-flame .fl-outer { fill: url(#pfFlameOuter); animation: pfFlick 1.6s ease-in-out infinite; }
.pf-flame .fl-mid { fill: url(#pfFlameMid); animation: pfFlick 1.2s ease-in-out -0.4s infinite reverse; }
.pf-flame .fl-core { fill: #fff7fd; opacity: 0.92; animation: pfFlick 0.9s ease-in-out -0.2s infinite; }
@keyframes pfFlick {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  25% { transform: scale(0.97, 1.05) skewX(-2.5deg); }
  50% { transform: scale(1.02, 0.96) skewX(1.5deg); }
  75% { transform: scale(0.98, 1.03) skewX(2.5deg); }
}
/* Unlit: no run going. Grey ember, no flicker, a slow glow at the base. */
.pf-flame.is-out .fl-outer { fill: color-mix(in srgb, var(--ink) 14%, transparent); animation: none; }
.pf-flame.is-out .fl-mid { fill: color-mix(in srgb, var(--ink) 9%, transparent); animation: none; }
.pf-flame.is-out .fl-core { fill: color-mix(in srgb, var(--pf-flame-a) 55%, transparent); animation: pfEmber 2.6s ease-in-out infinite; transform: scale(0.5, 0.35); }
@keyframes pfEmber { 50% { opacity: 0.35; } }
/* At risk: a run that has not been fed today burns low. */
.pf-flame.is-risk .fl-outer, .pf-flame.is-risk .fl-mid { animation-duration: 2.4s; opacity: 0.72; }
.pf-flame.is-risk svg { transform: scale(0.88); transform-origin: 50% 100%; }
/* Poked: the flame flares. */
.pf-flame.is-flare svg { animation: pfFlare 0.7s var(--pf-spring); }
@keyframes pfFlare { 30% { transform: scale(1.14, 1.22); } }
.pf-flame-spark {
  position: absolute;
  left: 50%; bottom: 40%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--pf-flame-a);
  box-shadow: 0 0 8px var(--pf-flame-a);
  pointer-events: none;
  animation: pfSpark 1.1s var(--pf-ease) forwards;
}
@keyframes pfSpark {
  from { transform: translate(-50%, 0) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(0.2); opacity: 0; }
}

.pf-streak-figure { display: grid; gap: 0.15rem; min-width: 0; }
.pf-streak-figure b {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(3.2rem, 7vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.pf-streak-figure > span { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.pf-streak-figure small { color: var(--ink-faint); font-size: 0.82rem; }

.pf-streak-status {
  margin: 1.1rem 0 0.9rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 38ch;
}
.pf-streak-status strong { color: var(--ink); font-weight: 600; }

/* The week: seven Activity rings, today's outlined. */
.pf-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.pf-day { display: grid; justify-items: center; gap: 0.35rem; }
.pf-day svg { width: 100%; max-width: 40px; aspect-ratio: 1; transform: rotate(-90deg); overflow: visible; }
.pf-day circle { fill: none; stroke-width: 4.2; }
.pf-day .d-bg { stroke: color-mix(in srgb, var(--ink) 9%, transparent); }
.pf-day .d-fg {
  stroke: url(#pfRingGrad);
  stroke-linecap: round;
  stroke-dasharray: 75.4;
  stroke-dashoffset: 75.4;
  transition: stroke-dashoffset 1.2s var(--pf-ease) var(--dd, 0s);
}
.pf-day.is-full .d-fg { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--pf-ring-b) 70%, transparent)); }
.pf-day span { font-size: 0.7rem; font-weight: 600; color: var(--ink-faint); letter-spacing: 0.02em; }
.pf-day.is-today span { color: var(--ink); }
.pf-day.is-today svg { outline: 1.5px solid color-mix(in srgb, var(--ink) 20%, transparent); outline-offset: 3px; border-radius: 50%; }
.pf-day.is-future { opacity: 0.35; }
.pf-week-foot { display: flex; justify-content: space-between; margin-top: 0.8rem; font-size: 0.78rem; color: var(--ink-faint); }

/* --- today's goal ---------------------------------------------------------- */

.pf-goal { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.1rem; align-items: center; grid-column: span 2; }
.pf-goal .pf-tile-label { grid-column: 1 / -1; margin-bottom: 0.2rem; }
.pf-ring { position: relative; width: clamp(108px, 12vw, 136px); aspect-ratio: 1; }
.pf-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.pf-ring circle { fill: none; stroke-width: 9; }
.pf-ring .r-bg { stroke: color-mix(in srgb, var(--pf-ring-a) 16%, transparent); }
.pf-ring .r-fg, .pf-ring .r-lap {
  stroke: url(#pfRingGrad);
  stroke-linecap: round;
  stroke-dasharray: 245;
  stroke-dashoffset: 245;
  transition: stroke-dashoffset 1.5s var(--pf-ease) 0.3s;
}
.pf-ring .r-lap { filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.35)); }
.pf-ring-tip {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--turn, 0) * 360deg));
  transition: transform 1.5s var(--pf-ease) 0.3s;
  pointer-events: none;
}
.pf-ring-tip::after {
  content: "";
  position: absolute;
  left: calc(50% - 4.5px);
  top: calc(6.7% - 4.5px);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--pf-ring-b);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--pf-ring-b) 60%, transparent), 2px 0 5px rgba(0, 0, 0, 0.3);
}
.pf-ring[data-empty] .pf-ring-tip { opacity: 0; }
.pf-ring-copy { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.pf-ring-copy b { font-size: 1.55rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.pf-ring-copy small { font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.25rem; }
.pf-ring.is-done .pf-ring-copy b { color: var(--accent); }
.pf-ring.is-done::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--pf-ring-b);
  opacity: 0;
  animation: pfRingPing 2.4s var(--pf-ease) 1.8s 2;
}
@keyframes pfRingPing { from { transform: scale(0.92); opacity: 0.7; } to { transform: scale(1.18); opacity: 0; } }
.pf-goal-copy h3 { margin: 0 0 0.3rem; font-size: 1.15rem; letter-spacing: -0.015em; font-weight: 600; }
.pf-goal-copy p { margin: 0 0 0.9rem; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.45; }
.pf-goal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* --- the next award -------------------------------------------------------- */

.pf-next { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.4rem 1rem; align-items: center; cursor: pointer; }
.pf-next .pf-tile-label { grid-column: 1 / -1; margin-bottom: 0.3rem; }
.pf-next h3 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.pf-next p { margin: 0.15rem 0 0.55rem; font-size: 0.8rem; color: var(--ink-faint); line-height: 1.4; }
.pf-bar { height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.pf-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--pf-ring-a), var(--pf-ring-b)); transition: width 1.3s var(--pf-ease) 0.4s; }
.pf-next-meta { display: flex; justify-content: space-between; margin-top: 0.35rem; font-size: 0.74rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* --- level ----------------------------------------------------------------- */

.pf-level { display: grid; align-content: space-between; cursor: default; }
.pf-level-num { display: flex; align-items: baseline; gap: 0.5rem; }
.pf-level-num b { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.pf-level-num > span { font-size: 0.95rem; font-weight: 600; color: var(--ink-soft); }
.pf-level small { display: block; margin-top: 0.5rem; font-size: 0.76rem; color: var(--ink-faint); }

@media (max-width: 960px) {
  .pf-dash { grid-template-columns: 1fr 1fr; }
  .pf-streak { grid-column: 1 / -1; grid-row: auto; }
  .pf-goal { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .pf-dash { grid-template-columns: 1fr; }
  .pf-goal { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .pf-goal-actions { justify-content: center; }
}

/* ---------------------------------------------------------- achievements -- */

.pf-ach-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pf-ach-count { font-size: 0.86rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pf-ach-count b { color: var(--ink); font-weight: 600; }

.pf-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: clamp(1.4rem, 3vw, 2.2rem) 1rem;
  margin-top: 1.6rem;
}
.pf-award { display: grid; justify-items: center; align-content: start; gap: 0.75rem; text-align: center; }
.pf-award h3 { margin: 0; font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }
.pf-award p { margin: 0.1rem 0 0; font-size: 0.77rem; color: var(--ink-faint); line-height: 1.4; max-width: 18ch; }
.pf-award .pf-award-xp {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.pf-award.is-earned .pf-award-xp { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.pf-award.is-new .pf-award-xp::before { content: "New · "; }

/* --- the medal ------------------------------------------------------------- */

.medal {
  --size: 124px;
  --depth: calc(var(--size) * 0.07);
  position: relative;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  perspective: 900px;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.medal:active { cursor: grabbing; }
.medal:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 50%; }
.medal-3d {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.medal-layer {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.medal-layer svg { width: 100%; height: 100%; display: block; overflow: visible; }
.medal-edge { backface-visibility: visible; }
.medal-back { transform: translateZ(calc(var(--depth) * -1)) rotateY(180deg); }
.medal-back-copy {
  position: absolute;
  inset: 18%;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.2em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.18);
  font-size: calc(var(--size) * 0.085);
  line-height: 1.2;
}
.medal-back-copy b { font-size: 1.25em; font-weight: 700; letter-spacing: -0.01em; }
.medal-back-copy em { font-style: normal; font-weight: 600; opacity: 0.8; }
.medal-shadow {
  position: absolute;
  left: 12%; right: 12%;
  bottom: -12%;
  height: 14%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.28), transparent);
  filter: blur(3px);
  transform: scaleX(var(--shadow-x, 1));
  pointer-events: none;
}
[data-theme="dark"] .medal-shadow { background: radial-gradient(closest-side, rgba(0, 0, 0, 0.7), transparent); }

.medal .emblem { transform-box: fill-box; transform-origin: 50% 50%; }
.medal.is-locked .emblem { opacity: 0.55; }

/* Progress ring around a locked medal. */
.medal-progress {
  position: absolute;
  inset: -9px;
  transform: rotate(-90deg);
  pointer-events: none;
  overflow: visible;
}
.medal-progress circle { fill: none; stroke-width: 2.2; }
.medal-progress .mp-bg { stroke: color-mix(in srgb, var(--ink) 9%, transparent); }
.medal-progress .mp-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: var(--c);
  stroke-dashoffset: var(--c);
  transition: stroke-dashoffset 1.4s var(--pf-ease) 0.5s;
}
.is-in .medal-progress .mp-fg, .medal-progress.is-drawn .mp-fg { stroke-dashoffset: calc(var(--c) * (1 - var(--p, 0))); }

/* An unseen award breathes until it is opened. */
.pf-award.is-new .medal::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 28%, transparent), transparent);
  animation: pfNewGlow 2.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pfNewGlow { 50% { transform: scale(1.12); opacity: 0.45; } }

/* --- each emblem moves in its own way (hover in the shelf, always in the sheet) */

.medal.is-hot .em-key, .ach-sheet .medal .em-key { animation: emKey 2.4s var(--pf-ease) infinite; }
@keyframes emKey { 0%, 15% { transform: rotate(0); } 40%, 70% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

.medal.is-hot .em-check path, .ach-sheet .medal .em-check path { animation: emCheck 2.2s var(--pf-ease) infinite; }
@keyframes emCheck { 0% { stroke-dashoffset: 60; } 45%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -60; } }
.em-check path { stroke-dasharray: 60; }

.medal.is-hot .em-flame, .ach-sheet .medal .em-flame { transform-origin: 50% 100%; animation: pfFlick 0.9s ease-in-out infinite; }

.medal.is-hot .em-lid, .ach-sheet .medal .em-lid { transform-origin: 50% 50%; animation: emBlink 3s ease-in-out infinite; }
.medal.is-hot .em-iris, .ach-sheet .medal .em-iris { animation: emLook 3s ease-in-out infinite; }
@keyframes emBlink { 0%, 44%, 52%, 100% { transform: scaleY(1); } 48% { transform: scaleY(0.08); } }
@keyframes emLook { 0%, 20% { transform: translateX(0); } 30%, 40% { transform: translateX(-3px); } 60%, 70% { transform: translateX(3px); } 85%, 100% { transform: translateX(0); } }

.medal.is-hot .em-crown, .ach-sheet .medal .em-crown { animation: emCrown 2s var(--pf-spring) infinite; }
@keyframes emCrown { 0% { transform: translateY(-6px); opacity: 0.4; } 30%, 100% { transform: translateY(0); opacity: 1; } }
.medal.is-hot .em-jewel, .ach-sheet .medal .em-jewel { animation: emTwinkle 1.6s ease-in-out infinite; }
.em-jewel:nth-of-type(2) { animation-delay: 0.3s !important; }
.em-jewel:nth-of-type(3) { animation-delay: 0.6s !important; }
@keyframes emTwinkle { 50% { opacity: 0.35; } }

.medal.is-hot .em-star, .ach-sheet .medal .em-star { animation: emStar 2.6s var(--pf-ease) infinite; }
@keyframes emStar { 0% { transform: rotate(0) scale(1); } 35% { transform: rotate(144deg) scale(1.12); } 60%, 100% { transform: rotate(144deg) scale(1); } }
.medal.is-hot .em-sparkle, .ach-sheet .medal .em-sparkle { animation: emTwinkle 1.3s ease-in-out infinite; }

/* ------------------------------------------------- the sheet / ceremony --- */

.ach-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.ach-scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  opacity: 0;
  transition: opacity 0.5s var(--pf-ease);
}
[data-theme="dark"] .ach-scrim { background: rgba(8, 8, 10, 0.62); }
.ach-sheet.is-open .ach-scrim { opacity: 1; }

.ach-stage {
  position: relative;
  display: grid;
  justify-items: center;
  text-align: center;
  width: min(440px, 100%);
  padding: 1rem 0 0;
}
.ach-rays {
  position: absolute;
  top: calc(var(--big) / 2 - 260px);
  left: 50%;
  width: 520px;
  height: 520px;
  margin-left: -260px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--hue-a, var(--accent)) 30%, transparent) 0deg 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(closest-side, #000 18%, transparent 100%);
  mask: radial-gradient(closest-side, #000 18%, transparent 100%);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 1s var(--pf-ease), transform 1.4s var(--pf-ease);
  animation: achSpin 40s linear infinite;
  pointer-events: none;
}
@keyframes achSpin { to { rotate: 360deg; } }
.ach-sheet.is-landed .ach-rays { opacity: 1; transform: scale(1); }
.ach-sheet.is-locked .ach-rays { display: none; }
.ach-sparks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ach-sparks-host { position: fixed; inset: 0; pointer-events: none; z-index: 1; }

.ach-medal-slot { --big: min(260px, 62vw); position: relative; width: var(--big); height: var(--big); margin-bottom: 1.8rem; z-index: 2; }
.ach-medal-slot .medal { --size: var(--big); }
.ach-stage { --big: min(260px, 62vw); }

.ach-copy { position: relative; z-index: 2; display: grid; justify-items: center; gap: 0.4rem; }
.ach-kicker { margin: 0; font-size: 0.82rem; font-weight: 600; color: var(--accent); letter-spacing: -0.005em; }
.ach-title { margin: 0; font-size: clamp(1.8rem, 5vw, 2.3rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.ach-detail { margin: 0; color: var(--ink-soft); font-size: 0.98rem; max-width: 30ch; }
.ach-reward {
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.05rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ach-reward .mx-odo { font-size: 1.05rem; }
.ach-when { font-size: 0.8rem; color: var(--ink-faint); }
.ach-progress { width: min(240px, 70vw); margin-top: 0.6rem; }
.ach-hint {
  display: flex; align-items: center; gap: 0.4rem;
  margin: 1.2rem 0 0; font-size: 0.75rem; color: var(--ink-faint);
}
.ach-hint svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; animation: achNudge 2.4s ease-in-out infinite; }
@keyframes achNudge { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
.ach-actions { display: flex; gap: 0.6rem; margin-top: 1.3rem; }
.ach-actions .btn { min-width: 9rem; }
.ach-pager { display: flex; gap: 6px; margin-top: 1rem; }
.ach-pager i { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background 0.3s, width 0.4s var(--pf-ease); }
.ach-pager i.is-on { width: 18px; border-radius: 3px; background: var(--ink); }

/* Copy rises in once the medal lands. */
.ach-copy > * { opacity: 0; transform: translateY(10px); filter: blur(6px); transition: opacity 0.7s var(--pf-ease), transform 0.7s var(--pf-ease), filter 0.7s var(--pf-ease); }
.ach-sheet.is-landed .ach-copy > * { opacity: 1; transform: none; filter: none; }
.ach-sheet.is-landed .ach-copy > *:nth-child(2) { transition-delay: 0.08s; }
.ach-sheet.is-landed .ach-copy > *:nth-child(3) { transition-delay: 0.16s; }
.ach-sheet.is-landed .ach-copy > *:nth-child(4) { transition-delay: 0.24s; }
.ach-sheet.is-landed .ach-copy > *:nth-child(5) { transition-delay: 0.32s; }
.ach-sheet.is-landed .ach-copy > *:nth-child(n+6) { transition-delay: 0.4s; }

.ach-medal-slot { transition: transform 0.9s var(--pf-spring), opacity 0.4s; }
.ach-sheet.is-closing .ach-scrim { opacity: 0; }
.ach-sheet.is-closing .ach-stage { opacity: 0; transform: scale(0.96); transition: opacity 0.3s, transform 0.3s; }

/* --------------------------------------------------------------- settings -- */

.pf-settings { display: grid; gap: 1.4rem; max-width: 720px; }
.pf-group-label { margin: 0 0 0.45rem 1rem; font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); letter-spacing: -0.005em; }
.pf-group-foot { margin: 0.45rem 1rem 0; font-size: 0.76rem; color: var(--ink-faint); line-height: 1.45; }
.pf-group {
  border-radius: var(--radius-lg);
  background: var(--glass-fill);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-hi), var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  overflow: hidden;
}
.pf-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 56px;
  padding: 0.65rem 1rem;
  position: relative;
}
.pf-row + .pf-row::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  left: 3.6rem;
  border-top: 1px solid var(--line);
}
.pf-row-icon {
  width: 30px; height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ic, #8e8e93);
}
.pf-row-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pf-row-text { display: grid; gap: 0.05rem; min-width: 0; flex: 1; }
.pf-row-text b { font-size: 0.94rem; font-weight: 500; letter-spacing: -0.01em; }
.pf-row-text small { font-size: 0.76rem; color: var(--ink-faint); }
.pf-row input[type="text"] {
  width: min(220px, 42vw);
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  text-align: right;
  transition: background 0.3s, box-shadow 0.3s;
}
.pf-row input[type="text"]:focus { outline: 0; background: var(--paper-raised); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); text-align: left; }
.pf-row--button { cursor: pointer; border: 0; width: 100%; background: none; font: inherit; color: inherit; text-align: left; transition: background 0.2s; }
.pf-row--button:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.pf-row--danger b { color: var(--danger); }

/* iOS switch. */
.pf-switch { position: relative; width: 51px; height: 31px; flex: none; }
.pf-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.pf-switch i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 14%, transparent);
  transition: background 0.3s var(--pf-ease);
}
.pf-switch i::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.4s var(--pf-spring), width 0.25s var(--pf-ease);
}
.pf-switch input:active + i::after { width: 33px; }
.pf-switch input:checked + i { background: #34c759; }
.pf-switch input:checked + i::after { transform: translateX(20px); }
.pf-switch input:checked:active + i::after { transform: translateX(14px); }
.pf-switch input:focus-visible + i { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }

/* Segmented control (thumb comes from Motion.segmented). */
.pf-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  flex: none;
}
.pf-seg button {
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.3s;
}
.pf-seg:not(.mx-seg) button[aria-pressed="true"] { background: var(--paper-raised); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }
.pf-seg button[aria-pressed="false"] { color: var(--ink-soft); }
.pf-row--stack { flex-wrap: wrap; }
@media (max-width: 600px) {
  .pf-row--stack .pf-seg { width: 100%; margin-left: 3.6rem; }
  .pf-row--stack .pf-seg { width: calc(100% - 3.6rem); }
  .pf-row--stack .pf-seg button { flex: 1; padding-inline: 0.3rem; }
}

.pf-saved {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem 0.6rem 0.75rem;
  border-radius: 14px;
  background: var(--glass-solid);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  font-size: 0.86rem;
  font-weight: 600;
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform 0.55s var(--pf-spring), opacity 0.3s;
  pointer-events: none;
}
.pf-saved.is-on { transform: translate(-50%, 0); opacity: 1; }
.pf-saved svg { width: 18px; height: 18px; fill: none; stroke: #34c759; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pf-saved path { stroke-dasharray: 24; stroke-dashoffset: 24; }
.pf-saved.is-on path { animation: pfDraw 0.5s var(--pf-ease) 0.15s forwards; }
@keyframes pfDraw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .pf-flame path, .pf-streak::before, .ach-rays, .medal .emblem, .medal *, .pf-award.is-new .medal::before { animation: none !important; }
}
.pf-next-medal { display: grid; margin: 4px 4px 0 8px; }

/* A medal at rest is flat vector art (crisp at any screen scale); it only
   becomes a 3D stack while it is tilted or spinning. */
.medal.is-rest .medal-3d { transform: none !important; transform-style: flat; }
.medal.is-rest .medal-edge, .medal.is-rest .medal-back { display: none; }
/* Entrance blur on an ancestor of 3D layers lowers their raster resolution
   on some GPUs; the shelf and the dashboard rise without it. */
.pf-shelf > *, .pf-dash > * { filter: none !important; }

/* --- the second shelf of emblems, each with its own motion -------------- */
/* Same rule as the first six: they move on hover in the shelf and loop in
   the sheet. Every keyframe rests on the drawn pose, so a still medal reads. */

:is(.medal.is-hot, .ach-sheet .medal) .em-page { transform-origin: 0% 50%; animation: emPage 2.6s var(--pf-ease) infinite; }
@keyframes emPage { 0%, 20% { transform: scaleX(1); } 45%, 60% { transform: scaleX(-1); opacity: .6; } 85%, 100% { transform: scaleX(1); } }

:is(.medal.is-hot, .ach-sheet .medal) .em-l2 { animation: emLayer 2.4s var(--pf-spring) .12s infinite; }
:is(.medal.is-hot, .ach-sheet .medal) .em-l3 { animation: emLayer 2.4s var(--pf-spring) .24s infinite; }
:is(.medal.is-hot, .ach-sheet .medal) .em-l1 { animation: emLayerTop 2.4s var(--pf-spring) infinite; }
@keyframes emLayer { 0% { transform: translateY(-7px); opacity: 0; } 30%, 100% { transform: none; opacity: 1; } }
@keyframes emLayerTop { 0% { transform: translateY(-5px); } 25%, 100% { transform: none; } }

:is(.medal.is-hot, .ach-sheet .medal) .em-cloth { transform-origin: 0% 50%; animation: emWave 1.4s ease-in-out infinite; }
@keyframes emWave { 0%, 100% { transform: skewY(0) scaleX(1); } 25% { transform: skewY(-5deg) scaleX(.96); } 75% { transform: skewY(4deg) scaleX(1.02); } }

:is(.medal.is-hot, .ach-sheet .medal) .em-bolt { animation: emBolt 2.2s ease-out infinite; }
@keyframes emBolt { 0%, 30%, 100% { transform: scale(1); opacity: 1; } 34% { transform: scale(1.14); opacity: .35; } 38% { opacity: 1; } 42% { opacity: .5; } 48% { transform: scale(1); opacity: 1; } }

.em-week .em-d { opacity: .35; }
.pf-award.is-earned .em-week .em-d, .ach-sheet .em-week .em-d { opacity: 1; }
:is(.medal.is-hot, .ach-sheet .medal) .em-week .em-d { animation: emTick 2.8s ease-out calc(var(--n) * .16s) infinite; }
@keyframes emTick { 0% { opacity: .3; transform: scale(.6); } 12%, 85% { opacity: 1; transform: scale(1); } 100% { opacity: .3; } }
.em-d, .em-c, .em-leaf { transform-box: fill-box; transform-origin: 50% 50%; }

:is(.medal.is-hot, .ach-sheet .medal) .em-sun { animation: emSun 3s var(--pf-ease) infinite; }
@keyframes emSun { 0% { transform: translateY(14px); opacity: 0; } 35%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; transform: translateY(-2px); } }

:is(.medal.is-hot, .ach-sheet .medal) .em-c { animation: emCell 2.6s ease-out calc(var(--n) * .12s) infinite; }
@keyframes emCell { 0% { opacity: .25; transform: scale(.55); } 14%, 80% { opacity: 1; transform: scale(1); } 100% { opacity: .25; } }

:is(.medal.is-hot, .ach-sheet .medal) .em-arrow { animation: emArrow 2.4s var(--pf-ease) infinite; }
@keyframes emArrow {
  0% { transform: translate(14px, -14px); opacity: 0; }
  22% { transform: translate(0, 0); opacity: 1; }
  27% { transform: translate(1.4px, -1.4px); }
  32% { transform: translate(-.6px, .6px); }
  37%, 100% { transform: none; opacity: 1; }
}

:is(.medal.is-hot, .ach-sheet .medal) .em-swirl { transform-origin: 50% 50%; animation: emTwinkleSpin 2.4s ease-in-out infinite; }
@keyframes emTwinkleSpin { 0%, 100% { transform: rotate(0) scale(1); opacity: 1; } 50% { transform: rotate(45deg) scale(.82); opacity: .6; } }
@keyframes emSwirl { to { transform: rotate(360deg); } }
:is(.medal.is-hot, .ach-sheet .medal) .em-orb { animation: emGlow 3s ease-in-out infinite; }
@keyframes emGlow { 50% { opacity: .8; } }

:is(.medal.is-hot, .ach-sheet .medal) .em-sa { transform-origin: 90% 90%; animation: emClashA 2.2s var(--pf-spring) infinite; }
:is(.medal.is-hot, .ach-sheet .medal) .em-sb { transform-origin: 10% 90%; animation: emClashB 2.2s var(--pf-spring) infinite; }
@keyframes emClashA { 0% { transform: rotate(-28deg); } 30%, 100% { transform: rotate(0); } }
@keyframes emClashB { 0% { transform: rotate(28deg); } 30%, 100% { transform: rotate(0); } }

/* The king topples: a giant, slain. */
:is(.medal.is-hot, .ach-sheet .medal) .em-piece { transform-origin: 85% 100%; animation: emTopple 3s var(--pf-ease) infinite; }
@keyframes emTopple { 0%, 15% { transform: rotate(0); } 45%, 70% { transform: rotate(72deg) translateY(2px); opacity: .85; } 90%, 100% { transform: rotate(0); opacity: 1; } }

:is(.medal.is-hot, .ach-sheet .medal) .em-gem { animation: emGem 2.4s var(--pf-ease) infinite; }
@keyframes emGem { 0%, 100% { transform: scale(1); } 20% { transform: scale(1.08); } 40% { transform: scale(1); } }
:is(.medal.is-hot, .ach-sheet .medal) .em-glint { transform-origin: 50% 50%; animation: emGlint 2.4s ease-in-out infinite; }
@keyframes emGlint { 0%, 15% { transform: scale(0) rotate(0); opacity: 0; } 30% { transform: scale(1.2) rotate(45deg); opacity: 1; } 55%, 100% { transform: scale(0) rotate(90deg); opacity: 0; } }

:is(.medal.is-hot, .ach-sheet .medal) .em-leaf { animation: emLeaf 3s var(--pf-spring) calc(var(--n) * .1s) infinite; }
@keyframes emLeaf { 0% { transform: scale(0); } 25%, 100% { transform: scale(1); } }
:is(.medal.is-hot, .ach-sheet .medal) .em-core { transform-origin: 50% 50%; animation: emStar 3s var(--pf-ease) .6s infinite; }

/* --- locked: gray labels, so what you have and what you are chasing read
   apart at a glance (the medal itself is already graphite) --------------- */
.pf-award:not(.is-earned) h3 { color: var(--ink-faint); }
.pf-award:not(.is-earned) p { color: color-mix(in srgb, var(--ink-faint) 80%, transparent); }
.pf-award:not(.is-earned) .pf-award-xp { color: var(--ink-faint); border-color: color-mix(in srgb, var(--ink) 8%, transparent); }
.ach-sheet.is-locked .ach-kicker { color: var(--ink-faint); }
.ach-sheet.is-locked .ach-title { color: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  .medal [class^="em-"], .medal [class*=" em-"] { animation: none !important; }
}
.medal [class^="em-"], .medal [class*=" em-"] { transform-box: fill-box; }
