/* Songbound lore page. Colours from art/ui/palette.json; panels, pills, gems and the cursor are the game's own
   kit. Pixel art is shown at whole scales only; paintings are smoothed. built.css (made by the build) holds
   the type colours, each Murm's idle, each person's walk and the map's pins. */
@font-face { font-family: "Jersey 10"; src: url("/assets/fonts/Jersey10-Regular.woff") format("woff"); font-display: swap; }

:root {
  --night-dark: #1a1e36; --night: #242a48; --night-light: #3e4870;
  --gold: #e2b252; --gold-light: #fade8c; --parchment: #f4e8cc; --parchment-light: #fcf6e4;
  --ink: #3a2c2e; --outline: #28212c;
  --px: 3px;                                   /* one pixel of the kit, in CSS px */
  --slice: calc(8 * var(--px));
  --edge: max(16px, env(safe-area-inset-left));
  --edge-r: max(16px, env(safe-area-inset-right));
  --edge-b: max(16px, env(safe-area-inset-bottom));
  --tabs: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--night-dark); -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--tabs) + 12px); }
body {
  margin: 0; background: var(--night-dark); color: var(--parchment-light);
  font: 24px/1.15 "Jersey 10", ui-monospace, monospace; overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-weight: normal; margin: 0; }
p { margin: 0 0 12px; }
ul, ol, dl { margin: 0 0 12px; padding: 0; list-style: none; }
figure { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 20; padding: 8px 14px; background: var(--parchment); color: var(--ink); }
.skip:focus { top: 8px; }

/* The hero: the title's valley loop, its gold motes and the words. */
.hero { position: relative; min-height: min(82vh, 760px); display: grid; align-items: end; isolation: isolate; overflow: hidden; }
.backdrop { position: absolute; inset: 0; z-index: -1; background: var(--night-dark) url("/assets/img/valley.webp") 50% 40% / cover no-repeat; }
.loop, .motes { position: absolute; inset: 0; width: 100%; height: 100%; }
.loop { object-fit: cover; object-position: 50% 40%; opacity: 0; transition: opacity 1.4s ease; }
.loop.is-on { opacity: 1; }
.motes { image-rendering: pixelated; }
.veil { position: absolute; inset: 0; background: linear-gradient(0deg, var(--night-dark) 0%, rgb(26 30 54 / 0.55) 34%, transparent 66%); }
.hero-in { padding: 0 var(--edge) 34px; max-width: 1020px; margin: 0 auto; width: 100%; }
.logo { display: block; width: clamp(200px, 40vw, 420px); line-height: 0; }
h1 { font-size: clamp(40px, 7vw, 66px); color: var(--gold-light); margin-top: 8px; }
h1, .tagline { text-shadow: 0 2px 0 var(--outline), 0 -2px 0 var(--outline), 2px 0 0 var(--outline), -2px 0 0 var(--outline); }
.tagline { margin: 6px 0 0; font-size: 28px; }
.js .hero-in > * { animation: rise 1.1s ease both; }
.js .hero-in > :nth-child(2) { animation-delay: 0.25s; }
.js .hero-in > :nth-child(3) { animation-delay: 0.5s; }
.hero .corner { position: absolute; }

/* The tabs: Cantara, then one pill per region; regions not out yet are greyed with a small cross. */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; justify-content: center;
  padding: 10px var(--edge) 10px calc(var(--edge) + 14px); background: rgb(26 30 54 / 0.95);
  border-bottom: 3px solid var(--outline); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.btn, .tab {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  height: 42px; padding: 0 20px 3px; font-size: 22px; color: var(--ink); text-decoration: none; white-space: nowrap;
  image-rendering: pixelated; border-image: url("/assets/kit/pill_normal.png") 8 fill / 18px stretch;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover, .btn:focus-visible, .tab:hover, .tab:focus-visible, .tab.on { border-image-source: url("/assets/kit/pill_focused.png"); }
.btn:active, .tab:active { border-image-source: url("/assets/kit/pill_pressed.png"); padding: 3px 20px 0; }
.btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--parchment-light); outline-offset: 3px; }
.tab.on::before {
  content: ""; position: absolute; left: -14px; top: 50%; width: 24px; height: 24px; margin-top: -12px;
  background: url("/assets/kit/cursor.png") 0 0 / 96px 24px; image-rendering: pixelated; animation: cursor 0.5s steps(4) infinite;
}
.tab.locked { color: rgb(58 44 46 / 0.55); gap: 8px; cursor: default; border-image-source: url("/assets/kit/pill_disabled.png"); padding: 0 16px 3px; }
.tab.locked:active { padding: 0 16px 3px; }
.tab .x { width: 18px; height: 18px; background: url("/assets/kit/cross.png") 0 0 / 100% 100%; image-rendering: pixelated; }

main { max-width: 1020px; margin: 0 auto; padding: 18px var(--edge) 0; }
.pane { display: grid; gap: 22px; }
.pane[hidden] { display: none; }
.pane > * { min-width: 0; }

/* A section is a kit panel: parchment with ink, or night with parchment. */
.panel {
  padding: calc(var(--slice) + 4px) calc(var(--slice) + 6px); color: var(--ink);
  border-image: url("/assets/kit/panel.png") 8 fill / var(--slice) stretch;
}
.panel.night { color: var(--parchment-light); border-image-source: url("/assets/kit/panel_night.png"); }
.panel p { max-width: 46em; }
h2 { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 40px; margin-bottom: 16px; text-align: center; }
.night h2 { color: var(--gold-light); }
h3 { font-size: 28px; }
.gem { flex: none; display: inline-block; width: calc(9 * var(--px)); height: calc(7 * var(--px)); background: url("/assets/kit/divider_gem.png") 0 0 / 100% 100%; image-rendering: pixelated; }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s ease, transform 0.7s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* A painting beside its words; flipped every other time. */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; margin-bottom: 8px; }
.duo.flip > :first-child { order: 2; }
.art img { display: block; width: 100%; border: 3px solid var(--outline); image-rendering: auto; }

.moods { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 6px 0 18px; }
.mood { display: grid; gap: 2px; padding: 10px 12px; background: var(--night); border: 3px solid var(--outline); transition: transform 0.2s; }
.mood:hover { transform: translateY(-3px); }
.mood b { font-weight: normal; font-size: 28px; color: var(--gold-light); }
.mood .ans { color: var(--parchment); }
.mood span:last-child { font-size: 20px; opacity: 0.85; }

/* The map: the painting with the game's pins and names on top, each a link to its place. */
.mapwrap { overflow-x: auto; margin: 0 0 16px; border: 3px solid var(--outline); }
.map { position: relative; min-width: 640px; line-height: 0; }
.map img { display: block; width: 100%; image-rendering: auto; }
.pin { position: absolute; transform: translate(-50%, -12px); display: grid; justify-items: center; gap: 2px; text-decoration: none; line-height: 1; }
.pin .mark { width: 32px; height: 32px; background: url("/assets/map/pin.png") 50% 50% / 32px 32px no-repeat; image-rendering: pixelated; }
.pin .name {
  font-size: clamp(16px, 1.9vw, 22px); color: var(--parchment-light); white-space: nowrap; padding: 0 4px;
  text-shadow: 0 2px 0 var(--outline), 0 -2px 0 var(--outline), 2px 0 0 var(--outline), -2px 0 0 var(--outline);
}
.pin:hover .mark, .pin:focus-visible .mark { animation: bob 0.6s steps(3) infinite alternate; }
.pin:hover .name, .pin:focus-visible .name { color: var(--gold-light); }

/* Places: each backdrop whole, at 1×, cropped (never resampled) when the card is narrower. */
.places { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 347px)); justify-content: center; gap: 16px 22px; }
.shot { height: 197px; overflow: hidden; border: 3px solid var(--outline); display: flex; justify-content: center; margin-bottom: 6px; }
.shot img { flex: none; width: 341px; max-width: none; height: 191px; image-rendering: pixelated; }
.place:target .shot { outline: 3px solid var(--gold); }
.place p { font-size: 21px; }
.hall { margin-top: 6px; }

/* People walk in place (their walk sheets, 4×); the grey strangers stand perfectly still. */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.person { display: flex; gap: 14px; align-items: flex-start; }
.walker { flex: none; image-rendering: pixelated; background-repeat: no-repeat; animation-duration: 0.66s; animation-timing-function: steps(4); animation-iteration-count: infinite; }
.person p { font-size: 21px; margin: 4px 0 0; }

/* Murms: each one's battle idle, at 1× (its battle size). */
.bestiary { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.murm { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 10px; text-align: center; background: var(--parchment-light); border: 3px solid var(--outline); transition: transform 0.2s; }
.murm:hover { transform: translateY(-4px); }
.murm .stage { height: 112px; display: grid; place-items: end center; }
.idle { display: block; image-rendering: pixelated; background-repeat: no-repeat; }
.murm p { font-size: 20px; margin: 4px 0 0; }
.types { display: flex; gap: 6px; }
.type { padding: 0 8px 2px; font-size: 20px; color: var(--outline); border: 2px solid var(--outline); }
.forms { margin-top: 8px; padding-top: 6px; border-top: 2px dashed rgb(58 44 46 / 0.3); width: 100%; }
.forms .label { font-size: 17px; opacity: 0.7; }
.forms ul { display: flex; justify-content: center; gap: 8px; margin: 2px 0 0; }
.forms li { display: grid; justify-items: center; font-size: 17px; }
.forms img { width: 64px; height: 64px; image-rendering: pixelated; }
.mystery { background: var(--night); color: var(--parchment-light); }
.mystery img { width: 96px; height: 96px; image-rendering: pixelated; animation: glimmer 3s ease-in-out infinite; }

/* The Old Song: the found line writes itself in; lost lines are rows of dim gems. */
.verses { display: grid; gap: 10px; margin: 8px 0 14px; }
.verses .known { font-size: 32px; color: var(--gold-light); min-height: 1.1em; }
.verses .lost { display: flex; gap: 10px; opacity: 0.45; }
.outro { color: var(--gold); }

.words { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; }
.words dt { font-size: 26px; color: var(--ink); }
.words dd { margin: 0; font-size: 22px; }

.foot { display: grid; justify-items: center; gap: 10px; padding: 30px var(--edge) var(--edge-b); color: var(--parchment); font-size: 20px; }
.foot p { margin: 0; }

@keyframes breathe { to { transform: translateY(-3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes cursor { to { background-position-x: -96px; } }
@keyframes bob { to { transform: translateY(-4px); } }
@keyframes glimmer { 50% { filter: brightness(1.6) drop-shadow(0 0 6px rgb(250 222 140 / 0.6)); } }

/* Still under reduced motion or with the background paused: idles and walks hold their first frame. */
[data-stage="still"] .idle, [data-stage="still"] .walker, [data-stage="still"] .tab.on::before { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  .hero .corner { top: max(12px, env(safe-area-inset-top)); bottom: auto; }   /* clear of the title on phones */
  .duo { grid-template-columns: 1fr; }
  .duo.flip > :first-child { order: 0; }
  .tabs { justify-content: flex-start; }
}
@media (max-width: 560px) {
  :root { --px: 2px; --tabs: 58px; }
  body { font-size: 22px; }
  h2 { font-size: 32px; }
  .tab, .btn { height: 38px; font-size: 20px; padding: 0 14px 3px; }
  .words { grid-template-columns: 1fr; }
  .words dd { margin-bottom: 8px; }
  .bestiary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .murm { padding: 8px 4px; overflow: hidden; }
  .murm p { font-size: 18px; }
  .places, .people { grid-template-columns: 1fr; }
}
