/* ── Лояльность (loyalty.js) ─────────────────────────────────────────────
   Hero = the night sky over the globe: fixed navy and ember on purpose, like the
   gift cards — it is an object and looks the same in every mood. Medals are
   fixed metals. Everything else (cards, tiers, bars) runs on tokens. */

.ly-head { flex-wrap: wrap; }
.ly-seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-pill);
  background: var(--elevated); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.ly-seg button {
  border: none; background: none; cursor: pointer; white-space: nowrap;
  padding: 7px 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--ink-2);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.ly-seg button:hover { color: var(--ink); }
.ly-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ── Hero ── */
.ly-hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.25fr) 220px; gap: 8px 28px;
  padding: 30px 32px 26px; margin-bottom: 18px; border-radius: var(--r-xl);
  color: #f6efe3;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(232, 118, 63, 0.38), transparent 55%),
    radial-gradient(80% 120% at 0% 100%, rgba(62, 95, 180, 0.45), transparent 60%),
    linear-gradient(160deg, #26304f 0%, #1b2340 60%, #151b33 100%);
  box-shadow: 0 30px 60px -36px rgba(21, 27, 51, 0.8);
}
/* Stars */
.ly-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 68%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 18%, #ffe2c7 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 82%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 34%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 86% 74%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 93% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 88%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 44%, #fff 50%, transparent 51%);
}
.ly-hero-main { min-width: 0; }
.ly-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: rgba(246, 239, 227, .7); }
.ly-hero-km { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 4px; }
.ly-count {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(40px, 6vw, 68px);
  line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff 30%, #ffd2ae 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ly-hero-unit { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: #ffb37a; }
.ly-hero-laps { font-size: 15px; color: rgba(246, 239, 227, .86); }
.ly-moon { margin-top: 20px; max-width: 520px; }
.ly-moon-track { height: 8px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .12); overflow: hidden; }
.ly-moon-fill {
  height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, #7fb8ff, #ffb37a 70%, #ffe6b8);
  box-shadow: 0 0 12px rgba(255, 179, 122, .7);
}
.ly-moon-cap { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 12px; color: rgba(246, 239, 227, .65); }
.ly-moon-cap span:nth-child(2) { color: #ffd2ae; font-weight: 600; text-align: center; }
.ly-hero-note { margin-top: 10px; font-size: 12px; color: rgba(246, 239, 227, .55); }

.ly-orbit { grid-row: span 2; align-self: center; position: relative; }
.ly-orbit svg { display: block; width: 100%; height: auto; overflow: visible; }
.ly-orbit-ring { fill: none; stroke: rgba(255, 255, 255, .16); stroke-width: 1.5; stroke-dasharray: 2 5; }
.ly-orbit-trail { fill: none; stroke-width: 3.5; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(255, 150, 90, .7)); }
.ly-earth-grid { fill: none; stroke: rgba(255, 255, 255, .18); stroke-width: .8; }
.ly-earth-shine { fill: none; stroke: rgba(255, 255, 255, .25); stroke-width: 1; }
.ly-plane { fill: #fff; filter: drop-shadow(0 0 4px rgba(255, 200, 150, .9)); }
.ly-plane-halo { fill: rgba(255, 179, 122, .22); animation: ly-pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ly-pulse { 50% { transform: scale(1.5); opacity: .3; } }
.ly-orbit-cap { text-align: center; margin-top: 2px; font-size: 12px; color: rgba(246, 239, 227, .6); }

.ly-hero-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-self: end; margin-top: 16px; }
.ly-kpi {
  padding: 12px 14px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(6px);
}
.ly-kpi-label { font-size: 12px; color: rgba(246, 239, 227, .65); }
.ly-kpi-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: #fff; }
.ly-kpi-sub { font-size: 11.5px; color: rgba(246, 239, 227, .55); line-height: 1.35; }
.ly-kpi.is-hot { background: rgba(232, 118, 63, .2); border-color: rgba(255, 179, 122, .35); }
.ly-kpi.is-hot .ly-kpi-value { color: #ffc195; }

/* ── Cards ── */
.ly-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.ly-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg); padding: 20px; min-width: 0; }
.ly-card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ly-card-head h3 { margin: 0; }
.ly-card-sub { font-size: 12.5px; color: var(--subtle); }

/* ── Podium ── */
.ly-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; padding-top: 8px; }
.ly-step { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.ly-step-who { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding-bottom: 10px; min-width: 0; max-width: 100%; position: relative; }
.ly-gold   { --metal: linear-gradient(135deg, #fff1b8, #e8b93c 45%, #b8841a); --metal-tone: #e3b23c; --metal-ink: #8a5f0c; --h: 118px; }
.ly-silver { --metal: linear-gradient(135deg, #ffffff, #c9cfdc 45%, #8b94a8); --metal-tone: #a9b1c4; --metal-ink: #5b6378; --h: 86px; }
.ly-bronze { --metal: linear-gradient(135deg, #ffd9bd, #d08a55 45%, #96572a); --metal-tone: #cd8752; --metal-ink: #7a4219; --h: 64px; }
.ly-medal-ring { padding: 3px; border-radius: 50%; background: var(--metal); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .45); }
.ly-medal-ring .ly-ava { border: 3px solid var(--surface); }
.ly-crown { position: absolute; top: -20px; font-size: 22px; animation: ly-bob 3s ease-in-out infinite; }
@keyframes ly-bob { 50% { transform: translateY(-3px) rotate(-6deg); } }
.ly-gold .ly-ava-lg { width: 84px; height: 84px; font-size: 26px; }
.ly-step-name {
  margin-top: 6px; font-weight: 600; color: var(--ink); text-decoration: none; max-width: 100%; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
a.ly-step-name:hover { color: var(--accent-ink); }
.ly-step-val { font-size: 12.5px; color: var(--subtle); white-space: nowrap; }
.ly-step-val b { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
.ly-step-meta { font-size: 11.5px; color: var(--subtle); }
.ly-step-block {
  width: 100%; height: var(--h); border-radius: var(--r-md) var(--r-md) 4px 4px;
  background:
    linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .35) 45%, transparent 60%) no-repeat,
    linear-gradient(180deg, color-mix(in srgb, var(--metal-tone) 34%, var(--surface)), color-mix(in srgb, var(--metal-tone) 8%, var(--surface)));
  background-size: 250% 100%, auto;
  border: 1px solid color-mix(in srgb, var(--metal-tone) 45%, transparent); border-bottom: none;
  display: flex; justify-content: center; padding-top: 10px; position: relative; overflow: hidden;
}
.ly-step-block::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--metal); }
.ly-step-block span {
  font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1;
  color: color-mix(in srgb, var(--metal-ink) 55%, var(--ink));
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
}
/* A light sweep across the metal, once on entrance and on hover. */
.ly-step:hover .ly-step-block { animation: ly-shine 1.1s ease both; }
@keyframes ly-shine { from { background-position: 120% 0, 0 0; } to { background-position: -120% 0, 0 0; } }
/* Empty seat: dashed, quiet, still the right height. */
.ly-step.is-empty .ly-step-block { background: var(--paper-2); border-style: dashed; border-color: var(--stroke); }
.ly-step.is-empty .ly-step-block::before { opacity: .35; }
.ly-step.is-empty .ly-step-block span { color: var(--subtle); text-shadow: none; opacity: .6; }
.ly-medal-ring.is-empty { background: none; border: 2px dashed var(--stroke); box-shadow: none; padding: 2px; }
.ly-ava.ly-ava-empty { background: var(--paper-2); color: var(--subtle); }
.ly-step-name.is-empty { color: var(--subtle); font-weight: 500; }

/* ── Avatars ── */
.ly-ava {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff; font-weight: 600; font-size: 13px; overflow: hidden;
}
.ly-ava img { width: 100%; height: 100%; object-fit: cover; }
.ly-ava-lg { width: 64px; height: 64px; font-size: 20px; font-family: var(--font-display); }

/* ── Tiers (token colours, so moods repaint them) ── */
.ly-t-first  { --tc: var(--green); --tw: var(--green-weak); }
.ly-t-back   { --tc: var(--blue);  --tw: var(--blue-weak); }
.ly-t-own    { --tc: var(--amber); --tw: var(--amber-weak); }
.ly-t-legend { --tc: var(--accent); --tw: var(--accent-weak); }
.ly-stack { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; gap: 2px; margin-bottom: 14px; background: var(--paper-2); }
.ly-stack-seg { width: var(--w); background: var(--tc); min-width: 6px; }
.ly-tiers { display: grid; gap: 8px; }
.ly-tier {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 10px 14px 10px 10px; cursor: pointer;
  background: var(--paper-2); border: 1px solid transparent; border-radius: var(--r-md); color: var(--ink);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.ly-tier:hover:not(:disabled) { border-color: color-mix(in srgb, var(--tc) 40%, transparent); transform: translateX(2px); }
.ly-tier.on { background: var(--tw); border-color: var(--tc); }
.ly-tier:disabled { opacity: .5; cursor: default; }
.ly-tier-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--tw); }
.ly-tier-body { display: flex; flex-direction: column; min-width: 0; }
.ly-tier-name { font-weight: 600; }
.ly-tier-hint { font-size: 12px; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ly-tier-num { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.ly-tier-num b { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--tc); font-variant-numeric: tabular-nums; }
.ly-tier-num small { font-size: 11.5px; color: var(--subtle); }

/* ── Ranking ── */
.ly-filter-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; cursor: pointer;
  border: 1px solid var(--tc); background: var(--tw); color: var(--ink); border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600;
}
.ly-list { list-style: none; padding: 0; margin: 0; }
.ly-row {
  display: grid; grid-template-columns: 34px 36px minmax(140px, 1.1fr) minmax(160px, 1.4fr) minmax(0, 1.3fr);
  align-items: center; gap: 14px; padding: 10px 8px; border-bottom: 1px solid var(--divider); border-radius: var(--r-sm);
  transition: background .12s ease;
}
.ly-row:last-child { border-bottom: none; }
.ly-row:hover { background: var(--paper-2); }
.ly-rank { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--subtle); text-align: center; font-variant-numeric: tabular-nums; }
.ly-top-1 .ly-rank { color: #c9961f; }
.ly-top-2 .ly-rank { color: #8b94a8; }
.ly-top-3 .ly-rank { color: #b0703f; }
.ly-who { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.ly-name { font-weight: 600; color: var(--ink); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ly-name:hover { color: var(--accent-ink); }
.ly-tier-chip { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: var(--r-pill); background: var(--tw); color: var(--tc); white-space: nowrap; }
.ly-bar-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ly-bar { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--paper-2); overflow: hidden; min-width: 40px; }
.ly-bar-fill { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent)); }
.ly-top-1 .ly-bar-fill { background: linear-gradient(90deg, #f3cf6a, #d9a024); }
.ly-top-2 .ly-bar-fill { background: linear-gradient(90deg, #dfe3ec, #9aa2b5); }
.ly-top-3 .ly-bar-fill { background: linear-gradient(90deg, #f0b98e, #c07a45); }
.ly-bar-val { font-size: 12.5px; color: var(--subtle); white-space: nowrap; min-width: 92px; }
.ly-bar-val b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ly-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ly-meta span { white-space: nowrap; }
.ly-more { display: block; margin: 12px auto 0; }

.ly-empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--stroke); border-radius: var(--r-xl); }
.ly-empty-art { font-size: 44px; margin-bottom: 8px; }
.ly-empty h3 { margin-bottom: 6px; }

/* ── Entrance ── */
.ly-in .ly-hero, .ly-in .ly-card { animation: ly-rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.ly-in .ly-grid .ly-card:nth-child(2) { animation-delay: .06s; }
.ly-in .ly-list-card { animation-delay: .12s; }
@keyframes ly-rise { from { opacity: 0; transform: translateY(10px); } }
.ly-in .ly-step-block { animation: ly-grow .7s cubic-bezier(.2, .8, .2, 1) both, ly-shine 1.2s ease .7s both; transform-origin: bottom; }
.ly-in .ly-silver .ly-step-block { animation-delay: .1s, .8s; }
.ly-in .ly-bronze .ly-step-block { animation-delay: .18s, .88s; }
@keyframes ly-grow { from { transform: scaleY(0); } }
.ly-in .ly-bar-fill, .ly-in .ly-moon-fill, .ly-in .ly-stack-seg { animation: ly-fill .9s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes ly-fill { from { width: 0; } }
.ly-in .ly-orbit-trail { animation: ly-trail 1.2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes ly-trail { from { stroke-dasharray: 0 var(--c); } }
@media (prefers-reduced-motion: reduce) {
  .ly-plane-halo, .ly-crown, .ly-step:hover .ly-step-block { animation: none; }
}

/* ── Smaller screens ── */
@media (max-width: 1180px) {
  .ly-grid { grid-template-columns: minmax(0, 1fr); }
  .ly-row { grid-template-columns: 30px 36px minmax(0, 1fr) minmax(0, 1.2fr); }
  .ly-meta { grid-column: 3 / -1; }
}
@media (max-width: 760px) {
  .ly-hero { grid-template-columns: minmax(0, 1fr) 120px; padding: 22px 18px 18px; gap: 8px 12px; }
  .ly-orbit { grid-row: 1; grid-column: 2; align-self: start; }
  .ly-hero-kpis { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ly-hero-unit { font-size: 16px; }
  .ly-row { grid-template-columns: 26px 36px minmax(0, 1fr); gap: 4px 10px; }
  .ly-bar-wrap, .ly-meta { grid-column: 3 / -1; }
  .ly-bar-val { min-width: 0; }
  .ly-gold .ly-ava-lg { width: 64px; height: 64px; }
  .ly-ava-lg { width: 50px; height: 50px; font-size: 16px; }
  .ly-step-val b { font-size: 15px; }
  .ly-step-meta { display: none; }
  .ly-step-name { font-size: 13px; }
  .ly-moon-cap { font-size: 11px; }
  .ly-moon-cap { flex-wrap: wrap; row-gap: 2px; }
  .ly-moon-cap span:nth-child(2) { order: -1; flex-basis: 100%; text-align: left; font-size: 12px; }
  .ly-gold { --h: 84px; } .ly-silver { --h: 62px; } .ly-bronze { --h: 46px; }
}
