:root {
  --s: 0.5;
  --hover: #a3a3a3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
}

body {
  font-family: 'Press Start 2P', monospace;
  -webkit-font-smoothing: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* 1920x1080 logical canvas, scaled by JS to cover the viewport. */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  margin: -540px 0 0 -960px;
  transform: scale(var(--s));
  background: #000;
}

img {
  image-rendering: pixelated;
  -webkit-user-drag: none;
}

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
}

.scene.is-active {
  visibility: visible;
}

.layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  max-width: none;
  pointer-events: none;
}

.cam {
  position: absolute;
  inset: 0;
}

#scene-music .cam {
  overflow: hidden;
}

.music-slot {
  transform-origin: 0 0;
}

.cloud,
.flying-dino,
.music-object,
.door,
.is-moving {
  will-change: transform;
}

/* ---------- Text ---------- */

.txt {
  margin: 0;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  white-space: nowrap;
}

.text-block {
  position: absolute;
  left: 960px;
  width: max-content;
  transform: translateX(-50%);
  top: calc(var(--cy) * 1px - 500px);
  height: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--fs) * var(--fit, 1));
  pointer-events: none;
}

.text-block > * {
  pointer-events: auto;
}

.btn {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  line-height: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn.is-static {
  cursor: default;
}

@media (hover: hover) {
  .btn:not(.is-static):hover {
    color: var(--hover);
  }
}

.btn.is-pressed {
  color: var(--hover);
  transform: translateY(0.12em);
}

.btn:focus {
  outline: none;
}

.btn:focus-visible {
  color: var(--hover);
}

.u {
  text-decoration: underline;
  text-decoration-thickness: 0.125em;
  text-underline-offset: 0.3em;
}

/* Title */
#scene-title {
  cursor: pointer;
}

.press-start {
  opacity: 0;
}

.press-start.is-shown {
  opacity: 1;
}

.dino-blink {
  visibility: hidden;
}

#scene-title.is-blinking .dino-blink {
  visibility: visible;
}

#scene-title.is-blinking .dino-standing:not(.dino-blink) {
  visibility: hidden;
}

/* Main menu / featured */
#menu-list,
#music-list {
  --fs: 38px;
  line-height: 1.7105;
}

#featured-list {
  --fs: 35px;
  line-height: 1.857;
}

.menu-group.is-off {
  visibility: hidden;
}

.menu-group.is-off > * {
  pointer-events: none;
}

/* Events */
.events-box {
  position: absolute;
  top: 0;
  left: calc(960px - var(--ew, 684px) / 2);
  width: var(--ew, 684px);
  height: 1080px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(19.5px * var(--fit, 1));
  line-height: 1.9;
  text-align: center;
}

.event {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.event + .event {
  margin-top: 1.9em;
}

/* Letterbox colour shown above/below the train while the camera is zoomed out. */
#scene-events {
  background: #0a0a0a;
}

#scene-events .cam {
  transform-origin: 960px 540px;
  will-change: transform;
}

/* Station wall behind the train, matching the tiles in the stairs artwork. */
.metro-wall {
  background:
    linear-gradient(90deg, #7a82a2 0 6px, transparent 6px) 0 0 / 73px 100%,
    linear-gradient(#7a82a2 0 6px, transparent 6px) 0 0 / 100% 69px,
    linear-gradient(transparent 0 138px, #ae486b 138px 207px) 0 0 / 100% 207px,
    #021242;
}

/* Vertically motion-blurred tile of the wall pattern above, faded in during the stairs travel. */
.metro-wall-blur {
  background: url(../assets/img/fx/blur-metro-wall.png) 0 0 / 73px 207px;
  opacity: 0;
}

.metro-train {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  will-change: transform;
}

/* Bellows between two carriages. */
.metro-gangway {
  position: absolute;
  top: 120px;
  width: 40px;
  height: 900px;
  background: repeating-linear-gradient(90deg, #18181e 0 7px, #38383f 7px 10px);
  border-top: 6px solid #080808;
  border-bottom: 6px solid #080808;
}

/* Rounded ends of the train, painted in the same bands as the carriage body. */
.metro-cap {
  position: absolute;
  top: 28px;
  width: 64px;
  height: 1024px;
  background: linear-gradient(
    #f8f0e8 0 65px,
    #c0b8b8 65px 102px,
    #080808 102px 128px,
    #303038 128px 152px,
    #080808 152px 584px,
    #303038 584px 600px,
    #080808 600px 630px,
    #f8f0e8 630px 655px,
    #b8b0b0 655px 957px,
    #808088 957px 1000px,
    #303040 1000px
  );
  border: 6px solid #080808;
}

.metro-cap-front {
  left: -3984px;
  border-right: 0;
  border-radius: 56px 0 0 56px;
}

.metro-cap-rear {
  left: 5840px;
  border-left: 0;
  border-radius: 0 56px 56px 0;
}

/* The artwork has a stray light pixel row at the very top and bottom. */
.metro-bg,
.metro-car {
  clip-path: inset(1px 0);
}

.door-strip-left {
  clip-path: inset(1px 1350px 1px 226px);
}

.door-strip-right {
  clip-path: inset(1px 223px 1px 1355px);
}

.door-left {
  transform: translateX(344px);
}

.door-right {
  transform: translateX(-341px);
}

/* About */
.about-box {
  position: absolute;
  top: 58px;
  left: var(--ax, 172px);
  width: var(--aw, 1576px);
  font-size: calc(20.2px * var(--fit, 1));
  line-height: 1.83;
}

.about-text p {
  margin: 0 0 1.83em;
  color: #fff;
  text-align: justify;
  white-space: normal;
}

.about-text p.cv,
.about-box.is-narrow .about-text p {
  text-align: left;
}

.about-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.about-indicator {
  font-size: 0.7em;
}

/* Pixel-framed button with notched corners */
.about-control {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin-left: 0.2em;
  padding: 0.55em 0.8em 0.5em;
  line-height: 1;
  box-shadow:
    0 -0.2em 0 0 currentColor,
    0 0.2em 0 0 currentColor,
    -0.2em 0 0 0 currentColor,
    0.2em 0 0 0 currentColor,
    0.2em 0.4em 0 0 rgba(0, 0, 0, 0.45);
}

.about-control::after,
.about-control.is-back::before {
  content: '';
  width: 0.5em;
  height: 0.8em;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  animation: about-nudge 0.8s steps(2, jump-none) infinite alternate;
}

.about-control.is-back::after {
  display: none;
}

.about-control.is-back::before {
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  animation-name: about-nudge-back;
}

@keyframes about-nudge {
  to { transform: translateX(0.2em); }
}

@keyframes about-nudge-back {
  to { transform: translateX(-0.2em); }
}

@media (prefers-reduced-motion: reduce) {
  .about-control::after,
  .about-control::before {
    animation: none;
  }
}

/* Contact */
.contact-block {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.contact-row {
  position: absolute;
  left: 0;
  width: 1920px;
  top: calc(var(--y) * 1px);
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-row .txt {
  font-size: calc(var(--fs) * 1px * var(--fit, 1));
  line-height: 1.6;
  pointer-events: auto;
  text-shadow: 0 0 0.3em #122958, 0 0 0.6em #122958;
}

@keyframes twinkle-a {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.6; }
  60% { opacity: 0.9; }
}

@keyframes twinkle-b {
  0%, 100% { opacity: 0.95; }
  30% { opacity: 1; }
  70% { opacity: 0.55; }
}

.stars-a {
  -webkit-mask-image: repeating-conic-gradient(#000 0 25%, transparent 0 50%);
  mask-image: repeating-conic-gradient(#000 0 25%, transparent 0 50%);
  -webkit-mask-size: 320px 320px;
  mask-size: 320px 320px;
  animation: twinkle-a 4.2s ease-in-out infinite;
}

.stars-b {
  -webkit-mask-image: repeating-conic-gradient(transparent 0 25%, #000 0 50%);
  mask-image: repeating-conic-gradient(transparent 0 25%, #000 0 50%);
  -webkit-mask-size: 320px 320px;
  mask-size: 320px 320px;
  animation: twinkle-b 5.7s ease-in-out infinite;
}

/* ---------- Transition helpers ---------- */

.fx {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  display: none;
  pointer-events: none;
}

#fx-white {
  height: 1080px;
  background: #fff;
  z-index: 20;
}

#fx-band {
  height: 1080px;
}

#fx-stairs img {
  display: block;
  width: 1920px;
  height: 1080px;
}

/* Stored squashed vertically; stretched back with smooth filtering since it is a blur anyway. */
.fx-blur {
  image-rendering: auto;
  z-index: 10;
}

#fx-blur-title {
  height: 3240px;
}

#fx-blur-stairs {
  height: 5400px;
}

/* ---------- Dino head (home) ---------- */

#home {
  position: absolute;
  z-index: 30;
  left: calc(env(safe-area-inset-left, 0px) + 29px * var(--s));
  top: calc(env(safe-area-inset-top, 0px) + 29px * var(--s));
  width: calc(117px * var(--s));
  height: calc(109px * var(--s));
  min-width: 44px;
  min-height: 41px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#home[hidden] {
  display: none;
}

#home img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#home .head-closed,
#home.is-closed .head-open {
  visibility: hidden;
}

#home.is-closed .head-closed {
  visibility: visible;
}

#home.is-pressed {
  filter: brightness(0.6);
}

#home:focus {
  outline: none;
}

#home:focus-visible {
  filter: brightness(0.8);
}

/* ---------- Footer home button (detail pages) ---------- */

#page-footer {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 32px * var(--s));
  display: flex;
  justify-content: center;
  pointer-events: none;
}

#page-footer[hidden] {
  display: none;
}

#page-footer .btn {
  pointer-events: auto;
  font-size: max(10px, calc(26px * var(--s)));
  line-height: 1.6;
  text-shadow: 0.125em 0.125em 0 #000;
}

@media (prefers-reduced-motion: reduce) {
  .stars-a,
  .stars-b {
    animation: none;
  }
}
