/* LeadGo State Animations — styles for <lg-state>.
   Theme with CSS variables on lg-state (or any ancestor). Set --lg-card to the background
   color the state sits on — it is used to "cut" gaps in the line art. */

lg-state {
  --lg-brand: #ff385c;
  --lg-ink: #16161a;
  --lg-text: #16161a;
  --lg-muted: #6b6b76;
  --lg-soft: #efeff3;
  --lg-border: #dcdce3;
  --lg-card: #ffffff;
  --lg-success: #12b76a;
  --lg-accent: var(--lg-brand);
  --lg-art-size: 200px;
  --lg-intro: 1.1s;
  --lg-ease: cubic-bezier(.65, 0, .35, 1);

  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 24px 16px;
  color: var(--lg-text);
  box-sizing: border-box;
}

lg-state[data-family="success"] { --lg-accent: var(--lg-success); }

lg-state[theme="dark"],
.lg-theme-dark lg-state {
  --lg-ink: #f4f4f6;
  --lg-text: #f4f4f6;
  --lg-muted: #a3a3ad;
  --lg-soft: #26262e;
  --lg-border: #3a3a44;
  --lg-card: #16161a;
}

lg-state[size="sm"] { --lg-art-size: 128px; gap: 10px; padding: 16px 12px; }
lg-state[size="lg"] { --lg-art-size: 280px; }

lg-state[layout="row"] {
  --lg-art-size: 112px;
  flex-direction: row;
  text-align: left;
  justify-content: center;
  gap: 20px;
}
lg-state[layout="row"] .lg-state__actions { justify-content: flex-start; }

/* ---------- Text & actions ---------- */

.lg-state__art { width: var(--lg-art-size); max-width: 100%; aspect-ratio: 200 / 160; flex: none; }
.lg-state__art svg { display: block; width: 100%; height: 100%; overflow: visible; }

.lg-state__body {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: lgs-rise .5s ease-out .3s both;
}
.lg-state__code { font-size: 12px; font-weight: 700; letter-spacing: .1em; color: var(--lg-brand); }
.lg-state__title { font-size: 18px; font-weight: 650; line-height: 1.3; }
.lg-state__msg { margin: 0; font-size: 14px; line-height: 1.55; color: var(--lg-muted); }
lg-state[size="sm"] .lg-state__title { font-size: 15px; }
lg-state[size="sm"] .lg-state__msg { font-size: 13px; }

.lg-state__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.lg-state__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s, filter .15s, background .15s;
}
.lg-state__btn:active { transform: scale(.97); }
.lg-state__btn--primary { background: var(--lg-brand); color: #fff; border: 1px solid transparent; }
.lg-state__btn--primary:hover { filter: brightness(.94); }
.lg-state__btn--secondary { background: transparent; color: var(--lg-text); border: 1px solid var(--lg-border); }
.lg-state__btn--secondary:hover { background: var(--lg-soft); }
.lg-state__btn:focus-visible { outline: 2px solid var(--lg-brand); outline-offset: 2px; }

.lg-state__progress {
  width: 240px;
  max-width: 100%;
  height: 6px;
  margin: 10px auto 0;
  border-radius: 99px;
  background: var(--lg-soft);
  overflow: hidden;
}
lg-state[layout="row"] .lg-state__progress { margin-left: 0; }
.lg-state__progress > span { display: block; height: 100%; border-radius: inherit; background: var(--lg-brand); transition: width .4s ease; }
.lg-state__progress.is-indeterminate > span { animation: lgs-indet 1.4s var(--lg-ease) infinite; }
.lg-state__pct { font-size: 12px; color: var(--lg-muted); font-variant-numeric: tabular-nums; }

/* ---------- Line art ---------- */

.lg-art * { transform-box: fill-box; transform-origin: center; }
.lg-art path, .lg-art rect, .lg-art circle, .lg-art ellipse {
  fill: none;
  stroke: var(--lg-ink);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lg-art .a { stroke: var(--lg-accent); }
.lg-art .b { stroke: var(--lg-brand); }
.lg-art .af { fill: var(--lg-accent); stroke: none; }
.lg-art .bf { fill: var(--lg-brand); stroke: none; }
.lg-art .kf { fill: var(--lg-ink); stroke: none; }
.lg-art .cf { fill: var(--lg-card); stroke: none; }
.lg-art .cfs { fill: var(--lg-card); }
.lg-art .cut { stroke: var(--lg-card); stroke-width: 17; }
.lg-art .sh, .lg-art .gb { fill: var(--lg-soft); stroke: none; }
.lg-art .ghost { stroke: var(--lg-soft); }
.lg-art .thin { stroke-width: 4.5; }
.lg-art .thin2 { stroke-width: 5.5; }
.lg-art .wst { stroke: #fff; stroke-width: 4; }
.lg-art .ring { stroke: var(--lg-card); stroke-width: 4; }
.lg-art .dashy { stroke-width: 5.5; }
.lg-art .logo-track { stroke: var(--lg-soft); stroke-width: 30; }
.lg-art .i-logo { stroke-width: 30; }

/* Intro: draw · pop · fade */
.lg-art .d {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: lgs-draw .8s var(--lg-ease) calc(var(--i, 0) * .11s + .05s) both;
}
.lg-art .f { animation: lgs-pop .45s cubic-bezier(.34, 1.56, .64, 1) calc(var(--i, 0) * .11s + .1s) both; }
.lg-art .fade { animation: lgs-fade .5s ease calc(var(--i, 0) * .11s + .1s) both; }

@keyframes lgs-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes lgs-pop  { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes lgs-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lgs-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes lgs-indet { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* Idle loops (start after the intro) */
.lg-art .i-bob     { animation: lgs-bob 3.2s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-shadow  { animation: lgs-shadow 3.2s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-shake   { animation: lgs-shake 2.8s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-wobble  { animation: lgs-wobble 3s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-blink   { animation: lgs-blink 3.6s linear var(--lg-intro) infinite both; }
.lg-art .i-wave    { animation: lgs-wave 1.8s ease-in-out calc(var(--lg-intro) + var(--k, 0) * .22s) infinite both; }
.lg-art .i-shimmer { animation: lgs-wave 1.6s ease-in-out calc(var(--lg-intro) + var(--k, 0) * .18s) infinite both; }
.lg-art .i-pulse   { animation: lgs-pulse 1.8s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-led     { animation: lgs-led 1.2s steps(1) calc(var(--lg-intro) + var(--k, 0) * .6s) infinite both; }
.lg-art .i-flicker { animation: lgs-flicker 2.8s linear var(--lg-intro) infinite both; }
.lg-art .i-spin    { animation: lgs-spin 1.4s linear var(--lg-intro) infinite both; }
.lg-art .i-spin-pause { animation: lgs-spin-pause 2.6s var(--lg-ease) var(--lg-intro) infinite both; }
.lg-art .i-scan    { animation: lgs-scan 3.6s ease-in-out var(--lg-intro) infinite both; }
.lg-art .i-rise    { animation: lgs-rise-dot 2.7s ease-out calc(var(--lg-intro) + var(--k, 0) * .9s) infinite both; }
.lg-art .i-drop    { animation: lgs-drop 2.4s ease-in calc(var(--lg-intro) + var(--k, 0) * .8s) infinite both; }
.lg-art .i-grow    { transform-origin: 50% 100%; animation: lgs-grow 2.4s ease-in-out calc(var(--lg-intro) + var(--k, 0) * .2s) infinite both; }
.lg-art .i-ripple  { animation: lgs-ripple 2.4s ease-out var(--lg-intro) infinite both; }
.lg-art .i-twinkle { animation: lgs-twinkle 2.4s ease-in-out calc(var(--lg-intro) + var(--k, 0) * .4s) infinite both; }

.lg-art .i-check {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: lgs-check 4s var(--lg-ease) calc(var(--lg-intro) + var(--k, 0) * .45s) infinite both;
}

.lg-art .i-logo {
  stroke-dasharray: var(--len) calc(var(--len) * 2);
  stroke-dashoffset: calc(var(--len) + 1);
  animation: lgs-logo 2.4s .15s infinite both;
}

.lg-art .i-flip     { animation: lgs-flip 4.4s var(--lg-ease) var(--lg-intro) infinite both; }
.lg-art .i-sand-top { transform-origin: 50% 100%; animation: lgs-sand-top 4.4s linear var(--lg-intro) infinite both; }
.lg-art .i-sand-bot { transform-origin: 50% 100%; animation: lgs-sand-bot 4.4s linear var(--lg-intro) infinite both; }
.lg-art .i-stream {
  stroke-width: 3;
  stroke-dasharray: 4 6;
  animation: lgs-stream .5s linear infinite, lgs-stream-vis 4.4s step-end var(--lg-intro) infinite both;
}

@keyframes lgs-bob     { 50% { transform: translateY(-5px); } }
@keyframes lgs-shadow  { 50% { transform: scaleX(.86); opacity: .7; } }
@keyframes lgs-shake   {
  0%, 78%, 100% { transform: translateX(0); }
  82% { transform: translateX(-6px); }
  86% { transform: translateX(6px); }
  90% { transform: translateX(-4px); }
  94% { transform: translateX(3px); }
}
@keyframes lgs-wobble  { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes lgs-blink   { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
@keyframes lgs-wave    { 50% { opacity: .2; } }
@keyframes lgs-pulse   { 50% { transform: scale(1.12); } }
@keyframes lgs-led     { 50% { opacity: .15; } }
@keyframes lgs-flicker { 0%, 70%, 100% { opacity: 1; } 74% { opacity: .2; } 78% { opacity: 1; } 82% { opacity: .3; } 86% { opacity: 1; } }
@keyframes lgs-spin    { to { transform: rotate(360deg); } }
@keyframes lgs-spin-pause { 0% { transform: rotate(0); } 45%, 100% { transform: rotate(360deg); } }
@keyframes lgs-scan    {
  25% { transform: translate(12px, -6px); }
  50% { transform: translate(0, 0); }
  75% { transform: translate(-12px, -6px); }
}
@keyframes lgs-rise-dot {
  0%   { opacity: 0; transform: translateY(16px) scale(.6); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(1); }
}
@keyframes lgs-drop {
  0%   { opacity: 0; transform: translateY(-14px); }
  15%  { opacity: 1; }
  70%  { opacity: 1; transform: translateY(42px); }
  85%, 100% { opacity: 0; transform: translateY(48px); }
}
@keyframes lgs-grow    { 50% { transform: scaleY(.45); } }
@keyframes lgs-ripple  { 0% { opacity: 0; transform: scale(1); } 8% { opacity: .5; } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes lgs-twinkle { 50% { transform: scale(.6) rotate(45deg); opacity: .5; } }
@keyframes lgs-check {
  0%   { stroke-dashoffset: var(--len); opacity: 1; }
  14%  { stroke-dashoffset: 0; }
  78%  { stroke-dashoffset: 0; opacity: 1; }
  90%  { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: var(--len); opacity: 0; }
}
@keyframes lgs-logo {
  0%   { stroke-dashoffset: calc(var(--len) + 1); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  50%  { stroke-dashoffset: 0; }
  62%  { stroke-dashoffset: 0; animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  100% { stroke-dashoffset: calc(var(--len) * -1 - 1); }
}
@keyframes lgs-flip     { 0%, 76% { transform: rotate(0); } 92%, 100% { transform: rotate(180deg); } }
@keyframes lgs-sand-top { 0% { transform: scale(1); } 76%, 100% { transform: scale(0); } }
@keyframes lgs-sand-bot { 0% { transform: scale(0); } 76%, 100% { transform: scale(1); } }
@keyframes lgs-stream   { to { stroke-dashoffset: -10; } }
@keyframes lgs-stream-vis { 0% { opacity: 1; } 76% { opacity: 0; } }

/* Respect "reduce motion": show the finished illustration, no movement. */
@media (prefers-reduced-motion: reduce) {
  lg-state *, lg-state *::before, lg-state *::after { animation: none !important; transition: none !important; }
  .lg-art .d, .lg-art .i-check, .lg-art .i-logo { stroke-dashoffset: 0 !important; stroke-dasharray: none !important; }
  .lg-art .i-rise, .lg-art .i-drop { opacity: 0; }
}
