/* Distiller website. Copper accents from the app icon; light and dark follow the system. */
:root {
  --bg: #fbf8f5;
  --bg-raised: #ffffff;
  --bg-sunk: #f3ede7;
  --text: #22201e;
  --text-muted: #6b625b;
  --line: #e6ddd5;
  --copper: #b05a24;
  --copper-strong: #8f4416;
  --copper-soft: #f6e6da;
  --focus: #d27a3d;
  --shadow: 0 1px 2px rgba(60, 35, 15, 0.06), 0 6px 18px rgba(60, 35, 15, 0.06);
  --radius: 12px;
  --gutter: clamp(16px, 4vw, 32px);
  --tier-platinum: #6c7a89;
  --tier-gold: #b8860b;
  --tier-silver: #8a8f96;
  --tier-bronze: #a0612f;
  --tier-borked: #b23a3a;
  --tier-none: #8b837c;
  --code-bg: #fdfbf9;
  --code-key: #9a4a17;
  --code-string: #2f6b3a;
  --code-number: #1f5f99;
  --code-literal: #7a3b8f;
  --code-comment: #8b837c;
  --code-punct: #8b7d72;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161412;
    --bg-raised: #1f1c19;
    --bg-sunk: #12100f;
    --text: #f1ebe5;
    --text-muted: #b2a79d;
    --line: #34302b;
    --copper: #e08a4f;
    --copper-strong: #f0a46f;
    --copper-soft: #3a2619;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --tier-platinum: #a9b7c6;
    --tier-gold: #e0b443;
    --tier-silver: #b9bec5;
    --tier-bronze: #d08a52;
    --tier-borked: #e06666;
    --code-bg: #1a1715;
    --code-key: #f0a46f;
    --code-string: #9fd39d;
    --code-number: #8cc3f0;
    --code-literal: #d6a3e6;
    --code-comment: #8f857c;
    --code-punct: #a39689;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
img { max-width: 100%; display: block; }
a { color: var(--copper); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--copper-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }
code { background: var(--bg-sunk); padding: 0.1em 0.35em; border-radius: 5px; }
pre { background: var(--bg-sunk); padding: 14px 16px; border-radius: 10px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding-inline: var(--gutter); }
.muted { color: var(--text-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header and footer */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 1.1rem; }
.brand img { width: 30px; height: 30px; }
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 520; }
.site-nav a:hover { color: var(--text); background: var(--bg-sunk); }
.site-nav a[aria-current="page"] { color: var(--copper-strong); background: var(--copper-soft); }
.nav-github { display: inline-flex; align-items: center; gap: 7px; }
.nav-icon { width: 16px; height: 16px; flex: none; }
.site-footer { border-top: 1px solid var(--line); margin-top: 72px; padding: 28px 0 calc(28px + env(safe-area-inset-bottom, 0px)); color: var(--text-muted); font-size: 0.9rem; }
.site-footer .wrap { display: flex; gap: 12px 28px; flex-wrap: wrap; justify-content: space-between; }

/* Buttons and chips */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-raised); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; box-shadow: var(--shadow);
}
.button:hover { color: var(--text); border-color: var(--copper); }
.button.primary { background: var(--copper); border-color: var(--copper); color: #fff; }
.button.primary:hover { background: var(--copper-strong); border-color: var(--copper-strong); color: #fff; }
.button.small { padding: 6px 12px; font-size: 0.9rem; box-shadow: none; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--bg-sunk); color: var(--text-muted); font-size: 0.8rem; font-weight: 550; }
.tier { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 0.85rem; }
.tier::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.tier-platinum { color: var(--tier-platinum); }
.tier-gold { color: var(--tier-gold); }
.tier-silver { color: var(--tier-silver); }
.tier-bronze { color: var(--tier-bronze); }
.tier-borked { color: var(--tier-borked); }
.tier-none { color: var(--tier-none); }

/* Home */
.hero { padding: clamp(28px, 5vw, 56px) 0 48px; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); margin: 0 0 16px; }
.hero p.lede { font-size: 1.2rem; color: var(--text-muted); margin: 0 0 28px; max-width: 34em; }
/* The app's window, captured with its own shadow on a transparent background. */
/* The figure is the grid item, not the image: some browsers (Safari) stretch an image that
   is itself a grid item without scaling its height. The image keeps its own proportions. */
.hero-shot { justify-self: center; width: 100%; max-width: 755px; min-width: 0; margin: 0; }
.hero-shot img { width: 100%; height: auto; aspect-ratio: 755 / 504; object-fit: contain; }
@media (max-width: 760px) { .hero .wrap { grid-template-columns: minmax(0, 1fr); } .hero-shot { max-width: 520px; } }
.section { padding: 40px 0; }
.section h2 { font-size: 1.7rem; margin: 0 0 8px; }
.section > .wrap > p.intro { color: var(--text-muted); margin: 0 0 24px; max-width: 46em; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.feature { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feature h3 { margin: 0 0 6px; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0; list-style: none; }
.steps li { counter-increment: step; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 20px 20px 64px; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: 20px; top: 18px; width: 30px; height: 30px; border-radius: 50%; background: var(--copper-soft); color: var(--copper-strong); display: grid; place-items: center; font-weight: 700; }
.steps strong { display: block; margin-bottom: 4px; }

/* Catalogue */
.page-head { padding: 36px 0 12px; }
.page-head h1 { margin: 0 0 6px; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0 22px; }
.filters input[type="search"], .filters select {
  font: inherit; color: var(--text); background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-height: 42px;
}
.filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
.filters select { flex: 0 1 auto; }
.result-count { color: var(--text-muted); font-size: 0.9rem; margin: -8px 0 14px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.game-card {
  display: flex; flex-direction: column; background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.game-card:hover { color: inherit; border-color: var(--copper); transform: translateY(-2px); }
.game-card .cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--copper-soft), var(--bg-sunk)); object-fit: cover; width: 100%; }
.game-card .body { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 12px; padding: 14px; align-items: center; }
.game-card .icon { width: 44px; height: 44px; border-radius: 10px; grid-row: span 2; background: var(--bg-sunk); object-fit: cover; }
.game-card h3 { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-muted); }
.empty { text-align: center; padding: 48px 16px; color: var(--text-muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.notice { background: var(--copper-soft); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }

/* Game page */
.back { display: inline-block; margin: 24px 0 8px; text-decoration: none; }
.game-head { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 20px; align-items: center; margin: 8px 0 24px; }
.game-head .icon { width: 96px; height: 96px; border-radius: 20px; background: var(--bg-sunk); object-fit: cover; box-shadow: var(--shadow); }
.game-head h1 { margin: 0 0 6px; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.facts { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--text-muted); }
@media (max-width: 560px) { .game-head { grid-template-columns: 64px minmax(0, 1fr); } .game-head .icon { width: 64px; height: 64px; border-radius: 14px; } }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
@media (max-width: 880px) { .game-layout { grid-template-columns: minmax(0, 1fr); } .game-layout > aside { order: -1; } }
.panel { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: 1.15rem; margin: 0 0 12px; }
.panel h3 { font-size: 1rem; margin: 18px 0 8px; }
.description { white-space: pre-line; margin: 0; }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.gallery-main { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--bg-sunk); cursor: zoom-in; border: 0; padding: 0; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.thumbs button[aria-pressed="true"] { border-color: var(--copper); }
.thumbs img { width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; }
.recipe { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.recipe:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.recipe-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.recipe-head h3 { margin: 0 0 4px; }
dl.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 12px 0 0; font-size: 0.93rem; }
dl.details dt { color: var(--text-muted); }
dl.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { dl.details { grid-template-columns: 1fr; } dl.details dd { margin-bottom: 6px; } }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; }
.report-notes { white-space: pre-line; }
.install-help { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 0; }

dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1600px); }
dialog.lightbox::backdrop { background: rgba(10, 8, 6, 0.85); }
dialog.lightbox img { max-height: 88vh; width: auto; border-radius: 10px; }
dialog.lightbox form { position: absolute; top: 10px; right: 10px; }

/* Docs */
.docs-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; padding-top: 28px; }
.docs-nav { position: sticky; top: 84px; display: grid; gap: 2px; font-size: 0.95rem; }
.docs-nav a { color: var(--text-muted); text-decoration: none; padding: 5px 10px; border-radius: 8px; }
.docs-nav a:hover { background: var(--bg-sunk); color: var(--text); }
@media (max-width: 820px) { .docs-layout { grid-template-columns: minmax(0, 1fr); } .docs-nav { position: static; display: flex; flex-wrap: wrap; } }
.docs article h1 { margin-top: 0; }
.docs article h2 { margin-top: 44px; padding-top: 8px; border-top: 1px solid var(--line); }
.docs article section:first-of-type h2 { border-top: 0; }
.docs article li { margin: 4px 0; }
.docs .callout { border-left: 3px solid var(--copper); background: var(--bg-raised); padding: 12px 16px; border-radius: 0 10px 10px 0; }
.docs article h3 { margin-top: 28px; }
.docs article h4 { margin: 0 0 6px; font-size: 1rem; }
.docs details.connect { border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin: 10px 0; background: var(--bg-raised); }
.docs details.connect > summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.docs details.connect[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.docs details.connect > :last-child { margin-bottom: 14px; }
.docs ol.walkthrough { padding-left: 1.4em; }
.docs ol.walkthrough > li { margin: 18px 0; }
.docs ol.walkthrough > li::marker { color: var(--copper); font-weight: 700; }
.docs .reply { border-left: 3px solid var(--copper); padding: 4px 0 4px 14px; }
.docs pre.prompt { white-space: pre-wrap; }
.copy-wrap { position: relative; }
.copy-wrap > pre { padding-right: 76px; }
.copy-wrap > .copy { position: absolute; top: 8px; right: 8px; }

/* Recipe files, shown like a code block in a Markdown viewer */
.code-details { margin-top: 14px; }
.code-details > summary { cursor: pointer; color: var(--copper); font-weight: 600; font-size: 0.95rem; padding: 4px 0; list-style-position: inside; }
.code-details > summary:hover { color: var(--copper-strong); }
.code-details[open] > summary { margin-bottom: 8px; }
.code-block { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--bg-sunk); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.code-name { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.code-lang { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.code-actions { margin-left: auto; display: flex; gap: 6px; }
.code-actions .button[aria-disabled="true"], .code-actions .button:disabled { opacity: 0.5; pointer-events: none; }
.code-body { max-height: 70vh; overflow: auto; }
.code-status { margin: 0; padding: 14px; color: var(--text-muted); font-size: 0.9rem; }
pre.code { margin: 0; padding: 12px 0; background: none; border-radius: 0; font-size: 0.85rem; line-height: 1.6; counter-reset: line; overflow: visible; }
pre.code code { display: block; min-width: max-content; }
pre.code .line { display: block; padding-right: 16px; white-space: pre; }
pre.code .line::before {
  counter-increment: line; content: counter(line);
  display: inline-block; width: 3.2em; padding-right: 1.1em; margin-right: 0.2em; text-align: right;
  color: var(--code-comment); opacity: 0.7; user-select: none; -webkit-user-select: none;
}
pre.code .line:hover { background: color-mix(in srgb, var(--copper-soft) 55%, transparent); }
.tok-key { color: var(--code-key); }
.tok-string { color: var(--code-string); }
.tok-number { color: var(--code-number); }
.tok-literal { color: var(--code-literal); }
.tok-comment { color: var(--code-comment); font-style: italic; }
.tok-punct { color: var(--code-punct); }
#examples .code-details { border-top: 1px solid var(--line); padding-top: 8px; }

/* Get Distiller: download, install steps, and building from source folded away. */
.install-steps { margin: 20px 0 0; padding-left: 1.3em; max-width: 46em; }
.install-steps li { margin: 6px 0; }
details.build-source { margin-top: 18px; max-width: 46em; }
details.build-source > summary { cursor: pointer; color: var(--copper); font-weight: 600; padding: 4px 0; }

/* About: a tour of the app, text beside each screenshot, alternating sides. */
.page-intro { padding: clamp(28px, 5vw, 56px) 0 8px; max-width: 46em; }
.page-intro h1 { margin: 0 0 14px; }
.page-intro .lede { font-size: 1.15rem; color: var(--text-muted); margin: 0 0 18px; }
.tour-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.95rem; }
.tour-item { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px 40px; align-items: center; padding: 48px 0; border-top: 1px solid var(--line); scroll-margin-top: 72px; }
.tour-item:first-of-type { border-top: 0; }
.tour-item.flip .tour-text { order: 2; }
.tour-text h2 { margin: 0 0 12px; }
.tour-text p { margin: 0 0 12px; }
.tour-shots { display: grid; gap: 12px; min-width: 0; }
.shot { margin: 0; }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: 4px; }
.tour-end { border-top: 1px solid var(--line); padding: 40px 0 8px; }
.tour-end h2 { margin: 0 0 8px; }
@media (max-width: 820px) {
  .tour-item { grid-template-columns: minmax(0, 1fr); padding: 36px 0; }
  .tour-item.flip .tour-text { order: 0; }
}
