/*
 * games-home — the only stylesheet.
 * Palette: deep indigo night + the viridis colour map (newborn yellow → old violet)
 * that colours the Game of Life on the home page. Type: Recursive (Arrow Type, OFL),
 * casual axis for headings, linear for reading, mono for key caps.
 */

@font-face {
  font-family: 'Recursive';
  font-style: normal;
  font-weight: 300 1000;
  font-display: swap;
  src: url('../fonts/recursive-latin-casl-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Recursive Mono';
  font-style: normal;
  font-weight: 300 1000;
  font-display: swap;
  src: url('../fonts/recursive-latin-mono-normal.woff2') format('woff2');
}

:root {
  --night: #15102a;
  --night-deep: #0f0b20;
  --panel: #1f1939;
  --line: #3a3163;
  --line-soft: #29214a;
  --paper: #efeaf8;
  --mist: #bdb5d6;
  --faint: #968db3;

  /* viridis, newborn → old */
  --yellow: #fde725;
  --lime: #b5de2b;
  --green: #6ece58;
  --emerald: #35b779;
  --teal: #1f9e89;
  --blue: #31688e;
  --violet: #46337e;

  --link: var(--green);
  --font: 'Recursive', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Recursive Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* type scale: major third on an 18px body */
  --step--1: 0.875rem;
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.35vw, 1.375rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.6rem, 1.35rem + 1.2vw, 2.2rem);
  --step-4: clamp(2rem, 1.6rem + 2vw, 3rem);
  --step-5: clamp(2.4rem, 1.8rem + 3vw, 3.9rem);

  --wrap: 74rem;
  --gutter: clamp(1rem, 4vw, 2.25rem);
  --radius: 4px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--night);
  color: var(--paper);
  font-family: var(--font);
  font-variation-settings: 'CASL' 0;
  font-size: var(--step-0);
  line-height: 1.6;
  font-kerning: normal;
}

main {
  flex: 1;
}

main:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

img,
svg,
video,
canvas,
iframe {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

h1,
h2,
h3 {
  font-variation-settings: 'CASL' 1;
  line-height: 1.12;
  letter-spacing: -0.012em;
  margin: 0 0 0.55em;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-5);
  font-weight: 860;
}

h2 {
  font-size: var(--step-3);
  font-weight: 800;
}

h3 {
  font-size: var(--step-1);
  font-weight: 760;
}

p {
  margin: 0 0 1em;
  max-width: 68ch;
  text-wrap: pretty;
}

:lang(de) p,
:lang(de) dd,
:lang(fr) p,
:lang(fr) dd {
  hyphens: auto;
  hyphenate-limit-chars: 7 3 3; /* never split short words such as ATLAS */
}

/* large text reads better without hyphenation (p.lead: as specific as :lang(de) p, and later) */
.intro-text p,
p.lead {
  hyphens: manual;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--yellow);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--yellow);
  color: var(--night);
}

code {
  font-family: var(--mono);
  font-variation-settings: 'MONO' 1;
  font-size: 0.9em;
}

kbd {
  display: inline-block;
  min-width: 1.75em;
  padding: 0.05em 0.45em;
  font-family: var(--mono);
  font-variation-settings: 'MONO' 1;
  font-size: 0.8125rem;
  font-weight: 620;
  line-height: 1.5;
  text-align: center;
  color: var(--paper);
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 5px;
}

.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.75rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--yellow);
  color: var(--night);
  font-weight: 700;
}

.skip:focus {
  left: 0.75rem;
}

.small {
  font-size: var(--step--1);
  color: var(--mist);
}

/* ------------------------------------------------------------ buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 680;
  line-height: 1;
  color: var(--paper);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}

.btn:hover {
  color: var(--paper);
  border-color: var(--faint);
}

.btn svg {
  width: 0.9em;
  height: 0.9em;
}

.btn-primary {
  color: #1a1430;
  background: var(--yellow);
  border-color: var(--yellow);
}

.btn-primary:hover {
  color: #1a1430;
  background: #fff07a;
  border-color: #fff07a;
}

.btn-large {
  padding: 1rem 1.5rem;
  font-size: var(--step-1);
}

/* ------------------------------------------------------------ header & footer */

.site-header {
  border-bottom: 1px solid var(--line-soft);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 2rem;
  min-height: 4.25rem;
  padding-block: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 auto 0 0;
  color: var(--paper);
  font-variation-settings: 'CASL' 1;
  font-size: 1.2rem;
  font-weight: 820;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: var(--paper);
}

.glider {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.6rem;
}

.site-nav a {
  padding-block: 0.3rem;
  color: var(--mist);
  font-weight: 560;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  color: var(--paper);
}

.site-nav a[aria-current],
.site-nav a.is-section {
  color: var(--paper);
  border-bottom-color: var(--yellow);
}

.lang ul {
  display: flex;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang a,
.lang-current {
  display: inline-block;
  min-width: 2.3rem;
  padding: 0.25rem 0.4rem;
  font-size: var(--step--1);
  font-weight: 680;
  text-align: center;
  text-decoration: none;
  color: var(--mist);
  border-radius: 3px;
}

.lang a:hover {
  color: var(--paper);
  background: var(--panel);
}

.lang-current {
  color: var(--paper);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.site-footer {
  margin-top: clamp(3rem, 8vw, 6rem);
  padding-block: 2rem 2.5rem;
  border-top: 1px solid var(--line-soft);
  color: var(--mist);
  font-size: var(--step--1);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 2.5rem;
}

.footer-row p {
  margin: 0;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--paper);
  font-variation-settings: 'CASL' 1;
  font-weight: 760;
}

.footer-brand .glider {
  align-self: center;
}

.footer-note {
  flex: 1 1 18rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ------------------------------------------------------------ the Game of Life */

.life {
  padding-top: clamp(1.25rem, 3vw, 2.5rem);
}

.life-board {
  position: relative;
  overflow: hidden;
  background-color: var(--night-deep);
  background-image:
    linear-gradient(to right, rgb(239 234 248 / 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(239 234 248 / 0.05) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) calc(100% / var(--rows));
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.life-board svg,
.life-board canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.life-board svg rect {
  shape-rendering: crispEdges;
}

.life-board canvas {
  cursor: crosshair;
  touch-action: pan-y;
}

.life-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}

.life-bar[hidden] {
  display: none;
}

.life-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.life-status {
  margin: 0;
  color: var(--mist);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.life-notes {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 0.5rem 3rem;
  margin-top: 1rem;
  color: var(--mist);
  font-size: var(--step--1);
}

.legend {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}

.swatches {
  display: inline-flex;
  flex: none;
  gap: 2px;
  transform: translateY(0.1em);
}

.swatches i {
  display: block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 1px;
}

/* ------------------------------------------------------------ home */

.intro {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2rem;
  padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(1.5rem, 4vw, 3rem);
}

.intro-text {
  grid-column: 1 / span 7;
}

.intro-text p {
  font-size: var(--step-1);
  line-height: 1.55;
}

.intro-text p:last-child {
  font-size: var(--step-0);
}

.intro-facts {
  grid-column: 9 / span 4;
  align-self: end;
  margin: 0;
}

.intro-facts div,
.interests div {
  padding-block: 0.9rem;
  border-top: 1px solid var(--line-soft);
}

.intro-facts dt,
.interests dt {
  font-variation-settings: 'CASL' 1;
  font-weight: 740;
}

.intro-facts dd,
.interests dd {
  margin: 0.2rem 0 0;
  color: var(--mist);
  font-size: var(--step--1);
}

.section {
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.4rem 2rem;
  margin-bottom: 2rem;
}

.section-head h2 {
  margin: 0;
}

.section-head p {
  grid-column: 1;
  margin: 0;
  color: var(--mist);
}

.section-more {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  white-space: nowrap;
}

/* the first game, larger */
.feature {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: center;
  gap: 1.5rem 2.5rem;
  margin-bottom: 3rem;
}

.feature img,
.feature .placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
}

.feature h3 {
  margin-bottom: 0.25rem;
  font-size: var(--step-4);
}

.feature .btn {
  margin-top: 1.25rem;
}

/* a whole card is one link: the title link stretches over it */
.card-link {
  color: var(--paper);
  text-decoration: none;
}

.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.card-link:hover {
  color: var(--paper);
}

.feature:hover img,
.feature:focus-within img,
.tile:hover img,
.tile:focus-within img,
.game-row:hover img,
.game-row:focus-within img,
.tile:hover .placeholder,
.tile:focus-within .placeholder {
  outline: 2px solid var(--accent, var(--yellow));
  outline-offset: 4px;
}

.feature:focus-within .card-link,
.tile:focus-within .card-link,
.game-row:focus-within .card-link {
  text-decoration: underline;
  text-decoration-color: var(--accent, var(--yellow));
}

.card-link:focus-visible {
  outline: none;
}

.genre {
  margin: 0 0 0.6rem;
  color: var(--mist);
  font-size: var(--step--1);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.75rem 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tiles--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tile {
  position: relative;
}

.tile img,
.tile .placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--panel);
}

.tile h3 {
  margin: 1rem 0 0.2rem;
}

.tile .summary {
  font-size: var(--step--1);
  color: var(--mist);
}

.placeholder {
  display: flex;
  align-items: flex-end;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(120% 90% at 85% 10%, color-mix(in oklab, var(--accent, var(--teal)) 55%, transparent), transparent 70%),
    var(--panel);
  font-variation-settings: 'CASL' 1;
  font-size: var(--step-2);
  font-weight: 820;
  line-height: 1.1;
  color: var(--paper);
}

.inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--faint);
  font-size: 0.8125rem;
}

.inputs li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.inputs svg {
  width: 1rem;
  height: 1rem;
}

/* ------------------------------------------------------------ inner pages */

.page-head {
  padding-block: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 3vw, 2rem);
}

.page-head h1 {
  margin-bottom: 0.35em;
}

.crumb {
  margin: 0 0 0.75rem;
  font-size: var(--step--1);
}

.lead {
  max-width: 60ch;
  color: var(--mist);
  font-size: var(--step-1);
  line-height: 1.5;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 2rem clamp(2rem, 5vw, 4.5rem);
  padding-block: clamp(2rem, 5vw, 3rem);
}

.columns h2 {
  font-size: var(--step-2);
}

.prose h2 {
  font-size: var(--step-2);
  margin-top: 2.25rem;
}

.prose h2:first-child,
.prose h3:first-child {
  margin-top: 0;
}

.prose h3 {
  margin-top: 2rem;
  font-size: var(--step-1);
}

.page-about .prose,
.page-privacy .prose {
  max-width: 44rem;
}

.section-tight {
  padding-block: 1.5rem 2rem;
}

.section-tight h2 {
  font-size: var(--step-2);
}

.footnote {
  margin-top: 3rem;
  color: var(--mist);
  font-size: var(--step--1);
}

/* definition lists of facts (game and video pages) */
.facts {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  font-size: var(--step--1);
}

.facts div {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
  gap: 1.25rem;
}

.facts dt {
  color: var(--faint);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warn {
  display: block;
  color: var(--yellow);
}

/* games list */
.game-list {
  display: grid;
  gap: clamp(2.5rem, 5vw, 3.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: start;
  gap: 1.25rem clamp(1.5rem, 4vw, 3rem);
}

.game-row img,
.game-row .placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
}

.game-row h2 {
  margin-bottom: 0.2rem;
}

.game-row .facts {
  margin-top: 1.25rem;
}

/* the game itself — a bit wider than the text column on large screens
   (Elevator Saga, for one, is a fixed 1220 px page) */
.stage {
  --stage-width: min(100vw - 2 * var(--gutter), 80rem);
  position: relative;
  width: var(--stage-width);
  margin-inline: calc((100% - var(--stage-width)) / 2);
  overflow: hidden;
  background: #000;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line-soft);
}

.stage--wide {
  aspect-ratio: 16 / 9;
  max-height: 88vh;
}

.stage--page {
  height: min(86vh, 58rem);
  min-height: 30rem;
}

.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.stage.is-playing {
  box-shadow: 0 0 0 2px var(--accent, var(--yellow));
}

.stage-start {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-decoration: none;
}

.stage-start img,
.stage-start .placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
}

.stage-start:hover img {
  opacity: 0.7;
}

.stage-start:focus-visible {
  outline-offset: -6px;
}

.stage-start .btn {
  position: relative;
}

.stage-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
  font-size: var(--step--1);
}

.stage-tools p {
  flex: 1 1 20rem;
  margin: 0;
  color: var(--mist);
}

.controls {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.controls th,
.controls td {
  padding: 0.6rem 0;
  text-align: left;
  vertical-align: baseline;
  border-bottom: 1px solid var(--line-soft);
}

.controls th {
  width: 48%;
  padding-right: 1rem;
  font-weight: 400;
}

.controls td {
  color: var(--mist);
}

.credits-block {
  padding-block: 1rem 2rem;
}

.credits-block h2 {
  font-size: var(--step-2);
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 1rem;
  padding-block: 2rem 0;
  border-top: 1px solid var(--line-soft);
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
}

.pager a span {
  font-variation-settings: 'CASL' 1;
  font-weight: 760;
  font-size: var(--step-1);
  color: var(--paper);
}

.pager a:hover span {
  color: var(--yellow);
}

.pager small {
  color: var(--faint);
  font-size: var(--step--1);
}

.pager .up {
  align-self: center;
  font-size: var(--step--1);
}

.pager .next {
  text-align: right;
}

/* videos */
.screen {
  margin: 0;
  overflow: hidden;
  background: #000;
  border-radius: var(--radius);
}

.screen video {
  width: 100%;
  height: auto;
  background: #000;
}

.screen-missing {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, var(--panel) 0 12px, var(--night-deep) 12px 24px);
  color: var(--mist);
}

/* tables on the credits page */
.table-wrap {
  overflow-x: auto;
}

.list {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.list th,
.list td {
  padding: 0.7rem 1.25rem 0.7rem 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

.list thead th {
  color: var(--faint);
  font-weight: 560;
}

.list tbody th {
  font-weight: 680;
}

.list .nowrap {
  white-space: nowrap;
}

/* language chooser (/) and 404 */
.page-root,
.page-404 {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.chooser {
  width: min(100% - 2rem, 34rem);
  padding-block: 3rem;
}

.chooser .brand {
  margin-bottom: 2rem;
  font-size: var(--step-3);
}

.chooser .big {
  margin: 0 0 1rem;
  font-variation-settings: 'CASL' 1;
  font-size: var(--step-5);
  font-weight: 900;
  color: var(--yellow);
}

.chooser ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.chooser li a {
  display: grid;
  gap: 0.1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line-soft);
  text-decoration: none;
}

.chooser li a strong {
  color: var(--paper);
  font-size: var(--step-1);
  font-variation-settings: 'CASL' 1;
}

.chooser li a span {
  color: var(--mist);
  font-size: var(--step--1);
}

.chooser li a:hover strong {
  color: var(--yellow);
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 60rem) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-text,
  .intro-facts {
    grid-column: 1 / -1;
  }

  .life-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 46rem) {
  .feature,
  .columns,
  .game-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-more {
    grid-column: 1;
    grid-row: auto;
  }

  .pager {
    grid-template-columns: 1fr 1fr;
  }

  .pager .up {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

@media (max-width: 34rem) {
  .tiles,
  .tiles--two {
    grid-template-columns: minmax(0, 1fr);
  }

  .site-nav {
    order: 3;
    width: 100%;
  }

  .stage--page {
    height: 75vh;
    min-height: 24rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
