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

:root {
  font-size: 16px;
  --color-text: #fff;
  --color-bg: #000;
  --color-link: #fff;
  --color-link-hover: #fff;
}

body {
  margin: 0;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-family: 'anonymous-pro', monospace;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

/* Page Loader */
.js .loading::before,
.js .loading::after {
  content: '';
  position: fixed;
  z-index: 1000;
}

.js .loading::before {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
}

.js .loading::after {
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  opacity: 0.4;
  background: var(--color-link);
  animation: loaderAnim 0.7s linear infinite alternate forwards;
}

@keyframes loaderAnim {
  to {
    opacity: 1;
    transform: scale3d(0.5, 0.5, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .loading::after {
    animation: none;
  }
}

a {
  text-decoration: none;
  color: var(--color-link);
  outline: none;
  cursor: pointer;
}

a:hover {
  color: var(--color-link-hover);
  outline: none;
}

/* Better focus styles from https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible */
a:focus {
  /* Provide a fallback style for browsers
	 that don't support :focus-visible */
  outline: none;
  background: lightgrey;
}

a:focus:not(:focus-visible) {
  /* Remove the focus indicator on mouse-focus for browsers
	 that do support :focus-visible */
  background: transparent;
}

a:focus-visible {
  /* Draw a very noticeable focus style for
	 keyboard-focus on browsers that do support
	 :focus-visible */
  outline: 2px solid red;
  background: transparent;
}

.frame {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100svh;
  color: var(--color-text);
  padding: 2rem;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto auto auto auto 1fr auto;
  grid-template-areas: 'title' 'description' 'links' 'demos' 'sponsor' 'tags' 'nav';
  justify-content: start;
  align-content: start;
  align-items: start;
  z-index: 100;
  pointer-events: none;
  grid-gap: 1rem;
}

body #cdawrap {
  grid-area: sponsor;
  align-self: start;
  justify-self: start;
}

.frame a,
.frame button {
  pointer-events: auto;
}

.frame__title {
  grid-area: title;
  font-size: inherit;
  margin: 0;
  font-weight: 400;
}

.frame strong {
  font-weight: 700;
}

/* What the current variation does, in a line under the title */
.frame__description {
  grid-area: description;
  margin: 0;
  max-width: 34ch;
  opacity: 0.7;
}

.frame__links,
.frame__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.frame__links {
  grid-area: links;
}

.frame__tags {
  grid-area: tags;
  align-self: end;
}

.frame__demos {
  grid-area: demos;
  display: grid;
  grid-template-columns: repeat(8, auto);
  column-gap: 1rem;
  row-gap: 0.5rem;
}

.frame__demos span {
  grid-column: 1 / span 8;
}

a.frame__demo {
  font-weight: 400;
  font-size: 1rem;
  text-decoration: none;
  opacity: 0.5;
  font-family: 'anonymous-pro', monospace;
}

a.frame__demo--current {
  font-weight: 700;
  opacity: 1;
  color: var(--color-link-hover);
}

.slides {
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 100%;
  grid-template-columns: 100%;
  place-items: center;
}

.slide {
  width: 100%;
  height: 100%;
  grid-area: 1 / 1 / -1 / -1;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  will-change: transform, opacity;
}

.slide--current {
  pointer-events: auto;
  opacity: 1;
}

.deco {
  width: 100%;
  height: 100%;
  grid-area: 1 / 1 / -1 / -1;
  pointer-events: none;
  position: relative;
  opacity: 0;
  background: #8c718e;
  will-change: transform, opacity;
}

.deco--1 {
  background: #d4503e;
}

.deco--2 {
  background: #1c1a1a;
}

.deco--3 {
  background: #4e4141;
}

.deco--4 {
  background: #000;
}

.deco--5 {
  background: #060b17;
}

.deco--6 {
  background: #34365c;
}

.deco--7 {
  background: #9f6794;
}

.slide__img {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  will-change: transform, opacity, filter;
}

/* Pieces of a slide's image, for the variations that cut it up (26, 27, 28, 30) */
.slide__piece {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* WebGL canvas, drawn over the slides only while a transition runs */
.slides__canvas {
  width: 100%;
  height: 100%;
  grid-area: 1 / 1 / -1 / -1;
  position: relative;
  pointer-events: none;
  visibility: hidden;
}

.slides__canvas--visible {
  visibility: visible;
}

.demo-2 .slide__img {
  width: 120%;
  height: 120%;
}

.slides-nav {
  grid-area: nav;
  display: flex;
  gap: 0.5rem;
  align-self: end;
  align-items: center;
}

.slides-nav::before {
  content: 'scroll / drag';
  margin-right: 2rem;
}

.slides-nav__item {
  border: 0;
  background: #fff;
  color: #000;
  width: 60px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s;
}

.slides-nav__item:hover {
  background-color: #ccc;
}

.slides-nav__item:focus-visible {
  outline: 2px solid red;
  outline-offset: 2px;
}

@media screen and (min-width: 53em) {
  .frame {
    height: 100vh;
    height: 100svh;
    grid-gap: 2rem;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      'title links ... demos'
      'description description ... demos'
      'sponsor sponsor sponsor ...'
      'tags tags tags nav';
  }

  .frame__links {
    gap: 2rem;
  }

  .frame__tags {
    align-self: center;
  }

  .frame__demos {
    justify-self: end;
    justify-content: end;
  }

  .frame__demos span,
  a.frame__demo {
    text-align: right;
  }

  .slides-nav {
    justify-self: end;
  }

  body #cdawrap {
    align-self: end;
    justify-self: start;
  }
}
