@import "grid";

:root {
  --link-color: #256798;
  --link-color-dark: #215c88;
  --link-underline-color: #add7ea;
  --link-underline-color-light: #bcdceb;
  --link-underline-color-lighter: #c6e4f2;
  --color-black: #282b42;
  --color-gray: #727483;
  --color-white: #fff;
  --color-border: #ebecf2;
  --color-dark-body: #23273a;
  --color-light-pink: #f6f1f4;
  --color-dark-text: #b8b7d1;
  --color-dark-nav-link: #9694ba;
  --link-dark-color: #f1b1eb;
  --link-dark-color-light: #f6c1f0;
  --link-underline-dark-color: #675682;
  --link-underline-dark-color-dark: #61517a;
  --link-underline-dark-color-darker: #5e4e75;
  --color-dark-border: #3b3d54;
}

* {
  box-sizing: border-box;
  &::before,
  &::after {
    box-sizing: border-box;
  }
}

html {
  scroll-behavior: smooth;
}

figcaption,
figure,
footer,
header,
main,
nav,
section {
  display: block;
}

a {
  font-weight: 600;
  text-decoration: none;
}

body {
  margin: 0;
  font-size: 1rem;
  font-family: "Assistant", sans-serif;
  color: var(--color-gray);
  line-height: 1.55;
  font-weight: normal;
  font-kerning: normal;
  font-feature-settings: "kern", "liga", "clig", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-white);

  @media (min-width: $sm) {
    font-size: 1rem;
  }

  @media (min-width: $md) {
    font-size: 1.125rem;
  }
}

img {
  display: block;
  max-width: 100%;
}

p {
  color: inherit;
}

figure {
  margin: 0;
}

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

  li {
    margin: 0 2rem 0 0;

    @media (min-width: $sm) {
      margin: 0 2.5rem 0 0;
    }
  }
}

.container {
  max-width: 76rem;
  margin: auto;
  width: 100%;
  padding: 0 1rem;
}

nav {
  position: absolute;
  padding: 1.25rem 0;
  width: 100%;

  @media (min-width: $md) {
    padding: 1.75rem 0;
  }

  .grid > [class*="column-"] {
    padding: 0 1rem;

    @media (min-width: $sm) {
      adding: 0.25rem 1rem;
    }
  }

  span {
    color: var(--color-black);
    font-weight: 600;

    @media (min-width: $md) {
      font-size: 17px;
    }
  }

  ul {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    height: 100%;

    @media (min-width: $sm) {
      justify-content: flex-end;
      flex-wrap: nowrap;
    }

    li {
      &:last-child {
        margin: 0;
      }

      a {
        position: relative;
        display: inline-block;
        color: var(--color-gray);
        font-weight: 600;
        transition: color 0.2s ease;

        &:hover,
        &:focus {
          color: var(--color-black);
        }

        @media (min-width: $md) {
          font-size: 17px;
        }
      }
    }
  }
}

.avatar {
  display: flex;
  align-items: center;

  @media (min-width: $sm) {
    width: 60px;
    height: 60px;

    &:hover .avatar-content,
    &:focus-within .avatar-content {
      opacity: 1;
      transform: translateX(4.5rem);
      transition: transform 200ms ease, opacity 300ms ease;
    }
  }

  .avatar-block {
    display: none;

    @media (min-width: $sm) {
      display: block;
      width: inherit;
      height: inherit;

      a {
        display: block;
      }
    }

    img {
      border-radius: 50%;
    }
  }

  .avatar-content {
    position: relative;

    @media (min-width: $sm) {
      z-index: -1;
      opacity: 0;
      position: absolute;
      transform: translateX(3rem);
      transition: transform 300ms ease, opacity 150ms ease;
    }
  }
}

.intro {
  padding: 9rem 0 2rem;

  @media (min-width: $md) {
    padding: 13rem 0 0;
  }
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: var(--color-black);

  @media (min-width: $md) {
    font-size: 3rem;
    max-width: 50rem;
  }
}

h2 {
  font-size: 2rem;
  line-height: 1.1;
  margin: 1.5rem 0 0;
  color: var(--color-black);

  @media (min-width: $md) {
    margin-top: 0.85rem;
    font-size: 2.125rem;
  }
}

h3 {
  font-size: 1.5rem;
  line-height: 1.1;
  margin: 1.25rem 0 0.5rem;
  padding: 0;
  color: var(--color-black);

  @media (min-width: $md) {
    font-size: 1.75rem;
  }
}

p.lead {
  font-size: 1.125rem;

  @media (min-width: $md) {
    font-size: 1.375rem;
    max-width: 44rem;
  }
}

.error-intro {
  display: flex;
  align-content: center;
  height: 100vh;

  .not-found {
    text-align: center;

    .face {
      font-family: serif;
      font-size: 4rem;
      font-weight: 500;
      @media (min-width: $md) {
        font-size: 6rem;
      }

      span {
        font-family: "Assistant", sans-serif;
      }

      sup {
        position: relative;
        top: 0.75rem;
        font-size: 2.5rem;

        @media (min-width: $md) {
          top: 0.875rem;
          font-size: 3rem;
        }
      }
    }

    .lead {
      max-width: 100%;
    }
  }
}

.link {
  color: var(--link-color);
  text-decoration-line: underline;
  text-decoration-skip-ink: auto;
  text-decoration-color: var(--link-underline-color);
  text-underline-offset: 0.125em;
  text-decoration-thickness: 2px;
  transition: text-decoration-color 0.15s ease;

  &:hover,
  &:focus {
    text-decoration-color: var(--link-color);
  }
}

#work {
  padding: 5rem 0 3rem;

  a {
    display: block;

    figure {
      margin-bottom: 1.5rem;
    }
  }
}

.portfolio-item {
  figure {
    &:hover .portfolio-img {
      clip-path: inset(0.5rem);
    }

    .portfolio-img {
      position: relative;
      clip-path: inset(0);
      overflow: hidden;
      transition: clip-path 300ms ease;
    }

    figcaption p {
      margin: 0;
      color: var(--color-gray);
      font-weight: 400;

      @media (min-width: $md) {
        width: 100%;
        max-width: 500px;
      }
    }
  }

  .img-container {
    position: relative;
    display: block;
    overflow: hidden;

    &::before {
      z-index: 1;
      position: absolute;
      content: "";
      width: 100%;
      height: 101%;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: var(--color-white);
      transform: scaleY(1);
      transform-origin: 100% 0%;
      transition-property: transform;
      transition-duration: 600ms;
    }

    &.aos-animate::before {
      transform: scaleY(0);
    }
  }
}

[data-aos="image-enter"] {
  overflow: hidden;
  transition: transform 1000ms ease-in-out 2000ms;
}

.post {
  padding: 1.375rem 0;
  border-bottom: 0.0625rem solid var(--color-border);
  display: block;

  p {
    margin: 0;
  }

  .post-title {
    font-size: 1.25rem;
    line-height: 1.4;

    @media (min-width: $md) {
      font-size: 1.325rem;
      line-height: 1.3;
      margin: 0 0 0.5rem;
    }
  }
}

#about .container,
#writing .container {
  border-top: 0.2rem solid var(--color-border);
  padding: 3rem 1rem;
}

footer {
  padding: 1.75rem 0 2.75rem;

  @media (min-width: $md) {
    font-size: 17px;
  }

  .grid > [class*="column-"] {
    padding: 0.25rem 1rem;
  }

  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  span {
    color: var(--color-black);
    font-weight: 600;
  }

  #copyright {
    @media (min-width: $md) {
      display: flex;
      justify-content: flex-end;
    }
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--color-dark-body);
    color: var(--color-dark-text);
  }

  h1,
  h2,
  h3 {
    color: var(--color-light-pink);
  }

  nav {
    ul li a {
      color: var(--color-dark-nav-link);

      &:hover,
      &:focus {
        color: var(--color-light-pink);
      }
    }

    span {
      color: var(--color-light-pink);
    }
  }

  .link {
    color: var(--link-dark-color);
    text-decoration-color: var(--link-underline-dark-color);

    &:hover,
    &:focus {
      text-decoration-color: var(--link-dark-color);
    }
  }

  .portfolio-item figure {
    figcaption p {
      color: var(--color-dark-text);
    }

    .img-container::before {
      background: var(--color-dark-body);
    }
  }

  #about .container,
  #writing .container {
    border-top: 0.2rem solid var(--color-dark-border);
  }

  #articles .post {
    border-bottom: 1px solid var(--color-dark-border);
  }

  footer span {
    color: var(--color-light-pink);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .portfolio-item .img-container.aos-animate::before {
    transform: scaleY(0) !important;
    transition: none !important;
  }
}
