/* The Museum of Us — museum.css
   Institutional and restrained: small labels, precise numbering, thin rules, generous space.
   One controller at the bottom (the tour card); everything else stays out of the architecture's way. */
:root {
  --white: #F5F4EF; --ivory: #E9E7DF; --timber: #D8CCB8; --metal: #A3A49C; --olive: #A4A59E;
  --grey: #77776F; --ink: #292523; --red: #A8452F; --rule: rgba(41, 37, 35, .16); --rule-strong: rgba(41, 37, 35, .7);
  --f: "Akzidenz-Grotesk Std", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--white); color: var(--ink); font-family: var(--f); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input, textarea { font: inherit; color: var(--ink); }
.hidden { display: none !important; }
.kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.btn { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 0 18px; font-size: 16px; font-weight: 500; width: 100%; text-align: left; }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:active { background: #000; }
.btn-primary[disabled] { opacity: .35; }
.btn-ghost { border: 1px solid var(--ink); }
.btn-line { border-top: 1px solid var(--rule-strong); padding: 0; min-height: 48px; }
.btn-text { min-height: 44px; padding: 0 2px; font-size: 14px; font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.arrow::after { content: "\2192"; font-weight: 400; }
.back::before { content: "\2190"; font-weight: 400; margin-right: 8px; }

/* ---------- opening ---------- */
#opening { position: fixed; inset: 0; z-index: 30; background: var(--white); display: flex; flex-direction: column; }
#opening .photo { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #e8e6df; }
#opening .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 54% 52%; transform-origin: 54% 56%; animation: drift 18s ease-in-out infinite alternate; will-change: transform; }
@keyframes drift { from { transform: scale(1.0); } to { transform: scale(1.07); } }
#opening .poster { flex: 0 0 auto; padding: 16px 20px calc(18px + var(--safe-b)); background: var(--white); }
#opening .meta { display: flex; justify-content: space-between; border-top: 1px solid var(--ink); padding-top: 8px; }
#opening .gift { font-size: 20px; font-weight: 700; letter-spacing: -.015em; margin-top: 14px; color: var(--red); }
#opening h1 { font-size: clamp(50px, 16vw, 72px); line-height: .86; letter-spacing: -.045em; font-weight: 700; margin: 12px 0 12px; }
#opening .sub { font-size: 18px; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
#opening .for { font-size: 14px; line-height: 1.4; color: var(--grey); margin-top: 4px; }
#opening .doors { margin-top: 16px; display: grid; gap: 8px; }
#opening.stepping .photo { position: fixed; inset: 0; z-index: 4; }
#opening.stepping .photo img { animation: none; object-position: 50% 50%; transform: scale(1.0); }
#opening.stepping .poster, #opening.stepping #desk { transform: translateY(110%); transition: transform .5s cubic-bezier(.5, 0, .3, 1); }
#opening.stepping.leaving { background: transparent; pointer-events: none; }
#opening.stepping.leaving .photo { background: transparent; }
#opening.stepping.leaving .photo img { transition: transform 2.2s cubic-bezier(.3, 0, .2, 1), opacity 1.3s ease .25s; transform: scale(1.2); opacity: 0; }
#desk { position: relative; flex: 0 0 auto; background: var(--white); padding: 18px 20px calc(18px + var(--safe-b)); }
#desk:not(.open) { display: none; }
#desk.open { animation: rise .5s cubic-bezier(.2, .7, .2, 1); }
#opening.desking .poster { display: none; }
@keyframes rise { from { transform: translateY(50px); opacity: 0; } to { transform: none; opacity: 1; } }
#desk .meta { display: flex; justify-content: space-between; border-top: 1px solid var(--ink); padding-top: 8px; }
#desk .dq-k { font-size: 13px; color: var(--grey); margin-top: 18px; }
#desk .dq { font-size: 26px; line-height: 1.12; letter-spacing: -.02em; font-weight: 700; margin-top: 6px; }
#desk .dq-m { font-size: 13px; line-height: 1.4; margin-top: 10px; min-height: 18px; }
#desk .actions { margin-top: 12px; display: grid; gap: 8px; }

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; z-index: 1; background: var(--white); }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
body.workshop #stage { bottom: auto; height: 44%; }
#chip { position: absolute; left: 12px; top: calc(10px + var(--safe-t)); background: rgba(245, 244, 239, .94); padding: 8px 10px 7px; font-size: 12.5px; line-height: 1.2; text-align: left; border: 1px solid var(--rule); display: flex; gap: 6px; align-items: baseline; max-width: calc(100% - 140px); }
#chip span { color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ctools { position: absolute; right: 12px; top: calc(10px + var(--safe-t)); display: flex; gap: 4px; }
#ctools button { min-height: 36px; padding: 0 10px; font-size: 13px; font-weight: 500; background: rgba(245, 244, 239, .94); border: 1px solid var(--rule); }
#ctools .dark { background: var(--ink); color: var(--white); border-color: var(--ink); }
#hint { position: absolute; left: 50%; top: calc(58px + var(--safe-t)); transform: translateX(-50%); font-size: 12px; color: var(--ink); background: rgba(245, 244, 239, .92); padding: 6px 10px; opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }
#hint.on { opacity: 1; }
body.finale #chip, body.finale #ctools, body.finale #dock, body.workshop #dock, body.workshop #ctools { opacity: 0; pointer-events: none; }
body.workshop #chip { pointer-events: none; }

/* ---------- the dock: progress rail + tour card ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 0 0; transition: opacity .3s; z-index: 5; }
#rail { display: flex; gap: 3px; padding: 0 12px 8px; align-items: flex-end; }
#rail button { flex: 1; height: 26px; position: relative; display: flex; align-items: flex-end; }
#rail button i { display: block; width: 100%; height: 2px; background: rgba(41, 37, 35, .22); transition: height .2s, background .2s; }
#rail button.seen i { background: rgba(41, 37, 35, .5); }
#rail button.on i { background: var(--ink); height: 4px; }
#rail button.start { flex: 0 0 22px; }
#rail button.start i { width: 8px; height: 8px; border-radius: 50%; background: rgba(41, 37, 35, .3); margin: 0 auto 0 0; }
#rail button.start.on i { background: var(--ink); }
#card { background: var(--white); border-top: 1px solid var(--ink); padding: 12px 16px calc(10px + var(--safe-b)); touch-action: pan-y; will-change: transform; box-shadow: 0 -18px 30px -24px rgba(41, 37, 35, .35); }
#card.slide-l { animation: slideL .32s ease; } #card.slide-r { animation: slideR .32s ease; }
@keyframes slideL { from { transform: translateX(40px); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes slideR { from { transform: translateX(-40px); opacity: .2; } to { transform: none; opacity: 1; } }
#card .k { display: flex; justify-content: space-between; align-items: baseline; }
#card h2 { font-size: 22px; line-height: 1.1; letter-spacing: -.02em; font-weight: 700; margin-top: 6px; }
#card .med { font-size: 13px; color: var(--grey); margin-top: 3px; }
#card .lead { font-size: 15px; line-height: 1.4; margin-top: 6px; }
#card .acts { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
#card .acts .sp { flex: 1; }
#card .arrows { display: flex; gap: 6px; }
#card .arrows button { width: 46px; height: 44px; border: 1px solid var(--rule-strong); font-size: 18px; }
#card .arrows button.go { background: var(--ink); color: var(--white); border-color: var(--ink); }
#card .arrows button[disabled] { opacity: .25; }
#card .primary { margin-top: 10px; }
#card .detail { max-height: 0; overflow: hidden; transition: max-height .35s ease; }
#card.open .detail { max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#card .detail .acct { font-size: 15px; line-height: 1.4; margin-top: 12px; padding-left: 10px; border-left: 1px solid var(--ink); white-space: pre-wrap; }
#card .detail .desc { font-size: 14px; line-height: 1.45; margin-top: 10px; }
#card .detail .more { font-size: 13px; line-height: 1.45; margin-top: 10px; color: var(--grey); border-top: 1px solid var(--rule); padding-top: 10px; }
#card .detail .row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
#card .amend { margin-top: 10px; padding: 9px 10px; background: #EEEFE4; border-left: 2px solid var(--olive); font-size: 13px; line-height: 1.4; }
#card .amend b { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: #5d5e55; margin-bottom: 3px; }
#card .pub { margin-top: 12px; border-top: 1px solid var(--rule); padding-top: 8px; }
#card .pub h4 { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); font-weight: 500; display: flex; justify-content: space-between; }
#card .pub li { list-style: none; font-size: 13px; line-height: 1.4; padding: 6px 0; border-bottom: 1px solid var(--rule); }
#card .pub li span { color: var(--grey); }
#card .photo-full { width: 100%; margin-top: 10px; display: block; border: 8px solid #fff; box-shadow: 0 0 0 1px var(--rule); }
#card .play { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
#card .play button { min-height: 44px; padding: 0 14px; background: var(--ink); color: var(--white); font-size: 14px; }
#card .play .track { flex: 1; height: 1px; background: var(--rule-strong); position: relative; }
#card .play .track i { position: absolute; left: 0; top: -1px; height: 3px; background: var(--ink); width: 0; }
#card .speaking { text-decoration: none; background: var(--ink); color: var(--white); padding: 0 10px; }

/* ---------- guide: plays itself ---------- */
#guide { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
#guide .cap { position: absolute; left: 12px; right: 12px; top: calc(54px + var(--safe-t)); background: var(--white); border-top: 1px solid var(--ink); padding: 10px 12px 12px; pointer-events: auto; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; box-shadow: 0 16px 30px -24px rgba(41, 37, 35, .4); }
#guide .steps { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
#guide .steps i { height: 2px; background: var(--rule); position: relative; overflow: hidden; }
#guide .steps i b { position: absolute; inset: 0; background: var(--ink); transform-origin: left; transform: scaleX(0); }
#guide .t { font-size: 18px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; min-height: 44px; display: flex; align-items: center; }
#guide .finger { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border: 1.5px solid var(--ink); border-radius: 50%; background: rgba(245, 244, 239, .5); left: -100px; top: -100px; transition: transform .15s; }
#guide .finger::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--ink); }
#guide .finger.down { transform: scale(.78); background: rgba(41, 37, 35, .18); }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--white); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(14px + var(--safe-t)) 20px calc(24px + var(--safe-b)); opacity: 0; transform: translateY(14px); transition: opacity .3s, transform .3s; pointer-events: none; visibility: hidden; }
.sheet.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; }
.sheet .top { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--ink); padding-bottom: 8px; min-height: 44px; }
.sheet .close { min-width: 44px; min-height: 44px; text-align: right; font-size: 14px; font-weight: 500; }
.sheet h2 { font-size: 30px; line-height: 1.02; letter-spacing: -.035em; font-weight: 700; margin: 20px 0 8px; }
.sheet p { font-size: 14px; line-height: 1.5; }
.sheet .muted { color: var(--grey); }
.sheet section { margin-top: 24px; }
.sheet section > .kicker { border-bottom: 1px solid var(--rule); padding-bottom: 6px; margin-bottom: 4px; display: block; }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); margin-bottom: 2px; }
.field input, .field textarea { width: 100%; border: 0; border-bottom: 1px solid var(--rule-strong); background: transparent; padding: 8px 0 7px; font-size: 17px; border-radius: 0; outline: none; resize: none; -webkit-appearance: none; }
.field textarea { min-height: 64px; line-height: 1.35; }
.field input:focus, .field textarea:focus { border-bottom-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }
.linkbox { margin-top: 10px; font-size: 12px; word-break: break-all; background: var(--ivory); padding: 10px; max-height: 76px; overflow: auto; user-select: all; -webkit-user-select: all; }
.choice { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; min-height: 46px; border-bottom: 1px solid var(--rule); width: 100%; text-align: left; font-size: 14px; }
.choice i { width: 14px; height: 14px; border: 1px solid var(--ink); display: block; }
.choice.on i { background: var(--ink); box-shadow: inset 0 0 0 2px var(--white); }
.notice { margin-top: 14px; font-size: 12.5px; line-height: 1.5; color: var(--grey); border-top: 1px solid var(--rule); padding-top: 10px; }

/* catalogue */
#catalogue .cover { padding: 24px 0 18px; border-bottom: 1px solid var(--rule); }
#catalogue .cover h1 { font-size: 52px; line-height: .86; letter-spacing: -.045em; font-weight: 700; margin: 10px 0 14px; }
#catalogue .entry { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); width: 100%; text-align: left; }
#catalogue .entry .th { width: 96px; height: 72px; background: var(--ivory); background-size: cover; background-position: center; }
#catalogue .entry .n { font-size: 11px; font-weight: 600; letter-spacing: .04em; display: block; }
#catalogue .entry .ti { font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin-top: 2px; display: block; }
#catalogue .entry .de { font-size: 12.5px; line-height: 1.4; color: var(--grey); margin-top: 4px; display: block; }
#catalogue .rev { font-size: 12.5px; color: var(--grey); padding: 7px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.links button, .links label { display: flex; width: 100%; justify-content: space-between; min-height: 48px; border-bottom: 1px solid var(--rule); font-size: 15px; font-weight: 500; align-items: center; cursor: pointer; }
.links input { display: none; }

/* letter */
#letter { display: flex; flex-direction: column; justify-content: center; }
#letter .paper { max-width: 340px; margin: 0 auto; width: 100%; }
#letter .byline { margin-bottom: 26px; }
#letter .msg { font-size: 21px; line-height: 1.38; letter-spacing: -.01em; white-space: pre-wrap; }
#letter .msg span { opacity: 0; transition: opacity 1.1s ease; }
#letter .msg span.on { opacity: 1; }
#letter .end { margin-top: 34px; opacity: 0; transition: opacity .8s; }
#letter .end.on { opacity: 1; }

/* finale */
#finale { position: absolute; inset: 0; z-index: 9; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: calc(56px + var(--safe-t)) 20px calc(16px + var(--safe-b)); }
#finale .line { font-size: 25px; line-height: 1.14; letter-spacing: -.025em; font-weight: 700; max-width: 320px; }
#finale .line span { display: block; opacity: 0; transform: translateY(6px); transition: opacity 1.4s, transform 1.4s; }
#finale .line span.on { opacity: 1; transform: none; }
#finale .acts { background: var(--white); border-top: 1px solid var(--ink); padding: 12px 0 0; pointer-events: auto; opacity: 0; transition: opacity .8s; }
#finale .acts.on { opacity: 1; }
#finale .acts .side { font-size: 14px; margin-bottom: 10px; }
#finale .acts .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---------- the workshop: making a museum ---------- */
#workshop { top: 44%; transform: none; border-top: 1px solid var(--ink); padding-top: 12px; }
#workshop.open { transform: none; }
#workshop .bar { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
#workshop h2 { font-size: 28px; margin: 10px 0 4px; }
#workshop .prompt { font-size: 16px; line-height: 1.35; color: var(--grey); }
.shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.shelf button { text-align: left; border: 1px solid var(--rule); padding: 10px 10px 11px; min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; position: relative; background: #FAF9F5; }
.shelf button svg { width: 34px; height: 34px; stroke: var(--ink); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.shelf button b { font-size: 15px; letter-spacing: -.01em; display: block; margin-top: 8px; }
.shelf button small { font-size: 12px; line-height: 1.3; color: var(--grey); display: block; margin-top: 2px; }
.shelf button.done { border-color: var(--ink); background: var(--white); }
.shelf button.done::after { content: attr(data-no); position: absolute; right: 8px; top: 8px; font-size: 10px; font-weight: 700; letter-spacing: .06em; background: var(--ink); color: var(--white); padding: 3px 5px 2px; }
.shelf button .sug { position: absolute; right: 8px; top: 9px; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.count { font-size: 13px; color: var(--grey); margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { border: 1px solid var(--rule-strong); padding: 7px 10px; font-size: 13px; min-height: 36px; text-align: left; }
.tray { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.tray button { border: 1px solid var(--rule); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10.5px; color: var(--grey); background: #FAF9F5; }
.tray button svg { width: 30px; height: 30px; stroke: var(--ink); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tray button.on { border-color: var(--ink); background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.wfoot { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin-top: 18px; position: sticky; bottom: calc(-24px - var(--safe-b)); background: var(--white); padding: 10px 0 calc(14px + var(--safe-b)); border-top: 1px solid var(--rule); }
.uploads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.uploads .u { aspect-ratio: 1; background-size: cover; background-position: center; position: relative; border: 1px solid var(--rule); }
.uploads .u button { position: absolute; right: 0; top: 0; width: 30px; height: 30px; background: rgba(245, 244, 239, .92); font-size: 15px; }
.pick { display: flex; align-items: center; justify-content: space-between; min-height: 52px; border: 1px solid var(--ink); padding: 0 16px; font-size: 15px; font-weight: 500; margin-top: 14px; cursor: pointer; }
.pick input { display: none; }
.printed { margin-top: 14px; border: 1px solid var(--rule); background: #FDFCF8; padding: 14px 14px 12px; }
.printed .pl { overflow: hidden; }
.printed .pl > * { animation: print .7s cubic-bezier(.2, .7, .2, 1) both; }
.printed .pl:nth-child(2) > * { animation-delay: .15s; } .printed .pl:nth-child(3) > * { animation-delay: .3s; } .printed .pl:nth-child(4) > * { animation-delay: .45s; }
@keyframes print { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.printed .t1 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; margin-top: 4px; }
.printed .t2 { font-size: 13px; color: var(--grey); margin-top: 3px; }
.printed .t3 { font-size: 14px; line-height: 1.45; margin-top: 8px; }
.tones { display: flex; gap: 0; margin-top: 12px; border: 1px solid var(--ink); }
.tones button { flex: 1; min-height: 40px; font-size: 13px; font-weight: 500; }
.tones button + button { border-left: 1px solid var(--ink); }
.tones button.on { background: var(--ink); color: var(--white); }
.editwords { margin-top: 6px; }

#imgview img { width: 100%; display: block; margin-top: 16px; border: 1px solid var(--rule); }
#toast { position: fixed; left: 50%; top: calc(60px + var(--safe-t)); transform: translate(-50%, -10px); background: var(--ink); color: var(--white); font-size: 13px; padding: 10px 14px; z-index: 40; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; max-width: 86%; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  #opening { flex-direction: row; }
  #opening .poster, #desk { width: 420px; display: flex; flex-direction: column; justify-content: flex-end; }
  .sheet > * { max-width: 560px; margin-left: auto; margin-right: auto; }
  #dock { left: auto; right: 24px; bottom: 24px; width: 420px; }
  #card { border: 1px solid var(--rule); border-top: 1px solid var(--ink); }
  #workshop { top: 0; left: auto; width: 460px; border-left: 1px solid var(--ink); border-top: 0; }
  body.workshop #stage { height: 100%; right: 460px; }
}
@media (prefers-reduced-motion: reduce) {
  #opening .photo img { animation: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
