/* Navbar */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space--4) var(--site--margin);
  position: sticky;
  top: 0;
  background: var(--color--bg-primary);
  height: var(--nav-height);
  z-index: 2;
}

.logo-link {
  font-size: var(--font-size--text-large);
  font-weight: 600;
  z-index: 2;

  &::after {
    overflow: hidden;
    display: inline-block;
    vertical-align: bottom;
    content: "...";
    width: auto;
  }
  &:hover {
    &::after {
      animation: ellipsis steps(4, end) 1500ms infinite;
      content: "...";
      /* ascii code for the ellipsis character */
      width: 0px;
    }
  }
}

@keyframes ellipsis {
  to {
    width: 1.125rem;
  }
}

/* Hidden checkbox for menu toggle */
.menu-toggle {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  visibility: hidden;
  -webkit-appearance: none;
  appearance: none;
}

/* Burger button - only visible on mobile */
.burger-button {
  display: none;
  flex-direction: column;
  gap: 0.375rem;
  cursor: pointer;
  z-index: 102;
  padding: 0.5rem;
  margin: -0.5rem;
  transition: transform 300ms ease;
}

.burger-line {
  width: 1.5rem;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 300ms ease;
  transform-origin: center;
}

/* Animate burger to X when menu is open */
.menu-toggle:checked ~ .burger-button .burger-line:nth-child(1) {
  transform: translateY(0.5rem) rotate(45deg);
}

.menu-toggle:checked ~ .burger-button .burger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.menu-toggle:checked ~ .burger-button .burger-line:nth-child(3) {
  transform: translateY(-0.5rem) rotate(-45deg);
}

/* Navigation */
.nav {
  position: relative;
}

.nav-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}

.nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: 300ms background ease;

  &:hover {
    background: #fafafa;
  }
}

/* Mobile styles */
@media (max-width: 767px) {
  .burger-button {
    display: flex;
  }

  .nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    background: var(--color--bg-primary);
    transform: translateX(100%);
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
  }
  body:has(.menu-toggle:checked) {
    overflow: hidden;
  }

  .menu-toggle:checked ~ .nav {
    transform: translateX(0);
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: calc(var(--nav-height) + var(--space--4)) var(--site--margin) var(--space--6);
    height: 100%;
    justify-content: flex-start;
  }

  .nav-list li {
    opacity: 0;
    transform: translateX(2rem);
    animation: slideIn 300ms ease forwards;
  
  }

  .menu-toggle:checked ~ .nav .nav-list li {
    opacity: 1;
    transform: translateX(0);
  }

  .menu-toggle:checked ~ .nav .nav-list li:nth-child(1) { animation-delay: 100ms; }
  .menu-toggle:checked ~ .nav .nav-list li:nth-child(2) { animation-delay: 150ms; }
  .menu-toggle:checked ~ .nav .nav-list li:nth-child(3) { animation-delay: 200ms; }
  .menu-toggle:checked ~ .nav .nav-list li:nth-child(4) { animation-delay: 250ms; }
  .menu-toggle:checked ~ .nav .nav-list li:nth-child(5) { animation-delay: 300ms; }
  .menu-toggle:checked ~ .nav .nav-list li:nth-child(6) { animation-delay: 350ms; }

  .nav a {
    display: block;
    padding: 1rem 0rem;
    font-size: var(--font-size--h3);
    border-radius: 0.5rem;
  }
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Desktop styles - ensure burger is hidden */
@media (min-width: 768px) {
  .burger-button {
    display: none;
  }

  .nav {
    position: static;
    transform: none;
  }

  .nav-list {
    opacity: 1;
    transform: none;
  }

  .nav-list li {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

/* Recipe lists*/
.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(80vw, 9rem), 1fr));
  gap: var(--space--8) var(--space--6);

  @media (min-width: 768px) {
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    grid-template-rows: 1fr;
  }
}

/* Special styles for the home page */
.home .recipe-list {
  @media (max-width: 767px) {
    overflow-x: scroll;
    padding: var(--site--margin);
    margin-inline: calc(var(--site--margin) * -1);
    width: 100vw;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    scrollbar-width: none; /* Firefox */
  }
  @media (min-width: 768px) {
    grid-auto-rows: 0px;
    overflow: hidden;
  }
}
.home .recipe-list_item {
  @media (max-width: 767px) {
    scroll-snap-align: center;
  }
}
/* Item Styles*/
.recipe-list_item {
  font-size: var(--font-size--text-large);

  picture {
    aspect-ratio: 4/5;
    background: #fafafa;
    width: 100%;
    overflow: hidden;
    margin-bottom: var(--space--4);
  }
  img {
    transition: scale 300ms cubic-bezier(0.45, 0, 0.55, 1);
    aspect-ratio: 4/5;
    width: 100%;
    height: 100%;
  }
  &:hover {
    text-decoration: underline;
    img {
      scale: 1.05;
    }
  }
}

/* Category styles*/

.category_h1 {
  margin-bottom: var(--size--8rem);
  view-transition-name: heading;
}

.category_list-wrap {
  margin-bottom: var(--size--8rem);
}

.category_h2 {
  font-size: var(--font-size--h3);
  margin-bottom: var(--space--6);
  view-transition-name: heading;
  &:hover {
    text-decoration: underline;
  }
  /* &:hover ::after {
    content: "→";
  } */
}

@view-transition {
  heading: auto;
}

::view-transition-old(heading),
::view-transition-new(heading) {
  animation-duration: 0.5s;
}
