/*
 * squishy-matter_v2a.
 *
 * Pinned to the light palette: the cutouts are photographed on white, and the
 * pack reads as a collage on paper.
 */
@layer sl-utilities {
  /*
   * The canvas fills the viewport and handles its own pointer gestures, so the
   * page itself must never scroll or rubber-band -- a drag on an object would
   * otherwise pull the page around on touch devices.
   */
  html,
  body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .shell {
    position: relative;
    height: 100dvh;
    width: 100%;
  }

  /* -- the scene -------------------------------------------------------- */

  .stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
  }

  .stage-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    /* The canvas owns every gesture on it, so the browser must not claim any
       of them for scrolling, text selection or the iOS callout menu. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /*
   * Shown while the asset pool decodes, and if it fails. Unlike v1a there is
   * a real wait here -- forty bitmaps have to be fetched and sampled before
   * the first body exists.
   */
  .status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: var(--sl-color-muted-foreground);
    pointer-events: none;
  }

  /* -- control panel ---------------------------------------------------- */

  /*
   * The panel floats over a full-viewport canvas that captures every pointer
   * gesture, so it opts back into pointer events.
   */
  .panel-root {
    --surface: rgba(255, 255, 255, 0.86);
    --panel-border: rgba(0, 0, 0, 0.1);
    --ink: #1a1a1a;
    --muted: #6b6b6b;
    --accent: #0d99ff;

    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    font-family: var(--sl-font-sans);
    pointer-events: none;
  }

  .panel-toggle {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding-inline: 10px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  }

  .panel-toggle:hover {
    background: rgba(255, 255, 255, 0.95);
  }

  .panel {
    pointer-events: auto;
    width: 284px;
    max-height: calc(100dvh - 68px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    color: var(--ink);
    font-size: 12px;
    padding: 4px;
  }

  .section {
    border-bottom: 1px solid var(--panel-border);
  }

  .section:last-child {
    border-bottom: none;
  }

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 0;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-align: left;
  }

  .chevron {
    width: 10px;
    height: 10px;
    color: var(--muted);
    transition: transform 0.15s ease;
  }

  .chevron.is-open {
    transform: rotate(90deg);
  }

  .section-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 8px 12px;
  }

  .row {
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    gap: 8px;
  }

  .row-label {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
    /* Long parameter names wrap rather than pushing the control off-panel. */
    overflow-wrap: anywhere;
  }

  .row-control {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .text-input {
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font: inherit;
    font-size: 12px;
  }

  .text-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
  }

  .number-input {
    width: 48px;
    flex-shrink: 0;
    height: 22px;
    padding: 0 4px;
    border-radius: 5px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font: inherit;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: right;
  }

  .range {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
    height: 18px;
    cursor: pointer;
  }

  .swatch {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: transparent;
    cursor: pointer;
  }

  .checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  .segmented {
    display: flex;
    width: 100%;
    padding: 2px;
    border-radius: 7px;
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.03);
    gap: 2px;
  }

  .segment {
    flex: 1;
    height: 20px;
    border-radius: 5px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
  }

  .segment:hover {
    color: var(--ink);
  }

  .segment.is-active {
    background: #fff;
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  }

  .button-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .button {
    flex: 1;
    min-width: 76px;
    height: 26px;
    padding-inline: 8px;
    border-radius: 7px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
  }

  .button:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.2);
  }

  .warning {
    margin: 0 8px 8px;
    padding: 6px 8px;
    border-radius: 7px;
    background: rgba(255, 179, 0, 0.14);
    border: 1px solid rgba(255, 179, 0, 0.35);
    color: #7a5200;
    font-size: 11px;
    line-height: 1.35;
  }

  .hint {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    padding: 0 0 2px;
  }

  /* An empty stats hint would otherwise leave a gap in the Actions section. */
  .hint:empty {
    display: none;
  }
}
