/* The interactives' stylesheet. An interactive is one small Kinetic page per
   function, shown in a frame on a docs page, in three parts from the top: the
   call, written out large with its live values; the stage, with the element
   the function moves; and the knobs that change both. The format is in
   docs/KINETIC_INTERACTIVES.md. The tokens are the site's
   (static/css/site.css), the few it needs. */

:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14161f;
    --surface: #1b1e29;
    --line: #2b2f3d;
    --text: #ece8df;
    --muted: #a3a7ba;
    --accent: #B1A8FF;
    --accent-fill: #B1A8FF;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f4f7;
    --surface: #ffffff;
    --line: #d9d9e2;
    --text: #18171d;
    --muted: #595766;
    --accent: #6351FF;
    --accent-fill: #6351FF;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Work Sans", BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.interactive {
    display: flex;
    flex-direction: column;
    padding: 14px;
}

/* The call, first and large: the function as the reader would write it, the
   live values in the accent, the time quieter. A long call wraps at a comma
   rather than being cut off. */
.call {
    margin: 0 0 10px;
    font-family: -apple-system, "Work Sans", BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
}
.call code { font: inherit; }
.call .v { color: var(--accent); }
.call .t { color: var(--muted); font-weight: 500; }

/* What the call returns, in the stage's corner beside the element it drives. */
.result {
    position: absolute;
    right: 12px;
    top: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

/* The speaker, in the corner of a stage whose composition has sound: off
   until pressed, since a browser plays sound only after a gesture on the
   page, then on and off. Its click does not reach the stage, so it never
   pauses. */
.sound {
    position: absolute;
    left: 10px;
    top: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px 2px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font: 600 12px/1.4 -apple-system, "Work Sans", BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    cursor: pointer;
}
.sound svg { width: 15px; height: 15px; fill: currentColor; }
.sound .when-on { display: none; }
.sound.on { color: var(--accent); border-color: var(--accent); }
.sound.on .when-on { display: block; }
.sound.on .when-off { display: none; }

/* The stage: the element the function moves, on the surface colour, with a
   faint mark at the element's rest position. A click pauses or plays. */
.stage {
    position: relative;
    height: 180px;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
}
.origin {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: var(--line);
}
.card {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 120px;
    height: 72px;
    margin: -36px 0 0 -60px;
    border-radius: 10px;
    background: var(--accent-fill);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* The knobs: a name, the value, and the slider under them. */
.knobs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px 20px;
}
.knob {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0 10px;
    font-size: 13px;
    color: var(--muted);
}
.knob output {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color: var(--text);
}
.knob input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0;
    accent-color: var(--accent-fill);
}
/* A kind or a name is a select, in the slider's place. */
.knob select {
    grid-column: 1 / -1;
    width: 100%;
    margin: 2px 0 0;
    padding: 3px 6px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.knob select:disabled { opacity: 0.45; }
/* A flag is a checkbox, in the slider's place, with the value beside it. */
.knob input[type="checkbox"] {
    grid-column: 1 / -1;
    justify-self: start;
    width: 18px;
    height: 18px;
    margin: 4px 0 0;
    accent-color: var(--accent-fill);
}

/* A quiet aside in the call, such as a value the call cannot carry. */
.call .note { color: var(--muted); font-weight: 400; }
