:root {
  --mist: #d8dcdc;
  --ink: #14181b;
  --slate: #566064;
  --sand: #ece8de;
  --dim: #a9a69d;
  --serif: 'Gowun Batang', 'Iowan Old Style', Georgia, serif;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #000; color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

/* Stage */
#stage { position: fixed; inset: 0; background: #000; color: var(--dim); font-size: 0.86rem; container-type: size; }
/* Frames for recording: 16 by 9, or an upright 9 by 16, in the middle of the window. The outline sits just outside it. */
#stage.reel { margin: auto; width: min(100vw, calc(100vh * 9 / 16)); height: min(100vh, calc(100vw * 16 / 9)); outline: 1px solid #2a2d2f; }
#stage.wide { margin: auto; width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16)); outline: 1px solid #2a2d2f; }
body:has(#stage.reel:not([hidden])) { background: #000; }
#stage[hidden] { display: none; }
#mount { position: absolute; inset: 0; display: grid; place-items: center; cursor: crosshair; touch-action: none; }
#mount canvas.square { width: min(84cqh, 92cqw); height: min(84cqh, 92cqw); display: block; }
#mount .error { max-width: 28rem; padding: 2rem; color: var(--sand); font-size: 1rem; }
.tools, .readout, .foot { position: absolute; margin: 0; z-index: 2; text-shadow: 0 0 12px #000, 0 0 3px #000; }
.tools { top: 1.1rem; right: 1.4rem; display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.tools button { background: none; border: 0; padding: 0.1rem 0; font: inherit; color: var(--sand); cursor: pointer; border-bottom: 1px solid transparent; transition: opacity 0.2s; }
.tools .sound { display: flex; align-items: center; padding: 0.3rem 0; opacity: 0.55; }
.tools .sound[aria-pressed="true"] { opacity: 1; }
.tools .sound svg { display: block; overflow: visible; }
.foot { right: 1.4rem; bottom: 1.1rem; display: flex; gap: 1rem; font-size: 0.8rem; }
.foot button { background: none; border: 0; padding: 0.1rem 0; font: inherit; color: var(--sand); cursor: pointer; border-bottom: 1px solid transparent; }
.foot .fly[aria-pressed="true"] { border-bottom-color: currentColor; }
.readout { font-size: 0.8rem; line-height: 1.3; left: 1.4rem; top: 1.38rem; max-width: calc(100cqw - 11.5rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; pointer-events: none; }

/* With the controls hidden only the picture is left. The button to bring them back shows on hover. */
#stage:not(.open) .tone { display: none; }
#stage.bare .readout, #stage.bare .tone, #stage.bare .foot, #stage.bare .tools button:not(.hide) { display: none; }
#stage.bare .hide { opacity: 0; }
#stage.bare .hide:hover, #stage.bare .hide:focus-visible { opacity: 1; }


/* The pointer: a disc that inverts what is under it. */
.own-cursor, .own-cursor * { cursor: none !important; }
.cursor { position: fixed; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; color: #000; mix-blend-mode: difference; pointer-events: none; z-index: 10; opacity: 0; font: 18px/1 var(--sans); transition: scale 0.1s ease-out, opacity 0.3s; }
.cursor.on { opacity: 1; }
.cursor.over { scale: 1.3; }
.cursor.down { scale: 0.88; }
.cursor.over.down { scale: 1.15; }
/* Over a setting, a small mark beside the disc shows which way it will step. */
.cursor::after { position: absolute; top: 50%; translate: 0 -58%; color: #fff; }
.cursor[data-d="-1"]::after { content: '‹'; right: calc(100% + 5px); }
.cursor[data-d="1"]::after { content: '›'; left: calc(100% + 5px); }

/* Left alone, the words fade and only the sand is left. Any movement or key brings them back. */
.tools, .tone, .readout, .foot { transition: opacity 0.4s; }
#stage.idle .tools, #stage.idle .tone, #stage.idle .readout, #stage.idle .foot { opacity: 0; transition-duration: 2.5s; }
#stage.idle .tone:has(:focus-visible), #stage.idle .tools:has(:focus-visible) { opacity: 1; }

/* Tone controls: what sets the tone, then each setting as a name and a value. The right half of a setting steps on, the left half steps back. */
.tone { position: absolute; right: 1.4rem; bottom: 3.4rem; width: min(13.5rem, calc(100cqw - 2.8rem)); text-shadow: 0 0 12px #000, 0 0 3px #000; z-index: 3; color: var(--sand); cursor: default; font-size: 0.8rem; line-height: 1.3; }
.tone .row[hidden] { display: none; }
.tone button { background: none; border: 0; padding: 0; font: inherit; color: var(--sand); cursor: pointer; }
.tone .src { display: flex; justify-content: space-between; margin-bottom: 0.55rem; }
.tone .src button { font-family: var(--serif); font-size: 0.95rem; opacity: 0.45; padding: 0.1rem 0; border-bottom: 1px solid transparent; }
.tone .src button:hover { opacity: 0.8; }
.tone .src button[aria-pressed="true"] { opacity: 1; border-bottom-color: currentColor; }
.tone .row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 0.45rem; padding: 0.22rem 0; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tone .row.wide { justify-content: flex-end; }
.tone .row span, .tone .settle span { color: var(--dim); transition: color 0.2s; }
.tone .row:hover span { color: var(--sand); }
.tone .row output { white-space: nowrap; }
.tone .row button { position: absolute; top: 0; bottom: 0; width: 50%; outline-offset: 0; }
.tone .row button:first-of-type { left: 0; cursor: w-resize; }
.tone .row button:last-of-type { right: 0; cursor: e-resize; }
.tone .settle { display: flex; align-items: center; gap: 0.6rem; padding: 0.22rem 0; }
.tone .settle input { flex: 1; min-width: 0; margin: 0; height: 1rem; background: linear-gradient(var(--slate), var(--slate)) center / 100% 1px no-repeat; -webkit-appearance: none; appearance: none; cursor: ew-resize; }
.tone .settle input::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 9px; border-radius: 50%; background: var(--sand); }
.tone .settle input::-moz-range-thumb { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--sand); }
.tone .say { color: var(--dim); font-size: 0.74rem; margin: 0.5rem 0 0; }
.tone .say:empty { display: none; }

/* The upright frame is for recording: the sand settles at the speed already set. */
#stage.reel .settle { display: none; }

}
