/* Gallery: same night palette, papel picado and sheet ghost as the story pages (template/ghost.css). */
:root {
  --night: #1b0b2b;
  --night-2: #2a1240;
  --night-3: #3b1a5a;
  --ink: #1d1029;
  --paper: #fff8e7;
  --marigold: #f29d1f;
  --candle: #ffd24a;
  --cream: #f7ead0;
  --muted: #cdbbe6;
  --pink: #e8457a;
  --teal: #2bb3a3;
  --lilac: #b48be0;
  --line: #5a3a8c;
  --radius: 14px;
  --rail: 112px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --title-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --balloon-font: "Chalkboard SE", "Comic Sans MS", "Comic Neue", ui-rounded, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--cream); font: 16px/1.55 var(--font);
  background-color: var(--night);
  background-image:
    radial-gradient(1200px 600px at 50% -200px, rgba(106, 42, 110, .75) 0%, transparent 70%),
    radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1.6px);
  background-size: 100% 100%, 9px 9px;
  background-repeat: no-repeat, repeat;
  overflow-x: hidden;
}
a { color: var(--candle); }
a:hover { color: var(--marigold); }
:focus-visible { outline: 3px solid var(--candle); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--candle); color: var(--ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 16px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* the papel picado strip, top bar and switches live in template/header.css (inlined by `ghosts gallery build`) */

.hero { padding-bottom: 18px; }
.hero .wrap { padding-top: 18px; }
.eyebrow { margin: 0 0 6px; color: var(--candle); letter-spacing: .16em; text-transform: uppercase; font: 800 .8rem/1.3 var(--title-font); }
h1 {
  margin: 0 0 12px; color: #fff; overflow-wrap: anywhere;
  font: 900 clamp(2rem, 8vw, 3.5rem)/1.04 var(--title-font); text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 var(--pink);
}
.lede { font-size: 1.08rem; max-width: 46rem; margin: 0; color: var(--cream); }

/* ---------- story of the day ---------- */
.featured {
  position: relative; display: grid; grid-template-columns: 1fr; margin: 6px 0 22px;
  background: linear-gradient(170deg, #2a1240 0%, #4b1d6e 62%, #6a2a6e 100%);
  border: 3px solid var(--ink); border-radius: 8px; box-shadow: 7px 7px 0 var(--marigold); overflow: hidden;
}
.f-stage { position: relative; min-height: 210px; overflow: hidden; }
.f-stage .stars { position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image: radial-gradient(#fff 1px, transparent 1.6px), radial-gradient(#ffd24a 1px, transparent 1.6px);
  background-size: 120px 90px, 170px 130px; background-position: 10px 20px, 60px 50px; }
.f-stage .moon { position: absolute; right: 9%; top: 18px; width: 62px; height: 62px; border-radius: 50%; background: #ffe9a8; box-shadow: 0 0 40px 8px rgba(255, 233, 168, .35); }
.f-cover { position: absolute; left: 16px; top: 16px; width: min(72%, 380px); aspect-ratio: 16 / 10; margin: 0; background: var(--paper); border: 3px solid var(--ink); padding: 6px 6px 18px; transform: rotate(-2.5deg); box-shadow: 5px 5px 0 var(--lilac); }
.f-cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; border: 1px solid var(--ink); }
.f-ghost { position: absolute; left: 50%; bottom: 6px; width: 150px; margin-left: -75px; }
.f-stage.has-cover .f-ghost { left: auto; right: 6%; margin-left: 0; width: 128px; }
.f-ghost svg { display: block; width: 100%; height: auto; }
.f-copy { position: relative; padding: 18px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.f-copy .kicker { margin: 0; font: 800 .8rem/1.2 var(--title-font); letter-spacing: .16em; text-transform: uppercase; color: var(--candle); }
.f-title { margin: 0; font: 900 clamp(1.6rem, 6vw, 2.5rem)/1.05 var(--title-font); text-transform: uppercase; color: #fff; text-shadow: 3px 3px 0 var(--ink), 5px 5px 0 var(--pink); overflow-wrap: anywhere; }
.f-name { margin: 0; font: 700 .95rem/1.3 var(--title-font); color: var(--muted); overflow-wrap: anywhere; }
.f-name code { font: .8rem var(--mono); color: #d9c8f0; }
.f-tagline { margin: 0; font: 1.08rem/1.45 var(--balloon-font); color: var(--cream); max-width: 36em; }
.f-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.f-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 2px 0 0; }
.f-stats div { background: rgba(27, 11, 43, .55); border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; }
.f-stats dt { font: 800 .68rem/1.2 var(--title-font); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.f-stats dd { margin: 2px 0 0; font: 800 1.05rem/1.2 var(--title-font); color: #fff; overflow-wrap: anywhere; }
.cta {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 10px 20px;
  background: var(--candle); color: var(--ink); text-decoration: none; border: 3px solid var(--ink); border-radius: 999px;
  font: 900 1rem/1 var(--title-font); text-transform: uppercase; letter-spacing: .05em; box-shadow: 4px 4px 0 var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cta:hover, .cta:focus-visible { color: var(--ink); background: var(--marigold); transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
@media (min-width: 760px) {
  .featured { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .f-stage { min-height: 340px; }
  .f-ghost { width: 190px; margin-left: -95px; bottom: 18px; }
  .f-stage.has-cover .f-ghost { width: 150px; bottom: 10px; }
  .f-cover { left: 22px; top: 30px; width: 76%; }
  .f-copy { padding: 26px 28px 28px; }
}
@media (min-width: 1240px) { .f-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- controls and grid ---------- */
.controls { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 8px 0 12px; padding: 14px; background: var(--night-2); border: 1px solid var(--night-3); border-radius: var(--radius); }
@media (min-width: 640px) { .controls { grid-template-columns: 2fr 1fr 1fr; } .kinds { grid-column: 1 / -1; } }
.field label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--cream);
  background: var(--night); border: 1px solid var(--line); border-radius: 10px;
}
input::placeholder { color: #9d88bf; }
.kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 14px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--cream); background: transparent; border: 1px solid var(--line); border-radius: 999px;
}
.chip[aria-pressed="true"] { background: var(--candle); color: var(--ink); border-color: var(--candle); }
.chip small { opacity: .75; font-weight: 500; margin-left: 4px; }

.count { color: var(--muted); margin: 6px 2px 10px; min-height: 1.5em; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card { position: relative; display: flex; flex-direction: column; height: 100%; background: var(--night-2); border: 1px solid var(--night-3); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: var(--marigold); box-shadow: 0 8px 28px rgba(242, 157, 31, .22); color: inherit; }
.cover { aspect-ratio: 16 / 9; background: linear-gradient(160deg, var(--night-3), var(--night)); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .glyph { font-size: 3rem; filter: drop-shadow(0 0 12px rgba(255, 210, 74, .6)); animation: float 5s ease-in-out infinite; }
.body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card h2 { margin: 0; font: 800 1.25rem/1.2 var(--title-font); color: var(--candle); overflow-wrap: anywhere; }
.card .short-addr { margin: -4px 0 0; font: 700 .9rem var(--mono); color: var(--muted); }
.card .title { margin: 0; color: var(--cream); font-style: italic; }
.card .tagline { margin: 0; color: var(--muted); font-size: .95rem; }
.addr { font: .75rem var(--mono); color: #b7a3d6; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0 0; font-size: .88rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

/* badges: the story pages' kind colors (white text, contrast >= 6.4:1) */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 2px solid var(--ink); font: 800 .75rem/1.4 var(--title-font); text-transform: uppercase; letter-spacing: .06em; color: #fff; background: #5a4a6e; white-space: nowrap; }
.k-friendly { background: #0f6b5c; }
.k-lingering { background: #5b3f8c; }
.k-bad { background: #a3122a; }
.k-banished { background: #3a3a3a; }
.k-alive { background: #1f5f99; }
.k-unknown { background: #5a4a6e; }
.badge.plain { background: var(--paper); color: var(--ink); text-transform: none; letter-spacing: .02em; }
.badge.tag-scarred { background: #ffd9e4; border-style: dashed; border-color: #a3122a; color: #6b0a1c; }
.badge.tag-never { background: #e8dcfa; border-style: dotted; color: var(--ink); }
.badge.tag-proxy { background: #d9c8f0; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }

.about { margin-top: 48px; padding: 28px 0 48px; background: var(--night-2); border-top: 3px solid var(--ink); box-shadow: 0 -4px 0 var(--marigold); color: var(--cream); }
.about h2 { font: 800 1.4rem var(--title-font); color: var(--candle); margin: 0 0 12px; }
.about p { max-width: 46rem; }
.fine { color: var(--muted); font-size: .9rem; }

/* ---------- About modal ---------- */
.about-dialog {
  width: min(42rem, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; overflow: auto;
  color: var(--cream); background: var(--night-2); border: 3px solid var(--ink); border-radius: 10px; box-shadow: 7px 7px 0 var(--marigold);
}
.about-dialog::backdrop { background: rgba(4, 0, 10, .72); }
.about-body { position: relative; padding: 22px 20px 24px; }
@media (min-width: 640px) { .about-body { padding: 28px 32px 30px; } }
.about-dialog h2 { margin: 0 0 12px; padding-right: 48px; font: 800 1.4rem var(--title-font); color: var(--candle); }
.about-dialog h3 { margin: 22px 0 8px; font: 800 1.05rem var(--title-font); color: var(--candle); letter-spacing: .08em; text-transform: uppercase; }
.about-dialog p { margin: 0 0 12px; }
.credits { margin: 0; padding-left: 20px; display: grid; gap: 10px; color: var(--muted); font-size: .92rem; }
.credits a, .about-dialog a { overflow-wrap: anywhere; }
.about-close {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; padding: 0; cursor: pointer;
  font: 800 1.5rem/1 var(--title-font); color: var(--ink); background: var(--candle); border: 2px solid var(--ink); border-radius: 50%; box-shadow: 2px 2px 0 var(--ink);
}
.about-close:hover { background: var(--marigold); }

/* ---------- the sheet ghost (faces picked by data-kind, as in ghost.css) ---------- */
.ghost .face { display: none; }
[data-kind="friendly"] .ghost .face-friendly,
[data-kind="alive"] .ghost .face-friendly,
[data-kind="unknown"] .ghost .face-friendly,
[data-kind="lingering"] .ghost .face-lingering,
[data-kind="bad"] .ghost .face-bad,
[data-kind="banished"] .ghost .face-banished { display: inline; }
[data-kind="bad"] .ghost .ghost-sheet path:first-child { fill: #efe2ff; }
[data-kind="bad"] .ghost { filter: drop-shadow(0 0 10px rgba(232, 69, 122, .55)); }
[data-kind="banished"] .ghost .ghost-sheet { opacity: .6; }
[data-kind="lingering"] .ghost { filter: drop-shadow(0 0 8px rgba(180, 139, 224, .6)); }
.bob { animation: bob 3.2s ease-in-out infinite; }

/* ---------- the ghost haunting the whole page, and the lights ---------- */
.haunt { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.fly { position: absolute; left: 0; top: 0; width: 84px; animation: haunt 90s ease-in-out infinite; transform: translate(62vw, 14vh); }
@media (min-width: 760px) { .fly { width: 112px; } }
.fly svg { display: block; width: 100%; height: auto; }
.haunt .ghost { filter: brightness(0) invert(.88); opacity: .13; transition: opacity .6s ease, filter .6s ease; }
.lights-off .haunt .ghost { filter: drop-shadow(0 0 16px rgba(255, 210, 74, .6)) drop-shadow(0 0 4px rgba(255, 255, 255, .5)); opacity: 1; }
html:not(.moving) .fly, html:not(.moving) .bob { animation-play-state: paused; }
@keyframes haunt {
  0%   { transform: translate(62vw, 14vh) rotate(0); }
  12%  { transform: translate(30vw, 34vh) rotate(-6deg); }
  25%  { transform: translate(4vw, 58vh) rotate(4deg); }
  38%  { transform: translate(34vw, 80vh) rotate(-3deg); }
  50%  { transform: translate(calc(100vw - 130px), 62vh) rotate(6deg); }
  62%  { transform: translate(70vw, 30vh) rotate(-4deg); }
  75%  { transform: translate(14vw, 8vh) rotate(3deg); }
  88%  { transform: translate(46vw, 46vh) rotate(-5deg); }
  100% { transform: translate(62vw, 14vh) rotate(0); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- the floating legend ---------- */
.legend {
  position: fixed; z-index: 60; right: 0; top: 50%; transform: translateY(-50%);
  max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden;
  padding: 8px 10px 10px; background: var(--night-2);
  border: 3px solid var(--ink); border-right: 0; border-radius: 14px 0 0 14px; box-shadow: -4px 4px 0 var(--lilac);
}
.legend-toggle {
  display: block; width: 100%; min-height: 32px; margin: 0 0 6px; padding: 4px 8px; cursor: pointer;
  font: 800 .72rem/1 var(--title-font); letter-spacing: .14em; text-transform: uppercase;
  color: var(--candle); background: transparent; border: 1px solid var(--line); border-radius: 8px;
}
.legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; }
.legend .badge { min-width: 7.6em; text-align: center; font-size: .68rem; padding: 2px 6px; }
.legend .desc {
  display: block; width: 0; opacity: 0; overflow: hidden; white-space: nowrap; margin-left: 0;
  font-size: .85rem; line-height: 1.3; color: var(--cream);
  transition: width .25s ease, opacity .2s ease, margin .25s ease;
}
.legend.open .desc { width: 19rem; opacity: 1; margin-left: 10px; white-space: normal; }
@media (hover: hover) {
  .legend:hover .desc, .legend:focus-within .desc { width: 19rem; opacity: 1; margin-left: 10px; white-space: normal; }
}
/* desktop: keep the right edge of the content clear of the collapsed rail */
@media (min-width: 700px) {
  .wrap, .eg-header .topbar { padding-right: max(16px, calc(var(--rail) - (100vw - 1100px) / 2)); }
}
/* phones: dock at the bottom, one row of badges; tap Key to open the descriptions */
@media (max-width: 699px) {
  body { padding-bottom: 64px; }
  .legend {
    top: auto; bottom: 0; left: 0; right: 0; transform: none; max-height: 70vh;
    display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border: 3px solid var(--ink); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 0 var(--lilac);
  }
  .legend-toggle { width: auto; flex: none; margin: 0; min-height: 30px; }
  .legend ul { flex-direction: row; overflow-x: auto; min-width: 0; padding-bottom: 2px; }
  .legend .badge { min-width: 0; }
  .legend.open { flex-direction: column; align-items: stretch; overflow-y: auto; }
  .legend.open ul { flex-direction: column; overflow-x: visible; }
  .legend.open .badge { min-width: 7.6em; }
  .legend.open .desc { width: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .card:hover, .card:focus-visible, .cta:hover, .cta:focus-visible { transform: none; }
  /* the visitor turned the flight on by hand: honor it */
  html.moving .fly { animation: haunt 90s ease-in-out infinite !important; }
  html.moving .bob { animation: bob 3.2s ease-in-out infinite !important; }
}

/* Pagination under the grid */
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 28px 0 8px; }
.pager[hidden] { display: none; }
.pager .pg {
  min-width: 44px; min-height: 44px; padding: 6px 14px; font: 800 .95rem/1 var(--title-font); cursor: pointer;
  color: var(--cream); background: var(--night-2); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--line);
}
.pager .pg:hover:not(:disabled) { border-color: var(--marigold); transform: translate(-1px, -1px); }
.pager .pg[aria-current="page"] { background: var(--candle); color: var(--ink); box-shadow: 3px 3px 0 var(--marigold); }
.pager .pg:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.pager .gap { color: var(--muted); padding: 0 2px; }

/* ---------- first-visit welcome: "Hunt the ghost" (template/header.js) ---------- */
/* the button rides inside the flying wrapper, so it follows the ghost; >= 56 px everywhere */
.eg-hunt { position: absolute; z-index: 2; left: 50%; top: 50%; width: 100%; height: 100%; min-width: 56px; min-height: 56px;
  transform: translate(-50%, -50%); padding: 0; background: transparent; border: 0; border-radius: 50%; pointer-events: auto; }
.eg-hunt:hover ~ .bob .ghost, .eg-hunt:focus-visible ~ .bob .ghost {
  filter: drop-shadow(0 0 22px rgba(255, 210, 74, .95)) drop-shadow(0 0 6px rgba(255, 255, 255, .8)); }
/* caught: the ghost pops to full colour while the lights come up, then settles back */
.eg-lit .haunt .ghost { filter: none; opacity: 1; transition: none; }
.moving.eg-lit .haunt .ghost { animation: eg-pop .7s ease-out; }
@keyframes eg-pop { 0% { transform: scale(1); } 35% { transform: scale(1.4) rotate(-8deg); } 70% { transform: scale(.9) rotate(4deg); } 100% { transform: none; } }
.eg-welcome-box .eg-line { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 61; white-space: nowrap; text-align: center; }
.eg-candle-solo { position: fixed; z-index: 61; left: 50%; bottom: 84px; transform: translateX(-50%); width: 72px; height: 120px; padding: 6px 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(255, 210, 74, .25), rgba(255, 210, 74, 0) 65%); border: 2px dashed rgba(255, 210, 74, .55); border-radius: 36px; }
.eg-candle-solo:hover, .eg-candle-solo:focus-visible { border-color: var(--candle); }
@media (max-width: 699px) {
  .eg-welcome-box .eg-line { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .eg-candle-solo { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }
}
