/* CSS DIRECTORY
	  1. =GLOBAL
    2. =BODY
    3. =MAIN
    4. =TITLE
    5. =VIEWPORT
    6. =FORM
    7. =BIG-RED-BUTTON
    8. =STATES
*/

/* Please Don't Touch Anything
original inspiration: https://store.steampowered.com/app/354240/Please_Dont_Touch_Anything/
secondary inspiration: https://noyamirai.github.io/css-to-the-rescue-2223/keypanel/ */

/* ===GLOBAL=== */

/* styling reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* colors */
  --primary-background-color: #293134;
  --secondary-background-color: #3f4d55;

  --primary-button-color: #be3334;
  --secondary-button-color: #87213c;

  --primary-accent-color: #afb3b5;
  --secondary-accent-color: #646f79;

  --active-color: #3cb371;
  --inactive-color: #ff5733;

  --text-color: #000;

  /* set button states */
  --fail-safe-1: false;
  --fail-safe-2: false;
  --fail-safe-3: false;

  --detonate: false;

  /* animation variables */
  --intro-text-content: 5s;
  --detonate-text-content: 9s;

  --fade: 1s;
  --fade-in-delay: 7s;
  --fade-out-delay: 5s;

  --detonate-shake-primary: 0.1s;
  --detonate-shake-primary-delay: 1s;
  --detonate-shake-primary-iterations: 40;

  --detonate-shake-secondary: 1s;
  --detonate-shake-secondary-delay: 4s;
  --detonate-shake-secondary-iterations: 3;

  --detonate-viewport: 7.5s;

  /* sizings */
  --button-size: 25vmin;
}

/* font */
@font-face {
  font-family: "dot-gothic";
  src: url("../fonts/dot-gothic.ttf") format("truetype");
}

/* ===BODY=== */

body {
  /* linear gradient background */
  /* linear-gradient optimizations: help from Sanne */
  background: linear-gradient(
    to bottom,
    var(--primary-background-color) 65%,
    var(--secondary-background-color) 0 66%,
    var(--primary-background-color) 0 67%,
    var(--secondary-background-color) 0 69%,
    var(--primary-background-color) 0 71%,
    var(--secondary-background-color) 0 100%
  );
  height: 100dvh;
  font-family: dot-gothic, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ===MAIN=== */

main {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

/* if detonate button is pressed */
@container style(--detonate:true) {
  /* shake screen animation */
  main {
    animation: detonate-shake var(--detonate-shake-primary) linear
        var(--detonate-shake-primary-delay)
        var(--detonate-shake-primary-iterations),
      detonate-shake var(--detonate-shake-secondary) linear
        var(--detonate-shake-secondary-delay)
        var(--detonate-shake-secondary-iterations);
  }
}

/* shake screen animation */
@keyframes detonate-shake {
  0%,
  100% {
    transform: translateX(0);
    filter: blur(0);
  }
  25%,
  75% {
    transform: translateX(-10px);
  }
  50% {
    transform: translateX(10px);
    filter: blur(5px);
  }
}

/* ===TITLE=== */

h1 {
  font-size: 5vmin;
  font-weight: 700;
  color: var(--primary-accent-color);
  text-align: center;
  position: relative;
  letter-spacing: 5px;
}

/* text content */
h1::before {
  content: "CSS to the Rescue";

  /* intro text content animation */
  animation: text-content var(--intro-text-content) ease forwards;
}

/* intro text content animation */
/* h1:before content: help from Roel */
@keyframes text-content {
  25% {
    content: "CSS to the Rescue";
  }

  75% {
    content: "Dante Piekart";
  }

  100% {
    content: "Please Don't Touch Anything";
  }
}

/* if detonate button is pressed */
@container style(--detonate:true) {
  h1::before {
    /* detonate text content animation */
    animation: detonate-text-content var(--detonate-text-content) ease forwards;
  }
}

/* detonate text content animation */
@keyframes detonate-text-content {
  0% {
    content: "What did I tell you";
  }

  60% {
    content: "What did I tell you";
  }

  100% {
    content: "Look what you've done";
  }
}

/* ===VIEWPORT=== */

img {
  border: var(--secondary-background-color) 10px solid;
  width: 90vmin;
  max-width: 640px;
  margin: 1rem;
  /* fade-in animation */
  animation: fade-in var(--fade) steps(10, end) forwards var(--fade-in-delay);
  opacity: 0;
}

/* fade-in animation */
@keyframes fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

/* if detonate button is pressed */
@container style(--detonate:true) {
  img {
    /* detonate viewport gif animation */
    animation: detonate-viewport var(--detonate-viewport) ease;
    opacity: 1;
  }
}

/* detonate viewport gif animation */
@keyframes detonate-viewport {
  0%,
  25% {
    content: url("../assets/website/gifs/explosion.gif");
  }

  75% {
    content: url("../assets/website/gifs/static.gif");
  }

  100% {
    content: url("../assets/website/images/stand-by.webp");
  }
}

/* ===FORM=== */

form {
  display: flex;
  gap: 10vmin;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0 5vmin 5vmin;
}

/* ===BIG-RED-BUTTON=== */
/* original source: https://codepad.co/snippet/big-red-button */

label {
  /* box styling */
  cursor: pointer;
  display: block;
  background: linear-gradient(
    var(--primary-accent-color) 80%,
    var(--secondary-accent-color) 80%
  );
  height: var(--button-size);
  width: var(--button-size);
  background-color: var(--primary-background-color);
  text-decoration: none;
  color: var(--primary-text-color);
  opacity: 0;
  /* fade-in animation */
  /* for animation, see 5. =VIEWPORT */
  animation: fade-in var(--fade) steps(10, end) forwards var(--fade-in-delay);

  /* last label styling (reset button) */
  &:last-of-type {
    position: absolute;
    bottom: 3rem;
    opacity: 0;
    z-index: -1;
    animation: none;

    div {
      filter: hue-rotate(120deg);
    }
  }

  input,
  button {
    /* hide original checkbox / button */
    display: none;

    /* animate button click */
    &:checked {
      ~ div {
        &::before {
          bottom: 5%;
        }

        &::after {
          height: 5%;
        }
      }

      /* box light when button pressed */
      ~ span {
        background-color: var(--active-color);
      }
    }
  }

  /* button styling */
  div {
    /* bottom of button */
    border: none;
    background-color: var(--secondary-button-color);
    position: relative;
    border-radius: 50%;
    top: 15%;
    left: 50%;
    width: 80%;
    height: 50%;
    transform: translateX(-50%);

    /* top of button */
    &::before {
      content: "";
      z-index: 1;
      border-radius: 50%;
      background-color: var(--primary-button-color);
      position: absolute;
      bottom: 25%;
      left: 0;
      transition: bottom 0.1s;
      width: 100%;
      height: 100%;
    }

    /* middle of button */
    &::after {
      content: "";
      background-color: var(--secondary-button-color);
      position: absolute;
      bottom: 50%;
      left: 0;
      width: 100%;
      height: 26%;
      transition: height 0.1s;
    }
  }

  /* box light */
  span {
    position: relative;
    top: 38%;
    border-radius: 50%;
    left: 7%;
    display: block;
    max-width: 1rem;
    max-height: 1rem;
    width: 1.5vw;
    height: 1.5vw;
    background-color: var(--secondary-background-color);
  }

  /* box title */
  p {
    text-align: center;
    position: relative;
    top: 7vmin;
    font-size: 2vmin;
  }
}

/* if not all fail-safe buttons are pressed */
@container style(--fail-safe-1:false) or style(--fail-safe-2: false) {
  /* disable detonate button */
  label:nth-child(2) {
    pointer-events: none;

    div {
      filter: grayscale(100%);

      &::before {
        bottom: 5%;
      }

      &::after {
        height: 5%;
      }
    }
  }
}

/* if all fail-safe buttons are pressed */
@container style(--fail-safe-1:true) and style(--fail-safe-2: true) {
  /* set "ready" box light color */
  label:nth-child(2) span {
    background-color: var(--inactive-color);
  }
}

/* if detonate button is pressed */
@container style(--detonate:true) {
  /* all buttons except the last one (reset) */
  /* disable buttons */
  label:not(:last-of-type) {
    pointer-events: none;
    opacity: 1;
    /* fade-out animation */
    animation: fade-out var(--fade) steps(10, end) forwards
      var(--fade-out-delay);

    div {
      filter: grayscale(100%);

      &::before {
        bottom: 5%;
      }

      &::after {
        height: 5%;
      }
    }
  }

  /* reset button */
  label:last-of-type {
    opacity: 0;
    /* fade-in animation */
    /* for animation, see 5. =VIEWPORT */
    animation: fade-in var(--fade) steps(10, end) forwards
      calc(var(--fade-in-delay) - 1s);
    z-index: 1;
  }
}

/* fade-out animation */
/* fixing animation: help from Nils */
@keyframes fade-out {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ===STATES=== */

/* check button states */
html:has([name="fail-safe-1"]:checked) {
  --fail-safe-1: true;
}

html:has([name="fail-safe-2"]:checked) {
  --fail-safe-2: true;
}

html:has([name="fail-safe-3"]:checked) {
  body {
    --detonate: true;
  }
}

/* hey! what are you snooping in my code for :) */
