/* Gnomecraft
   Layout: dark ink ground so the white logo and the colourful box art carry the page.
   Home = logo, one line, a row of covers, about. Game pages = art-lit hero band, then copy. */

:root {
  --ink: #101215;        /* page */
  --ink-2: #171a1f;      /* raised surfaces */
  --line: #262a31;
  --fg: #eef0f2;
  --muted: #8b929c;
  --glow: rgba(255, 255, 255, .06);

  --display: "Luckiest Guy", "Arial Black", Impact, sans-serif;  /* titles only */
  --hand: "Shadows Into Light", "Comic Sans MS", cursive;  /* About only */
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;

  --step-0: 17px;
  --step-1: 20px;
  --step-2: clamp(24px, 3vw, 30px);
  --label: 12px;

  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--fg);
  font: 400 var(--step-0)/1.6 var(--body);
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 4px; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

.label {
  font-family: var(--body);
  font-weight: 600;
  font-size: var(--label);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- header ---------- */

.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 14px;
}
.site-header .home img { height: 34px; width: auto; }
.site-header nav { display: flex; gap: 28px; }
.site-header nav a { text-decoration: none; color: var(--muted); transition: color .2s; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--fg); }

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

.hero { padding-block: 72px 40px; text-align: center; }
.hero img {
  width: min(560px, 82vw);
  margin: 0 auto;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .6));
}
.hero .label { margin: 28px 0 0; font-size: 13px; letter-spacing: .3em; color: var(--fg); opacity: .7; }

/* ---------- section heads ---------- */

.section { padding-block: 56px 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { margin: 0; color: var(--fg); }

/* ---------- game row ---------- */

.games {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 34px;
}
.game-card { -webkit-tap-highlight-color: transparent; text-decoration: none; display: grid; gap: 16px; perspective: 1200px; }
/* ---------- the 3D box ---------- */

.stage {
  perspective: 1300px;
  display: flex; justify-content: center; align-items: flex-end;
  padding: 24px 0 22px;
  position: relative;
  /* same height in every cell so all boxes stand on one shelf line: tallest box is 2:3 */
  height: calc(var(--box-w) * 1.5 + 46px);
}
.games li { container-type: inline-size; --box-w: 76cqw; }
/* soft floor shadow under each box */
.stage { isolation: isolate; }

.box {
  --d: 60px;
  --ratio: 1240 / 1754;
  --spine: #2b2f37;
  --spine-fg: #fff;
  position: relative;
  width: var(--box-w, 76%);
  aspect-ratio: var(--ratio);
  max-width: 100%;
  transform-style: preserve-3d;
  transform: rotateY(32deg) rotateX(2deg);
  transform-origin: 50% 100%;
  transition: transform .6s cubic-bezier(.2, .9, .25, 1.15);
  z-index: 1;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.box img { -webkit-user-drag: none; pointer-events: none; }
.game-card:hover .box, .game-card:focus-visible .box {
  transform: rotateY(-6deg) rotateX(4deg) translateY(-12px) translateZ(24px);
}
.box .face { position: absolute; backface-visibility: hidden; }
.box .front {
  inset: 0;
  transform: translateZ(calc(var(--d) / 2));
  border-radius: 2px 4px 4px 2px;
  overflow: hidden;
  background: var(--ink-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.box .front img { width: 100%; height: 100%; object-fit: cover; }
/* shrink-wrap shine */
.box .front::after {
  content: "";
  position: absolute; inset: -20%;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .25) 45%, transparent 55%);
  transform: translateX(-60%);
  transition: transform .9s ease;
}
.game-card:hover .box .front::after, .game-card:focus-visible .box .front::after { transform: translateX(60%); }
/* shadow cast by the box itself: the back face throws a soft shadow, so it follows the box's outline and angle */
.box .floor { display: none; }
.box .back { inset: 0; transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); background: #0b0c0e; box-shadow: 0 22px 28px 4px rgba(0, 0, 0, .75); backface-visibility: visible; }
.box .spine {
  top: 0; bottom: 0; width: var(--d);
  left: calc(var(--d) / -2);
  transform: rotateY(-90deg);
  background: var(--spine);
  color: var(--spine-fg);
  display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl;
  font-family: var(--display);
  font-size: min(calc(var(--d) * .48), 9cqw);  /* 9cqw keeps "Train-Tiles Express" inside the shortest box */
  line-height: 1;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  padding-top: 2px;
  box-shadow: inset -6px 0 10px rgba(0, 0, 0, .35);
}
.box .side-r {
  top: 0; bottom: 0; width: var(--d);
  right: calc(var(--d) / -2);
  transform: rotateY(90deg);
  background: var(--spine); filter: brightness(.55);
}
.box .top {
  left: 0; right: 0; height: var(--d);
  top: calc(var(--d) / -2);
  transform: rotateX(90deg);
  background: var(--spine); filter: brightness(1.3);
}

/* the unannounced one */
.box .front.mystery {
  display: grid; place-content: center; text-align: center; gap: 4px;
  background:
    radial-gradient(120% 80% at 50% 0%, #2a2f3a, transparent 70%),
    repeating-linear-gradient(135deg, #15171b 0 14px, #121418 14px 28px);
  font-family: var(--display);
  color: var(--fg);
}
.box .front.mystery b { font-weight: 400; font-size: clamp(40px, 6vw, 72px); line-height: 1; }
.box .front.mystery span { font-size: 18px; color: var(--muted); letter-spacing: .06em; }

.game-card { text-decoration: none; display: grid; gap: 8px; }
.game-card:focus-visible { outline: none; }
.game-card:focus-visible h3 { text-decoration: underline; text-underline-offset: 4px; }

.game-card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: .02em;
  text-transform: uppercase;
  line-height: 1.15;
  text-wrap: balance;
}
.game-card .label { margin-top: 4px; }
.game-card h3, .game-card .label { text-align: center; }

/* ---------- about ---------- */

.about { max-width: 34em; margin: 36px auto 0; text-align: center; }
.games-section { padding-top: 0; }
.games-section .games { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 56px; }
.about p { margin: 0; font-family: var(--hand); font-size: clamp(24px, 2.6vw, 30px); line-height: 1.45; }

/* ---------- footer ---------- */

.site-footer { margin-top: 96px; border-top: 1px solid var(--line); }
.site-footer .wrap {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding-block: 24px 32px;
  font-size: 14px; color: var(--muted);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--fg); }
.site-footer nav { display: flex; gap: 20px; }

/* ---------- game page ---------- */

.game-hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.game-hero .backdrop {
  position: absolute; inset: -40px;
  background: var(--art) center / cover no-repeat;
  filter: blur(40px) saturate(1.3) brightness(1.1);
  opacity: .8;
  transform: scale(1.1);
}
.game-hero video.backdrop {
  inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: none; opacity: .75; transform: none;
  mix-blend-mode: var(--video-blend, screen);
}
.game-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(16, 18, 21, 0) 40%, var(--ink));
}
.game-hero .wrap {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; justify-items: center;
  text-align: center;
  padding-block: 40px 56px;
}
.game-hero .stage { height: auto; width: min(280px, 64vw); padding-bottom: 22px; }
.game-hero .box { width: 100%; --d: 72px; }
.game-hero .buttons { justify-content: center; }
.game-hero .box:hover { transform: rotateY(-6deg) rotateX(4deg) translateY(-8px); }
.game-title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 1;
  letter-spacing: .01em;
  text-transform: uppercase;
  text-wrap: balance;
}
.game-title, .game-hero .label { text-shadow: 0 2px 16px rgba(0, 0, 0, .55); }
.site-header.is-home .home { visibility: hidden; }
.game-hero .label { color: var(--fg); opacity: .8; }

.game-hero .back-row { display: block; padding-block: 24px 0; }
.btn.back { width: 44px; height: 44px; padding: 0; justify-content: center; }
.game-hero .back-row + .wrap { padding-top: 24px; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(16, 18, 21, .4);
  color: var(--fg);
  text-decoration: none;
  font-weight: 600; font-size: 15px;
  transition: background .2s, color .2s, border-color .2s;
}
.btn:hover { border-color: var(--fg); }
.btn.solid { background: var(--fg); color: var(--ink); border-color: var(--fg); }
.btn.solid:hover { background: #fff; }

.game-body {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 56px;
  padding-block: 56px 0;
}
.copy { min-width: 0; }
.copy p { margin: 0 0 16px; max-width: 62ch; }
.copy p.lead { font-size: var(--step-2); line-height: 1.3; font-weight: 600; text-wrap: balance; }
.features { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); align-self: start; }
.features li { padding: 12px 0; border-bottom: 1px solid var(--line); }

.shots {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
  margin-top: 56px;
}
.shots img { border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }

.gallery {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
  margin-top: 56px;
}
.gallery img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.gallery img:first-child { grid-column: 1 / -1; }

.video {
  margin-top: 56px;
  aspect-ratio: 16 / 9; max-width: 100%;
  border-radius: 6px; overflow: hidden; background: #000;
}
.video iframe { width: 100%; height: 100%; border: 0; display: block; }


/* ---------- plain documents (privacy) ---------- */

.doc { max-width: 680px; padding-block: 48px 0; }
.doc h1 {
  font-family: var(--display); font-weight: 400;
  text-transform: uppercase; letter-spacing: .01em;
  font-size: clamp(26px, 4vw, 36px); line-height: 1.1; margin: 0 0 8px; text-wrap: balance;
}
.doc h2 { font-size: var(--step-1); margin: 32px 0 6px; }
.doc p { margin: 0 0 12px; color: #d3d7dc; }
.doc .muted { color: var(--muted); font-size: 15px; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .games { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; margin: 0 auto; }
}

@media (max-width: 860px) {
  .game-body { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 600px) {
  .games { grid-template-columns: minmax(0, 1fr); gap: 40px; max-width: 360px; }
  .games li { --box-w: 62cqw; }
  .box { --d: 56px; }
  .hero { padding-block: 48px 24px; }
  .game-card h3 { font-size: 22px; }
  .game-card .label { font-size: 11px; letter-spacing: .1em; }
  .game-hero .box { --d: 52px; }
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-header nav { gap: 18px; }
}

/* touch screens: boxes turn as they scroll up the screen (desktop keeps the hover turn) */
@keyframes box-tilt {
  from { transform: rotateY(42deg) rotateX(6deg); }
  to   { transform: rotateY(-22deg) rotateX(-2deg); }
}
@media (hover: none) {
  @supports (animation-timeline: view()) {
    .box {
      transition: none;
      animation: box-tilt linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }
  }
}

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