@font-face {
  font-family: 'Montserrat Alternates';
  src: url('/fonts/montserrat-alternates-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat Alternates';
  src: url('/fonts/montserrat-alternates-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat Alternates';
  src: url('/fonts/montserrat-alternates-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat Alternates';
  src: url('/fonts/montserrat-alternates-bolditalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

:root {
  --mainWidth: 900px;
  --mainMaxWidth: 60%;
  --sideWidth: calc((100% - min(var(--mainWidth), var(--mainMaxWidth))) / 2);

  font-size: 17px;
  line-height: 1.5;
  font-family:
    'Montserrat Alternates',
    Arial,
    sans-serif;
  color: white;
  background-color: black;
}

a { color: inherit }

html, body, main {
  min-height: 100vh;
  margin: 0;
}

/*
 * Background layers
 *
 * Back to front: `.sky` (stars, then the chronosphere and its rays) and
 * `.ground` (the arch and partner logos), which ends the page. The layers
 * are drawn at their natural pixel size, multiplied by `--layerScale`, and
 * centered horizontally.
 *
 * By default nothing moves: the sky scrolls with the page and the chronosphere
 * is locked in its final position behind the arch. This is what visitors who
 * prefer reduced motion (or have no JavaScript) see.
 *
 * Otherwise a script on the page adds the `parallax` class to the root
 * element and sets `--scrollProgress` (0 at the top of the page, 1 at the
 * bottom) and `--scrollY` (pixels). The sky is then fixed to the viewport and
 * its layers move with the scroll position, ending in the same composition.
 */

:root {
  --layerScale: 1;
  --scrollProgress: 1;
  --scrollY: 0;

  /* Natural sizes of the layer images. */
  --starsSize: 1024px;
  --chronoWidth: 3213px;
  --chronoHeight: 2064px;
  --groundWidth: 2408px;
  --groundHeight: 1236px;

  /* Where the center of the sphere is within the chronosphere image. The
     layer grows around this point. */
  --chronoCenterX: 1617px;
  --chronoCenterY: 1063px;

  /* The chronosphere layer starts small with only its top edge above the fold,
     then grows to full size as it moves into place behind the arch. */
  --chronoStartScale: 0.3;
  --chronoStartVisible: 0.4; /* Fraction of the layer above the fold at first. */

  /* Distance from the bottom of the viewport up to the top of the full-size
     layer once it has lined up with the arch. */
  --chronoRiseEnd: 1760px;

  /* The same journey measured to the center of the sphere: how far above the
     bottom of the viewport it starts and ends. */
  --chronoCenterRiseStart: calc(
    var(--chronoStartScale) *
    (var(--chronoHeight) * var(--chronoStartVisible) - var(--chronoCenterY))
  );
  --chronoCenterRiseEnd: calc(var(--chronoRiseEnd) - var(--chronoCenterY));

  /* How fast the stars scroll, relative to the page. */
  --starsSpeed: 0.25;

  /* Height of anything below the arch image (the stacked partner logos on
     narrow screens), which the chronosphere has to clear. */
  --belowGround: 0px;
}

body {
  position: relative;
}

.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;

  background-image: url('/images/enter-the-chronosphere/etc-layer-background-tile.webp');
  background-repeat: repeat;
  background-size: calc(var(--starsSize) * var(--layerScale));
  background-position: 50% 0;
}

.parallax .sky {
  position: fixed;
  background-position: 50% calc(var(--scrollY) * var(--starsSpeed) * -1px);
}

.sky-chrono {
  position: absolute;
  left: 50%;
  bottom: calc(
    (var(--chronoRiseEnd) - var(--chronoHeight)) * var(--layerScale) +
    var(--belowGround)
  );
  width: calc(var(--chronoWidth) * var(--layerScale));
  max-width: none;
  height: auto;
  transform: translateX(-50%);
}

.parallax .sky-chrono {
  top: 0;
  bottom: auto;
  transform-origin:
    calc(var(--chronoCenterX) * var(--layerScale))
    calc(var(--chronoCenterY) * var(--layerScale));
  transform:
    translate(
      -50%,
      calc(
        100vh -
        var(--belowGround) * var(--scrollProgress) -
        (
          var(--chronoCenterY) +
          var(--chronoCenterRiseStart) +
          (var(--chronoCenterRiseEnd) - var(--chronoCenterRiseStart)) *
            var(--scrollProgress)
        ) * var(--layerScale)
      )
    )
    scale(
      calc(
        var(--chronoStartScale) +
        (1 - var(--chronoStartScale)) * var(--scrollProgress)
      )
    );
  will-change: transform;
}

.ground {
  position: relative;
  z-index: 0;
  height: calc(var(--groundHeight) * var(--layerScale));
  overflow: hidden;
}

.ground-image {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: calc(var(--groundWidth) * var(--layerScale));
  max-width: none;
  height: auto;
  transform: translateX(-50%);
  pointer-events: none;
}

/*
 * Partner logos, drawn in black over the sand. On wide screens they sit in a
 * row along the bottom of the arch image, laid out as they were designed: a
 * 1919px wide row with 35px either side of each logo, scaled down to fit.
 * On narrow screens they stack below the arch on more sand.
 */
.partnerLogos {
  --rowWidth: 1919;
  --logoSpace: 35;

  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(100%, 1919px);
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  justify-content: center;
  transform: translateX(-50%);
}

.partnerLogos > li {
  flex: none;
  width: calc(var(--logoWidth) / var(--rowWidth) * 100%);
  margin: 0 calc(var(--logoSpace) / var(--rowWidth) * 100%);
}

.partnerLogos a {
  display: block;
}

.partnerLogos img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 1024px) {
  :root {
    --layerScale: 0.5;
  }
}

@media (max-width: 600px) {
  :root {
    /* The logo images include some space above and below each logo. */
    --logoHeight: 72px;
    --logoGap: 0px;
    /* Five logos, four gaps, plus padding below. */
    --belowGround: calc(5 * var(--logoHeight) + 4 * var(--logoGap) + 1.5em);
  }

  .ground {
    height: auto;
  }

  .ground-image {
    position: relative;
    display: block;
    /* Overlap the sand below to hide any rounding seam. */
    margin-bottom: -1px;
  }

  .partnerLogos {
    position: static;
    width: auto;
    flex-direction: column;
    align-items: center;
    gap: var(--logoGap);
    height: var(--belowGround);
    padding: 0 0 1.5em;
    transform: none;
    background-color: #eadebd; /* The sand in the arch image. */
  }

  .partnerLogos > li {
    width: auto;
    margin: 0;
  }

  .partnerLogos img {
    width: auto;
    height: var(--logoHeight);
  }
}

h1 {
  margin: 0;
  padding: 1em 0 0.5em 0;
}

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

h2 {
  font-size: 1.2em;
  font-weight: bold;
}

p {
  /* Margins, so the space between neighbouring blocks collapses to 2em. */
  margin: 2em 0;
}

.availability {
  margin-top: 0;
}

.content {
  /* Size */
  height: 100%;

  /* Position */
  position: relative;
  z-index: 1;
  margin: auto;
  padding-bottom: var(--panelFade);

  /* Appearance: a translucent panel that fades out below the footer. */
  --panelColor: rgba(0, 0, 0, 0.8);
  --panelFade: 6em;
  background-image: linear-gradient(
    to bottom,
    var(--panelColor) calc(100% - var(--panelFade)),
    transparent
  );

  /* Text */
  text-align: center;
}

main {
  padding-top: 0;
}

header, main, footer {
  padding-left: 10%;
  padding-right: 10%;
}

footer {
  padding-bottom: 1em;
  margin-top: 5em;
}

footer a {
  color: inherit;
}

.storeList {
  padding: 0;
}

.storeList > li {
  list-style: none;
}

.storeList > li > a {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.storeList > li > a:hover {
  text-decoration: underline;
}

.storeList > li > a > i {
  margin-left: 0.4em;
}

.homeLink {
  text-decoration: none;
  white-space: nowrap;
}

.homeLink:hover {
  text-decoration: underline;
}

.homeLink > i {
  margin-right: 0.4em;
}

@media (min-width: 1024px) {
  .content {
    width: var(--mainWidth);
    max-width: var(--mainMaxWidth);
    margin: auto;
  }

  .storeList {
    /* Position */
    position: fixed;
    top: 0;
    right: 0;
    max-width: var(--sideWidth);

    /* Appearance */
    text-align: right;
    margin-right: 30px;
    line-height: 1.8em;
  }

  .homeLink {
    position: fixed;
    top: 1em;
    left: 30px;
    line-height: 1.8em;
  }
}

@media (max-width: 1024px) {
  .storeList > li > a > .storeList-label {
    display: none;
  }

  .storeList > li {
    display: inline-block;
    padding: 0 0.4em;
  }
}

.responsiveYoutube {
    overflow: hidden;
    padding-bottom: 56.25%;
    position: relative;
    height: 0;
}

.responsiveYoutube iframe {
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    position: absolute;
}

/*
 * Changelog page: the same star background and center column, without the
 * chronosphere, arch or parallax. The page scrolls normally, so the browser's
 * scrollbar is shown; `color-scheme` makes it dark to suit the background.
 */

.changelog {
  color-scheme: dark;
  overflow-y: scroll;
}

.etcLogo {
  display: block;
  padding: 1em 0 0;
}

.etcLogo img {
  display: block;
  width: 100%;
  height: auto;
}

.changelog h1 a {
  text-decoration: none;
}

.changelog h1 a:hover {
  text-decoration: underline;
}

.changelog-entries {
  text-align: left;
}

.changelog-entries h2 {
  margin: 2em 0 0;
}

.changelog-entries p {
  margin: 0.5em 0;
}

.changelog-entries li {
  margin-bottom: 0.4em;
}
