:root {
  --bg: #f6f5f2;
  --text: #1c1d21;
  --muted: #6b6e76;
  --accent: #3b5bdb;
  --surface: #ffffff;
  --border: #e3e1dc;
  color-scheme: light;
}

/* Dark design: only when chosen with the light/dark switch (see /theme.js).
   The device's own light/dark setting is deliberately ignored. */
:root[data-theme="dark"] {
  --bg: #111318;
  --text: #e9eaee;
  --muted: #8e93a0;
  --accent: #7c96ff;
  --surface: #181b22;
  --border: #2a2e38;
  color-scheme: dark;
}

/* Light/dark switch button (shown by /theme.js; stays hidden without JavaScript) */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
/* On pages without a top bar the switch floats in the top-right corner. */
.theme-toggle.floating {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  z-index: 20;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
}

.domain {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Footer on the coming-soon page */
body:not(.legal) { grid-template-rows: 1fr auto; }

.site-footer {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  padding-block: 1rem;
  font-size: 0.9rem;
}

a { color: var(--accent); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }

/* Legal pages (Impressum, Datenschutz) */
body.legal {
  display: block;
  text-align: left;
  line-height: 1.6;
}

body.legal main {
  max-width: 44rem;
  margin: 0 auto;
  padding-block: 2rem 4rem;
}

body.legal h1 { font-size: clamp(2rem, 6vw, 2.75rem); margin-bottom: 0.25rem; }
body.legal h2 { font-size: 1.15rem; margin: 2.25rem 0 0.5rem; }
body.legal p, body.legal li, body.legal dd { color: var(--text); }
body.legal ul { padding-left: 1.25rem; }
body.legal .meta { color: var(--muted); margin-top: 0; }
body.legal .back { margin: 0 0 2rem; }
body.legal .back a { text-decoration: none; }
body.legal .links { margin-top: 3rem; }

body.legal dl { margin: 0; }
body.legal dt { font-weight: 600; margin-top: 0.75rem; }
body.legal dd { margin: 0; }

/* "Gamelist" link on the coming-soon page */
.cta { margin: 2rem 0 0; }
.cta a {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}
.cta a:hover { background: var(--accent); color: var(--bg); }

/* Gamelist page (generated by ~/bin/gamecollector) */
body.gamelist {
  display: block;
  text-align: left;
  line-height: 1.5;
}

body.gamelist main {
  max-width: 64rem;
  margin: 0 auto;
  padding-block: 2rem 3rem;
}

body.gamelist h1 { font-size: clamp(2rem, 6vw, 2.75rem); margin-bottom: 0.25rem; }
body.gamelist .meta { color: var(--muted); margin-top: 0; }
body.gamelist .back { margin: 0 0 2rem; }
body.gamelist .back a { text-decoration: none; }
body.gamelist .empty { color: var(--muted); margin-top: 2rem; }

body.gamelist .search { margin-top: 1.5rem; }
body.gamelist .search input {
  width: 100%;
  max-width: 28rem;
  padding: 0.65rem 0.9rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}
body.gamelist .search input::placeholder { color: var(--muted); }
body.gamelist .search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

body.gamelist h2 {
  font-size: 1.2rem;
  margin: 2.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

body.gamelist .count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
}

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.9rem;
}

.games li { min-width: 0; }

/* Game card: a button that opens the detail popover */
.game {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: border-color 0.15s, transform 0.15s;
}
.game:hover { border-color: var(--accent); transform: translateY(-1px); }
.game:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.game .name { font-size: 1.05rem; font-weight: 600; }

.serial {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.05rem 0.4rem;
}

/* Detail popover */
.detail {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  margin: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.25);
  text-align: left;
  overflow-wrap: anywhere;
}
.detail::backdrop { background: rgb(0 0 0 / 0.45); }

.detail h3 { margin: 0 2rem 1rem 0; font-size: 1.3rem; }
.detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.55rem 1.25rem;
  margin: 0;
}
.detail dt { color: var(--muted); font-size: 0.9rem; }
.detail dd { margin: 0; white-space: pre-line; }
.detail dd.none { color: var(--muted); }

.detail .close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.detail .close:hover { background: var(--border); color: var(--text); }

@media (max-width: 26rem) {
  .detail dl { grid-template-columns: 1fr; gap: 0.15rem; }
  .detail dd { margin-bottom: 0.5rem; }
}

/* ===== Landing page (index.html) ===== */
body.home {
  display: block;
  text-align: left;
  padding: 0;
  line-height: 1.55;
}

.home .wrap {
  max-width: 64rem;
  margin: 0 auto;
  padding-inline: 1.5rem;
}

/* Top bar */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.75rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 1rem;
}
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
}
.topbar nav a:hover { color: var(--text); background: var(--border); }

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(4rem, 12vw, 8rem) clamp(3rem, 8vw, 5rem);
  background:
    radial-gradient(40rem 22rem at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(30rem 18rem at -5% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}
.eyebrow {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 {
  max-width: 18ch;
  font-size: clamp(2.4rem, 7vw, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.hero .accent { color: var(--accent); }
.lead {
  max-width: 34rem;
  margin: 1.25rem 0 0;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--muted);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .card:focus-visible, .brand:focus-visible, .topbar nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.button.primary { background: var(--accent); color: var(--bg); }
.button.primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--text)); }
.button.secondary { color: var(--text); border-color: var(--border); background: var(--surface); }
.button.secondary:hover { border-color: var(--accent); }

/* Feature cards */
.features { padding-block: 1rem 4.5rem; }
.features h2 {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.4rem;
  border-radius: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
a.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0.75rem 2rem color-mix(in srgb, var(--accent) 12%, transparent);
}
.card h3 { margin: 0.25rem 0 0; font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); }
.card-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.card-link { margin-top: auto; padding-top: 0.5rem; color: var(--accent); font-weight: 600; }
.card.muted { border-style: dashed; background: transparent; }
.card.muted .card-icon { background: var(--border); color: var(--muted); }

/* Footer */
.home-footer {
  display: block;
  border-top: 1px solid var(--border);
  padding-block: 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  .button, .card { transition: none; }
  .button:hover, a.card:hover { transform: none; }
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
