/* Bundled fonts keep the site self-contained. */
@font-face {
  font-family: 'C64 Keyboard';
  src: url('fonts/c64-keyboard-regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Pirata One';
  src: url('fonts/pirata-one-regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url('fonts/instrument-sans-variable.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --paper: #fff;
  --ink: #252721;
  --muted: #64665b;
  --rule: #d3d1c7;
  --accent: #993c2c;
  --heading-font: 'C64 Keyboard', Arial, sans-serif;
  --wordmark-font: 'Pirata One', Georgia, serif;
  --text-font: 'Instrument Sans', Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--text-font);
  font-size: 16px;
  line-height: 1.6;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, input, select { border: 1px solid var(--rule); border-radius: 0; background: transparent; }
button { padding: 0.5rem 0.9rem; }
button:hover { border-color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, p, figure { margin: 0; }
h1, h2 { font-family: var(--heading-font); font-weight: 400; }
img { display: block; max-width: 100%; }

.page { width: min(1280px, calc(100% - 64px)); margin-inline: auto; padding-block: 1.5rem; }
.site-header { margin-bottom: 1.75rem; text-align: center; }
.wordmark { font-family: var(--wordmark-font); font-weight: 400; font-size: clamp(1.75rem, 3.5vw, 2.75rem); line-height: 1.1; letter-spacing: 0.02em; }

/* Diamond-tipped rule beneath the wordmark, drawn in CSS. */
.ornament { display: flex; align-items: center; gap: 1rem; margin-top: 0.9rem; }
.ornament::before, .ornament::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.ornament span { width: 7px; height: 7px; border: 1px solid var(--ink); transform: rotate(45deg); }
.skip-link { position: absolute; top: -100px; left: 1rem; background: var(--paper); padding: 0.75rem; z-index: 1; }
.skip-link:focus { top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filters input, .filters select, .filters button { min-height: 42px; padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.filters input { flex: 1 1 260px; min-width: 0; background: var(--paper); border-color: #9c9e90; }
.filters input::placeholder { color: var(--muted); }
.filters select { max-width: 100%; }
.result-count { color: var(--muted); font-size: 0.75rem; margin-block: 0.75rem; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 2.5rem 3rem; padding: 0; margin: 0; list-style: none; }
.app-card { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; padding-block: 1rem; border-top: 1px solid var(--rule); }
/* Wrap maturity before squeezing title words. */
.card-heading { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.card-heading h2 { flex: 1 1 min-content; min-width: 0; font-size: 1.4rem; line-height: 1.25; overflow-wrap: break-word; }
.card-heading a { text-decoration: none; }
/* Traffic-light dots supplement readable maturity labels. */
.app-status { display: inline-flex; align-items: center; gap: 0.35rem; flex-shrink: 0; margin-left: auto; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.app-status::before { content: ''; width: 0.5rem; height: 0.5rem; flex-shrink: 0; border: 1px solid var(--maturity-light, var(--muted)); border-radius: 50%; background: var(--maturity-light, transparent); }
.app-status[data-maturity="experimental"] { --maturity-light: #b33b33; }
.app-status[data-maturity="usable"] { --maturity-light: #a87300; }
.app-status[data-maturity="polished"] { --maturity-light: #287848; }
.app-icon { object-fit: contain; flex-shrink: 0; }
.app-summary { font-size: 0.875rem; line-height: 1.5; }
.app-meta { font-size: 0.75rem; color: var(--muted); }
.platforms { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; vertical-align: middle; color: var(--muted); }
.platform-icon { width: 1.125rem; height: 1.125rem; flex-shrink: 0; fill: currentColor; }
.app-preview { display: block; width: 100%; margin-top: auto; padding-top: 0.5rem; }
.app-preview img { width: 100%; height: 140px; object-fit: contain; }
/* Follow the screenshot pixels, including transparent corners and contain padding. */
.app-preview img, .gallery img {
  filter: drop-shadow(0 0 1px rgb(37 39 33 / 22%)) drop-shadow(0 2px 3px rgb(37 39 33 / 10%));
}
.empty-state { padding-block: 3.5rem; }
.empty-state h2 { font-size: 2rem; }
.empty-state p { color: var(--muted); margin-block: 0.5rem 1.5rem; }
.catalogue-empty { padding-block: 3rem; }

.back-link { display: inline-block; font-size: 0.85rem; text-decoration: none; }
.detail-heading { padding-block: 1.25rem 2rem; max-width: 950px; }
.category-label { color: var(--accent); font-size: 0.75rem; margin-bottom: 0.75rem; }
.detail-title { display: flex; align-items: center; gap: 1.25rem; }
.detail-title h1 { flex: 1; min-width: 0; font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.1; overflow-wrap: anywhere; }
.detail-title .app-icon { width: 72px; height: 72px; }
.detail-summary { font-size: 1.15rem; max-width: 740px; margin-top: 1rem; }
.maturity-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.75rem; }
.detail-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2rem; border-top: 1px solid var(--ink); padding-top: 2rem; }
.detail-facts dl { margin: 0; }
.detail-facts dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.65rem; }
.detail-facts dd { margin: 0.4rem 0 1.5rem; font-size: 0.9rem; }
.detail-facts small { display: block; color: var(--muted); margin-top: 0.4rem; font-size: 0.75rem; }
.app-links { margin-top: 2rem; border-top: 1px solid var(--rule); }
.app-link { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.85rem; text-decoration: none; padding-block: 0.8rem; border-bottom: 1px solid var(--rule); }
.app-link span { color: var(--accent); }
.description p + p { margin-top: 1rem; }
.features { margin-top: 2rem; }
.features h2 { font-size: 1.75rem; }
.features ul { padding-left: 1.25rem; }
.features li { margin-block: 0.5rem; }
.gallery { margin-top: 2.5rem; }
.gallery figure + figure { margin-top: 2rem; }
.gallery img { max-height: 750px; width: 100%; object-fit: contain; object-position: left; }
.gallery figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; }

/* Pixel-art haunted carnival beneath the directory, drawn by carnival.js.
   Pixel colours are read from these properties: site palette plus maturity lights. */
.carnival {
  --pixel-red: #b33b33;
  --pixel-amber: #a87300;
  --pixel-green: #287848;
  position: relative;
  height: 200px;
  margin-top: 2rem;
}
.carnival-scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: manipulation; }
.carnival-scene[data-hot] { cursor: pointer; }
.carnival-controls { position: absolute; top: 0.5rem; right: 0.75rem; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.carnival-controls :is(button, select) { padding: 0.25rem 0.6rem; background: var(--paper); color: var(--muted); font-family: var(--heading-font); font-size: 0.7rem; }
.carnival-controls :is(button, select):hover { color: var(--ink); }
.carnival-target { max-width: 9rem; }
/* Ticket and game dialogs with a two-step pixel border. */
.carnival-panel { position: absolute; max-width: calc(100% - 16px); padding: 0.7rem 1.6rem 0.8rem 0.8rem; background: var(--paper); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px var(--ink); font-family: var(--heading-font); font-size: 0.7rem; line-height: 1.6; }
.carnival-panel:focus { outline: none; }
.carnival-panel a { color: var(--accent); }
.carnival-panel button { padding: 0.25rem 0.6rem; background: var(--paper); }
.carnival-ticket { width: 15rem; }
.carnival-hint { margin-top: 0.5rem; }
/* At least 24 px square, the WCAG 2.5.8 minimum target. */
.carnival-panel .carnival-close { position: absolute; top: 0.3rem; right: 0.3rem; min-width: 1.5rem; min-height: 1.5rem; padding: 0; border: 0; background: transparent; font-size: 1rem; line-height: 1; }
/* The hidden high striker game stands on the band's foot, above the gargoyle. */
.carnival-game { bottom: 0.5rem; z-index: 3; width: 18rem; }
.carnival-game-title { color: var(--accent); }
.carnival-meter { position: relative; height: 0.9rem; margin-block: 0.5rem; border: 2px solid var(--ink); }
.carnival-meter span { position: absolute; top: 0; bottom: 0; left: 0; }
.carnival-meter-zone { right: 0; background: var(--accent); }
.carnival-meter-fill { width: 0; background: var(--ink); }
.carnival-game-status { margin-bottom: 0.5rem; }
.carnival-claim { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.carnival-claim label { display: flex; flex: 1 1 10rem; flex-direction: column; gap: 0.25rem; }
.carnival-claim input { padding: 0.3rem 0.5rem; border-color: #9c9e90; background: var(--paper); font-family: var(--text-font); font-size: 0.85rem; }
/* Invite codes are lower case, which the pixel font would capitalise. */
.carnival-invite { margin-top: 0.25rem; overflow-wrap: anywhere; font-family: var(--text-font); font-size: 0.8rem; }
/* Clicks pass through to the page; carnival.js still startles the gargoyle. */
.carnival-flyer { position: fixed; top: 0; left: 0; z-index: 2; image-rendering: pixelated; pointer-events: none; will-change: transform; }

@media (max-width: 760px) {
  .page { width: calc(100% - 40px); }
  .filters input { flex-basis: 100%; }
  .filters select { flex: 1 1 140px; min-width: 0; }
  .detail-layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .detail-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .app-links { margin-top: 0; }
  .detail-title .app-icon { width: 56px; height: 56px; }
}

@media (max-width: 480px) {
  .detail-summary { font-size: 1rem; }
}

@media print {
  .filters, .back-link, .carnival, .carnival-flyer { display: none; }
  .page { width: 100%; }
  .detail-layout { display: block; }
  .app-card, figure { break-inside: avoid; }
}
