/* Slingshot. The space viewport is dark in both themes; everything around it
   follows the site theme through DaisyUI's colour variables. */

/* Our display rules below must not win over the hidden attribute. */
.sling [hidden] { display: none !important; }

.sling {
  --sl-hit: #22c55e;
  --sl-near: #eab308;
  --sl-miss: #ef4444;
  --sl-dust: #f5c542;
}

/* ---- The viewport ---- */

.sling-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 78vh;
  width: 100%;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #05060f;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.06) inset, 0 18px 40px -24px rgb(4 6 20 / 0.55);
  isolation: isolate;
}
@media (max-width: 639px) {
  /* Phones: the system is turned on its side so the ring is at the top. */
  .sling-stage {
    aspect-ratio: 10 / 14.6;
    max-height: 74svh;
    margin-inline: -0.75rem;
    width: calc(100% + 1.5rem);
  }
}

.sling-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sling-canvas.is-dragging { cursor: grabbing; }
.sling-canvas.is-busy { cursor: progress; }
.sling-canvas.is-done { cursor: default; }
.sling-stage:has(.sling-canvas:focus-visible)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 2px #7dd3fc inset, 0 0 0 4px rgb(125 211 252 / 0.25) inset;
  pointer-events: none;
}

.sling-loading {
  position: absolute;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  color: #e6ecff;
}
.sling-loading {
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9375rem;
  opacity: 0.8;
}

/* ---- Side panel ---- */

.sling-icon {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sling-mute { gap: 0.4rem; }
.sling-mute .sling-icon-off { display: none; }
.sling-mute[aria-pressed="false"] { color: var(--color-muted, currentColor); }
.sling-mute[aria-pressed="false"] .sling-icon-on { display: none; }
.sling-mute[aria-pressed="false"] .sling-icon-off { display: block; }

.sling-tries {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sling-tries li {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  max-height: 3.25rem;
  border-radius: 0.6rem;
  border: 1.5px dashed var(--color-base-300);
  color: var(--color-muted, currentColor);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}
[data-theme="dark"] .sling-tries li { border-color: color-mix(in oklab, var(--color-base-content) 22%, transparent); }
.sling-tries li[data-state="next"] {
  border-style: solid;
  border-color: var(--cat, #9a3f63);
  color: var(--color-base-content);
}
.sling-tries li[data-grade] {
  border-style: solid;
  color: #fff;
  animation: sling-pop 0.42s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.sling-tries li[data-grade="hit"] { background: var(--sl-hit); border-color: var(--sl-hit); }
.sling-tries li[data-grade="near"] { background: var(--sl-near); border-color: var(--sl-near); color: #241a00; }
.sling-tries li[data-grade="miss"] { background: var(--sl-miss); border-color: var(--sl-miss); }
.sling-tries li svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@keyframes sling-pop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

.sling-dust-row {
  display: flex;
  gap: 0.2rem;
  margin: 0;
}
.sling-dust-row span {
  width: 1.1rem;
  height: 1.1rem;
  color: color-mix(in oklab, var(--color-base-content) 22%, transparent);
  transition: color 0.3s ease, transform 0.3s ease;
}
.sling-dust-row span.is-on { color: var(--sl-dust); transform: scale(1.1); filter: drop-shadow(0 0 4px rgb(245 197 66 / 0.6)); }
.sling-dust-row svg { width: 100%; height: 100%; fill: currentColor; }

.sling-status {
  min-height: 3rem;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.sling-status strong { font-weight: 700; }

.sling-aim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.sling-aim-row + .sling-aim-row { margin-top: 0.5rem; }
.sling-aim-label { font-size: 0.875rem; font-weight: 600; }
.sling-step { width: 2.5rem; font-size: 1rem; }
.sling-readout {
  display: inline-grid;
  place-items: center;
  min-width: 5.25rem;
  height: var(--size, 2rem);
  border-block: 1px solid var(--color-base-300);
  background: var(--color-base-200);
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .sling-readout { border-color: color-mix(in oklab, var(--color-base-content) 14%, transparent); }
.sling-aim :disabled { opacity: 0.45; }
@media (pointer: coarse) and (hover: none) {
  .sling-keys { display: none; }
}
.sling-keys .kbd { min-height: 1.35rem; min-width: 1.35rem; padding-inline: 0.3rem; font-size: 0.6875rem; }

/* ---- Results ---- */

.sling-result-squares {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0;
}
.sling-result-squares .sq {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.4rem;
  animation: sling-pop 0.42s cubic-bezier(0.2, 1.6, 0.4, 1) backwards;
}
.sling-result-squares .sq:nth-child(2) { animation-delay: 0.06s; }
.sling-result-squares .sq:nth-child(3) { animation-delay: 0.12s; }
.sling-result-squares .sq:nth-child(4) { animation-delay: 0.18s; }
.sling-result-squares .sq:nth-child(5) { animation-delay: 0.24s; }
.sling-result-squares .sq[data-grade="hit"] { background: var(--sl-hit); }
.sling-result-squares .sq[data-grade="near"] { background: var(--sl-near); }
.sling-result-squares .sq[data-grade="miss"] { background: var(--sl-miss); }
.sling-result-squares .gap { width: 0.6rem; }
.sling-result-squares .dust { width: 1.5rem; height: 1.5rem; color: color-mix(in oklab, var(--color-base-content) 20%, transparent); }
.sling-result-squares .dust.is-on { color: var(--sl-dust); filter: drop-shadow(0 0 5px rgb(245 197 66 / 0.55)); }
.sling-result-squares svg { width: 100%; height: 100%; fill: currentColor; }
.sling-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
}
.sling-stats div {
  padding: 0.6rem 0.25rem;
  border-radius: 0.6rem;
  background: var(--color-base-200);
  text-align: center;
}
.sling-stats dt { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted, currentColor); }
.sling-stats dd { margin: 0.15rem 0 0; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }

.sling-dist {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sling-dist li {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.sling-dist .bar {
  display: block;
  min-width: 1.6rem;
  width: var(--w, 0%);
  padding: 0.1rem 0.45rem;
  border-radius: 0.35rem;
  background: color-mix(in oklab, var(--color-base-content) 16%, transparent);
  text-align: right;
  font-weight: 600;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sling-dist li.is-today .bar { background: var(--sl-hit); color: #fff; }
.sling-dist li.is-today.is-x .bar { background: var(--sl-miss); }

.sling-results { animation: sling-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes sling-rise {
  from { opacity: 0; transform: translateY(0.75rem); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sling-results,
  .sling-result-squares .sq,
  .sling-tries li[data-grade] { animation: none; }
  .sling-dist .bar { transition: none; }
}
