/* Instrument Serif and IBM Plex Mono (SIL Open Font License), latin, served from fonts/ */
@font-face { font-family: 'Instrument Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/instrument-serif-latin.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/instrument-serif-italic-latin.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-500-latin.woff2) format('woff2'); }

:root {
  --bg: #050505;
  --ink: #ece6dc;
  --dim: rgba(236, 230, 220, 0.52);
  --faint: rgba(236, 230, 220, 0.32);
  --amber: #e2953a;
  --glass: rgba(18, 16, 14, 0.62);
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body { font: 400 12px/1.5 var(--mono); }

#c {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; cursor: grab; opacity: 0; transition: opacity 1.4s var(--ease);
}
body.ready #c { opacity: 1; }
body.orbiting #c { cursor: grabbing; }
body.on-strings #c { cursor: crosshair; }
body.on-peg #c { cursor: ns-resize; }
body.on-wood #c { cursor: pointer; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.link { padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.link:hover { text-decoration-color: var(--ink); }

.intro { position: fixed; top: 26px; left: 30px; max-width: 360px; z-index: 2; transition: opacity 1.2s var(--ease); }
body.film .intro, body.film .readout, body.reciting .readout { opacity: 0; pointer-events: none; }
.intro h1 { font: 400 34px/1 var(--serif); letter-spacing: -0.01em; margin-bottom: 10px; }
.intro p { color: var(--dim); }
.intro .more { margin-top: 12px; display: grid; gap: 9px; }
.intro .more[hidden] { display: none; }

.top { position: fixed; top: 24px; right: 26px; display: flex; gap: 2px; z-index: 3; }
.top button { padding: 8px 12px; border-radius: 999px; letter-spacing: 0.04em; color: var(--dim); transition: color .3s var(--ease), background .3s var(--ease); }
.top button:hover, .top button[aria-expanded="true"] { color: var(--ink); background: rgba(236, 230, 220, 0.07); }
#play { display: flex; align-items: center; gap: 8px; }
#play i { width: 0; height: 0; border-left: 7px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; }
#play[aria-pressed="true"] { color: var(--amber); }
#play[aria-pressed="true"] i { width: 7px; height: 9px; border: 0; border-left: 2.5px solid currentColor; border-right: 2.5px solid currentColor; }

.panel {
  position: fixed; top: 66px; right: 26px; width: 272px; z-index: 3;
  padding: 16px 16px 14px; border-radius: 14px; background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  display: grid; gap: 16px; max-height: calc(100vh - 140px); overflow: auto;
}
.panel[hidden] { display: none; }
.panel h2 { font: 500 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 9px; }
.panel section { display: grid; gap: 7px; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(236, 230, 220, 0.05); }
.seg button { flex: 1; padding: 6px 4px; border-radius: 7px; color: var(--dim); white-space: nowrap; font-size: 11px; }
.seg button[aria-checked="true"] { background: rgba(236, 230, 220, 0.12); color: var(--ink); }
.row { display: grid; grid-template-columns: 76px 1fr 42px; align-items: center; gap: 8px; color: var(--dim); }
.row output { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.row select { grid-column: 2 / 4; font: inherit; color: var(--ink); background: rgba(236, 230, 220, 0.06); border: 0; border-radius: 7px; padding: 5px 6px; }
.row select option { background: #141210; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: rgba(236, 230, 220, 0.18); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 2px; background: rgba(236, 230, 220, 0.18); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--amber); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--amber); }
.acts { grid-template-columns: 1fr 1fr; }
.acts button { padding: 8px 6px; border-radius: 8px; background: rgba(236, 230, 220, 0.06); color: var(--ink); font-size: 11px; }
.acts button:hover { background: rgba(236, 230, 220, 0.12); }
.acts #knock { grid-column: 1 / 3; }

.readout { position: fixed; left: 30px; bottom: 26px; z-index: 2; width: 250px; color: var(--dim); pointer-events: none; transition: opacity 1.2s var(--ease); }
#scope { width: 240px; height: 40px; display: block; margin-bottom: 8px; }
.readout dl { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; row-gap: 1px; font-size: 11px; }
.readout dt { color: var(--faint); }
.readout dd { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.readout dt.head { color: var(--ink); grid-column: 1 / 3; margin-bottom: 4px; letter-spacing: 0.04em; }

.intro .hint { margin-top: 14px; color: var(--amber); opacity: 0.85; transition: opacity 1.2s var(--ease); pointer-events: none; }
.intro .hint.gone { opacity: 0; }

.foot { position: fixed; right: 30px; bottom: 26px; z-index: 2; display: flex; gap: 18px; color: var(--faint); }
.foot .made a { color: var(--dim); text-decoration: none; }
.foot .made a:hover, .foot .made a:focus-visible { color: var(--ink); }

#recite[aria-pressed="true"] { color: var(--amber); }

.verse { position: fixed; left: 50%; bottom: 8vh; transform: translateX(-50%); width: min(92vw, 980px); text-align: center; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 1s var(--ease); }
.verse.on { opacity: 1; }
.verse .oe { font: italic 400 clamp(26px, 3.3vw, 46px)/1.2 var(--serif); color: var(--ink); text-shadow: 0 1px 22px rgba(0, 0, 0, 0.75); }
.verse .oe span { display: inline-block; opacity: 0; transform: translateY(4px); transition: opacity 1.1s var(--ease), transform 1.4s var(--ease); }
.verse .oe .h2 { margin-left: 0.8em; }
.verse .gl { margin-top: 12px; font-size: 13px; color: rgba(236, 230, 220, 0.74); text-shadow: 0 1px 14px rgba(0, 0, 0, 0.8); opacity: 0; transition: opacity 1.4s var(--ease); }
.verse .oe span.on, .verse .gl.on { opacity: 1; transform: none; }

.err { position: fixed; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--dim); z-index: 9; }
.err[hidden] { display: none; }

@media (max-width: 760px) {
  .intro { left: 16px; top: 16px; right: 16px; max-width: none; }
  .intro h1 { font-size: 28px; }
  .top { top: 12px; right: 8px; gap: 0; }
  .top button { padding: 8px 8px; font-size: 11px; }
  .panel { left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; max-height: 60vh; }
  .readout { left: 16px; bottom: 18px; width: 200px; }
  .readout dl { font-size: 10px; }
  .readout dt:not(.head), .readout dd { display: none; }   /* just the string and the scope on a phone */
  .readout dt.head { margin-bottom: 0; }
  #scope { width: 200px; }
  .hint { font-size: 11px; }
  .foot { right: 16px; bottom: 18px; font-size: 11px; }
  .foot #reset { display: none; }   /* a phone's reset is double-tap; the footer keeps only the hosted page's credit */
  .verse { bottom: 16vh; }
  .verse .oe .h2 { margin-left: 0; }
  .verse .gl { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { #c { transition: none; } }

/* ?render: the canvas alone, for the capture scripts */
body.render > :not(#c) { display: none !important; }
body.render #c { opacity: 1; transition: none; }
