/* Art App — gallery-wall look: warm plaster, matted works, museum wall labels.
   Each work tints its own page with a colour pulled from the photo. */

/* Fraunces (SIL Open Font Licence), self-hosted: no third-party font service */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/fraunces.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('fonts/fraunces-italic.woff2') format('woff2'); }

:root {
  --wall: #F3EFE7;
  --paper: #FCFAF6;
  --ink: #1B1A17;
  --mute: #7C766B;
  --line: rgba(27, 26, 23, .13);
  --th: 9; --ts: 68%; --al: 45%;
  --accent: hsl(var(--th) var(--ts) var(--al));
  --wash: transparent;
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --shadow: 0 1px 1px rgba(0, 0, 0, .08), 0 10px 22px -10px rgba(40, 30, 10, .38);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wall: #141311; --paper: #201E1A; --ink: #EEE9DF; --mute: #989184;
    --line: rgba(238, 233, 223, .15); --al: 62%;
    --shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 12px 26px -10px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
/* Walk mode is always the evening gallery */
body.tour {
  --wall: #100F0E; --paper: #1E1C19; --ink: #EEE9DF; --mute: #989184;
  --line: rgba(238, 233, 223, .15); --al: 62%;
  color-scheme: dark;
}
.tinted {
  --accent: hsl(var(--th) var(--ts) var(--al));
  --wash: hsl(var(--th) var(--ts) 50% / .16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--wall); color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
/* plaster grain */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .07;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app { position: relative; z-index: 1; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
p, h1, h2, h3, figure { margin: 0; }
::selection { background: var(--accent); color: #fff; }

/* ───────── Home ───────── */
.top { padding: calc(var(--st) + 30px) 20px 0; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: flex-end; gap: 12px; font: 400 46px/.9 var(--serif); letter-spacing: -.025em; }
.brand svg { width: 40px; height: 40px; stroke: none; }
.sub { margin-top: 12px; color: var(--mute); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.search { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--mute); }
.search[hidden] { display: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: 16px var(--sans); }
.search input::placeholder { color: var(--mute); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 20px 6px; margin: 0 -20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--wall); border-color: var(--ink); }

.hang { display: flex; align-items: flex-start; gap: 16px; padding: 18px 16px calc(var(--sb) + 130px); max-width: 1200px; margin: 0 auto; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 26px; }
.col:nth-child(even) { margin-top: 38px; }
.work { display: block; color: inherit; text-decoration: none; animation: rise .5s both; }
.work:active .mat { transform: scale(.975); }
.mat { display: block; padding: 7px; background: var(--paper); border-radius: 2px; box-shadow: var(--shadow); transition: transform .2s; }
.mat img { display: block; width: 100%; aspect-ratio: var(--ar); object-fit: cover; background: var(--wash); }
.cap { display: block; padding: 11px 2px 0; font-size: 12px; line-height: 1.35; }
.cap::before { content: ''; display: block; width: 16px; height: 2px; margin-bottom: 7px; background: var(--accent); }
.cap b { display: block; font-weight: 600; letter-spacing: .03em; }
.cap i { font: italic 15px/1.25 var(--serif); color: var(--mute); }
.cap .mic { width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; color: var(--accent); }
.none { padding: 40px 6px; color: var(--mute); font: italic 18px var(--serif); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.empty { display: block; text-align: center; padding-top: 26px; }
.empty .art { width: 210px; height: 230px; stroke: none; }
.empty h2 { font: 400 italic 30px/1.1 var(--serif); margin: 6px 0 10px; }
.empty p { color: var(--mute); max-width: 30ch; margin: 0 auto 24px; }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 300px; margin: 0 auto; }

.dock {
  position: fixed; z-index: 10; left: 50%; bottom: calc(var(--sb) + 16px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 99px;
  background: color-mix(in srgb, var(--paper) 76%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
}
.dock button { display: flex; align-items: center; gap: 8px; height: 52px; min-width: 92px; justify-content: center; padding: 0 16px; border-radius: 99px; font-size: 14px; }
.dock button:active { background: var(--line); }
.dock .add { width: 62px; min-width: 0; height: 62px; padding: 0; background: var(--ink); color: var(--wall); }
.dock .add:active { background: var(--accent); }
.dock .add svg { width: 26px; height: 26px; }

/* ───────── Viewer (leaf through) ───────── */
.viewer { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--wall); }
.vbar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(var(--st) + 10px) 12px 8px; pointer-events: none; }
.vbar > * { pointer-events: auto; }
.vbar .sp { flex: 1; }
.ib {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px var(--line);
}
.ib:active { transform: scale(.94); }
.ib.off { color: var(--mute); }
.vcount {
  padding: 0 14px; height: 32px; display: flex; align-items: center; border-radius: 99px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.pager { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.pager::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; height: 100%; overflow-y: auto; scroll-snap-align: center; scroll-snap-stop: always; background: linear-gradient(var(--wash), transparent 560px); }
.piece { max-width: 680px; margin: 0 auto; padding: calc(var(--st) + 74px) 22px calc(var(--sb) + 50px); }

.hero { display: grid; place-items: center; padding: 6px 0 34px; cursor: zoom-in; }
.frame { width: min(100%, calc(56svh * var(--ar))); aspect-ratio: var(--ar); border: 9px solid var(--paper); background: var(--paper); box-shadow: 0 2px 2px rgba(0, 0, 0, .12), 0 34px 50px -24px rgba(25, 15, 0, .6); animation: rise .5s both; }
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.strip { display: flex; gap: 10px; overflow-x: auto; margin: -14px -22px 26px; padding: 0 22px 6px; scrollbar-width: none; }
.strip button { flex: none; width: 62px; height: 62px; padding: 3px; background: var(--paper); box-shadow: var(--shadow); }
.strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.label { padding-top: 16px; border-top: 2px solid var(--accent); }
.artist { font-size: 12.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.ghost { color: var(--mute); font-weight: 400; }
.label h1 { margin: 8px 0 12px; font: 400 italic 36px/1.08 var(--serif); letter-spacing: -.015em; overflow-wrap: anywhere; }
.yr { font-style: normal; color: var(--mute); }
.meta { color: var(--mute); font-size: 14px; }
.room { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }
.room svg { width: 15px; height: 15px; color: var(--accent); }

.listen { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 24px; padding: 14px 18px; border-radius: 14px; background: var(--accent); color: #fff; text-align: left; font-size: 15px; font-weight: 500; }
.listen .dur { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .85; font-weight: 400; }
.listen .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: rgba(255, 255, 255, .85); }
.listen .i-pause, .listen.on .i-play { display: none; }
.listen.on .i-pause { display: block; }
.listen.soft { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.listen.soft svg { color: var(--accent); }

.sec { margin-top: 34px; }
.sec h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font: 600 11.5px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.sec h3::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.sec h3 em { font-style: normal; font-weight: 400; letter-spacing: .04em; text-transform: none; display: inline-flex; gap: 4px; align-items: center; }
.sec h3 svg { width: 13px; height: 13px; }
.prose { font: 400 17.5px/1.6 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14.5px; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.doc { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; }
.doc span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc svg { color: var(--accent); }
.doc .x { color: var(--mute); padding: 6px; margin: -6px; }
.doc .x svg { color: inherit; width: 18px; height: 18px; }
.nudge { margin-top: 30px; padding: 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--mute); font: italic 16px/1.45 var(--serif); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 36px; }

.pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 99px; background: var(--ink); color: var(--wall); font-size: 14px; font-weight: 500; }
.pill:active { opacity: .8; }
.pill.ghosty { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.pill svg { width: 18px; height: 18px; }
.danger { color: #C4402F !important; }

/* ───────── Sheets ───────── */
#sheet-root { position: relative; z-index: 50; }
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 5, .5); animation: fade .25s both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  max-width: 620px; margin: 0 auto; padding: 10px 22px calc(var(--sb) + 26px);
  background: var(--paper); color: var(--ink); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .3); animation: up .32s cubic-bezier(.2, .8, .2, 1) both;
}
.grab { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 4px; background: var(--line); }
.sh-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; position: sticky; top: -10px; padding: 10px 0; background: var(--paper); z-index: 2; }
.sheet h2 { font: 400 italic 28px/1.1 var(--serif); }
.hint { color: var(--mute); font-size: 14px; margin-bottom: 16px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.opt { display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 4px; border-bottom: 1px solid var(--line); text-align: left; font-size: 16px; }
.opt:last-child { border-bottom: 0; }
.opt svg { width: 24px; height: 24px; color: var(--accent); }
.opt small { display: block; color: var(--mute); font-size: 13px; }
.opt .n { margin-left: auto; color: var(--mute); font-size: 13px; }

.edit { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.f { display: block; grid-column: span 2; }
.f.half { grid-column: span 1; }
.f span { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.f input, .f textarea { width: 100%; padding: 8px 0 9px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; outline: 0; background: none; color: var(--ink); font: 17px/1.4 var(--serif); resize: vertical; }
.f input:focus, .f textarea:focus { border-bottom-color: var(--accent); }
.edit h3 { grid-column: span 2; margin-top: 14px; font: 600 11.5px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.edit .pill { grid-column: span 2; margin-top: 10px; }

.rec { display: grid; place-items: center; gap: 14px; padding: 14px 0 22px; }
.recbtn { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 3px var(--ink); }
.recbtn i { width: 62px; height: 62px; border-radius: 50%; background: #D8432B; transition: all .2s; }
.recbtn.on i { width: 30px; height: 30px; border-radius: 7px; }
.recbtn.on { animation: pulse 1.4s infinite; }
.rectime { font-variant-numeric: tabular-nums; font-size: 16px; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 3px var(--ink), 0 0 0 12px rgba(216, 67, 43, .18); } }

.zoom { position: fixed; inset: 0; background: #0B0A09; display: grid; place-items: center; animation: fade .2s both; }
.zoom img { max-width: 100%; max-height: 100dvh; object-fit: contain; }
.zbar { position: absolute; left: 0; right: 0; bottom: calc(var(--sb) + 18px); display: flex; justify-content: center; gap: 8px; }
.zbar .pill { background: rgba(255, 255, 255, .14); color: #fff; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }

#toast { position: fixed; z-index: 99; left: 50%; bottom: calc(var(--sb) + 104px); transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 99px; background: var(--ink); color: var(--wall); font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; max-width: 86vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .brand { font-size: 60px; }
  .top { padding-left: 32px; padding-right: 32px; }
  .hang { padding-left: 32px; padding-right: 32px; gap: 26px; }
  .sheet { bottom: 24px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
