/*
 * confetti-burst playground - Evomedia.net Snippets
 * https://github.com/evomedia-net/evo.snippets
 * Created by Kelly Michels - dev@evomedia.net
 * Licensed under the MIT License. See LICENSE.
 *
 * Styling for the control panel that playground.js builds.
 *
 * Every colour, radius and font here comes from a --cbp-* variable with a
 * fallback, so a host site can hand it their own design tokens without
 * touching this file:
 *
 *   #confetti-playground {
 *     --cbp-accent: var(--color-accent);
 *     --cbp-font:   var(--font-sans);
 *   }
 *
 * Left alone, the fallbacks give a neutral panel that looks deliberate
 * rather than unstyled.
 */

.cbp {
  --cbp-ink: var(--cbp-ink-override, #16202e);
  --cbp-muted: var(--cbp-muted-override, #5b6a7d);
  --cbp-line: var(--cbp-line-override, rgba(22, 32, 46, 0.14));
  --cbp-surface: var(--cbp-surface-override, #ffffff);
  --cbp-sunken: var(--cbp-sunken-override, #f4f6fa);
  --cbp-accent: var(--cbp-accent-override, #2563eb);
  --cbp-accent-ink: var(--cbp-accent-ink-override, #ffffff);
  --cbp-radius: var(--cbp-radius-override, 10px);
  --cbp-font: var(--cbp-font-override, inherit);
  --cbp-mono: var(--cbp-mono-override, ui-monospace, Consolas, "Cascadia Code", monospace);

  font-family: var(--cbp-font);
  color: var(--cbp-ink);
  display: grid;
  gap: 1rem;
}

.cbp * { box-sizing: border-box; }

/* ── layout ─────────────────────────────────────────────────────────── */
.cbp-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  align-items: start;
}

.cbp-panel {
  background: var(--cbp-surface);
  border: 1px solid var(--cbp-line);
  border-radius: var(--cbp-radius);
  padding: 1rem 1.1rem 1.15rem;
  display: grid;
  gap: 0.7rem;
  align-content: start;
}

.cbp-panel > h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cbp-muted);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--cbp-line);
}

.cbp-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--cbp-muted);
}

.cbp-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ── a slider with its readout ──────────────────────────────────────── */
.cbp-ctl { display: grid; gap: 0.15rem; }

.cbp-ctl > label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.83rem;
  cursor: pointer;
}

.cbp-ctl output {
  font-family: var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cbp-accent);
}

.cbp input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 0.35rem 0 0;
  border-radius: 999px;
  background: var(--cbp-line);
  cursor: pointer;
}
.cbp input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--cbp-accent);
  border: 2px solid var(--cbp-surface);
  box-shadow: 0 0 0 1px var(--cbp-accent);
  cursor: pointer;
}
.cbp input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border: none;
  border-radius: 50%;
  background: var(--cbp-accent);
  box-shadow: 0 0 0 1px var(--cbp-accent);
  cursor: pointer;
}
.cbp input[type="range"]:focus-visible {
  outline: 2px solid var(--cbp-accent);
  outline-offset: 3px;
}

/* ── the numpad ─────────────────────────────────────────────────────── */
/* Laid out so 1 5 21 25 sit where the screen corners are, 13 in the
   middle. Twenty-five keys in the width the nine used to take, so the
   buttons lose a little height and a little type rather than the panel
   growing to swallow its neighbours. */
.cbp-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.22rem;
  max-width: 12.5rem;
}
.cbp-pad button {
  height: 1.75rem;
  padding: 0;
  font: 600 0.72rem/1 var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  color: var(--cbp-muted);
  background: var(--cbp-surface);
  border: 1px solid var(--cbp-line);
  border-radius: 7px;
  cursor: pointer;
}
.cbp-pad button:hover { border-color: var(--cbp-accent); color: var(--cbp-accent); }
.cbp-pad button[aria-pressed="true"] {
  background: var(--cbp-accent);
  border-color: var(--cbp-accent);
  color: var(--cbp-accent-ink);
}
.cbp-pad button:focus-visible { outline: 2px solid var(--cbp-accent); outline-offset: 2px; }

/* ── per-cannon aim ─────────────────────────────────────────────────── */
.cbp-aims { display: grid; gap: 0.4rem; }
.cbp-aim {
  display: grid;
  grid-template-columns: 2.1rem 1.5rem 1.15rem 1fr auto;
  gap: 0.45rem;
  align-items: center;
}

/* Snap to 45. Drawn as the thing it does - a baseline, a ray 45 degrees
   off it, and the arc between - so the button looks like its own result.
   Quiet until hovered: it sits in every row, and five of them shouting is
   a busier panel than the control is worth. */
.cbp-aim-snap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--cbp-muted);
  cursor: pointer;
}
.cbp-aim-snap:hover {
  color: var(--cbp-accent);
  border-color: var(--cbp-line);
}
.cbp-aim-snap:focus-visible { outline: 2px solid var(--cbp-accent); outline-offset: 2px; }
.cbp-aim-snap svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cbp-aim-snap-arc { stroke-width: 1.4; opacity: 0.75; }

/* Which way this cannon points, as a picture rather than a number to
   convert. Drawn pointing up because up is 0 on the compass the aim
   uses, so the rotation IS the bearing. */
.cbp-aim-arrow {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--cbp-accent);
  transition: transform 0.18s ease;
}
.cbp-aim-arrow svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cbp-aim-at {
  font: 600 0.8rem/1 var(--cbp-mono);
  color: var(--cbp-accent);
}
.cbp-aim-deg {
  font: 0.72rem/1 var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  color: var(--cbp-muted);
  white-space: nowrap;
}

/* ── buttons, text inputs ───────────────────────────────────────────── */
.cbp-btn {
  font: 600 0.85rem/1 var(--cbp-font);
  padding: 0.55rem 0.85rem;
  border-radius: 7px;
  border: 1px solid var(--cbp-line);
  background: var(--cbp-surface);
  color: var(--cbp-ink);
  cursor: pointer;
}
.cbp-btn:hover { border-color: var(--cbp-accent); }
.cbp-btn:focus-visible { outline: 2px solid var(--cbp-accent); outline-offset: 2px; }

/* A button that holds a choice has to look like it holds one. The palette
   buttons were setting aria-pressed and styling nothing, so the panel told
   a screen reader which palette was in use and told everyone else
   nothing. Same treatment the pad keys use for the same meaning, so
   "selected" looks like one thing throughout. */
.cbp-btn[aria-pressed="true"] {
  background: var(--cbp-accent);
  border-color: var(--cbp-accent);
  color: var(--cbp-accent-ink);
}
.cbp-btn--go {
  background: var(--cbp-accent);
  border-color: var(--cbp-accent);
  color: var(--cbp-accent-ink);
}
.cbp-btn--sm { padding: 0.32rem 0.55rem; font-size: 0.75rem; }

.cbp input[type="text"],
.cbp select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.42rem 0.55rem;
  border-radius: 7px;
  border: 1px solid var(--cbp-line);
  background: var(--cbp-surface);
  color: var(--cbp-ink);
}
.cbp input[type="text"] { font-family: var(--cbp-mono); }

.cbp-check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.85rem; }
.cbp-check output {
  margin-left: auto;
  font-family: var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--cbp-accent);
}
.cbp input[type="range"]:disabled { opacity: 0.45; cursor: default; }
.cbp-check input { width: 15px; height: 15px; accent-color: var(--cbp-accent); cursor: pointer; }
.cbp input[type="file"] { font-size: 0.78rem; color: var(--cbp-muted); max-width: 100%; }

/* Six colours of your own, 3 x 2. Each cell wears the colour it holds and
   prints its hex, so the control and the readout are the same object -
   there is nothing else to look at to know what you picked.

   The <input type="color"> is laid over the whole cell at zero opacity
   rather than hidden, so it stays keyboard-reachable and the cell has one
   hit target instead of a small OS swatch inside a bigger button. */
.cbp-colours {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.cbp-colour {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.1rem;
  border-radius: 7px;
  border: 1px solid var(--cbp-line);
  cursor: pointer;
  overflow: hidden;
}

.cbp-colour input[type="color"] {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.cbp-colour-face {
  font: 600 0.68rem/1 var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.cbp-colour:focus-within { outline: 2px solid var(--cbp-accent); outline-offset: 2px; }

/* The palette you are actually holding. Random re-rolls on every press,
   so without these the only way to see what you got is to fire. */
.cbp-swatches { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.cbp-swatch {
  width: 1.5rem;
  height: 0.85rem;
  border-radius: 3px;
  border: 1px solid var(--cbp-line);
}

/* ── readings ───────────────────────────────────────────────────────── */
.cbp-read { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.cbp-read th, .cbp-read td { text-align: left; padding: 0.32rem 0; border-bottom: 1px solid var(--cbp-line); }
.cbp-read th { font-weight: 500; color: var(--cbp-muted); }
.cbp-read td {
  text-align: right;
  font-family: var(--cbp-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.cbp-read tr:last-child th, .cbp-read tr:last-child td { border-bottom: 0; }

.cbp-verdict { margin: 0; font-size: 0.78rem; line-height: 1.5; color: var(--cbp-muted); }

.cbp-emit {
  margin: 0;
  padding: 0.8rem 0.9rem;
  overflow-x: auto;
  background: var(--cbp-sunken);
  border: 1px solid var(--cbp-line);
  border-radius: var(--cbp-radius);
  font-family: var(--cbp-mono);
  font-size: 0.74rem;
  line-height: 1.6;
  white-space: pre;
  color: var(--cbp-ink);
}

@media (prefers-reduced-motion: reduce) {
  .cbp * { transition: none !important; }
}
