::view-transition-group(root) {
  animation-duration: 1s;
}

::view-transition-group(title) {
  animation-duration: 1s;
}

.title-transition-goquest {
  view-transition-name: title-goquest;
}

.title-transition-ascii-image-generator {
  view-transition-name: title-ascii-image-generator;
}

.title-transition-screen-recorder {
  view-transition-name: title-screen-recorder;
}

.title-transition-docker-tui {
  view-transition-name: title-docker-tui;
}

.title-transition-ollama-webui {
  view-transition-name: title-ollama-webui;
}

.title-transition-personal-website {
  view-transition-name: title-personal-website;
}

/*
  header
    line height: 1.1, 1.3
    letter-spacing: -1, -2

  body text
    line height: 1.4, 1.6
*/

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

html {
  hanging-punctuation: first last;
  color-scheme: dark light;
}

:root {
  interpolate-size: allow-keywords;

  --font-size-sm: clamp(0.8rem, 0.17vw + 0.76rem, 0.89rem);
  --font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
  --font-size-md: clamp(1.25rem, 0.61vw + 1.1rem, 1.58rem);
  --font-size-lg: clamp(1.56rem, 1vw + 1.31rem, 2.11rem);
  --font-size-xl: clamp(1.95rem, 1.56vw + 1.56rem, 2.81rem);
  --font-size-xxl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
  --font-size-xxxl: clamp(3.05rem, 3.54vw + 2.17rem, 5rem);

  --border-radius: 10px;
  --font-family:
    system-ui, -apple-system, blinkmacsystemfont, "segoe ui", roboto, oxygen,
    ubuntu, cantarell, "open sans", "helvetica neue", sans-serif;

  --max-width-screen: 1300px;
  --max-width-content: 950px;
  --primary-color: hsl(360 83% 54%);
  --main-padding: 0.8em;
  --bg-color: light-dark(#fefefe, #1c1b22);
  --bg-color-invert: light-dark(#1c1b22, #fefefe);
  --dark-color: #1c1b22;
}

body {
  font-family: var(--font-family);
  background: var(--bg-color);
  font-size: 1.125rem;
  height: 100dvh;
  height: 100lvh;

  padding: 1em;
  height: 100vh;
}

body > :is(header, footer),
section,
main,
article {
  container-type: inline-size;
}

pre {
  background: light-dark(#eeefff, #272834);
  padding: 0.75rem;
  border-radius: 10px;
  color: var(--bg-color-invert);
  white-space: normal;
  margin-bottom: 0.5rem;
}

code {
  font-family:
    source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
  white-space: pre-line;
}

main {
  overflow: auto;
  height: 100%;

  padding: var(--main-padding);
  border-radius: var(--border-radius);
  border: 3px solid var(--primary-color);

  display: grid;
  place-items: center;
  gap: 2rem;
}

section {
  position: relative;
  max-width: var(--max-width-content);
  width: 100%;
}

nav {
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 10;

  max-width: calc(var(--max-width-content) + (180px * 2));

  div {
    display: flex;
    justify-content: flex-end;
    gap: 1.2em;
    flex-direction: column;
    position: absolute;
    background: transparent;

    a {
      font-weight: 600;
      color: inherit;
      font-size: var(--font-size-lg);
    }
  }
}

@media (width < 1350px) {
  nav {
    margin-inline: calc(var(--main-padding) * -2);
    margin-bottom: var(--main-padding);

    div {
      margin-top: calc(var(--main-padding) * -1);
      width: 100%;
      padding: 10px 20px;
      flex-direction: row;
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);

      a {
        font-size: var(--font-size-md);
      }
    }
  }
}

@media (width < 450px) {
  nav {
    display: none;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

p,
li,
figcaption {
  text-wrap: pretty;
  max-width: 65ch;
}

body > :is(header, footer),
section,
main,
article {
  container-type: inline-size;
}

h1 {
  --font-size: var(--font-size-xxl);
  margin-bottom: 0.5em;
  font-size: var(--font-size);
  font-weight: 900;
  line-height: calc(var(--font-size) * 1.1);
  letter-spacing: -2px;
}

h2 {
  place-self: start;

  --font-size: var(--font-size-xl);
  font-size: var(--font-size);
  font-weight: 600;
  line-height: calc(var(--font-size) * 1.1);
  letter-spacing: -2px;
  margin-bottom: 0.5em;
}

h3 {
  --font-size: var(--font-size-lg);
  font-size: var(--font-size);
  font-weight: 400;
  line-height: calc(var(--font-size) * 1.1);
  letter-spacing: -2px;
  margin-bottom: 0.5em;
}

small {
  font-size: var(--font-size-sm);
}

p {
  --font-size: var(--font-size-base);
  font-size: var(--font-size);
  line-height: calc(var(--font-size) * 1.3);
  margin-bottom: 0.5em;
  text-wrap: pretty;
}

a {
  text-decoration: none;
  color: inherit;

  &:hover {
    color: hsl(from var(--primary-color) h s l / 70%);
  }

  &:not(:has(i)) {
    font-weight: 400;
    color: hsl(from var(--primary-color) h 50% l);
  }
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: var(--border-radius);
}

button {
  cursor: pointer;
  border-radius: var(--border-radius);
  outline: none;
  border: none;
  min-width: 10ch;
}

& i,
.ts-icon {
  & svg {
    & path {
      fill: var(--bg-color-invert);
    }
  }
}

#mode-toggle {
  z-index: 1;
  border: none;
  background: transparent;
  overflow: hidden;
  top: 0;
  right: 0;

  position: absolute;
  width: 100px;
  height: 40px;

  display: grid;
  place-items: center;

  #sun,
  #moon {
    position: absolute;

    svg {
      transition: transform 2s
        linear(
          0,
          0.013 0.6%,
          0.05 1.2%,
          0.199 2.5%,
          0.395 3.7%,
          0.948 6.7%,
          1.201 8.4%,
          1.289 9.2%,
          1.354 10%,
          1.396 10.8%,
          1.416 11.6%,
          1.418 12.2%,
          1.405 12.9%,
          1.345 14.3%,
          1.258 15.6%,
          1.012 18.8%,
          0.909 20.5%,
          0.851 22%,
          0.826 23.6%,
          0.83 24.8%,
          0.854 26.2%,
          0.996 30.8%,
          1.039 32.5%,
          1.063 34%,
          1.073 35.5%,
          1.061 38.2%,
          0.984 44.4%,
          0.97 47.4%,
          0.973 49.8%,
          1.004 55.8%,
          1.013 59.2%,
          0.995 71%,
          1.002 82.8%,
          1
        );
    }
  }

  #sun {
    svg path {
      stroke: #feff94;
      filter: drop-shadow(0px 0px 3px yellow);
    }

    &[data-visible="false"] svg {
      transform: translateX(-75px);
    }
  }

  #moon {
    svg path {
      stroke: #505050;
      filter: drop-shadow(0px 0px 1px black);
    }

    &[data-visible="false"] svg {
      transform: translateX(75px);
    }
  }
}

.hero-section {
  --_gradient-color-light: hsl(from var(--primary-color) h s l / 8%);
  --_gradient-color-dark: hsl(from var(--primary-color) h s l / 15%);

  --_gradient-color: light-dark(
    var(--_gradient-color-light),
    var(--_gradient-color-dark)
  );

  height: 100vh;
  height: 100dvh;
  height: 100lvh;

  display: grid;
  place-items: center;

  background: radial-gradient(
    circle,
    var(--_gradient-color) 0%,
    var(--bg-color) 50%
  );
  text-align: right;

  h1 {
    span {
      color: var(--primary-color);
    }
  }

  .more-about-me {
    background: transparent;
    color: var(--primary-color);
    font-weight: 900;
    overflow: hidden;

    padding: 1em 0.8em;

    display: flex;
    gap: 5px;
    align-items: Center;

    i {
      font-weight: 800;
      font-size: 30px;
      animation: arrowanimation 1300ms infinite;
    }
  }
}

.about-me {
  display: grid;

  .content {
    container-type: inline-size;
    display: grid;
    place-items: Center;
    gap: 1rem;

    .contact-picture {
      overflow: clip;
      max-width: 300px;
      width: 100%;
      z-index: 1;
      position: relative;

      & img {
        transition: all 500ms ease;
        transform: translateY(10%);

        &:hover {
          transform: translateY(0%);
          transform: scale(1.1);
        }
      }

      & .eyes {
        position: absolute;
        inset: 0;

        & .eye {
          position: absolute;
          width: 4rem;
          aspect-ratio: 1;
          border: 2px solid black;
          border-radius: 100%;
          background: #fff;

          &::after {
            content: "";
            position: absolute;
            width: 7px;
            aspect-ratio: 1;
            background: black;
            border-radius: 100%;

            left: 45%;
            top: 7px;
          }
        }
      }
    }
  }

  @container (width > 65ch) {
    .content {
      grid-template-columns: auto 1fr;
    }
  }
}

.skills {
  .skill-cards {
    display: grid;
    width: 100%;
    transform-style: preserve-3d;
    transform: perspective(800px);
    margin-bottom: 0.8rem;

    &:hover > div {
      filter: brightness(0.3);
    }

    > div {
      --_gap: 0.5rem;
      --_icon-width: 50px;
      display: flex;
      gap: var(--_gap);
      place-items: center;
      position: relative;
      margin-top: -0.2rem;

      transition: all 600ms linear(0, 0.999 44.8%, 0.866 58.4%, 0.998 77.2%, 1);
      filter: brightness(1);

      &:hover {
        filter: brightness(1);
        transform: translateZ(100px);
      }

      &:hover + * {
        filter: brightness(0.8);
        transform: translateZ(80px) rotateX(-40deg);
      }

      &:hover + * + * {
        filter: brightness(0.6);
        transform: translateZ(60px) rotateX(-20deg);
      }

      &:hover + * + * + * {
        filter: brightness(0.4);
        transform: translateZ(40px) rotateX(-15deg);
      }

      &:has(+ *:hover) {
        filter: brightness(0.8);
        transform: translateZ(80px) rotateX(40deg);
      }

      &:has(+ * + *:hover) {
        filter: brightness(0.6);
        transform: translateZ(60px) rotateX(20deg);
      }

      &:has(+ * + * + *:hover) {
        filter: brightness(0.4);
        transform: translateZ(40px) rotateX(10deg);
      }

      & i,
      .ts-icon {
        font-size: var(--font-size-lg);
        position: relative;
        place-self: center;
        display: flex;
        aspect-ratio: 1;
        width: var(--_icon-width);

        &::before {
          width: 100%;
          display: flex;
          place-self: center;
          justify-content: center;
        }
      }

      &:after {
        content: "5 Years";
        position: absolute;
        right: 0;
        top: 0;

        font-size: var(--font-size-sm);
        font-weight: 800;
      }

      &::before {
        content: "";
        transition: opacity 0.4s ease-in-out;
        opacity: 0;
      }

      &:hover::before {
        left: calc(var(--_gap) + var(--_icon-width) + 0.2rem);
        content: attr(data-message);
        position: absolute;
        color: inherit;
        font-weight: bold;
        top: 10px;
        z-index: 2;
        opacity: 1;
      }
    }
  }
}

.projects {
  .project-list {
    width: 100%;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20ch, 1fr));
    gap: 0.8em;

    &:hover > .card:not(:hover) {
      opacity: 0.5;
      transform: scale(0.9);
    }

    .card:hover {
      opacity: 1;
      scale: 1.3;
      background: var(--bg-color);
      z-index: 2;
    }

    .card {
      position: relative;
      min-height: 15rem;
      perspective: 150rem;
      transition: all 200ms;

      .card-front,
      .card-back {
        position: absolute;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: auto;
        border: 1px solid red;
        border-radius: 1rem;
        transition: 800ms
          linear(
            0,
            0.008 1.1%,
            0.031 2.2%,
            0.129 4.8%,
            0.257 7.2%,
            0.671 14.2%,
            0.789 16.5%,
            0.881 18.6%,
            0.957 20.7%,
            1.019 22.9%,
            1.063 25.1%,
            1.094 27.4%,
            1.114 30.7%,
            1.112 34.5%,
            1.018 49.9%,
            0.99 59.1%,
            1
          );
        backface-visibility: hidden;
        overflow: hidden;
        padding: 1rem;
      }

      .card-front {
        text-align: center;
      }

      .card-back {
        display: grid;
        gap: 1rem;
        transform: rotateX(180deg);
      }

      &:hover .card-front {
        transform: rotateX(-180deg);
      }

      &:hover .card-back {
        transform: rotateX(0deg);
      }
    }
  }
}

.progress-bar {
  width: 100%;
  height: 30px;
  position: relative;

  .progress {
    max-width: var(--value, 0);

    height: 30px;
    background: hsl(from var(--primary-color) h s l / 85%);
    transition: width 2s ease 0.4s;

    animation: scroll-progress linear;
    animation-timeline: view();
    animation-range: 0px 200px;
    transform-origin: left;
  }
}

.contact {
  div {
    display: flex;
    justify-content: center;
    gap: 1em;

    a {
      display: grid;
      place-items: Center;

      font-size: var(--font-size-md);
    }
  }
}

footer {
  display: grid;
  place-items: center;

  padding-block: 1em;
}

/* Keyframa animations */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  :has(:target) {
    scroll-behavior: smooth;
    scroll-padding-top: 4rem;
  }

  @keyframes scrolling {
    to {
      transform: translateX(-100%);
    }
  }

  @keyframes scroll-progress {
    from {
      width: 0;
    }

    to {
      width: 100%;
    }
  }

  @keyframes arrowanimation {
    from {
      transform: translate(0px, -50px);
    }

    to {
      transform: translate(0px, 50px);
    }
  }
}
