@import url("/css/game-frame.css");

@font-face {
  font-family: Crimson;
  src: url("/fonts/CrimsonPro-VariableFont_wght.ttf");
  font-style: normal;
}

@font-face {
  font-family: Crimson;
  src: url("/fonts/CrimsonPro-Italic-VariableFont_wght.ttf");
  font-style: italic;
}

@font-face {
  font-family: Young;
  src: url("/fonts/YoungSerif-Regular.ttf");
  font-weight: bold;
  font-style: normal;
}

:root {
  --bg-color: #000;
  --fg-color: #fefefe;
  --light-purple: #beaad1;
  --light-blue: #bfe1f7;
  --ui-blue: #486483;
  --ui-deep-blue: #1e2f47;
}

/* Focused resets */

button,
select,
input {
  appearance: none;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--light-blue);
  text-decoration-color: color-mix(in srgb, var(--light-blue) 30%, transparent);
  transition: text-decoration 0.3s ease-out;

  &:hover {
    text-decoration-color: var(--light-blue) 100%;
  }
}

/* Main layout properties */

html {
  /* Game fonts & colors */
  font-family: Crimson, Georgia, serif;
  color: var(--fg-color);
  background-color: var(--bg-color);
}

body {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: Young, Georgia, serif;
  line-height: 1.1;
}

.home h3 {
  font-size: 1.5rem;
  text-transform: uppercase;
}

/* Utilities */

.container {
  padding: 0 4rem;
  max-width: 56rem;
  margin: 0 auto;

  @media (max-width: 600px) {
    padding: 0 2rem;
  }

  @media (max-width: 420px) {
    padding: 0 1rem;
  }
}

.button {
  display: inline-block;
  padding: 0.5em 1.25em;
  color: var(--bg-color);
  text-decoration: none;
  border-radius: 4px;
  background: linear-gradient(
    180deg,
    rgba(182, 226, 250, 0.9) 0%,
    rgba(167, 131, 159, 0.9) 100%
  );
  background: linear-gradient(
    180deg,
    color(display-p3 0.749 0.882 0.969 / 0.9) 0%,
    color(display-p3 0.631 0.522 0.616 / 0.9) 100%
  );
  box-shadow:
    0px 0px 12px #162749,
    inset 4px 4px 12px rgba(140, 49, 37, 0.3);
  box-shadow:
    0px 0px 12px color(display-p3 0.102 0.153 0.278),
    inset 4px 4px 12px color(display-p3 0.506 0.216 0.165 / 0.3);
  transition: opacity 0.15s ease-out;

  &:focus {
    outline: solid 2px var(--light-blue);
  }

  &:hover {
    opacity: 0.8;
  }
}

.interstitial-image {
  position: relative;
  z-index: -1;
  margin: -2rem 0;
  padding: 0;

  img {
    width: 100vw;
  }
}

.columns {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

/* Home template */

.home-header {
  position: relative;
  background-size: cover;
  display: flex;
  flex-direction: column;
  height: min(80vh, 600px);
  padding: 2rem 0;

  @media (min-width: 600px) {
    height: min(50vw, 80vh);
  }

  .home-nav {
    float: right;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;

    a.support-link {
      font-size: 0.8rem;
      font-family: Young, serif;
      text-transform: uppercase;
    }

    .language-menu {
      text-align: right;
    }
  }

  .content {
    .title {
      text-align: center;

      img,
      svg {
        max-width: 56rem; /* container width */
        width: max(60vw, 200px);
        height: auto;

        @media (max-width: 600px) {
          width: max(80vw, 200px);
        }
      }
    }
  }

  .image-layers {
    position: absolute;
    inset: 0;
    z-index: -1;

    animation: fade-in 3s ease-out;

    .mansion,
    .overlay,
    .clouds {
      position: absolute;
      inset: 0;
      z-index: -1;
      background-size: max(100vw, 1200px);
      background-position: center top;
      background-repeat: no-repeat;
    }

    .mansion {
      z-index: 3;
      background-image: url("/img/header_mansion.png");
    }

    .overlay {
      z-index: 2;
      background-image: url("/img/header_overlay.png");
      mix-blend-mode: overlay;
    }

    .clouds {
      z-index: 1;
      background-image: url("/img/header_clouds.jpg");
      background-repeat: repeat-x;
      animation: pan-background 90s linear infinite;
    }
  }
}

@keyframes pan-background {
  0% {
    background-position: 0 top;
  }
  100% {
    background-position: calc(max(100vw, 1200px) * -1) top;
  }
}

@keyframes fade-in {
  0% {
    scale: 1.02;
    opacity: 0;
  }
  100% {
    scale: 1;
    opacity: 1;
  }
}

section.trailer {
  margin: -2rem 0 0;
  padding: 0 2rem;
  position: relative;

  @media (max-width: 420px) {
    padding: 0 1rem;
  }

  .trailer-container {
    display: grid;

    border-radius: 0.5rem;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: 0px 0px 32px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(158, 100, 136, 0.25);

    & > * {
      /* Overlays children full size on top of each other */
      grid-area: 1 / 1;
    }

    iframe {
      border: 0;
      width: 100%;
      height: 100%;
    }

    .trailer-overlay {
      color: inherit;
      text-decoration: none;
      position: relative;

      padding: 2rem;

      display: block;
      background: url("/img/trailer-preview-image.jpg") no-repeat center center;
      background-size: cover;

      transition: opacity 0.3s ease-in-out;

      .trailer-play-icon {
        display: block;
        width: min(4rem, 12vw);
        aspect-ratio: 1 / 1;
        background: url("/img/play-icon.png") no-repeat center center;
        background-size: contain;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        opacity: 1;

        transition: opacity 0.1s;
      }

      h3 {
        margin: 0;
      }

      &.hidden {
        opacity: 0;
        pointer-events: none;
      }

      &:hover {
        .trailer-play-icon {
          opacity: 0.7;
          scale: 1.05;
        }
      }

      @media (max-width: 600px) {
        padding: 1rem;

        h3 {
          font-size: 1.25rem;
        }
      }
    }
  }
}

section.presentation {
  margin-top: 6rem;

  .content,
  .critiques {
    width: calc(50% - 1rem);

    @media (max-width: 700px) {
      width: 100%;
    }
  }

  .content {
    font-size: 1.25rem;
    max-width: 30rem;

    h4 {
      font-size: 1.4rem;
      font-weight: normal;
    }

    p:first-of-type {
      margin-top: 0;
    }
  }

  .critiques {
    max-width: 32rem;

    ul {
      list-style: none;
      padding: 0;
      margin: 0;

      border: solid var(--ui-blue) 4px;
      background-color: var(--bg-color);
      position: relative;
      overflow-x: scroll;

      display: flex;
      flex-direction: row;
      align-items: center;

      scroll-snap-type: x mandatory;
      scrollbar-color: var(--ui-deep-blue) transparent;

      li {
        flex: 0 0 100%;
        scroll-snap-align: start;

        blockquote {
          margin: 0;
          font-size: 1.1rem;
        }

        figure {
          padding: 1rem 2rem;
          margin: 0;

          @media (max-width: 800px) {
            padding: 0.5rem 1rem;
          }
        }

        figcaption {
          text-align: right;
        }
      }
    }

    .buttons-row {
      display: flex;
      justify-content: flex-end;
      gap: 1rem;
      margin-top: 0.5rem;

      button {
        appearance: none;
        border: solid 4px
          color-mix(in srgb, var(--ui-deep-blue) 100%, transparent);
        background-color: var(--bg-color);
        display: flex;
        align-items: center;
        gap: 0.5rem;

        padding: 0.25rem 1rem;
        transition: border-color 0.1s ease-out;

        box-shadow: 4px 4px 0
          color-mix(in srgb, var(--ui-blue) 25%, transparent);

        svg {
          opacity: 0.8;
          transition: opacity 0.15s ease-out;
        }

        &:hover {
          border: solid 4px
            color-mix(in srgb, var(--ui-deep-blue) 80%, transparent);
          box-shadow: 4px 4px 0
            color-mix(in srgb, var(--ui-blue) 15%, transparent);

          svg {
            opacity: 0.9;
          }
        }

        &:active {
          border: solid 4px
            color-mix(in srgb, var(--ui-deep-blue) 60%, transparent);
          box-shadow: 2px 2px 0
            color-mix(in srgb, var(--ui-blue) 10%, transparent);

          svg {
            opacity: 1;
          }
        }
      }
    }
  }
}

section.presentation + .interstitial-image {
  margin-top: max(-20vw, -16rem);
}

.steam-widget {
  margin: 4rem auto;
  text-align: center;
  position: relative;

  iframe {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    color-scheme: light; /* Steam widget breaks its transparency on "dark" scheme */
  }
}

/* Page */

.page-header {
  padding: 2rem 0;
  /* Passing clouds effect */

  background-image:
    linear-gradient(to bottom, transparent 50%, var(--bg-color)),
    url("/img/header_clouds.jpg");
  background-repeat: repeat-x, repeat-x;
  animation: pan-background 90s linear infinite;
  background-size:
    100% 100%,
    max(100vw, 1200px);
  background-position:
    center top,
    center top;

  .top-bar {
    margin: 0 0 3rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;

    .home-link {
      margin-right: auto;
    }

    a.support-link {
      font-size: 0.8rem;
      font-family: Young, serif;
      text-transform: uppercase;
    }

    .language-menu {
      text-align: right;
    }
  }

  .home-link {
    font-family: Young, serif;
    text-transform: uppercase;
    color: var(--light-blue);
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.1s ease-out;
    will-change: opacity;

    mix-blend-mode: hard-light;

    &:hover {
      opacity: 0.8;
    }
  }

  .title {
    color: var(--light-blue);
    font-size: 2.4rem;
    font-family: Young, serif;
    margin: 2rem 0 0;
  }
}

.page main.content {
  margin-bottom: 4rem; /* Space it away from the footer image's halo */
  font-size: 1.25rem;

  .rendered-markdown {
    max-width: 38rem; /* Comfortable line length (~70 characters) */
    line-height: 1.5;

    code {
      font-family: ui-monospace, Menlo, Consolas, monospace;
      font-size: 0.8em; /* Monospace runs visually larger than Crimson */
    }

    pre {
      overflow-x: auto; /* Long paths scroll instead of breaking layout */
      padding: 0.75rem 1rem;
      background-color: var(--ui-deep-blue);
    }
  }
}

/* Support section */

ul.support-index {
  list-style: none;
  padding: 0;
  margin: 0 0 4rem;
  display: flex;
  flex-direction: column;

  li {
    border-bottom: solid 1px color-mix(in srgb, var(--ui-blue) 50%, transparent);

    &.focus {
      border-bottom: none;
      margin-top: 2.5rem;

      .button {
        display: inline-block;
        font-size: 1.15rem;
        padding: 0.5em 1.25em;

        &:hover,
        &:focus {
          text-decoration: none;
        }
      }
    }

    a {
      display: block;
      padding: 1rem 0;
      text-decoration: none;
      font-size: 1.25rem;

      &:hover,
      &:focus {
        text-decoration: underline;
      }
    }
  }
}

/* Footer */

footer.evil-trout {
  margin: 2rem auto;
  position: relative;

  .evil-trout-logo {
    text-align: center;
    margin: -4rem 0; /* Offset the size of the fading white a bit */
    z-index: -1;

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

  h3 {
    font-size: 1.25rem;

    @media (max-width: 600px) {
      font-size: 1.1rem;
      margin-bottom: 0.35rem;
    }
  }

  .games {
    margin-bottom: 4rem;
  }

  .links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem 4rem;

    @media (max-width: 800px) {
      gap: 1rem 2rem;
    }

    @media (max-width: 600px) {
      grid-template-columns: 1fr;
    }

    ul {
      list-style: none;
      padding: 0.75rem 0 0;
      display: flex;
      gap: 1rem;
      align-items: center;
    }

    .social-links a {
      color: var(--light-purple);
      transition: opacity 0.15s ease-out;
      border-radius: 3px;

      &:focus {
        outline: solid 2px
          color-mix(in srgb, var(--light-purple) 60%, transparent);
      }

      &:hover {
        opacity: 0.8;
      }
    }
  }

  .newsletter form {
    background: color-mix(in oklab, #1b1e28 95%, var(--bg-color));
    border-radius: 0.5rem;
    border: solid 2px
      color-mix(in oklab, var(--light-blue) 35%, var(--bg-color));
    display: flex;
    padding: 0.125rem;
    gap: 1rem;
    transition: border-color 0.15s ease-out;

    input[type="submit"] {
      color: var(--bg-color);
      padding: 0.25rem 0.5rem;
      background: linear-gradient(
        180deg,
        rgba(182, 226, 250, 0.9) 0%,
        rgba(167, 131, 159, 0.9) 100%
      );
      background: linear-gradient(
        180deg,
        color(display-p3 0.749 0.882 0.969 / 0.9) 0%,
        color(display-p3 0.631 0.522 0.616 / 0.9) 100%
      );
      box-shadow:
        0px 0px 12px #162749,
        inset 4px 4px 12px rgba(140, 49, 37, 0.3);
      box-shadow:
        0px 0px 12px color(display-p3 0.102 0.153 0.278),
        inset 4px 4px 12px color(display-p3 0.506 0.216 0.165 / 0.3);
      border-radius: 4px;

      transition: opacity 0.15s ease-out;

      &:focus {
        outline: solid 2px var(--light-blue);
      }

      &:hover {
        opacity: 0.8;
      }
    }

    &:focus-within {
      border-color: color-mix(in oklab, var(--light-blue) 55%, var(--bg-color));
    }

    input[type="email"] {
      background: transparent;
      border: none;
      flex: 1;
      padding: 0.5rem 0 0.5rem 0.5rem;
      font-size: 1.4rem;
      color: var(--text-color);

      &:focus {
        outline: none;
      }
    }

    @media (max-width: 700px) {
      flex-direction: column;
      padding: 0.25rem;
      gap: 0;

      input[type="email"] {
        padding: 0.5rem 0.25rem;
        border-radius: 0.5rem;
        font-size: 1rem;
      }

      .button {
        border-radius: 0;
      }
    }
  }
}

/* Dialogs */

.modal {
  border: none;
  min-width: 12rem;

  ul {
    list-style: none;
    padding: 0;
  }

  .lang-close-button {
    display: block;
    margin-left: auto;
    margin-bottom: 1rem;
  }
}

/* Animations */

@keyframes flip-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0px);
    opacity: 1;
  }
}

/* Dialog animations */

dialog {
  transition:
    display 0.75s allow-discrete,
    overlay 0.75s allow-discrete;

  animation: close 0.75s forwards;
  &[open] {
    animation: open 0.75s forwards;
  }
}

@keyframes open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes close {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
