@import url(https://fonts.bunny.net/css?family=architects-daughter:400|bellefair:400);

@layer base, demo;

@layer demo {
  .card-title {
    font-weight: 300;
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
    text-shadow: 4px 4px 15px #92ff04;
  }

  @keyframes flicker {
    0%,
    100% {
      box-shadow: 0 0 25px 5px rgba(255, 223, 100, 0.4);
    }
    50% {
      box-shadow: 0 0 35px 10px rgba(255, 223, 100, 0.7);
    }
  }

  .cards {
    --width: 300px;
    --rotate-duration: 500ms;
    --rotate-timing-function: linear(
      0,
      0.417 25.5%,
      0.867 49.4%,
      1 57.7%,
      0.925 65.1%,
      0.908 68.6%,
      0.902 72.2%,
      0.916 78.2%,
      0.988 92.1%,
      1
    );

    margin-bottom: 2rem;

    --article-reveal-duration: 300ms;
    --article-reveal-delay: 500ms;

    --degrees: 360deg;
    --degree-start: 45deg;
    --items: 8;
    --radius: 400px;
    --item-size: 130px;

    @media (width > 800px) {
      --width: 400px;
      --radius: 450px;
      --item-size: 200px;
    }

    position: relative;
    width: var(--width);
    aspect-ratio: 3/4.25;
    background-image: linear-gradient(
        rgba(208 135 0 / 0.35),
        rgba(208 135 0 / 0.35)
      ),
      url("https://images.unsplash.com/photo-1475965894430-b05c9d13568a?q=80&w=1935&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    background-repeat: no-repeat;
    background-size: cover;
    overflow: hidden;
    border-radius: 10px;
    animation: flicker 3s infinite ease-in-out;

    color: black;
    display: grid;

    &:has(#card-1:checked) {
      --target: 1;
      --opacity-card-1: 1;
    }
    &:has(#card-2:checked) {
      --target: 2;
      --opacity-card-2: 2;
    }
    &:has(#card-3:checked) {
      --target: 3;
      --opacity-card-3: 3;
    }
    &:has(#card-4:checked) {
      --target: 4;
      --opacity-card-4: 4;
    }
    &:has(#card-5:checked) {
      --target: 5;
      --opacity-card-5: 5;
    }
    &:has(#card-6:checked) {
      --target: 6;
      --opacity-card-6: 6;
    }
    &:has(#card-7:checked) {
      --target: 7;
      --opacity-card-7: 7;
    }
    &:has(#card-8:checked) {
      --target: 8;
      --opacity-card-8: 8;
    }

    /* hide inputs */
    & input[type="radio"] {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border-width: 0;
    }
  }

  /* Rotating circle background */
  .circle-container {
    &::before {
      content: "";
      position: absolute;
      inset: -230%;
      margin: auto;
      z-index: -1;
      background-color: rgba(60 99 0 / 0.35);
      background-image: linear-gradient(
          rgba(124, 201, 8, 0.5),
          rgba(47, 71, 11, 0.5)
        ),
        url("https://images.unsplash.com/photo-1542500500-7210b17bde86?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
      background-repeat: no-repeat;
      background-size: cover;
      border-radius: 50%;
      border: 1px solid rgba(0 0 0 / 0.25);
      z-index: 2;
      box-shadow: inset 5px 5px 15px 10px rgba(175, 57, 57, 0.15),
        5px 5px 10px 5px rgba(0 0 0 / 0.25);
      outline: 10px double rgba(129, 240, 101, 0.5);
      outline-offset: -15px;
      filter: brightness(0.6) contrast(1.2) saturate(0.8);
    }

    position: absolute;
    top: calc(var(--radius) * -1);
    left: 50%;
    translate: -50%;
    margin: auto;
    width: var(--item-size);
    height: var(--item-size);
    rotate: calc(var(--degrees) / var(--items) * var(--target));

    transition-property: rotate;
    transition-duration: var(--rotate-duration);
    transition-timing-function: var(--rotate-timing-function);
  }

  .circle-container > div {
    pointer-events: none;
    z-index: 2;
    &:nth-child(1) {
      --i: 1;
    }
    &:nth-child(2) {
      --i: 2;
    }
    &:nth-child(3) {
      --i: 3;
    }
    &:nth-child(4) {
      --i: 4;
    }
    &:nth-child(5) {
      --i: 5;
    }
    &:nth-child(6) {
      --i: 6;
    }
    &:nth-child(7) {
      --i: 7;
    }
    &:nth-child(8) {
      --i: 8;
    }

    --angle: calc(
      (var(--degrees) / var(--items)) * (var(--i) - 1) + var(--degree-start)
    );

    position: absolute;
    inset: 0;
    margin: auto;

    transform: rotate(var(--angle)) translate(var(--radius)) rotate(90deg);
    display: grid;
    place-content: center;

    & > img {
      width: auto;
      height: 200px;
      object-fit: contain;
      rotate: 180deg;
      filter: drop-shadow(6px 14px 5px rgba(0 0 0 / 0.35));
    }
  }

  .contents {
    margin-top: var(--item-size);
    padding: 2rem 2rem 1rem;
    display: grid;
    position: relative;
    background: url("../images/paper-background.webp") center/cover no-repeat;
    padding: 2rem;

    & > article {
      grid-area: 1/1;
      display: grid;
      grid-template-rows: auto 1fr auto;

      opacity: var(--article-opacity, 0);
      pointer-events: none;
      padding: 3rem;

      & :is(li, h2) {
        transition: var(--article-reveal-duration) ease-in-out;
        transition-delay: var(--article-delay, 0ms);
        opacity: var(--article-opacity, 0);
        translate: 0 var(--article-y, 20px);
      }
      & li:nth-child(1) {
        transition-delay: calc(var(--article-delay) * 2);
      }
      & li:nth-child(2) {
        transition-delay: calc(var(--article-delay) * 3);
      }
      & li:nth-child(3) {
        transition-delay: calc(var(--article-delay) * 4);
      }
      & h2 {
        font-size: 1rem;
        margin-block: 1rem;
        font-weight: 300;
      }
      & ul {
        margin-block: 0;
        font-weight: 300;
        padding-inline-start: 1rem;
        display: grid;
        gap: 0.5rem;
        place-content: start;
      }
      & li {
        margin: 0;
      }
      & li > span {
        color: #616427;
      }
      & a {
        position: relative;
      }
      & > .buttons {
        display: flex;
        justify-content: center;
        gap: 1rem;

        & > label {
          font-size: 1.4rem;
          cursor: pointer;
          transition: color 150ms ease-in-out;
          &:hover {
            color: rgb(225, 228, 82);
          }
          &[disabled] {
            opacity: 0.25;
            pointer-events: none;
          }
        }
      }
    }
  }

  .cards {
    &:has(#card-1:checked) > .contents > article:nth-child(1) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-2:checked) > .contents > article:nth-child(2) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-3:checked) > .contents > article:nth-child(3) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-4:checked) > .contents > article:nth-child(4) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-5:checked) > .contents > article:nth-child(5) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-6:checked) > .contents > article:nth-child(6) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-7:checked) > .contents > article:nth-child(7) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
    &:has(#card-8:checked) > .contents > article:nth-child(8) {
      --article-opacity: 1;
      --article-y: 0;
      pointer-events: auto;
      --article-delay: var(--article-reveal-delay);
    }
  }
}

/* General Styling */
@layer base {
  * {
    box-sizing: border-box;
  }
  :root {
    color-scheme: light dark;
    --bg-dark: rgb(27, 15, 5);
    --bg-light: rgb(255, 237, 212);

    --txt-light: rgb(10, 10, 10);
    --txt-dark: rgb(245, 245, 245);
  }

  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
    font-family: "Architects Daughter", serif;
    height: 100%;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  html {
    height: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scroll-timeline: --page-scroll block;
    scroll-timeline: --page-scroll vertical;
  }

  body {
    background-color: light-dark(var(--bg-light), var(--bg-dark));
    color: light-dark(var(--txt-light), var(--txt-dark));
    min-height: 100%;
    /* margin: 0;
    padding: 1rem 2rem; */
    font-size: 14px;
    line-height: 1.5;
    display: grid;
    place-content: center;
    gap: 1rem;
  }
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header / Nav */
.assignment-header {
  text-align: center;
  margin-bottom: 2rem;
  color: #fdf6e3;
  font-family: "Bellefair", serif;
}

.assignment-header h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 12px #92ff04;
}

.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.glow-button {
  background-color: rgba(40, 60, 20, 0.7);
  border: 2px solid #92ff04;
  color: #f5f5f5;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 1rem;
  font-family: "Architects Daughter", sans-serif;
  text-decoration: none;
  text-shadow: 0 0 3px #000;
  box-shadow: 0 0 10px #92ff04;
  transition: all 0.3s ease;
}

.glow-button:hover {
  background-color: rgba(100, 150, 60, 0.9);
  color: #000;
  box-shadow: 0 0 20px #c8ff84, 0 0 5px #92ff04;
}

/* Firefly Effect */
#firefly-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.firefly {
  width: 4px;
  height: 4px;
  position: absolute;
  background-color: #63ec5e;
  box-shadow: 0px 0px 17px 2px rgb(179, 245, 242);
  border-radius: 50%;
  filter: blur(1px) brightness(1.2);
  opacity: 0.9;
  transition: all 0.4s ease-out;
}

/* Info section */
.info {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background: rgba(50, 30, 10, 0.5);
  border-radius: 12px;
  text-align: center;
  font-family: "Bellefair", serif;
}

.info h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: wheat;
}

.info p {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  color: #f5f5f5;
}

a {
  color: #ecc45e;
  text-decoration: underline;
}

.card-wrapper {
  margin-top: 2rem;
  display: grid;
  place-content: center;
}

/* Code Explanations */
.code-explanation {
  max-width: 800px;
  margin: 4rem auto;
  padding: 2rem;
  background: rgba(20, 20, 20, 0.7);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  color: #dad4d4;
}

.code-explanation h2 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 2rem;
}

.code-blurb {
  margin-bottom: 3rem;
}

.code-blurb h3 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  color: #ffd369;
}

.code-blurb p {
  margin-bottom: 1rem;
  font-size: 1rem;
}

pre {
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  word-wrap: normal;
  white-space: pre;
}

/* Background - was going to be parallax but could not get it to work right*/
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("../images/background-forrest.webp") center center / cover
    no-repeat;
  background-attachment: fixed;
  z-index: -1;
  pointer-events: none;
}

/* Footer */
footer {
  margin-top: auto;
  text-align: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
  font-family: "Bellefair", serif;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

/* Media Queries */
@media (max-width: 600px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    display: block;
    padding: 0;
    margin: 0;
  }

  .page-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
  }

  .assignment-header {
    padding-top: 1rem;
  }

  .assignment-header h1 {
    font-size: 1.6rem;
    width: 100%;
    margin-bottom: 1rem;
    text-align: center;
  }

  .nav-buttons {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .glow-button {
    width: 100%;
    max-width: 280px;
    font-size: 1rem;
    padding: 0.6rem 1rem;
    margin: 0 auto;
  }

  .code-explanation,
  .info {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
    box-sizing: border-box;
  }

  .cards {
    --width: 90vw;
    --item-size: 110px;
    --radius: 250px;
  }

  .circle-container > div img {
    height: 80px;
  }

  .contents > article {
    padding: 1rem;
  }

  .code-explanation h2 {
    font-size: 1.5rem;
  }

  pre[class*="language-"],
  code[class*="language-"] {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-x: hidden !important;
  }

  pre {
    background: #1e1e1e;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: hidden;
  }

  code {
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
  }

  footer {
    padding: 1rem 0.5rem;
  }

  .footer-links {
    gap: 1rem;
    flex-direction: column;
  }

  .background {
    background-attachment: scroll;
  }
}
