/* The words are set in Shippori Mincho, cut down to the characters the site shows (tools/subset_font.sh). */
@font-face { font-family: "Shippori Mincho"; src: url("fonts/shippori-mincho.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --bg: #0b0806;
  --desk: #0b0806;
  --bone: #efe6d2;
  --bone-dim: #9a917f;
  --paper: #e6d8b4;
  --paper-shade: #8a6a3c;
  --rule: #7a5a3a;
  --ink-wet: #120a06;
  --ink-dry: #3d2616;
  --ink-other: #5f6670;
  --candle: #ffbe78;
  --serif: "Iowan Old Style", "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow-x: clip; background: var(--bg); color: var(--bone); font-family: var(--serif); }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.panel {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1.1rem;
  padding: 2rem; text-align: center; opacity: 0; visibility: hidden;
  transition: opacity 1.6s ease, visibility 0s linear 1.6s;
}
.panel.on { opacity: 1; visibility: visible; transition: opacity 1.6s ease; }

h1 { font-size: clamp(3rem, 9vw, 7.5rem); font-weight: 400; letter-spacing: 0.02em; line-height: 1; overflow-wrap: break-word; min-width: 0; }
h1 .ja { display: block; margin: 1.1rem 0 0.6rem; font-size: clamp(1rem, 2.2vw, 1.5rem); letter-spacing: 0.3em; color: var(--bone-dim); }
.work { color: var(--bone-dim); font-size: 1rem; }
.note { color: var(--bone-dim); font-size: 0.9rem; margin-top: 2.2rem; }

button {
  font: inherit; color: var(--bone); background: none; border: 1px solid var(--bone-dim);
  padding: 0.7rem 2.2rem; border-radius: 2px; cursor: pointer; min-height: 44px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
button:hover { border-color: var(--bone); background-color: color-mix(in srgb, var(--bone) 8%, transparent); }
button:disabled { opacity: 0.4; cursor: default; }
button:active { background-color: color-mix(in srgb, var(--bone) 16%, transparent); }
button:focus-visible, a:focus-visible, #progress:focus-visible { outline: 2px solid var(--candle); outline-offset: 3px; transition: none; }

#movements { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 1.4rem; max-width: 46rem; margin-top: 1.4rem; font-size: 0.85rem; }
#movements a, #outro a.next { color: var(--bone-dim); text-decoration: none; padding: 0.75rem 0.25rem; border-bottom: 1px solid transparent; transition: color 0.2s ease, border-color 0.2s ease; }
#movements a:hover, #outro a.next:hover { color: var(--bone); }
#movements a[aria-current] { color: var(--bone); border-bottom-color: var(--bone-dim); }
[hidden] { display: none !important; }

#silence { gap: 1.2rem; pointer-events: none; place-content: end center; padding-bottom: 9vh; }
#silence p { text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere; font-size: clamp(1.15rem, 2.4vw, 1.9rem); opacity: 0; transition: opacity 2s ease; }
#silence p.small { font-size: clamp(0.9rem, 1.4vw, 1.05rem); color: var(--bone-dim); }
#silence p.on { opacity: 1; }
#silence p.caption { font-size: 0.75rem; color: var(--bone-dim); }

#sub {
  position: fixed; left: 0; right: 0; bottom: 3.4rem; display: grid; justify-items: center; gap: 0.3rem;
  padding: 0 1.25rem; text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.9s ease;
}
#sub.on { opacity: 1; }
#sub-la { font-style: italic; font-size: clamp(0.8rem, 1.2vw, 0.95rem); color: var(--bone-dim); }
/* A long line may fold on a phone: at a phrase boundary where the browser can find one, and never before a full stop. */
#sub-ja { font-size: clamp(1rem, 2vw, 1.5rem); letter-spacing: 0.06em; text-wrap: balance; line-break: strict; word-break: auto-phrase; }

/* A remark about the music. The light on the whole page goes down, as if the candle had been shaded, and the words
   come up out of it in the middle; then they go, and the light comes back. The staves keep moving underneath. */
#note {
  position: fixed; inset: 0 0 20% 0; pointer-events: none; display: grid; place-content: center; justify-items: center; gap: 1.5rem;
  padding: 0 1.75rem; text-align: center;
  background: linear-gradient(color-mix(in srgb, var(--bg) 50%, transparent), color-mix(in srgb, var(--bg) 72%, transparent) 50%, color-mix(in srgb, var(--bg) 50%, transparent));
  opacity: 0; transition: opacity 2.2s ease 0.5s;
}
#note.on { opacity: 1; transition: opacity 2.4s ease; }
/* The words follow the dark in and leave before it: out of focus and a little low at first, then still. */
#note > * { opacity: 0; filter: blur(7px); translate: 0 0.5rem; transition: opacity 1.4s ease, filter 1.4s ease, translate 1.4s ease; }
#note.on > * { opacity: 1; filter: none; translate: 0 0; transition: opacity 2.6s ease 1s, filter 2.6s ease 1s, translate 3.4s cubic-bezier(0.2, 0.7, 0.2, 1) 1s; }
#note.on > .by { transition-delay: 2s; }
#note-text, #slide-text { text-wrap: balance; line-break: strict; word-break: auto-phrase; }
#note-text { max-width: 34em; font-size: clamp(1rem, 1.6vw, 1.3rem); line-height: 2.2; letter-spacing: 0.14em; text-shadow: 0 0 1.2rem var(--bg); }
.by { display: grid; justify-items: center; gap: 0.9rem; font-size: 0.74rem; color: var(--bone-dim); letter-spacing: 0.24em; }
.by::before { content: ""; width: 2.2rem; border-top: 1px solid color-mix(in srgb, var(--bone-dim) 60%, transparent); }
.by:empty { display: none; }

@media (max-width: 699px) { #note-text { letter-spacing: 0.08em; line-height: 2.05; } }

/* A page of words alone, in silence, before the music or after it. */
/* It comes down slowly and lifts slowly: this is the dark between two movements as well. */
#interlude { background: var(--bg); gap: 0; z-index: 2; transition: opacity 2.6s ease, visibility 0s linear 2.6s; }
#interlude.on { transition: opacity 2.2s ease; }
/* The last leaf of the autograph, torn corner and all, a ghost behind the words. Kept off the middle so the words stay clear. */
#leaf { position: absolute; inset: 0; margin: auto; width: min(92vw, 150vh); height: auto; max-height: 86vh; object-fit: contain; opacity: 0; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 46% 40% at 50% 50%, transparent 30%, #000 100%); mask-image: radial-gradient(ellipse 46% 40% at 50% 50%, transparent 30%, #000 100%);
  transition: opacity 1.2s ease; }
#leaf.on { opacity: 0.13; transition: opacity 3.2s ease 0.8s; }
#slide { position: relative; display: grid; justify-items: center; gap: 1.6rem; max-width: 40rem; opacity: 0; filter: blur(7px); transition: opacity 1.2s ease, filter 1.2s ease; }
#slide.on { opacity: 1; filter: none; transition: opacity 2.2s ease, filter 2.2s ease; }
#slide-text { white-space: pre-line; font-size: clamp(1.1rem, 2.1vw, 1.6rem); line-height: 2.1; letter-spacing: 0.14em; }
#skip { position: absolute; right: 1.25rem; bottom: 1.25rem; border: none; color: var(--bone-dim); font-size: 0.8rem; padding: 0.7rem 1rem; }
#sources { border: none; color: var(--bone-dim); font-size: 0.8rem; padding: 0.7rem 1rem; }

#outro { background: color-mix(in srgb, var(--bg) 82%, transparent); gap: 1.6rem; overflow-y: auto; place-content: safe center; padding-block: 1.5rem; }
#outro dl { max-width: 42rem; display: grid; gap: 0.3rem; text-align: left; font-size: 0.85rem; line-height: 1.7; color: var(--bone-dim); }
#outro dt { color: var(--bone); margin-top: 0.6rem; }
#outro a { color: var(--bone); }

#overlay {
  position: fixed; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; background-color: color-mix(in srgb, var(--bg) 62%, transparent);
  opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0s linear 0.35s, border-color 0.2s ease, background-color 0.2s ease;
}
#overlay:hover { background-color: color-mix(in srgb, var(--bg) 78%, transparent); }
#overlay svg { width: 30px; height: 30px; fill: none; stroke: var(--bone); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#overlay .play, .paused #overlay .pause { display: none; }
.paused #overlay .play { display: block; }
/* Only over a piece that is under way: never over the opening or the sources. */
body:has(#hud.on):is(.awake, .paused) #overlay, body:has(#hud.on) #overlay:focus-visible {
  opacity: 1; visibility: visible; transition: opacity 0.35s ease, border-color 0.2s ease, background-color 0.2s ease;
}

#hud {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; gap: 1rem;
  padding: 0 1.25rem 1.6rem; font-size: 0.8rem; color: var(--bone-dim);
  opacity: 0; transition: opacity 1s ease;
}
#hud.on { opacity: 1; }
#bar { min-width: 6em; font-variant-numeric: tabular-nums; }
#toggle { border: none; padding: 0 0.5rem; min-height: 44px; margin-bottom: -0.8rem; margin-left: auto; color: var(--bone-dim); font-size: 0.8rem; }
#toggle:hover { color: var(--bone); background: none; }
#progress { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; cursor: pointer; }
#progress::before, #fill, #mark { content: ""; position: absolute; bottom: 0; height: 1px; }
#progress::before { left: 0; right: 0; background: color-mix(in srgb, var(--bone) 14%, transparent); }
#fill { left: 0; width: 100%; background: var(--bone-dim); transform-origin: left; transform: scaleX(0); }
#mark { width: 1px; height: 7px; background: var(--candle); }

@media (prefers-reduced-motion: reduce) {
  .panel, .panel.on, #silence p, #hud, #sub, #note, #note > *, #note.on > *, #slide, #leaf, button, #overlay { transition: none; filter: none; translate: none; }
}
