/* Pixel world, the design of every page. Rules: docs/STYLEGUIDE.md.
   Every level is one generated scene split into two layers (plate without
   Leander, Leander as a transparent cut-out) that move at different speeds.
   All motion is CSS: scroll-driven animations inside @supports and
   prefers-reduced-motion. Without them every element simply stands in its
   final state, fully readable. */

/* Jersey 25 for display, Geist Pixel for game UI, Geist for reading. All OFL, licences next to the files. */
@font-face {
  font-family: "Jersey 25";
  src: url("/fonts/jersey-25.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Geist Pixel";
  src: url("/fonts/geist-pixel-square.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@property --n {
  syntax: "<integer>";
  inherits: false;
  initial-value: 0;
}

@property --c {
  syntax: "<integer>";
  inherits: false;
  initial-value: 9;
}

:root {
  --blue: #2c4bfd;
  --night: #141c52;
  --red: #f00020;
  --ink: #0b1030;
  --paper: #f4f4f4;
  --white: #fff;
  --yellow: #f0c418;
  --px: clamp(3px, 0.3vw, 5px);
  --gutter: clamp(1.25rem, 5vw, 5rem);
  --display: "Jersey 25", ui-monospace, monospace;
  --ui: "Geist Pixel", ui-monospace, monospace;
  --text: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Notched corners like a game dialogue box. */
  --notch: polygon(
    0 var(--px), var(--px) var(--px), var(--px) 0,
    calc(100% - var(--px)) 0, calc(100% - var(--px)) var(--px), 100% var(--px),
    100% calc(100% - var(--px)), calc(100% - var(--px)) calc(100% - var(--px)), calc(100% - var(--px)) 100%,
    var(--px) 100%, var(--px) calc(100% - var(--px)), 0 calc(100% - var(--px))
  );
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: var(--night);
}

body {
  margin: 0;
  background: var(--night);
  color: var(--white);
  font-family: var(--text);
  font-size: clamp(1.05rem, 0.98rem + 0.3vw, 1.25rem);
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: var(--px) solid var(--yellow);
  outline-offset: var(--px);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  background: var(--white);
  color: var(--ink);
}

.skip-link:focus {
  top: 1rem;
}

/* Type: the pixel face for everything a game would print, Geist for reading. */

h1,
h2,
.t-name,
.plate-name,
.n,
.num,
.count {
  font-family: var(--display);
  font-weight: 400;
}

h3,
.label,
.kicker,
.press,
.meta,
.home,
summary,
.speaker,
.flip,
.plate-class,
.rec,
.hud ol,
.xp-label,
.rhythm,
.save-slots a,
.hint {
  font-family: var(--ui);
  font-weight: 400;
}

h2 {
  margin: 0 0 0.9rem;
  font-size: clamp(2.4rem, 1.4rem + 4vw, 5.2rem);
  line-height: 0.95;
  text-wrap: balance;
}

h3 {
  margin: 0 0 1.4rem;
  font-size: clamp(1rem, 0.85rem + 0.6vw, 1.35rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.label,
.kicker {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--yellow);
}

p {
  margin: 0;
  text-wrap: pretty;
}

/* Layers: plate and figure share one canvas, so they line up exactly. */

.layer,
.layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer img {
  object-fit: cover;
  object-position: var(--fx, 72%) var(--fy, 50%);
  image-rendering: pixelated;
}

/* Title screen */

.title {
  position: relative;
  height: 100svh;
  min-height: 36rem;
  overflow: hidden;
  isolation: isolate;
  background: var(--night);
  --fx: 62%;
  --jump: -10% 22%;
  --jump-scale: 1.45;
}

.hud {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem var(--gutter);
}

.home {
  display: block;
  width: clamp(3.4rem, 5vw, 4.6rem);
}

.home img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.home:hover img {
  translate: 0 calc(var(--px) * -1);
}

/* The navigation is a level-select window: a double pixel frame, digits on
   tiles, and a blinking cursor on the item under the pointer or focus. */
.hud nav {
  position: relative;
  padding: 0.55rem 0.7rem;
  background: var(--ink);
  border: var(--px) solid var(--white);
  box-shadow: inset 0 0 0 var(--px) var(--blue);
  clip-path: var(--notch);
}

.hud nav::before {
  content: "Level wählen";
  position: absolute;
  left: 1.1rem;
  top: calc(var(--px) * -0.5);
  padding: 0 0.4rem;
  font-family: var(--ui);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--yellow);
}

.hud ol {
  display: flex;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.hud ol a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem 0.35rem 1.1rem;
  text-decoration: none;
  white-space: nowrap;
}

.hud ol a::before {
  content: "▶";
  position: absolute;
  left: 0.1rem;
  font-size: 0.7em;
  color: var(--yellow);
  opacity: 0;
}

.hud ol a span {
  display: inline-grid;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  background: var(--yellow);
  color: var(--ink);
  clip-path: var(--notch);
}

.hud ol a:hover,
.hud ol a:focus-visible {
  color: var(--yellow);
  outline: none;
}

.hud ol a:hover::before,
.hud ol a:focus-visible::before {
  opacity: 1;
}

.hud ol a:hover span,
.hud ol a:focus-visible span {
  background: var(--white);
}

.title-copy {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  top: clamp(6rem, 18vh, 11rem);
  max-width: min(40rem, 46vw);
}

.logo {
  margin: 0 0 0.6rem;
}

.logo img {
  display: block;
  width: clamp(15rem, 8rem + 19vw, 26rem);
  height: auto;
  image-rendering: pixelated;
}

.line {
  max-width: 26rem;
  padding: 0.8rem 1rem;
  background: var(--ink);
  border: var(--px) solid var(--white);
  clip-path: var(--notch);
  margin-bottom: 1.8rem;
  font-size: 1.15em;
  font-weight: 500;
}

.press {
  display: inline-block;
  padding: 0.8rem 1.3rem;
  background: var(--yellow);
  color: var(--ink);
  font-size: 1rem;
  text-transform: uppercase;
  text-decoration: none;
  clip-path: var(--notch);
}

.press:hover {
  background: var(--white);
}

.meta {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: rgb(255 255 255 / 0.75);
}

/* Levels: one scene, a dialogue box, then the level's own mechanic. */

.level {
  position: relative;
  isolation: isolate;
}

.stage {
  position: relative;
  height: 100svh;
  min-height: 34rem;
  overflow: hidden;
  isolation: isolate;
  background: var(--night);
}

#amrum { --fx: 60%; }
#schramberg { --fx: 64%; }
#rottweil { --fx: 74%; }
#hamburg { --fx: 78%; }
#wedel { --fx: 68%; }
#otto { --fx: 70%; }
#bonus { --fx: 62%; }
#kontakt { --fx: 70%; }

.box {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  bottom: clamp(1.5rem, 6vh, 4rem);
  width: min(36rem, calc(100% - 2 * var(--gutter)));
  padding: clamp(1.2rem, 2.5vw, 2rem);
  background: var(--ink);
  border: var(--px) solid var(--white);
  clip-path: var(--notch);
}

/* Section headlines are game-cover logos (metal letters, ribbon, badge). */
.cover {
  position: absolute;
  z-index: 2;
  margin: 0;
  left: var(--gutter);
  top: clamp(4.5rem, 11vh, 8rem);
  width: min(42rem, 44vw);
}

.cover img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.cover.tc {
  left: 50%;
  top: clamp(1.5rem, 5vh, 3.5rem);
  width: min(48rem, 60vw);
  translate: -50% 0;
}

.cover.tilt {
  rotate: -3deg;
}

.continue .cover {
  position: static;
  width: min(30rem, 100%);
  margin: 0 0 1rem;
}

.box p:not(.label) {
  font-size: 1em;
}

.box a {
  color: var(--yellow);
}

.hint {
  position: absolute;
  z-index: 2;
  right: var(--gutter);
  top: 1.5rem;
  margin: 0;
  padding: 0.45rem 0.7rem;
  font-family: var(--ui);
  font-size: 0.8rem;
  background: var(--white);
  color: var(--ink);
  clip-path: var(--notch);
}

/* Flat blocks after a scene start with a crenellated pixel edge. */

.after,
.flat {
  position: relative;
  padding: clamp(3.5rem, 9vh, 6.5rem) var(--gutter);
  --c-ground: var(--night);
  background: var(--c-ground);
}

.after::before,
.flat::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--px) * -4);
  height: calc(var(--px) * 4);
  background:
    linear-gradient(90deg, var(--c-ground) 50%, transparent 0) 0 0 / calc(var(--px) * 8) 50% repeat-x,
    linear-gradient(var(--c-ground), var(--c-ground)) 0 100% / 100% 50% no-repeat;
}

.blue { --c-ground: var(--blue); }
.night { --c-ground: var(--night); }
.red { --c-ground: var(--red); }
.ink { --c-ground: var(--ink); }
.paper { --c-ground: var(--paper); color: var(--ink); }

.paper .label {
  color: var(--blue);
}

/* Player card: a trading card that flips. */

.card-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 26rem);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: center;
  max-width: 72rem;
}

.xp-label {
  margin: 1.2rem 0 0.6rem;
  font-family: var(--ui);
  font-size: 0.9rem;
}

.xp {
  height: calc(var(--px) * 5);
  max-width: 24rem;
  background: rgb(11 16 48 / 0.12);
  clip-path: var(--notch);
}

.xp span {
  display: block;
  width: calc(100% * 2 / 7);
  height: 100%;
  background: var(--blue);
  transform-origin: left;
}

.card {
  perspective: 1200px;
}

.card summary {
  position: relative;
  display: grid;
  list-style: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s steps(6);
}

.card summary::-webkit-details-marker {
  display: none;
}

.card[open] summary {
  transform: rotateY(180deg);
}

.face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--white);
  border: calc(var(--px) * 2) solid var(--ink);
  clip-path: var(--notch);
  backface-visibility: hidden;
}

.face img {
  width: 100%;
  image-rendering: pixelated;
}

.plate-name {
  padding: 0.8rem 1rem 0;
  font-size: 1.3rem;
}

.plate-class {
  padding: 0.2rem 1rem 1rem;
  font-size: 0.85rem;
  color: var(--yellow);
}

.back {
  transform: rotateY(180deg);
  justify-content: center;
  background: var(--blue);
  border-color: var(--ink);
}

.stats {
  display: grid;
  gap: 0.9rem;
  padding: 1.5rem;
  font-size: 0.95rem;
}

.stats b {
  display: block;
  font-family: var(--ui);
  font-weight: 400;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--yellow);
}

.flip {
  justify-self: center;
  margin-top: 0.9rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: var(--yellow);
  color: var(--ink);
  clip-path: var(--notch);
  backface-visibility: hidden;
}

.card[open] .flip {
  transform: rotateY(180deg);
}

/* Level 2: training bars in the real ratio 6 : 1 : 1. */

.bars {
  display: grid;
  gap: 1rem;
  max-width: 48rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bars li {
  display: grid;
  gap: 0.35rem;
}

.bar {
  display: block;
  height: calc(var(--px) * 5);
  background:
    repeating-linear-gradient(90deg, var(--white) 0 calc(var(--px) * 3), transparent 0 calc(var(--px) * 4));
  transform-origin: left;
}

.y6 .bar { width: 100%; }
.y1 .bar { width: calc(100% / 6); }

.bars b {
  font-family: var(--display);
  font-weight: 400;
  color: var(--yellow);
  margin-right: 0.4rem;
}

.jersey {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.num {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.8rem;
  background: var(--ink);
  color: var(--yellow);
  clip-path: var(--notch);
}

/* Level 3: skill tree. */

.tree {
  position: relative;
  display: grid;
  gap: 1.1rem;
  max-width: 44rem;
  margin: 0;
  padding: 0 0 0 2.2rem;
  list-style: none;
}

.tree::before {
  content: "";
  position: absolute;
  left: calc(var(--px) * 2);
  top: 0.6rem;
  bottom: 0.6rem;
  width: var(--px);
  background: rgb(255 255 255 / 0.35);
}

.tree li {
  position: relative;
  color: rgb(255 255 255 / 0.8);
}

.tree li::before {
  content: "";
  position: absolute;
  left: -2.2rem;
  top: 0.35rem;
  width: calc(var(--px) * 5);
  height: calc(var(--px) * 5);
  background: var(--blue);
  box-shadow: 0 0 0 var(--px) var(--night), 0 0 0 calc(var(--px) * 2) var(--white);
}

.tree b {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--white);
}

.tree .goal::before {
  background: var(--yellow);
}

/* Achievements: toasts, the last one locked. */

.toasts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  max-width: 76rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.toast {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--ink);
  color: var(--white);
  clip-path: var(--notch);
}

.toast .kicker {
  margin: 0;
  font-size: 0.7rem;
}

.t-name {
  font-size: 1.15rem;
}

.t-desc {
  font-size: 0.92rem;
  color: rgb(255 255 255 / 0.85);
}

.toast a {
  color: var(--yellow);
}

.toast.locked {
  background: repeating-linear-gradient(45deg, #1b2150 0 calc(var(--px) * 2), var(--ink) 0 calc(var(--px) * 4));
}

.toast.locked .kicker {
  color: rgb(255 255 255 / 0.7);
}

/* Level 4: the world map is an isometric Wimmelbild with a numbered legend. */

.world {
  position: relative;
  background: var(--night);
}

.world-title,
.wimmel-title {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  top: 1.4rem;
  margin: 0;
  padding: 0.4rem 0.7rem;
  font-family: var(--ui);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--white);
  color: var(--ink);
  clip-path: var(--notch);
}

.world-map,
.world-map img {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
}

.world-map img {
  image-rendering: pixelated;
}

.legend {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0;
  padding: 1.4rem var(--gutter) 0.6rem;
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.35;
}

.legend li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.55rem;
}

.legend span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  font-family: var(--display);
  font-size: 1.2rem;
  background: var(--yellow);
  color: var(--ink);
  clip-path: var(--notch);
}

.legend b {
  font-family: var(--ui);
  font-weight: 400;
}

.side {
  padding: 0 var(--gutter) 2rem;
  font-size: 0.85rem;
  color: rgb(255 255 255 / 0.75);
}

.semesters {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 4.5rem));
  gap: 0.5rem;
  margin: 0 0 1.4rem;
  padding: 0;
  list-style: none;
}

.semesters li {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-family: var(--display);
  font-size: 1.3rem;
  background: rgb(11 16 48 / 0.35);
  clip-path: var(--notch);
}

.semesters .done {
  background: var(--white);
  color: var(--blue);
}

.semesters .next {
  background: var(--yellow);
  color: var(--ink);
}

.semesters .otto {
  background: var(--red);
}

.save {
  max-width: 36rem;
  margin-bottom: 1.6rem;
}

.rhythm {
  display: flex;
  max-width: 44rem;
  font-family: var(--ui);
  font-size: 0.8rem;
}

.rhythm span {
  padding: 0.6rem 0.8rem;
}

.rhythm .uni {
  flex: 16;
  background: var(--white);
  color: var(--blue);
}

.rhythm .co {
  flex: 10;
  background: var(--red);
}

/* Level 6: quest log and team score board. */

.quest-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(2.5rem, 6vw, 6rem);
  align-items: start;
}

.quests {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quests details {
  background: var(--ink);
  clip-path: var(--notch);
}

.quests summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 1.05rem;
}

.quests summary::-webkit-details-marker {
  display: none;
}

.quests summary::after {
  content: "+";
  color: var(--yellow);
}

.quests details[open] summary::after {
  content: "−";
}

.quests details p {
  padding: 0 1rem 1rem;
  font-size: 0.95rem;
}

.board {
  padding: clamp(1.2rem, 2.5vw, 2rem);
  background: var(--ink);
  clip-path: var(--notch);
}

.board h3 {
  margin-bottom: 0.3rem;
  color: var(--yellow);
}

.board-sub {
  margin-bottom: 1.4rem;
  font-size: 0.85rem;
  color: rgb(255 255 255 / 0.8);
}

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

.scores li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: 0.7rem 0;
  border-top: var(--px) dotted rgb(255 255 255 / 0.25);
}

.scores .n {
  font-size: 1.6rem;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.scores li:first-child .n {
  font-size: 2.4rem;
  color: var(--yellow);
}

.scores .d {
  font-size: 0.92rem;
}

.source {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: rgb(255 255 255 / 0.75);
}

/* Quote: an RPG dialogue box with portrait and name plate. */

.dialog {
  display: grid;
  grid-template-columns: clamp(5rem, 12vw, 9rem) minmax(0, 1fr);
  grid-template-areas:
    "avatar speaker"
    "avatar quote"
    ". cite";
  column-gap: clamp(1rem, 3vw, 2rem);
  max-width: 64rem;
  margin: 0;
  padding: clamp(1.2rem, 3vw, 2.2rem);
  background: var(--ink);
  border: var(--px) solid var(--white);
  clip-path: var(--notch);
}

.avatar {
  grid-area: avatar;
  width: 100%;
  image-rendering: pixelated;
  border: var(--px) solid var(--white);
}

.speaker {
  grid-area: speaker;
  justify-self: start;
  margin-bottom: 0.8rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
  background: var(--yellow);
  color: var(--ink);
}

.dialog blockquote {
  grid-area: quote;
  margin: 0;
}

.dialog blockquote p {
  font-family: var(--display);
  font-size: clamp(1.3rem, 0.9rem + 1.8vw, 2.4rem);
  line-height: 1.25;
}

.dialog blockquote span {
  display: inline;
}

.cite {
  grid-area: cite;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: rgb(255 255 255 / 0.8);
}

/* Inventory: slots with item cards. */

.bags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
  max-width: 80rem;
  margin-top: 2.2rem;
}

.bag h3 {
  color: var(--yellow);
  font-size: 0.9rem;
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  height: 100%;
  background: #172060;
  clip-path: var(--notch);
}

.item summary {
  display: block;
  min-height: 4.2rem;
  padding: 0.8rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  line-height: 1.2;
}

.item summary::-webkit-details-marker {
  display: none;
}

.item[open] {
  background: var(--blue);
}

.item p {
  padding: 0 0.8rem 0.9rem;
  font-size: 0.88rem;
}

@media (hover: hover) {
  .item:hover {
    background: var(--blue);
  }
}

/* Bonus: drone viewfinder over the scene. */

.hud-frame {
  position: absolute;
  inset: clamp(1rem, 4vw, 3rem);
  z-index: 1;
  pointer-events: none;
  --l: clamp(1.5rem, 4vw, 3.5rem);
  background:
    linear-gradient(var(--white), var(--white)) 0 0 / var(--l) var(--px) no-repeat,
    linear-gradient(var(--white), var(--white)) 0 0 / var(--px) var(--l) no-repeat,
    linear-gradient(var(--white), var(--white)) 100% 0 / var(--l) var(--px) no-repeat,
    linear-gradient(var(--white), var(--white)) 100% 0 / var(--px) var(--l) no-repeat,
    linear-gradient(var(--white), var(--white)) 0 100% / var(--l) var(--px) no-repeat,
    linear-gradient(var(--white), var(--white)) 0 100% / var(--px) var(--l) no-repeat,
    linear-gradient(var(--white), var(--white)) 100% 100% / var(--l) var(--px) no-repeat,
    linear-gradient(var(--white), var(--white)) 100% 100% / var(--px) var(--l) no-repeat;
}

.rec {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.rec::before {
  content: "";
  width: calc(var(--px) * 3);
  height: calc(var(--px) * 3);
  background: var(--red);
}

/* Contact: save slots and a countdown bound to scrolling. */

.continue .mail {
  font-size: clamp(1.1rem, 0.9rem + 1vw, 1.6rem);
  font-weight: 700;
  color: var(--white);
}

.save-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
}

.save-slots a {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--white);
  background: var(--blue);
  font-family: var(--ui);
  font-size: 0.9rem;
  clip-path: var(--notch);
}

.save-slots a span {
  color: var(--yellow);
}

.save-slots a:hover {
  background: var(--white);
  color: var(--ink);
}

.count {
  display: inline-block;
  margin-right: 0.4em;
  color: var(--yellow);
}

.foot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding-bottom: 1.6rem;
  background: var(--ink);
  font-size: 0.85rem;
  color: rgb(255 255 255 / 0.75);
}

.foot > p {
  padding: 0 var(--gutter);
}

/* Footer Wimmelbild: on phones it is wider than the screen and pans sideways. */
.wimmel {
  position: relative;
  grid-column: 1 / -1;
  color: var(--white);
}

.wimmel-title {
  font-size: 0.85rem;
}

.pan {
  overflow-x: auto;
  scrollbar-width: thin;
}

.canvas {
  position: relative;
}

.canvas img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.find {
  position: absolute;
  z-index: 2;
  right: var(--gutter);
  top: 1.4rem;
  max-width: 16rem;
}

.find summary {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
  background: var(--yellow);
  color: var(--ink);
  clip-path: var(--notch);
}

.find summary::-webkit-details-marker {
  display: none;
}

.find p {
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  background: var(--ink);
}

.ring {
  position: absolute;
  /* Leander on the bench in the courtyard of w2-otto. */
  left: 45.4%;
  top: 77.5%;
  display: none;
  width: clamp(3rem, 7%, 9rem);
  aspect-ratio: 1;
  translate: -50% -50%;
  border: var(--px) solid var(--yellow);
  box-shadow: 0 0 0 var(--px) var(--ink), inset 0 0 0 var(--px) var(--ink);
}

.wimmel:has(.find[open]) .ring {
  display: block;
}

/* 404: the contact scene without Leander, a game-over box. */

.missing h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(3rem, 2rem + 5vw, 6rem);
  line-height: 0.9;
}

.missing .press {
  margin-top: 1.4rem;
  color: var(--ink);
}

/* The PIN in front of the picture vault: the 404 box with a field. */

.pin label {
  display: block;
}

.pin-error {
  margin-top: 0.8rem;
  color: var(--yellow);
  font-weight: 600;
}

.pin-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.pin input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  background: var(--night);
  color: var(--white);
  border: var(--px) solid var(--white);
  font: 1.4rem var(--ui);
  letter-spacing: 0.3em;
}

.pin input:focus-visible {
  outline: var(--px) solid var(--yellow);
  outline-offset: 2px;
}

.pin .press {
  margin-top: 0;
  border: 0;
  cursor: pointer;
}

/* Level select shrinks to its seven tiles before the names run out of room;
   they stay for screen readers. */

@media (max-width: 900px) {
  .hud nav {
    flex: 1;
    max-width: 21rem;
    padding: 0.5rem 0.4rem 0.4rem;
  }

  .hud ol {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0;
    font-size: 0;
  }

  .hud ol a {
    justify-content: center;
    padding: 0.25rem 0;
  }

  .hud ol a::before {
    content: none;
  }

  .hud ol a span {
    width: min(1.9rem, 100% - 0.3rem);
    height: auto;
    aspect-ratio: 1;
    font-size: 0.9rem;
  }
}

/* Narrow screens: a level is a cartridge (title, scene, dialogue box), the
   mechanics stack. A 16:9 scene that filled a tall screen showed a quarter of
   its width, so here it is a window about as tall as it is wide. */

@media (max-width: 760px) {
  .level .stage {
    display: grid;
    grid-template-rows: auto min(100vw, 72svh) auto;
    height: auto;
    min-height: 0;
    padding-bottom: 2.5rem;
  }

  .level .layer,
  .level .hint,
  .level .hud-frame {
    grid-row: 2 / 3;
  }

  .level .layer {
    overflow: hidden;
  }

  #amrum { --fx: 100%; }
  #schramberg { --fx: 84%; }
  #rottweil { --fx: 74%; }
  #hamburg { --fx: 100%; }
  #wedel { --fx: 82%; }
  #otto { --fx: 92%; }
  #bonus { --fx: 78%; }
  #kontakt { --fx: 80%; }

  .stage > .cover,
  .stage > .cover.tc {
    position: relative;
    grid-row: 1;
    left: auto;
    top: auto;
    width: auto;
    margin: 1.75rem var(--gutter) 1rem;
    translate: none;
  }

  .level .box {
    position: relative;
    grid-row: 3;
    left: auto;
    bottom: auto;
    width: auto;
    margin: -2.5rem var(--gutter) 0;
  }

  .level .hint {
    top: 0.8rem;
    right: 0.8rem;
  }

  /* The viewfinder ends above the dialogue box that overlaps the scene. */
  .level .hud-frame {
    bottom: 3.5rem;
  }

  /* The world map is too fine for a phone at full width: it pans sideways. */
  .world-map {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .world-map img {
    width: 190vw;
    max-width: none;
  }

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

  .canvas {
    width: 260vw;
  }

  .find {
    top: 4.2rem;
    left: var(--gutter);
    right: auto;
  }

  /* Name on top, the sentence and the button at the bottom, so the face stays free. */
  .title {
    --jump: 0 12%;
    --jump-scale: 1.2;
  }

  .title-copy {
    top: 6rem;
    bottom: 2.25rem;
    max-width: none;
    right: var(--gutter);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .title-copy .kicker {
    margin-bottom: auto;
    padding: 0.3rem 0.55rem;
    background: var(--ink);
    font-size: 0.7rem;
  }

  .line {
    max-width: 18rem;
    font-size: 1em;
  }

  .card-wrap,
  .quest-grid {
    grid-template-columns: 1fr;
  }

  .card {
    max-width: 20rem;
  }

  .semesters {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
  }

  .semesters li {
    font-size: 1rem;
  }

  .scores li {
    grid-template-columns: 5.5rem 1fr;
  }

  .dialog {
    grid-template-columns: 4.5rem minmax(0, 1fr);
  }
}

/* Motion. Everything here is progressive: without scroll-driven animations
   or with reduced motion the page shows the final state. */

@media (prefers-reduced-motion: no-preference) {
  .press {
    animation: blink 1.2s steps(1) infinite;
  }

  @keyframes blink {
    50% {
      background: var(--white);
    }
  }

  .semesters .next {
    animation: blink 1s steps(1) infinite;
  }

  .rec::before {
    animation: rec 1s steps(1) infinite;
  }

  @keyframes rec {
    50% {
      opacity: 0.2;
    }
  }

  .logo {
    animation: boot 0.9s steps(9) both;
  }

  @keyframes boot {
    from {
      clip-path: inset(0 0 100% 0);
      translate: 0 calc(var(--px) * 6);
    }
  }

  @supports (animation-timeline: view()) {
    /* Title: Leander lets go of the hook and jumps towards you. */
    .title .plate img {
      animation: plate-drift linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }

    .title .figure img {
      animation: hero-jump linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }

    .title-copy {
      animation: copy-away steps(8) both;
      animation-timeline: scroll(root);
      animation-range: 0 70vh;
    }

    @keyframes plate-drift {
      to {
        translate: 0 12%;
        scale: 1.04;
      }
    }

    @keyframes hero-jump {
      to {
        translate: var(--jump);
        scale: var(--jump-scale);
      }
    }

    @keyframes copy-away {
      to {
        translate: 0 -40%;
        opacity: 0;
      }
    }

    /* Levels: the plate lags behind the page, the figure runs ahead of it.
       Both share one scale and only move vertically, so they meet exactly
       when the scene is centred and a figure never leaves what it stands on.
       The scale hides the edges: 4% of travel needs 5% of overflow. */
    .stage {
      view-timeline: --stage block;
    }

    .stage .layer img {
      scale: 1.1;
      animation: parallax-plate linear both;
      animation-timeline: --stage;
    }

    .stage .figure img {
      animation-name: parallax-figure;
    }

    @keyframes parallax-plate {
      from { translate: 0 -4%; }
      to { translate: 0 4%; }
    }

    @keyframes parallax-figure {
      from { translate: 0 4%; }
      to { translate: 0 -4%; }
    }

    /* Zoom levels: descend into the scene until it is centred. */
    .zoom .plate img {
      animation: parallax-plate linear both, descend linear both;
      animation-timeline: --stage;
      animation-range: normal, entry 0% cover 50%;
    }

    @keyframes descend {
      from { scale: 1.3; }
    }

    .box {
      animation: box-in steps(6) both;
      animation-timeline: --stage;
      animation-range: entry 35% cover 45%;
    }

    @keyframes box-in {
      from {
        translate: -2rem 3rem;
        clip-path: inset(0 55% 0 0);
      }
    }

    .hint {
      animation: hint-out linear both;
      animation-timeline: --stage;
      animation-range: cover 45% cover 60%;
    }

    @keyframes hint-out {
      to {
        opacity: 0;
        translate: 0 -1rem;
      }
    }

    .xp span,
    .bar {
      animation: fill steps(12) both;
      animation-timeline: view();
      animation-range: entry 60% cover 40%;
    }

    @keyframes fill {
      from {
        scale: 0.02 1;
      }
    }

    .tree li {
      animation: light linear both;
      animation-timeline: view();
      animation-range: entry 90% cover 35%;
    }

    @keyframes light {
      from {
        color: rgb(255 255 255 / 0.55);
      }
    }

    .tree li::before {
      animation: node steps(2) both;
      animation-timeline: view();
      animation-range: entry 90% cover 35%;
    }

    @keyframes node {
      from {
        background: var(--night);
      }
    }

    .toast {
      animation: toast-in steps(5) both;
      animation-timeline: view();
      animation-range: entry 10% entry 90%;
    }

    @keyframes toast-in {
      from {
        translate: 2.5rem 0;
        clip-path: inset(0 0 0 60%);
      }
    }

    /* The world map pans in like a camera over the overworld. */
    @media (min-width: 761px) {
      .world-map img {
        animation: world-pan linear both;
        animation-timeline: view();
        animation-range: entry 0% cover 60%;
      }
    }

    @keyframes world-pan {
      from {
        scale: 1.25;
        translate: 6% 4%;
      }
    }

    .legend li {
      animation: pin steps(3) both;
      animation-timeline: view();
      animation-range: entry 40% cover 20%;
    }

    @keyframes pin {
      from {
        scale: 0.2;
      }
    }

    /* Cover titles land differently per level: stamp, tilt, drop or slam. */
    .cover {
      animation: cover-stamp steps(6) both;
      animation-timeline: view();
      animation-range: entry 30% cover 40%;
    }

    .cover.tilt {
      animation-name: cover-tilt;
    }

    .cover.drop {
      animation-name: cover-drop;
    }

    .cover.slam {
      animation-name: cover-slam;
      animation-timing-function: steps(4);
    }

    .continue .cover {
      animation-name: cover-stamp;
    }

    @keyframes cover-stamp {
      from {
        scale: 1.3;
        clip-path: inset(0 50% 0 50%);
      }
    }

    @keyframes cover-tilt {
      from {
        rotate: -14deg;
        translate: -30% 0;
      }
    }

    @keyframes cover-drop {
      from {
        translate: 0 -60vh;
      }
    }

    @keyframes cover-slam {
      from {
        scale: 2.4;
        clip-path: inset(0 0 100% 0);
      }
    }

    .semesters li {
      animation: pin steps(3) both;
      animation-timeline: view();
      animation-range: entry 60% cover 35%;
    }

    /* Counters count up while the board scrolls into view. */
    .n.c15,
    .n.c88,
    .n.c31,
    .n.c19 {
      font-size: 0;
      animation: count linear both;
      animation-timeline: view();
      animation-range: entry 40% cover 50%;
      counter-reset: n var(--n);
    }

    .n.c15::after,
    .n.c88::after,
    .n.c31::after,
    .n.c19::after {
      content: counter(n) / "";
      font-size: 1.6rem;
    }

    .n.c15::before {
      content: "rund " / "";
      font-size: 1.6rem;
    }

    .n.c15 { --to: 15; }
    .n.c88 { --to: 88; }
    .n.c31 { --to: 31; }
    .n.c19 { --to: 19; }

    @keyframes count {
      to {
        --n: var(--to);
      }
    }

    .dialog blockquote span {
      animation: type steps(10) both;
      animation-timeline: view();
    }

    .dialog blockquote span:nth-child(1) { animation-range: entry 60% cover 38%; }
    .dialog blockquote span:nth-child(2) { animation-range: cover 38% cover 46%; }
    .dialog blockquote span:nth-child(3) { animation-range: cover 46% cover 54%; }

    @keyframes type {
      from {
        color: transparent;
      }
    }

    /* Continue? 9 … 0, reaching zero when the footer arrives. */
    .count::before {
      content: counter(c) / "";
    }

    .count {
      animation: countdown steps(10) both;
      animation-timeline: scroll(root);
      animation-range: calc(100% - 100vh) 100%;
      counter-reset: c var(--c);
    }

    @keyframes countdown {
      from {
        --c: 9;
      }
      to {
        --c: 0;
      }
    }
  }
}
