/* Nixon in China listening notes.

   The look is that of the visit itself, which was staged for television: a
   dark screen with scan lines, colour bars on the title page, captions in
   the lower third of the picture, level meters for the three measures, and
   a monospaced face for every label. The page is a screen, so it is dark
   whatever the reader's colour scheme.

   The colours change with the scene, six grounds and one for the pages
   around them:

     bars     the pages of introduction: neutral, with the bars' yellow
     air      Act I, scene 1: the airfield on a cold morning, blue
     study    Act I, scene 2: Mao's study, lamplight and books, amber
     banquet  Act I, scene 3: the Great Hall of the People, red and gold
     tour     Act II, scene 1: Pat's morning in the snow, pale green-blue
     ballet   Act II, scene 2: The Red Detachment of Women, magenta
     night    Act III: the last night in Peking, after sign-off, grey

   The page is a deck of full-screen pages turned sideways, as on the
   Turandot and Bach pages: a title page, four pages of introduction, then
   for each scene a contents page and one page per passage (one track of the
   recordings), and two closing pages. A bar along the bottom turns the
   pages; the timer, when switched on, adds a row above it. */

@font-face {
    font-family: 'IBM Plex Sans'; font-weight: 300 600; font-display: swap;
    src: url('../assets/fonts/ibm-plex-sans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'IBM Plex Sans'; font-weight: 300 600; font-display: swap;
    src: url('../assets/fonts/ibm-plex-sans-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113;
}
@font-face {
    font-family: 'IBM Plex Sans'; font-style: italic; font-weight: 400; font-display: swap;
    src: url('../assets/fonts/ibm-plex-sans-400i-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap;
    src: url('../assets/fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap;
    src: url('../assets/fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
}

:root {
    color-scheme: dark;
    --sans: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    --gut: max(20px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --ink: #eef0f2; --body: #c9cfd6; --dim: #8b949e; --line: rgba(255, 255, 255, .16);
    --lo: #39d27a; --mid: #f2c230; --hi: #ff5a4c;
}
/* Each ground: the screen, the accent of labels, and the caption's two fields
   (the tag on the left, the band beside it). */
:root, .sc-bars, [data-sc="bars"]       { --bg: #0b0d10; --acc: #f2c230; --tag: #f2c230; --on-tag: #0b0d10; --band: #2b313a; }
.sc-air, [data-sc="air"]                 { --bg: #090d14; --acc: #8cc4ff; --tag: #f2c230; --on-tag: #0b0d10; --band: #12439b; }
.sc-study, [data-sc="study"]             { --bg: #110d08; --acc: #f0a840; --tag: #f0a840; --on-tag: #160f06; --band: #5c3410; }
.sc-banquet, [data-sc="banquet"]         { --bg: #130909; --acc: #ffcf5a; --tag: #ffcf5a; --on-tag: #2a0806; --band: #a3201a; }
.sc-tour, [data-sc="tour"]               { --bg: #091112; --acc: #8fe0d4; --tag: #e8eef0; --on-tag: #0a1416; --band: #1b6670; }
.sc-ballet, [data-sc="ballet"]           { --bg: #120911; --acc: #ff7dba; --tag: #ff7dba; --on-tag: #22061a; --band: #8f1260; }
.sc-night, [data-sc="night"]             { --bg: #060708; --acc: #a9bab2; --tag: #a9bab2; --on-tag: #0a0c0c; --band: #252b2c; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    background: var(--bg); color: var(--ink); transition: background-color .4s;
    font-family: var(--sans); font-size: 16.5px; line-height: 1.45; font-kerning: normal;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--acc); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; height: 100dvh; display: flex; flex-direction: column; }
/* the tube: scan lines and darkened corners, over the pages only */
.tube { flex: 1; min-height: 0; position: relative; display: flex; }
.tube::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .16) 2px 3px),
                radial-gradient(130% 100% at 50% 45%, transparent 60%, rgba(0, 0, 0, .5));
}

/* labels: monospaced capitals */
.mono, .meta, .cue small, .ms dt, .strip, .bar, .tr, .prose h2 small, .prose h3, .scenehead .sn, .tl .n, .tl .d, .tl .ah,
.btn, .cast dt, .days dt, .links a, dialog .dh, .away, .tool h3 small, .cells, .chord, .l3 {
    font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em;
}

/* ═════════ The deck ═════════ */
.deck {
    flex: 1; min-width: 0; display: flex;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.slide {
    flex: 0 0 100%; width: 100%; height: 100%;
    scroll-snap-align: start; scroll-snap-stop: always;
    overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: none;
    color: var(--ink); background: var(--bg);
}
.slide::-webkit-scrollbar { display: none; }
.in {
    max-width: 640px; margin: 0 auto; min-height: 100%;
    padding: calc(max(18px, env(safe-area-inset-top, 0px)) + 6px) var(--gut) 28px;
}

/* ─── Title page ─── */
.cover .in { display: flex; flex-direction: column; padding-top: 0; padding-bottom: 0; }
.bars { display: flex; height: min(22vh, 170px); margin: 0 calc(-1 * var(--gut)); flex: none; }
.bars2 { display: flex; height: 16px; margin: 0 calc(-1 * var(--gut)); flex: none; }
.bars i, .bars2 i { flex: 1; }
.cover .mono { font-size: 11.5px; display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; color: var(--dim); }
.live { color: var(--hi); }
.live::before, .who::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 7px; }
.cover h1 {
    font-weight: 600; font-size: clamp(54px, 18vw, 96px); line-height: .88; letter-spacing: -.035em; margin-top: max(28px, 5vh);
    text-shadow: 2px 0 rgba(224, 48, 48, .5), -2px 0 rgba(32, 192, 224, .5);
}
.cover .by { font-size: 11.5px; color: var(--dim); margin-top: 18px; display: block; line-height: 1.7; }
.go { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn { border: 1.5px solid var(--ink); padding: 11px 14px 10px; font-size: 12.5px; font-weight: 500; border-radius: 3px; background: var(--ink); color: var(--bg); }
.btn.alt { background: none; color: var(--ink); }
.hint { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 18px 0; }
/* a caption in the lower third of the picture */
.l3 { margin: auto calc(-1 * var(--gut)) 0; display: flex; align-items: stretch; font-size: 12px; flex: none; }
.l3 b { background: var(--tag); color: var(--on-tag); padding: 9px 12px 8px var(--gut); font-weight: 500; letter-spacing: .12em; }
.l3 span { flex: 1; background: var(--band); padding: 9px var(--gut) 8px 12px; font-family: var(--sans); text-transform: none; letter-spacing: .01em; font-size: 13.5px; font-weight: 500; }

/* ─── Pages of prose ─── */
.prose h2, .scenehead h2 { font-weight: 600; font-size: clamp(28px, 8vw, 40px); line-height: 1.02; letter-spacing: -.02em; text-wrap: balance; margin: 6px 0 16px; }
.prose h2 small, .scenehead .sn { display: block; font-size: 11px; font-weight: 400; color: var(--acc); margin-bottom: 10px; letter-spacing: .1em; }
.prose h3 { font-size: 11px; font-weight: 500; color: var(--acc); margin: 1.6em 0 .5em; letter-spacing: .1em; }
.prose p, .prose li, .prose dd { color: var(--body); text-wrap: pretty; }
.prose p + p { margin-top: .7em; }
.prose ul { padding-left: 1.1em; }
.prose li { margin: .45em 0; }
.prose li::marker { color: var(--acc); }
.prose b { font-weight: 600; color: var(--ink); }
.cast, .days { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 14px 0 6px; }
.cast dt, .days dt { font-size: 11px; color: var(--acc); padding-top: .35em; }
.cast dd b { display: block; font-size: 18px; }
.cast:not(.small) { display: block; }
.cast:not(.small) dt { padding-top: 14px; }
.cast.small { gap: 2px 16px; }
.cast.small dd { color: var(--ink); }
.days dd i { font-style: normal; color: var(--dim); display: block; font-size: 14px; margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.links a { font-size: 11px; text-decoration: none; border: 1px solid var(--line); padding: 8px 10px 7px; color: var(--ink); border-radius: 3px; }
.scale { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 14px 0; align-items: center; }
.home { margin-top: 36px !important; font-size: 14px; }
.rec + .rec { margin-top: 26px; padding-top: 4px; border-top: 1px solid var(--line); }

/* The three measures: four segments of a level meter */
/* Chinese names: the system's Chinese face, upright and unspaced */
.zh { font-family: 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Noto Sans CJK SC', 'Source Han Sans SC', 'Microsoft YaHei', 'WenQuanYi Zen Hei', sans-serif; font-style: normal; letter-spacing: 0; white-space: nowrap; }

.lv { display: inline-flex; gap: 3px; vertical-align: middle; }
.lv i { width: 15px; height: 9px; background: rgba(255, 255, 255, .11); }
.lv i.f { background: var(--lo); }
.lv i.f:nth-child(3) { background: var(--mid); }
.lv i.f:nth-child(4) { background: var(--hi); }

/* ─── Scene pages ─── */
.scenehead h2 { font-size: clamp(30px, 9vw, 46px); margin-bottom: 8px; }
.scenehead .when { font-size: 15px; color: var(--dim); margin: 0 0 14px; }
.scenehead .syn { color: var(--body); text-wrap: pretty; margin-bottom: 18px; }
.tl { list-style: none; }
.tl button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: baseline; padding: 9px 0 8px; border-bottom: 1px solid var(--line); }
.tl .n { font-size: 11px; color: var(--acc); width: 2.1em; flex: none; }
.tl .t { flex: 1; font-weight: 500; }
.tl .t small { display: block; font-weight: 400; font-size: 13.5px; color: var(--dim); }
.tl .d { font-size: 11px; color: var(--dim); }
.tl .ah { font-size: 10.5px; color: var(--acc); padding: 18px 0 4px; letter-spacing: .1em; }
.tl .cur .t { color: var(--acc); }

/* ─── A passage ─── */
.page .in { display: flex; flex-direction: column; padding-bottom: 0; }
.mid { flex: 1; padding-bottom: 22px; }
.meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 10.5px; color: var(--dim); }
.meta .who { color: var(--hi); text-align: right; }
.page h2 { font-size: clamp(27px, 7.6vw, 38px); line-height: 1.04; font-weight: 600; letter-spacing: -.02em; margin: 10px 0 0; text-wrap: balance; }
.cue { font-size: clamp(19px, 5.4vw, 23px); line-height: 1.25; margin: 14px 0 4px; padding-left: 12px; border-left: 3px solid var(--acc); text-wrap: balance; }
.cue small { display: block; font-size: 10.5px; color: var(--acc); margin-bottom: 3px; letter-spacing: .1em; }
.page .mid > p { color: var(--body); margin-top: 12px; text-wrap: pretty; }
.page .mid > p b { color: var(--ink); font-weight: 600; }
.keyline { margin: 16px 0 2px; padding: 12px 14px; background: rgba(255, 255, 255, .055); border-radius: 3px; }
.keyline q { display: block; font-size: 19px; line-height: 1.28; font-style: italic; quotes: "“" "”"; color: var(--ink); }
.keyline span { display: block; font-size: 14.5px; color: var(--body); margin-top: 6px; }
.ms { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 12px; align-items: center; margin-top: 18px; }
.ms dt { font-size: 10.5px; color: var(--dim); }
.ms dd.w { font-size: 14px; color: var(--body); }
.strip {
    flex: none; position: sticky; bottom: 0; z-index: 1; background: var(--band); color: var(--ink);
    margin: 0 calc(-1 * var(--gut)); padding: 10px var(--gut) 9px;
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: left;
    font-size: 11px; letter-spacing: .05em;
}
.strip .rc::after { content: " ▾"; }
.strip .at { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ─── Adams's toolkit: four sounding examples ─── */
.tool { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; }
.tool h3 { font-family: var(--sans); text-transform: none; letter-spacing: -.01em; font-size: 21px; font-weight: 600; color: var(--ink); margin: 0 0 4px; }
.tool h3 small { font-size: 10.5px; color: var(--acc); margin-right: 10px; font-weight: 400; letter-spacing: .1em; }
.tool .play { margin-top: 12px; border: 1.5px solid var(--ink); border-radius: 3px; padding: 8px 14px 7px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; min-width: 92px; }
.tool .play[aria-pressed="true"] { background: var(--hi); border-color: var(--hi); color: #14080a; }
.cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 12px; font-size: 10px; }
.cells i { height: 22px; background: rgba(255, 255, 255, .09); font-style: normal; }
.cells i.acc { background: rgba(255, 255, 255, .26); height: 30px; margin-top: -8px; }
.cells i.on { background: var(--lo); }
.cells i.acc.on { background: var(--mid); }
.lanes { margin-top: 12px; display: grid; gap: 3px; }
.lanes .cells { margin-top: 0; }
.say { font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); margin-top: 8px; min-height: 1.5em; }
.chord { display: flex; gap: 6px; margin-top: 12px; font-size: 15px; }
.chord i { font-style: normal; flex: 1; text-align: center; padding: 9px 0 8px; background: rgba(255, 255, 255, .09); color: var(--ink); transition: background-color .15s; }
.chord i.mv { background: var(--mid); color: #14100a; }

/* ═════════ The timer row ═════════ */
.timer { flex: none; border-top: 1px solid var(--line); padding: 0 var(--gut); background: #07080a; color: var(--ink); }
.tr { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 6px; height: 58px; font-size: 11px; }
.tr .where { font-size: 10px; line-height: 1.4; color: var(--dim); }
.tr .where b { display: block; font-size: 15px; font-weight: 500; color: var(--acc); font-variant-numeric: tabular-nums; }
.tr .clock { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.tr button { min-width: 48px; height: 44px; white-space: nowrap; }
.tr .pp { width: 40px; min-width: 40px; height: 40px; margin: 0 10px; background: var(--ink); color: #07080a; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.tr .pp svg { width: 15px; height: 15px; fill: currentColor; }
.tr .pp .i-pause, .playing .tr .pp .i-play { display: none; }
.playing .tr .pp .i-pause { display: block; }
.playing .tr .pp { background: var(--hi); }
.away { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.away span { flex: 1; font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--body); line-height: 1.2; }
.away button { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; }
.away #tonow { background: var(--ink); color: #07080a; border-color: var(--ink); }

/* ═════════ The bar ═════════ */
.bar {
    flex: none; position: relative; display: grid; grid-template-columns: 52px 1fr auto 1fr 52px; align-items: center;
    border-top: 1px solid var(--line); background: #07080a; color: var(--dim);
    padding: 0 max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px));
    font-size: 11.5px;
}
.bar button { height: 50px; }
.bar .arrow { display: flex; align-items: center; justify-content: center; color: var(--ink); }
.bar .arrow svg { width: 20px; height: 20px; }
.bar .arrow:disabled { opacity: .25; }
.bar .txt { justify-self: center; padding: 0 12px; color: var(--ink); }
.bar .txt[aria-pressed="true"] { color: var(--hi); }
.bar .txt[aria-pressed="true"]::after { content: " on"; }
.bar .pos { font-variant-numeric: tabular-nums; white-space: nowrap; }
.prog { position: absolute; left: 0; right: 0; top: -1px; height: 2px; }
.prog i { display: block; height: 100%; width: 0; background: var(--acc); }

/* ═════════ Dialogs ═════════ */
dialog {
    margin: auto; width: min(540px, calc(100vw - 28px)); max-height: min(82vh, 720px);
    background: #0d1014; color: var(--ink); border: 1px solid rgba(255, 255, 255, .3); border-radius: 4px; padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog .dh { position: sticky; top: 0; background: #0d1014; display: flex; justify-content: space-between; align-items: center; padding: 13px 16px 11px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
dialog .dh button { color: var(--acc); text-transform: uppercase; letter-spacing: .08em; min-height: 32px; }
dialog .tl { padding: 0 16px 16px; }
.pick { list-style: none; padding: 6px 16px 16px; }
.pick button { display: block; width: 100%; text-align: left; padding: 12px 0 11px; border-bottom: 1px solid var(--line); }
.pick b { display: block; font-weight: 600; }
.pick small { display: block; font-size: 14px; color: var(--dim); }
.pick .cur b::before { content: "● "; color: var(--hi); }

/* ═════════ Wide screens ═════════ */
@media (min-width: 900px) {
    body { font-size: 18.5px; }
    .in, .tr, .away { max-width: 760px; }
    .cover h1 { font-size: 120px; }
    .ms dd.w { font-size: 15.5px; }
    .keyline q { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { body { transition: none; } }
