/* The "Play with the wave" control (scripts/tuner.js). Moved out of the script so the Content-Security-Policy needs no inline styles. */
#tuner { --closed: 208px; --opened: 304px;
  --shadow-primary: 0 0 0 1px var(--surface); /* the primary's ring is the colour of the panel it sits on */
  position: fixed; right: var(--page-x); bottom: var(--space-6); z-index: 50;
  width: min(var(--closed), calc(100vw - 2 * var(--page-x)));
  border-radius: calc(var(--control-h) / 2);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-button);
  font: var(--weight-ui) var(--text-meta) / var(--leading-meta) var(--font-sans); letter-spacing: var(--tracking-ui);
  overflow: hidden; transform-origin: 100% 100%;
  transition: width .28s var(--ease-out), border-radius .28s var(--ease-out), box-shadow .28s var(--ease-out),
              transform var(--dur-hover) var(--ease-out), opacity .2s var(--ease-out), translate .3s var(--ease-out), visibility 0s; }
#tuner.open { width: min(var(--opened), calc(100vw - 2 * var(--page-x)));
  border-radius: var(--radius-container); box-shadow: var(--shadow-popover); }
/* Home screen out of view, or not ready yet */
#tuner.away { opacity: 0; translate: 0 24px; visibility: hidden; pointer-events: none;
  transition: opacity .2s var(--ease-out), translate .25s var(--ease-out), visibility 0s .25s; }
/* the closed pill is a button: it squeezes when pressed (an open panel is a surface, so it doesn't) */
#tuner:not(.open):has(.tn-head:active) { transform: scale(.97); }

#tuner .tn-head { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--control-h);
  padding: 0 var(--space-3) 0 14px; background: transparent; border: 0; color: inherit; text-align: left;
  white-space: nowrap; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  font: var(--weight-ui) var(--text-body) / var(--leading-body) var(--font-sans); letter-spacing: var(--tracking-ui);
  transition: background-color var(--dur-hover) var(--ease-out); }
@media (hover: hover) { #tuner .tn-head:hover { background: var(--ground); } }
#tuner .tn-head:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -4px; }
#tuner .tn-title { flex: 1; }
/* five dots whose sizes travel in a wave, like the picture behind */
#tuner .tn-dots { display: flex; align-items: center; gap: 3px; height: 14px; color: var(--text); }
#tuner .tn-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor;
  animation: tn-wave 1.6s ease-in-out infinite; animation-delay: calc((4 - var(--k)) * -0.2s); }
#tuner.excited .tn-dots i { animation-duration: .4s; }
@keyframes tn-wave { 0%, 100% { transform: scale(.55); } 50% { transform: scale(1.7); } }
/* a plus that turns into a cross */
#tuner .tn-plus { position: relative; flex: none; width: 14px; height: 14px; color: var(--text-faint); transition: transform .25s var(--ease-out); }
#tuner .tn-plus::before, #tuner .tn-plus::after { content: ''; position: absolute; left: 1px; right: 1px; top: 6px; height: 2px; border-radius: 1px; background: currentColor; }
#tuner .tn-plus::after { transform: rotate(90deg); }
#tuner.open .tn-plus { transform: rotate(135deg); }

/* the body unfolds by animating its row from 0 to 1fr; hidden while closed so keyboard focus skips it */
#tuner .tn-body { display: grid; grid-template-rows: 0fr; visibility: hidden;
  transition: grid-template-rows .26s var(--ease-out), visibility 0s .26s; }
#tuner.open .tn-body { grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows .3s var(--ease-out), visibility 0s; }
#tuner .tn-inner { min-height: 0; overflow: hidden; max-height: calc(100svh - 2 * var(--space-6) - var(--control-h)); }
#tuner.open.settled .tn-inner { overflow-y: auto; overscroll-behavior: contain; }
#tuner .tn-pad { padding: 2px var(--space-4) var(--space-4); border-top: var(--hairline) solid var(--line); }

/* every control fades up one after another */
#tuner .tn-item { opacity: 0; transform: translateY(8px); transition: opacity .12s var(--ease-out), transform .12s var(--ease-out); }
#tuner.open .tn-item { opacity: 1; transform: none;
  transition: opacity .2s var(--ease-out), transform .25s var(--ease-out);
  transition-delay: calc(min(var(--i, 0), 8) * 40ms + 100ms); }

#tuner .hint { color: var(--text-secondary); margin-top: 10px; }
#tuner label { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-2); margin-top: 10px; color: var(--text-secondary); }
/* values are machine values, so they are set in the mono */
#tuner output { font: 400 var(--text-meta) / var(--leading-meta) var(--font-mono); letter-spacing: 0; color: var(--text); }
#tuner .tn-sub { margin-top: 18px; padding-top: 10px; border-top: var(--hairline) solid var(--line);
  font-size: var(--text-body); line-height: var(--leading-body); color: var(--text); }

/* sliders: a 2px hairline track; the knob is a gray-12 dot with a white ring and a crisp drop */
#tuner input[type=range] { -webkit-appearance: none; appearance: none; grid-column: 1 / -1; width: 100%; height: 24px;
  margin: 0; background: transparent; cursor: pointer; }
#tuner input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
#tuner input[type=range]::-moz-range-track { height: 2px; background: var(--line); }
#tuner input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px;
  border: 0; border-radius: 50%; background: var(--text); box-shadow: var(--shadow-knob); }
#tuner input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%;
  background: var(--text); box-shadow: var(--shadow-knob); }
#tuner input[type=range]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* buttons: white and raised by the ring and drop; Surprise me is the panel's one (black) primary */
#tuner .row { display: flex; gap: 6px; margin-top: var(--space-3); }
#tuner .tn-btn { flex: 1; min-height: var(--control-h); padding: 0 var(--space-2); border: 0;
  border-radius: var(--radius-control); background: var(--surface); color: var(--text); box-shadow: var(--shadow-button);
  font: var(--weight-ui) var(--text-body) / var(--leading-body) var(--font-sans); letter-spacing: var(--tracking-ui);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-hover) var(--ease-out), background-color var(--dur-hover) var(--ease-out); }
@media (hover: hover) { #tuner .tn-btn:hover { background: var(--ground); } }
#tuner .tn-btn:active { background: var(--ground); transform: scale(.97); }
#tuner .tn-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
#tuner .tn-btn.primary { background: var(--primary-bg); color: var(--primary-fg); box-shadow: var(--shadow-primary); }
@media (hover: hover) { #tuner .tn-btn.primary:hover { background: var(--primary-hover); } }
#tuner .tn-btn.primary:active { background: var(--primary-hover); }

/* phone: the pill sits top right, in the header row, and the panel unfolds downward */
@media (max-width: 767px) {
  #tuner { top: var(--space-4); bottom: auto; transform-origin: 100% 0; }
  #tuner.away { translate: 0 -24px; }
  #tuner .tn-head { padding: 0 var(--space-4); }
  #tuner .tn-inner { max-height: calc(100svh - 2 * var(--space-4) - var(--control-h)); }
}
