.planner-stack {
  box-shadow: 0 4px 8px -2px rgba(0, 0, 0, 0.15), 0 1px 0 0 rgba(0, 0, 0, 0.06);
  position: relative;
  max-width: 100ch;
  margin: 0 auto;
}

:root {
  --z-5: 5;
}

.planner-headers {
  display: grid;
  grid-template-columns: minmax(70px, 8%) repeat(
      var(--planner-columns, 2),
      minmax(calc((100ch - 70px) / var(--planner-columns, 2)), 1fr)
    );
  position: sticky;
  top: 70px;
  z-index: 100;
  background: #fffdf7;
  border-radius: 6px 6px 0 0;
  margin: 0 auto;
  max-width: 100ch;
  overflow: hidden;

  .header {
    color: rgb(112, 57, 26);
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    justify-content: center;
    padding: 1em 0.25em;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(112, 57, 26, 0.07);

    a {
      font-size: 0.85rem;
    }
  }
}

.planner-wrapper {
  background: #fffdf7;
  border-radius: 0 0 6px 6px;
  padding: 0 0 2em 0;
  overflow-x: auto;
}

.planner-wrapper-1 {
  transform: rotate(0deg);
}

.planner {
  display: grid;
  min-width: fit-content;

  /* Day column + X columns with minimum widths */
  grid-template-columns: minmax(70px, 8%) repeat(
      var(--planner-columns, 2),
      minmax(calc((100ch - 70px) / var(--planner-columns, 2)), 1fr)
    );

  grid-auto-rows: minmax(6em, auto);

  /* Rows containing day-row elements should be smaller */
  &:has(.day-row) {
    grid-auto-rows: auto;
  }

  .day-row {
    height: 3.25em;
  }

  /* Regular day cells maintain minimum height */
  .day-cell {
    min-height: 6em;
  }

  > div {
    align-items: center;
    border-bottom: 1px solid rgba(112, 57, 26, 0.07);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.5em 1em;
  }

  .day {
    align-items: center;
    background: #fffdf7;
    color: rgb(112, 57, 26);
    font-family: "Bricolage Grotesque", sans-serif;
    justify-content: center;
    font-size: 2rem;
    font-weight: 100;
    text-align: center;
    padding: 0.5em 0.1em;
    position: sticky;
    left: 0;
    z-index: 50;

    /* Value should match that of the fixed headers to ensure
    day is at top of scroll view */
    scroll-margin-top: 135px;

    .day-name {
      font-size: 0.375em;
      font-weight: 100;
    }

    .day--add-item {
      font-size: 2rem;
      height: 1em;
      padding: 0;
      position: absolute;

      &:hover {
        background-color: rgb(247 246 245);
        color: rgb(112 57 26);
        font-weight: 400;
      }
    }
  }

  .day--add-item {
    align-items: center;
    background: transparent;
    border: none;
    color: transparent;
    cursor: pointer;
    display: flex;
    height: 3rem;
    font-size: 3rem;
    justify-content: center;
    padding: 0 0 0.15em 0;
    text-decoration: none;
    transform: rotate(-0.5deg);
    width: 90%;

    &:hover {
      background-color: rgba(241, 241, 241, 0.56);
      border: 3px dashed rgb(223, 223, 223);
      border-radius: 6px;
      color: rgb(223, 223, 223);
    }
  }

  .day--weekend,
  .day-cell.day--weekend {
    background-color: rgb(247, 246, 245);
    border: none;
  }

  .day--today {
    font-weight: 900;
  }

  .day-row {
    border: none;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.5em;
    padding: 0 0.5em;
    position: relative;

    .day--item-container {
      min-width: 0;
    }
  }

  .day-cell {
    --day-item-z: var(--z-5);

    position: relative;

    &:hover .day--item-stack {
      align-items: center;
      background-color: rgb(247 246 245);
      border-radius: 20px;
      box-shadow: 0 0 12px 0px rgba(160, 141, 122, 0.3);
      display: flex;
      flex-direction: column;
      gap: 0.5em;
      opacity: 1;
      padding: 1.15em 1em;
      position: absolute;
      z-index: 100;

      > * {
        position: initial;
        transform: none !important;
        width: 100%;
      }

      .day--add-item {
        background-color: rgba(241, 241, 241, 0.56);
        border: 3px dashed rgb(223, 223, 223);
        border-radius: 6px;
        color: rgb(223, 223, 223);

        &:hover {
          background-color: rgb(238, 238, 238);
          border-color: rgb(197, 197, 197);
          color: rgb(197, 197, 197);
        }
      }
    }
  }

  .day--item-stack {
    position: relative;
    min-height: 5em;
    width: 100%;

    .day--item-container {
      height: 100%;
      position: absolute;
      width: 100%;
    }
  }

  .day-cell:not(:hover) .day--item-stack .day--item-container {
    &:nth-child(1) {
      --day-item-z: 10;
      transform: rotate(0.8deg);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    &:nth-child(2) {
      --day-item-z: 8;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
      top: 0.85em;
      transform: rotate(-3deg) translateX(4px) translateY(-12px);
    }

    &:nth-child(3) {
      --day-item-z: 6;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
      top: 1.25em;
      transform: rotate(1deg) translateX(1px) translateY(-12px);
    }

    &:nth-child(4) {
      --day-item-z: 4;
      top: 1.75em;
      transform: rotate(-1deg) translateX(9px) translateY(-20px);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    &:nth-child(n + 5) {
      --day-item-z: 0;
      top: 5em;
      transform: rotate(0.2deg);
      opacity: 0.85;
    }
  }

  .day--item-container {
    background-color: var(--container-bg-color, rgb(182, 218, 249));
    border-radius: 14px;
    left: 0;
    opacity 0.3s ease;
    padding: 0.45em 0.6em 0.65em;
    right: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease, top 0.3s ease;
    z-index: var(--day-item-z, 10);

    &:hover {
      transform: translateY(-2px);
    }

    &.day--item-past {
      --day-item-z: 1;
      filter: grayscale(0.75) brightness(0.975);
    }

    &.day--item-all {
      border-radius: 8px;
      padding: 0;

      &.day--item-past {
        filter: grayscale(0.75) brightness(0.975);
      }

      .day--item {
        align-items: center;
        border-radius: 6px;
        flex-direction: row-reverse;
        gap: 0.5em;
        justify-content: flex-end;
        transform: rotate(0.1deg);
      }
    }
  }

  .day--item {
    background-color: var(--item-bg-color, #f0f8ff);
    border-radius: 10px;
    box-shadow: 0 3px 0 0 rgba(0, 0, 0, 0.25);
    color: inherit;
    display: flex;
    flex-direction: column;
    font-weight: bold;
    padding: 0.5em 0.75em;
    position: relative;
    text-decoration: none;
    transform: rotate(-1deg);
    z-index: 1;

    .row {
      align-items: center;
      display: flex;
      justify-content: space-between;
    }

    &:hover .day--item-action {
      display: flex;
    }
  }

  .day--item-sticky {
    position: absolute;
    right: -32px;
    top: 10%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    z-index: 2;
  }

  .day--item-sticky-only {
    background-color: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;

    &:hover {
      transform: none;
    }

    .day--item {
      background-color: transparent;
      box-shadow: none;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transform: none;
    }
  }

  .day--item-sticky-standalone {
    width: 80px;
    height: 80px;
    display: block;
    transition: transform 0.2s;
    transform: scale(1.75);

    &:hover {
      transform: scale(1.5) rotate(5deg);
    }
  }

  .day--item-title {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .day--item-action {
    display: none;
    font-family: "Inter";
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;

    &:hover {
      opacity: 0.8;
    }
  }

  .day--item-time {
    font-family: "Inter", sans-serif;
    font-weight: 300;
  }

  .day--item-duration {
    font-size: 0.875em;
  }

  .option-day-item {
    --container-bg-color: transparent;
    --item-bg-color: rgb(255 249 239);
  }

  .option-f0f8ff {
    --container-bg-color: rgb(182, 218, 249);
    --item-bg-color: #f0f8ff;
  }

  .option-f7f5ff {
    --container-bg-color: rgba(181, 193, 242, 0.58);
    --item-bg-color: #f7f5ff;
  }

  .option-f5fff7 {
    --container-bg-color: rgba(181, 242, 199, 0.58);
    --item-bg-color: #f5fff7;
  }

  .option-fff5f5 {
    --container-bg-color: rgba(242, 192, 181, 0.58);
    --item-bg-color: #fff5f5;
  }

  .option-f5f5f5 {
    --container-bg-color: rgba(205, 205, 205, 0.58);
    --item-bg-color: #f5f5f5;
  }
}
