html,
body {
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

body {
  background-color: black;
}

:root {
  --font-mono:
    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  --padding: 24px;
  --font-size: 0.9rem;
}

html,
body {
  font-family: var(--font-mono);
  margin: 0;
}

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

  &:visited {
    color: white;
  }
}

button,
input,
select,
textarea,
pre,
code,
p,
span {
  font-family: inherit;
}

/* === Header + Menu === */
.site-nav {
  position: fixed;
  inset: 0 auto auto 0;
  right: 0;
  height: 56px;
  max-width: 1440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  z-index: 20;
  backdrop-filter: blur(10px);
  margin: auto;

  .nav-left {
    justify-self: start;

    a {
      padding: 6px calc(var(--padding) - 4px);
    }
  }

  .nav-right {
    justify-self: end;

    button {
      color: white;
      padding: 6px calc(var(--padding) - 4px);
    }
  }

  .home-link,
  .menuToggle {
    font: inherit;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: none;
    border: 0;
    cursor: pointer;
  }
}

/* Backdrop */
.menu-overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 10;
}

/* Bottom sheet */
.menu-overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: 100%;
  height: 50vh;
  z-index: 11;
  background: black;
  border-top: 1px solid #e5e5e5;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
  transition: top 0.5s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;

  .overlay-grid {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: 50vh;

    .overlay-left {
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;
    }

    .overlay-left,
    .overlay-right {
      font-size: var(--font-size);
      line-height: 1.5;

      img {
        max-height: 95%;
        max-width: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
      }

      p {
        margin: 0 0 12px;
        color: white;
      }

      ul {
        margin: 0 0 12px 1.2em;
      }

      a {
        text-decoration: none;
        color: white;
      }
    }
  }
}

/* Open state */
body.menu-open {
  overflow: hidden;
  touch-action: none;

  .menu-overlay {
    top: 50%;
  }

  .menu-overlay-bg {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Shuffle */
.shuffle-on {
  transition: opacity 0.12s;
  opacity: 0.6;
}

/* === Home page projects === */
.home-page {
  margin: 100px auto 50px;
  color: white;
  max-width: 1440px;
  min-height: 100dvh;

  .project-list {
    padding: 0 var(--padding);
    list-style: none;
    margin-bottom: 50px;

    .project-item {
      position: relative;
      opacity: 0;
      transition: opacity 0.4s ease;

      &.visible {
        opacity: 1;
      }

      &:hover {
        background-color: rgba(0, 0, 0, 0.8);
        box-shadow:
          inset 0 1px 0 white,
          inset 0 -1px 0 white;
      }

      .project-link {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        padding: 8px 0;
        align-items: center;
        width: 100%;
        text-decoration: none;

        .left {
          width: 100%;
          display: flex;

          .inner {
            width: 91%;
            display: flex;
            flex-wrap: wrap;
            gap: 16px;

            span {
              width: calc(33.33333% - 16px);
            }
          }

          .project-year {
            text-align: right;
            width: 9%;
          }
        }

        .right {
          display: none;
        }
      }
    }
  }

  .contact {
    margin: auto;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 30px;

    a {
      color: white;
      background-color: black;
      transition:
        background-color 200ms ease-in-out,
        color 200ms ease-in-out;

      &:hover {
        color: black;
        background-color: white;
      }
    }
  }
}

/* Hover background */
.project-background {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 60vw;
  height: 60vh;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

/* === Project === */
.project-page {
  margin: auto;
  color: white;
  max-width: 1440px;
  height: 100dvh;

  /* DESKTOP */
  display: grid;
  grid-template-rows: 4fr 1fr;
  overflow: hidden;

  /* -----------------------------
     TOP 4/5 — SLIDESHOW
  ----------------------------- */

  .project-hero {
    position: relative;
    display: grid;
    place-items: center;

    width: 100%;
    height: 100%;
    min-height: 0;

    .project-prev,
    .project-next {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);

      z-index: 10;

      background: none;
      border: none;
      padding: 0;

      color: white;
      font: inherit;

      cursor: pointer;
    }

    .project-prev {
      left: var(--padding);
    }

    .project-next {
      right: var(--padding);
    }

    .project-swiper {
      width: 100%;
      height: 100%;
      max-width: 80%;
      max-height: 60dvh;

      .swiper-slide {
        align-content: center;
      }

      img {
        max-width: 100%;
        max-height: 60dvh;
        margin: auto;
        height: auto;
        display: block;
      }

      video {
        max-width: 100%;
        max-height: 60dvh;
        margin: auto;
        display: block;
      }
    }

    .slide-counter {
      position: absolute;
      bottom: 2rem;
      left: var(--padding);
      text-transform: uppercase;
    }

    /* No scroll-to-details button on desktop */
    .scroll-details {
      display: none;
    }
  }

  /* -----------------------------
     BOTTOM 1/5 — DETAILS
  ----------------------------- */

  .project-details {
    position: relative;

    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 2rem;

    width: 100%;
    height: 100%;

    padding: 24px;
    box-sizing: border-box;

    align-items: start;

    .about,
    .details {
      padding: 0;
      height: auto;

      a {
        color: white;
        background-color: black;
        transition: 0.5s;

        &:hover {
          background-color: white;
          color: black;
        }
      }

      p {
        margin: 0;
        line-height: 130%;
      }
    }

    .return {
      justify-self: end;
      align-self: end;
      width: fit-content;
      text-align: right;
      display: inline-block;
      margin-right: -35px;

      color: white;
      background-color: black;
      transition: 0.5s;

      &:hover {
        background-color: white;
        color: black;
      }
    }
  }
}

/* --------------------------------
   MOBILE
-------------------------------- */

@media (max-width: 767px) {
  .project-page {
    display: block;

    height: 100dvh;
    overflow-y: auto;

    scroll-snap-type: y mandatory;

    scrollbar-width: none;
    -ms-overflow-style: none;

    &::-webkit-scrollbar {
      display: none;
    }

    .section {
      height: 100dvh;
      scroll-snap-align: start;
    }

    /* -----------------------------
       MOBILE SLIDESHOW
    ----------------------------- */

    .project-hero {
      position: relative;
      display: grid;
      place-items: center;

      width: 100%;
      height: 100dvh;

      .project-swiper {
        width: 100%;
        height: 100%;
        max-width: 80%;
        max-height: 60dvh;

        .swiper-slide {
          align-content: center;
        }

        img {
          max-width: 100%;
          max-height: 60dvh;
          margin: auto;
          height: auto;
          display: block;
        }

        video {
          max-width: 100%;
          max-height: 60dvh;
          display: block;
          margin: auto;
        }
      }

      .slide-counter {
        position: absolute;
        bottom: 2rem;
        left: var(--padding);
        text-transform: uppercase;
      }

      .scroll-details {
        display: block;

        position: absolute;
        bottom: 2rem;
        left: 50%;
        transform: translateX(-50%);

        background: none;
        border: none;
        cursor: pointer;
        color: white;
      }
    }

    /* -----------------------------
       MOBILE DETAILS
    ----------------------------- */

    .project-details {
      display: grid;
      grid-template-columns: 1fr;
      grid-template-rows: auto 1fr auto;

      gap: 1.5rem;

      width: calc(100% - 48px);
      height: 100dvh;

      padding: 0 24px;

      .details {
        order: 1;
        padding-top: 80px;
        height: fit-content;
      }

      .about {
        order: 2;
        padding-top: 0;
        height: auto;
      }

      .return {
        order: 3;

        align-self: end;

        margin-bottom: 50px;

        text-align: center;
        white-space: normal;
      }
    }
  }
}
/* === Recipes page === */
.recipes-page {
  margin: 100px auto;
  color: white;
  max-width: 1440px;

  .recipe-grid,
  .selected-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .recipe-card {
    padding: 16px;
    border: 1px solid transparent;
    cursor: pointer;
  }

  .recipe-card.selected {
    border: 1px solid #fff;
  }

  #selected-recipes {
    margin-bottom: 40px;
  }

  .selected-recipes {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition:
      max-height 2s ease,
      opacity 1s ease,
      padding 1s ease;
  }

  .selected-recipes.is-visible {
    max-height: 1000px;
    opacity: 1;
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .email-controls {
    display: flex;
    gap: 16px;
  }

  .recipient,
  .send-email {
    cursor: pointer;
    border: 1px solid transparent;
    padding: 4px 8px;
  }

  .recipient.selected {
    border: 1px solid #fff;
  }

  .send-email {
    text-decoration: underline;
  }

  .recipe-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding: 10px 0;
    border-bottom: solid 1px white;
  }

  .filter-tag {
    cursor: pointer;
    border: 1px solid transparent;
    padding: 4px 8px;
  }

  .filter-tag.selected {
    border: 1px solid #fff;
  }
}

/* === Single recipe page === */

.single-recipe-page {
  margin: 100px auto;
  color: white;
  max-width: 1440px;
}

.maintenance {
  margin: 100px auto;
  color: white;
  max-width: 1440px;
}

/* === inactivity page === */
#inactivity-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;

  display: grid;
  align-items: start;
  justify-items: start;

  .inactivity-content {
    padding: 2rem;
    color: white;
    max-width: 400px;

    img {
      max-width: 100%;
      margin-bottom: 1rem;
      display: block;
    }

    .clock {
      margin-top: 1rem;
      font-size: var(--font-size);
      opacity: 0.7;
    }
  }
}

/* === Library page === */
.library-page {
  margin: 100px auto;
  color: white;
  max-width: 1440px;

  .library {
    max-width: 1440px;
    margin: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 6px;
    padding: 40px 24px;
    padding-bottom: 0;
  }

  .book-spine {
    width: var(--spine-width);
    height: var(--spine-height);
    background: transparent;
    border: 1px solid white;
    color: white;

    display: flex;
    align-items: center;
    justify-content: center;

    writing-mode: vertical-rl;
    text-orientation: mixed;

    font-size: 12px;
    cursor: pointer;

    overflow: hidden;
    transform: translateY(0);
    transition: transform 150ms ease;
    position: relative;

    .spine-text {
      max-height: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      color: white;
    }
  }

  .book-spine:hover {
    transform: translateY(-12px);
  }

  .shelf-label {
    max-width: 1440px;
    margin: 0 auto 0;
    padding: 12px 24px;
    border: 2px solid white;
    text-transform: uppercase;
    color: white;
  }
}

/* ========================== */
/* ========= Mobile ========= */
/* ========================== */

@media screen and (max-width: 849px) {
  .menu-overlay {
    height: 93dvh;

    .overlay-grid {
      display: flex;
      flex-wrap: wrap;
      height: 93dvh;
      height: auto;
      width: 100vw;

      .overlay-right {
        order: 1;
        width: 100%;
        height: 63dvh;
      }

      .overlay-left {
        order: 2;
        width: 100%;
        height: 26dvh;
        margin: auto;
      }
    }
  }

  body.menu-open {
    .menu-overlay {
      top: 7%;
    }
  }

  .home-page {
    margin-bottom: 50px;

    .projects .project-list .project-link {
      gap: 0;
      box-shadow:
        inset 0 1px 0 white,
        inset 0 -1px 0 white;

      .left {
        width: 80%;
        display: inline-block;
        gap: 0px;

        .inner {
          display: inline-block;
          gap: 0;

          span {
            width: 100%;
          }

          .project-client {
            display: block;
          }
        }
        .project-year {
          text-align: left;
          width: 100%;
          display: inline-block;
        }
      }
      .right {
        display: block;
        width: 20%;

        img {
          width: 100%;
          height: 80px;
          object-fit: contain;
        }
      }
    }
  }

  @media (max-width: 767px) {
    .project-page {
      display: block;

      height: 100dvh;
      overflow-y: auto;

      scroll-snap-type: y mandatory;

      scrollbar-width: none;
      -ms-overflow-style: none;

      &::-webkit-scrollbar {
        display: none;
      }

      .section {
        height: 100dvh;
        scroll-snap-align: start;
      }

      /* -----------------------------
       MOBILE SLIDESHOW
    ----------------------------- */

      .project-hero {
        position: relative;
        display: grid;
        place-items: center;

        width: 100%;
        height: 100dvh;

        .project-swiper {
          height: 100%;
          max-width: 80%;
          max-height: 60dvh;

          .swiper-slide {
            align-content: center;
          }

          img {
            max-width: 100%;
            max-height: 60dvh;
            margin: auto;
            height: auto;
            display: block;
          }

          video {
            max-width: 100%;
            max-height: 60dvh;
            display: block;
            margin: auto;
          }
        }

        .slide-counter {
          position: absolute;
          bottom: 2rem;
          left: var(--padding);
        }

        .scroll-details {
          display: block;

          position: absolute;
          bottom: 2rem;
          left: 50%;
          transform: translateX(-50%);

          background: none;
          border: none;
          cursor: pointer;
          color: white;
        }
      }

      /* -----------------------------
       MOBILE DETAILS
    ----------------------------- */

      .project-details {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;

        gap: 1.5rem;

        width: calc(100% - 48px);
        height: 100dvh;

        padding: 0 24px;

        overflow: visible;

        .details {
          order: 1;
          padding-top: 80px;
          height: fit-content;
        }

        .about {
          order: 2;
          padding-top: 0;
          height: auto;
        }

        .return {
          order: 3;

          align-self: end;
          margin-top: 0;
          margin-bottom: 50px;

          text-align: center;
        }
      }
    }
  }
}
