@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --pitch-green: #006400;
  --pitch-line: #3cb371;
  --blue-player: #00bfff;
  --pink-player: #ff1493;
  --blue-goalkeeper: #4b0082;
  --pink-goalkeeper: #dc143c;
  --ball: #ffffff;
  --text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--pitch-green);
  font-family: "IBM Plex Mono", monospace;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.pitch-wrapper {
  position: relative;
  width: min(1000px, 100vw, 62.5vh);
  aspect-ratio: 5 / 8;
  overflow: hidden;
}

.pitch-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity 1.2s ease;
}

.pitch-wrapper.is-writing img {
  opacity: 0;
}

.pitch-border {
  position: absolute;
  z-index: 2;
  left: 30%;
  top: 28.35375%;
  width: 40%;
  height: 43.2925%;
  border: 2px solid color-mix(in srgb, var(--pitch-line) 25%, transparent);
  pointer-events: none;
}

.football-link,
.writing-link {
  position: absolute;
  z-index: 4;
  top: calc(71.64625% + 30px);
  left: 50%;
  color: var(--text);
  font: 400 14px/1 "IBM Plex Mono", monospace;
  text-decoration: none;
  transform: translateX(-50%);
  transition: opacity 500ms ease;
}

.football-link:hover,
.football-link:focus-visible,
.writing-link:hover,
.writing-link:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--text);
  text-underline-offset: 3px;
}

.football-link:focus-visible,
.writing-link:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 4px;
}

.pitch-wrapper.is-writing .football-link {
  opacity: 0;
  pointer-events: none;
}

.writing-link {
  opacity: 0;
  pointer-events: none;
}

.pitch-wrapper.is-writing .writing-link {
  opacity: 1;
  pointer-events: auto;
}

.wrapper-label {
  position: absolute;
  z-index: 3;
  left: 20px;
  margin: 0;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  line-height: 1;
}

.wrapper-label--top {
  position: fixed;
  top: 20px;
  font-size: 14px;
}

.wrapper-label--bottom {
  position: fixed;
  bottom: 20px;
  font-size: 12px;
}

.about-link {
  position: fixed;
  z-index: 5;
  top: 12px;
  right: 12px;
  display: flex;
  width: 46px;
  height: 34px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding: 8px;
}

.about-link span {
  display: block;
  height: 1px;
  background: var(--text);
  transition: width 180ms ease;
}

.about-link span:first-child {
  width: 20px;
}

.about-link span:last-child {
  width: 14px;
}

.about-link:hover span:last-child,
.about-link:focus-visible span:last-child {
  width: 20px;
}

.about-link:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.about-close {
  position: fixed;
  z-index: 5;
  top: 12px;
  right: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--text);
  font: 400 20px/1 "IBM Plex Mono", monospace;
  text-decoration: none;
  transition: opacity 180ms ease;
}

.about-close:hover,
.about-close:focus-visible {
  opacity: 0.6;
}

.about-close:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.players {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 900ms ease;
}

.pitch-wrapper.is-writing .players,
.pitch-wrapper.is-writing .ball {
  opacity: 0;
}

.player {
  position: absolute;
  width: 2.5%;
  aspect-ratio: 1;
  border-radius: 50%;
  will-change: transform;
}

.player--blue {
  background: var(--blue-player);
}

.player--pink {
  background: var(--pink-player);
}

.player--blue.player--goalkeeper {
  background: var(--blue-goalkeeper);
}

.player--pink.player--goalkeeper {
  background: var(--pink-goalkeeper);
}

.ball {
  position: absolute;
  z-index: 2;
  width: 1.8%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ball);
  pointer-events: none;
  will-change: left, top, transform;
  transition: opacity 900ms ease;
}

.writing-page {
  position: absolute;
  z-index: 1;
  left: 30%;
  top: 28.35375%;
  width: 40%;
  height: 43.2925%;
  padding: 5% 6%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease 700ms;
}

.pitch-wrapper.is-writing .writing-page {
  opacity: 1;
}

.writing-lines {
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 18%;
}

.writing-paragraph {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 12px);
}

.writing-title {
  width: var(--title-width);
  height: 20px;
  flex: 0 0 20px;
  margin-bottom: clamp(4px, 0.7vh, 7px);
  background: var(--text);
  opacity: 0.84;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 700ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--in-delay);
}

.writing-line {
  width: var(--line-width);
  height: 2px;
  flex: 0 0 2px;
  border-radius: 999px;
  background: var(--text);
  opacity: 0.72;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 700ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--out-delay);
}

.pitch-wrapper.is-writing .writing-line,
.pitch-wrapper.is-writing .writing-title {
  clip-path: inset(0 0 0 0);
  transition-delay: var(--in-delay);
}

.pitch-wrapper.is-writing.is-writing-reset .writing-line,
.pitch-wrapper.is-writing.is-writing-reset .writing-title {
  clip-path: inset(0 0 0 100%);
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: var(--out-delay);
}

.pitch-wrapper.is-writing.is-writing-prep .writing-line,
.pitch-wrapper.is-writing.is-writing-prep .writing-title {
  clip-path: inset(0 100% 0 0);
  transition: none;
}

.pitch-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 28px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 20px/40px "IBM Plex Mono", monospace;
  text-align: center;
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity 200ms ease;
}

.pitch-nav:hover:not(:disabled),
.pitch-nav:focus-visible {
  opacity: 0.6;
}

.pitch-nav:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.pitch-nav:disabled {
  cursor: default;
  opacity: 0.22;
}

.pitch-nav--previous {
  left: calc(30% - 68px);
}

.pitch-nav--next {
  right: calc(30% - 68px);
}

@media (prefers-reduced-motion: reduce) {
  .player,
  .ball {
    will-change: auto;
  }

  .pitch-wrapper img,
  .players,
  .ball,
  .writing-page,
  .writing-line,
  .writing-title {
    transition-duration: 1ms;
    transition-delay: 0ms;
  }
}

@media (max-width: 599px) {
  .writing-title {
    height: 10px;
    flex-basis: 10px;
    margin-bottom: 3px;
  }

  .writing-paragraph .writing-line:nth-child(n + 9) {
    display: none;
  }

  .writing-paragraph {
    gap: clamp(5px, 1vh, 8px);
  }

  .writing-lines {
    gap: 16%;
  }
}

.about-page {
  display: block;
  overflow-y: auto;
  color: var(--text);
}

.about-page .wrapper-label--top {
  color: var(--text);
  text-decoration: none;
}

.about-page .wrapper-label--top:hover,
.about-page .wrapper-label--top:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-content {
  width: min(620px, calc(100% - 48px));
  margin: 0 auto;
  padding: clamp(120px, 18vh, 190px) 0 100px;
  font-size: 14px;
  line-height: 1.8;
}

.about-content p {
  margin: 0 0 1.8em;
}

.about-content p:last-child {
  margin-bottom: 0;
}

@media (max-width: 599px) {
  .about-content {
    width: calc(100% - 40px);
    padding-top: 110px;
    padding-bottom: 90px;
    font-size: 13px;
    line-height: 1.75;
  }
}
