/**
 * Lever styles: an arcade cabinet arm that reads as part of the composer tool
 * row, plus the jackpot burst it fires when LiangShen mode lands.
 *
 * Semantic hooks are the data attributes (`data-dsh-plugin` / `data-dsh-part` /
 * `data-state`), never these hashed class names, so skins can target the lever
 * without a build-time dependency. Every animation is disabled under
 * `prefers-reduced-motion`, where the burst degrades to a short fade.
 */

.lever {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  line-height: 1;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px 8px 2px 4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--dsw-alias-label-secondary, inherit);
  font: inherit;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.control:hover:not(:disabled) {
  background: var(--dsw-alias-interactive-bg-hover, rgb(0 0 0 / 6%));
}

.control:focus-visible {
  outline: 2px solid var(--dsw-alias-brand-primary, currentColor);
  outline-offset: 2px;
}

.control:disabled {
  cursor: default;
  opacity: 0.55;
}

/* The cabinet slot the arm swings inside: dark, so the arm reads against it. */
.track {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 24px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #2b2f36, #14161a);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 14%),
    inset 0 6px 10px rgb(0 0 0 / 55%);
}

/* The base plate the arm pivots on. */
.track::after {
  content: '';
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 2px;
  height: 3px;
  border-radius: 2px;
  background: rgb(255 255 255 / 22%);
}

.arm {
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 16px;
  height: 26px;
  margin-left: -8px;
  transform-origin: 50% 24px;
  transform: rotate(-24deg);
  transition: transform 0.34s cubic-bezier(0.2, 1.7, 0.32, 1);
}

.lever[data-state='on'] .arm {
  transform: rotate(24deg);
}

.rod {
  fill: #c9ced6;
  transition: fill 0.2s ease;
}

.knob {
  fill: #e04a33;
  stroke: rgb(0 0 0 / 35%);
  stroke-width: 0.6;
  transition: fill 0.2s ease;
}

.lever[data-state='on'] .rod {
  fill: #ffd76a;
}

.lever[data-state='on'] .knob {
  fill: #f7c637;
}

.lever[data-state='on'] .track {
  box-shadow:
    inset 0 0 0 1px var(--dsw-alias-border-l3, rgb(0 0 0 / 12%)),
    0 0 10px rgb(247 198 55 / 55%);
}

.lever[data-busy='true'] .arm {
  animation: lever-jitter 0.42s ease-in-out infinite;
}

/* Width-stable label: the composer row must not shift when the mode changes. */
.readout {
  min-width: 4.4em;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.lever[data-state='on'] .readout {
  color: var(--dsw-alias-label-primary, inherit);
  font-weight: 600;
}

/*
 * Inline error, kept in flow so it never floats over the composer: the full
 * host reason stays available through the title attribute when it is elided.
 */
.error {
  max-width: 22ch;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--dsw-alias-bg-layer-3, rgb(0 0 0 / 6%));
  color: var(--dsw-alias-state-error-primary, #c0392b);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── the jackpot ─────────────────────────────────────────────────────────── */

.burst {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 62%, rgb(255 246 200 / 92%), rgb(255 208 74 / 45%) 38%, rgb(255 160 0 / 0%) 72%);
  animation: burst-flash 0.72s ease-out both;
}

.ring {
  position: absolute;
  width: 220px;
  height: 220px;
  border: 6px solid rgb(255 214 90 / 85%);
  border-radius: 50%;
  animation: burst-ring 1.1s cubic-bezier(0.16, 0.9, 0.3, 1) both;
}

.ring:nth-of-type(2) {
  animation-delay: 0.12s;
}

.ring:nth-of-type(3) {
  animation-delay: 0.24s;
}

.banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 40px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgb(24 16 4 / 94%), rgb(64 38 4 / 92%));
  box-shadow:
    0 0 0 2px rgb(255 214 90 / 75%),
    0 24px 70px rgb(0 0 0 / 45%);
  color: #ffe9a8;
  text-align: center;
  animation: banner-slam 0.6s cubic-bezier(0.16, 1.5, 0.3, 1) both, banner-shake 0.5s ease-in-out 0.6s 2;
}

.bannerName {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.16em;
  background: linear-gradient(180deg, #fff6d0, #ffc93c 55%, #b8730a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgb(255 201 60 / 65%);
}

.line {
  font-size: 15px;
  letter-spacing: 0.08em;
}

.code {
  font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11px;
  letter-spacing: 0.06em;
  opacity: 0.82;
  animation: code-blink 0.5s steps(2, end) 6;
}

.sparks {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

/*
 * Sparks pivot about their own centre: the `rotate` property puts each one on
 * its spoke, and the keyframes' translate then travels along that spoke, so
 * they read as speed lines leaving the centre rather than stray hairlines.
 */
.spark {
  grid-area: 1 / 1;
  width: 3px;
  height: 30px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgb(255 236 160 / 95%), rgb(255 170 20 / 0%));
  transform-origin: 50% 50%;
  animation: spark-fly 0.95s ease-out both;
}

@keyframes lever-jitter {
  0%, 100% { transform: rotate(-22deg); }
  50% { transform: rotate(-8deg); }
}

@keyframes burst-flash {
  0% { opacity: 0; transform: scale(0.6); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.5); }
}

@keyframes burst-ring {
  0% { opacity: 0.9; transform: scale(0.2); }
  100% { opacity: 0; transform: scale(3.4); }
}

@keyframes banner-slam {
  0% { opacity: 0; transform: scale(3.6) rotate(-9deg); }
  55% { opacity: 1; transform: scale(0.94) rotate(1.5deg); }
  75% { transform: scale(1.06) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes banner-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-9px) rotate(-0.6deg); }
  75% { transform: translateX(9px) rotate(0.6deg); }
}

@keyframes spark-fly {
  0% { opacity: 0; transform: translateY(-40px) scaleY(0.3); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-300px) scaleY(1.15); }
}

@keyframes code-blink {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .arm,
  .control,
  .rod,
  .knob {
    transition: none;
  }

  .lever[data-busy='true'] .arm,
  .flash,
  .ring,
  .banner,
  .code,
  .spark {
    animation: none;
  }

  .burst {
    animation: burst-flash 0.3s ease-out both;
  }

  .spark {
    display: none;
  }
}
