.custom-cart-drawer {
  --custom-cart-drawer-green: #4cdc26;
  --custom-cart-drawer-green-hover: #5AED31;
  --custom-cart-drawer-border: #c9eec0;
  --custom-cart-drawer-hover-background: rgb(76 220 38 / 10%);
  --custom-cart-drawer-input-border: #c6e9bd;
  --custom-cart-drawer-text: #10141b;
  --custom-cart-drawer-muted: #606060;
  --custom-cart-drawer-radius: 99px;

  background: transparent;
  border: 0;
  box-sizing: border-box;
  color: var(--custom-cart-drawer-text);
  height: 100%;
  inset: 0;
  margin: 0;
  max-height: none;
  max-width: none;
  overflow: visible;
  padding: 0;
  position: fixed;
  width: 100%;
  z-index: 999999;

  &::backdrop {
    background: rgba(0, 0, 0, 0.2);
  }

  &.is-visible .custom-cart-drawer__panel {
    transform: translate3d(0, 0, 0);
  }

  .custom-cart-drawer__panel {
    background: #fff;
    bottom: 0;
    box-sizing: border-box;
    box-shadow: -2px 0 8px rgb(0 0 0 / 12%);
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    max-width: 100vw;
    position: absolute;
    right: 0;
    top: 0;
    transform: translate3d(100%, 0, 0);
    transition: transform 0.3s ease;
    width: min(400px, 100vw);
  }

  .custom-cart-drawer__header {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 20px 15px;

    .custom-cart-drawer__header-row {
      align-items: center;
      display: flex;
      justify-content: space-between;
      width: 100%;
    }
  }

  .custom-cart-drawer__title {
    font-size: 16px;
    line-height: 1.2;
    margin: 0;

    .custom-cart-drawer__title-loader {
      animation: custom-cart-drawer-title-spin 0.7s linear infinite;
      border: 2px solid rgb(16 20 27 / 24%);
      border-radius: 50%;
      border-top-color: currentColor;
      display: none;
      height: 16px;
      margin-left: 8px;
      vertical-align: -2px;
      width: 16px;
    }
  }

  .custom-cart-drawer__close,
  .custom-cart-drawer__remove {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    transition:
      color 0.3s ease,
      background-color 0.3s ease;

    & svg {
      color: var(--custom-cart-drawer-text);
      display: block;
      height: 18px;
      width: 18px;
    }
  }

  .custom-cart-drawer__remove {
    box-sizing: border-box;
    height: 26px;
    min-height: 26px;
    min-width: 26px;
    position: relative;
    width: 26px;

    &[aria-busy='true'] {
      cursor: wait;
      pointer-events: none;

      &::after {
        animation: custom-cart-drawer-remove-spin 0.7s linear infinite;
        border: 2px solid rgb(16 20 27 / 24%);
        border-radius: 50%;
        border-top-color: currentColor;
        content: '';
        height: 14px;
        left: 50%;
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 14px;
      }

      & svg {
        visibility: hidden;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      &[aria-busy='true']::after {
        animation: none;
      }
    }
  }

  .custom-cart-drawer__reservation {
    border: 1px solid #222;
    font-size: 16px;
    margin: 12px 0 0;
    padding: 12px;
    text-align: center;
    width: 100%;
  }

  .custom-cart-drawer__shipping-container {
    align-self: stretch;
    width: 100%;
  }

  .custom-cart-drawer__shipping {
    box-sizing: border-box;
    padding: 12px 0 8px;
    text-align: center;
    width: 100%;

    & p {
      font-size: 16px;
      margin: 0 0 10px;
    }

    .custom-cart-drawer__shipping-track {
      background: #ececec;
      border-radius: var(--custom-cart-drawer-radius);
      display: block;
      height: 7px;
      position: relative;
    }

    .custom-cart-drawer__shipping-fill {
      background: var(--custom-cart-drawer-green);
      border-radius: inherit;
      display: block;
      height: 100%;
      transition: width 0.2s ease;
      width: var(--custom-cart-drawer-shipping-progress);
    }

    .custom-cart-drawer__shipping-icon {
      align-items: center;
      background: #fff;
      border-radius: 50%;
      box-sizing: border-box;
      box-shadow: 0 1px 4px rgb(0 0 0 / 14%);
      color: var(--custom-cart-drawer-green);
      display: flex;
      height: 24px;
      justify-content: center;
      left: clamp(12px, var(--custom-cart-drawer-shipping-progress), calc(100% - 12px));
      position: absolute;
      top: 50%;
      transition: left 0.2s ease;
      transform: translate(-50%, -50%);
      width: 24px;

      & svg {
        color: var(--custom-cart-drawer-green);
        display: block;
        height: 16px;
        width: 16px;
      }
    }

    &.custom-cart-drawer__shipping--unlocked {
      & .custom-cart-drawer__shipping-track,
      & .custom-cart-drawer__shipping-fill {
        background: var(--custom-cart-drawer-green);
      }

      & .custom-cart-drawer__shipping-icon {
        background: var(--custom-cart-drawer-green);
        color: #fff;

        & svg {
          color: #fff;
        }
      }
    }
  }

  .custom-cart-drawer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .custom-cart-drawer__error {
    color: #c01616;
    font-size: 14px;
    min-height: 0;
    padding: 0 20px;
  }

  .custom-cart-drawer__items {
    padding: 0 20px 12px;
  }

  .custom-cart-drawer__item {
    display: grid;
    gap: 10px;
    grid-template-columns: 100px 1fr;
    padding: 0 0 14px;
  }

  .custom-cart-drawer__item:last-child {
    padding-bottom: 0;
  }

  .custom-cart-drawer__image {
    align-self: center;
    display: block;
    transition: opacity 0.3s ease;

    & img {
      display: block;
      height: auto;
      width: 100%;
    }
  }

  .custom-cart-drawer__item-details {
    min-width: 0;
  }

  .custom-cart-drawer__item-topline,
  .custom-cart-drawer__item-bottomline,
  .custom-cart-drawer__total,
  .custom-cart-drawer__shipping-summary,
  .custom-cart-drawer__discount-summary {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
  }

  .custom-cart-drawer__item-title,
  .custom-cart-drawer__accessory-title {
    color: #000;
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.3s ease;
  }

  .custom-cart-drawer__variant,
  .custom-cart-drawer__property {
    color: var(--custom-cart-drawer-muted);
    font-size: 13px;
    margin: 4px 0 0;
  }

  .custom-cart-drawer__discount-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 0;
  }

  .custom-cart-drawer__discount-pill {
    align-items: center;
    background: #4cdc2657;
    border-radius: var(--custom-cart-drawer-radius);
    color: var(--custom-cart-drawer-text);
    display: inline-flex;
    font-size: 12px;
    gap: 5px;
    line-height: 1.2;
    max-width: 100%;
    min-height: 26px;
    min-width: 0;
    padding: 5px 9px;

    & svg {
      color: var(--custom-cart-drawer-text);
      display: block;
      flex: 0 0 20px;
      height: 20px;
      width: 20px;
    }

    & > span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .custom-cart-drawer__item-bottomline {
    margin-top: 10px;
  }

  .custom-cart-drawer__quantity {
    align-items: center;
    border: 1px solid #bdeab1;
    border-radius: var(--custom-cart-drawer-radius);
    display: inline-flex;
    overflow: hidden;
    min-width: 92px;
    min-height: 36px;

    .custom-cart-drawer__quantity-button {
      align-items: center;
      background: transparent;
      border: 0;
      color: var(--custom-cart-drawer-text);
      cursor: pointer;
      display: inline-flex;
      height: 30px;
      justify-content: center;
      line-height: 1;
      padding: 0;
      width: 30px;
      padding: 5px;
      flex: 0 0 30px;
      transition: color 0.3s ease;

      .custom-cart-drawer__quantity-button svg {
        color: var(--custom-cart-drawer-text);
        display: block;
        height: 100%;
        width: 100%;
      }
    }

    .custom-cart-drawer__quantity-input {
      align-items: center;
      appearance: textfield;
      background: transparent;
      border: 1px solid transparent;
      border-radius: 12px;
      box-sizing: border-box;
      color: var(--custom-cart-drawer-text);
      display: inline-flex;
      font-size: 14px;
      height: 24px;
      justify-content: center;
      line-height: 1;
      min-width: 0;
      padding: 0 2px;
      text-align: center;
      flex: 1 1 0;
      width: 0;
      transition: border-color 0.3s ease;

      &:focus {
        border-color: var(--custom-cart-drawer-green);
        box-shadow: 0 0 0 1px var(--custom-cart-drawer-green);
        outline: none;
      }

      &:disabled {
        cursor: wait;
      }
    }
  }

  .custom-cart-drawer__quantity-input::-webkit-inner-spin-button,
  .custom-cart-drawer__quantity-input::-webkit-outer-spin-button {
    appearance: none;
    margin: 0;
  }

  .custom-cart-drawer__price {
    column-gap: 4px;
    display: grid;
    font-size: 14px;
    grid-template-columns: max-content max-content;
    margin: 0;
    row-gap: 2px;
    text-align: right;

    & s {
      color: #666;
    }

    & strong {
      font-weight: 700;
    }
  }

  .custom-cart-drawer__savings {
    color: #f00;
    font-size: 12px;
    grid-column: 1 / -1;
    line-height: 1.35;
  }

  .custom-cart-drawer__accessories {
    border-top: 1px solid #ececec;
    margin-top: 6px;
    padding: 18px 0 20px;
    transition:
      opacity 0.28s ease,
      transform 0.28s ease;

    &.custom-cart-drawer__accessories--entering {
      opacity: 0;
      transform: translateY(16px);
    }

    &.custom-cart-drawer__accessories--visible {
      opacity: 1;
      transform: translateY(0);
    }

    & h3 {
      font-size: 16px;
      margin: 0 20px 10px;
    }
  }

  .custom-cart-drawer__accessories-list {
    display: grid;
    gap: 16px;
    padding: 0 20px;
  }

  .custom-cart-drawer__accessory {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 80px minmax(0, 1fr);

    .custom-cart-drawer__accessory-image {
      display: block;
      transition: opacity 0.3s ease;

      & img {
        display: block;
        height: auto;
        width: 100%;
      }
    }

    .custom-cart-accessories-heading {
      font-size: 16px;
      margin: 0 0 10px;
      font-weight: 600;
    }

    & > div {
      min-width: 0;
    }

    & p {
      font-size: 14px;
      margin: 4px 0;
    }
  }

  .custom-cart-drawer__accessory-add,
  .custom-cart-drawer__checkout,
  .custom-cart-drawer__discount-wrapper > button {
    background: var(--custom-cart-drawer-green);
    border: 0;
    border-radius: var(--custom-cart-drawer-radius);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.3s ease;
  }

  .custom-cart-drawer__accessory-add {
    min-height: 32px;
    min-width: 182px;
    position: relative;
    width: fit-content;
    font-size: 14px;
    height: 32px;

    &[aria-busy='true'] {
      color: transparent;
      cursor: wait;
      pointer-events: none;

      &::after {
        border: 2px solid rgb(255 255 255 / 45%);
        border-radius: 50%;
        border-top-color: #fff;
        content: '';
        height: 15px;
        left: 50%;
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 15px;
        animation: custom-cart-drawer-spin 0.7s linear infinite;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      &[aria-busy='true']::after {
        animation-duration: 1.4s;
      }
    }
  }

  .custom-cart-drawer__footer {
    border-top: 1px solid var(--custom-cart-drawer-border);
    color: #000;
    padding: 20px;
  }

  .custom-cart-drawer__discount {
    margin: 0 0 15px;

    .custom-cart-drawer__discount-wrapper {
      display: flex;
      gap: 10px;
    }

    & input {
      border: 1px solid var(--custom-cart-drawer-input-border);
      border-radius: var(--custom-cart-drawer-radius);
      box-sizing: border-box;
      color: var(--custom-cart-drawer-text);
      font-family: Inter, sans-serif;
      font-size: 16px;
      height: 42px;
      line-height: 19px;
      min-width: 0;
      padding: 0 10px;
      width: 100%;
      margin-block: 0;
      transition: border-color 0.3s ease;

      &::placeholder {
        color: #777;
        opacity: 1;
      }
    }

    .custom-cart-drawer__discount-wrapper > button {
      flex: 0 0 83px;
      font-family: Inter, sans-serif;
      font-size: 14px;
      height: 42px;
      min-width: 83px;
      padding: 0 12px;
    }
  }

  .custom-cart-drawer__discount-error {
    color: #000;
    font-size: 14px;
    line-height: 20px;
    margin: 0;
  }

  .custom-cart-drawer__discount-submit {
    position: relative;

    &:disabled {
      cursor: not-allowed;
      pointer-events: none;
    }

    &[aria-busy='true'] {
      cursor: wait;
      pointer-events: none;

      & .custom-cart-drawer__discount-submit-label {
        visibility: hidden;
      }

      & .custom-cart-drawer__discount-submit-loader {
        display: block;
      }
    }

    .custom-cart-drawer__discount-submit-label {
      transition: visibility 0s linear 0.1s;
    }

    .custom-cart-drawer__discount-submit-loader {
      animation: custom-cart-drawer-spin 0.7s linear infinite;
      border: 2px solid rgb(255 255 255 / 45%);
      border-radius: 50%;
      border-top-color: #fff;
      display: none;
      height: 14px;
      left: 50%;
      position: absolute;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 14px;
    }
  }

  .custom-cart-drawer__shipping-summary,
  .custom-cart-drawer__discount-summary {
    font-size: 14px;
    line-height: 17px;
    margin: 0 0 10px;
    min-height: 17px;
  }

  .custom-cart-drawer__discount-summary {
    font-size: 12px;
    line-height: 14.5px;
    min-height: 14.5px;
  }

  .custom-cart-drawer__discount-label,
  .custom-cart-drawer__shipping-summary > span:first-child {
    flex: 0 0 auto;
  }

  .custom-cart-drawer__discount-value,
  .custom-cart-drawer__shipping-summary > span:last-child {
    align-items: center;
    display: flex;
    flex: 1 1 auto;
    gap: 8px;
    min-width: 0;
    text-align: right;
  }

  .custom-cart-drawer__discount-value {
    justify-content: flex-start;
  }

  .custom-cart-drawer__shipping-summary > span:last-child {
    justify-content: flex-end;
  }

  .custom-cart-drawer__discount-pill {
    flex: 0 1 auto;
    padding: 4px 8px;
  }

  .custom-cart-drawer__discount-clear {
    align-items: center;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 20px;
    font-size: 16px;
    height: 20px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 20px;
    transition:
      color 0.3s ease,
      background-color 0.3s ease;

    & svg {
      color: var(--custom-cart-drawer-text);
      display: block;
      height: 20px;
      width: 20px;
    }
  }

  .custom-cart-drawer__discount-amount {
    color: var(--custom-cart-drawer-text);
    flex: 0 0 auto;
    font-size: 14px;
    margin-left: auto;
  }

  .custom-cart-drawer__total {
    font-size: 16px;
    line-height: 19.5px;
    margin: 15px 0 15px;
    font-weight: 700;

    & b,
    & strong {
      font-weight: 700;
    }
  }

  .custom-cart-drawer__payment-image {
    align-items: center;
    display: flex;
    justify-content: center;
    margin: 0 0 10px;
    min-height: 24px;
    overflow: hidden;
    width: 100%;

    .custom-cart-drawer__payment-image-img {
      display: block;
      height: auto;
      max-width: 100%;
      object-fit: contain;
      width: 360px;
      max-height: 24px;
    }
  }

  .custom-cart-drawer__checkout {
    box-sizing: border-box;
    font-size: 14px;
    height: 42px;
    line-height: 20px;
    min-height: 42px;
    padding: 0 16px;
    width: 100%;
    font-weight: 600;
  }

  .custom-cart-drawer__additional-checkout {
    margin: 10px 0 0;
    min-width: 0;
    overflow: hidden;

    & > div,
    & > div > div {
      background: transparent;
      margin: 0;
      min-height: 0;
      padding: 0;
      text-align: center;
    }

    & > div > div {
      width: 100%;
    }

    & ul {
      align-items: center;
      display: flex;
      flex-wrap: nowrap;
      gap: 6px;
      justify-content: center;
      margin: 0;
      min-width: 0;
      padding: 0;
    }

    & li {
      flex: 0 0 auto;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    & shopify-accelerated-checkout,
    & shopify-accelerated-checkout-cart {
      --shopify-accelerated-checkout-button-block-size: 42px !important;
      --shopify-accelerated-checkout-button-inline-size: 42px !important;
      --shopify-accelerated-checkout-button-border-radius: 999px !important;
      --shopify-accelerated-checkout-button-box-shadow: none !important;
      --shopify-accelerated-checkout-inline-alignment: space-between !important;
      --shopify-accelerated-checkout-row-gap: 8px !important;
      display: block;
      width: 100%;
    }

    & shopify-accelerated-checkout,
    & shopify-accelerated-checkout-cart {
      transition: filter 0.3s ease;
    }
  }

  .custom-cart-drawer__continue {
    background: transparent;
    border: 0;
    color: #000;
    cursor: pointer;
    display: block;
    font-family: Inter, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 17px;
    margin: 10px auto 0;
    padding: 0;
    text-decoration: underline;
    transition: color 0.3s ease;
  }

  @media (hover: hover) and (pointer: fine) {
    .custom-cart-drawer__close:hover,
    .custom-cart-drawer__discount-clear:not(:disabled):hover {
      background-color: var(--custom-cart-drawer-hover-background);
      border-radius: 50%;
    }

    .custom-cart-drawer__remove:not([aria-busy='true']):hover,
    .custom-cart-drawer__quantity-button:not(:disabled):hover {
      color: var(--custom-cart-drawer-green);
    }

    .custom-cart-drawer__remove:not([aria-busy='true']):hover svg,
    .custom-cart-drawer__quantity-button:not(:disabled):hover svg {
      color: var(--custom-cart-drawer-green);
    }

    .custom-cart-drawer__quantity-input:not(:disabled):hover:not(:focus),
    .custom-cart-drawer__discount input:hover {
      border-color: var(--custom-cart-drawer-input-border);
    }

    .custom-cart-drawer__discount-clear:not(:disabled):hover svg {
      color: var(--custom-cart-drawer-green);
    }

    .custom-cart-drawer__accessory-add:not(:disabled):not([aria-busy='true']):hover,
    .custom-cart-drawer__checkout:not(:disabled):hover,
    .custom-cart-drawer__discount-submit:not(:disabled):not([aria-busy='true']):hover {
      background-color: var(--custom-cart-drawer-green-hover);
    }

    .custom-cart-drawer__item-title:hover,
    .custom-cart-drawer__accessory-title:hover,
    .custom-cart-drawer__continue:hover,
    .custom-cart-drawer__empty-link:hover {
      color: var(--custom-cart-drawer-green);
    }

    .custom-cart-drawer__image:hover,
    .custom-cart-drawer__accessory-image:hover {
      opacity: 0.82;
    }

    .custom-cart-drawer__additional-checkout shopify-accelerated-checkout:hover,
    .custom-cart-drawer__additional-checkout shopify-accelerated-checkout-cart:hover {
      filter: brightness(0.94);
    }
  }

  &.custom-cart-drawer--loading {
    & .custom-cart-drawer__title-loader {
      display: inline-block;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .custom-cart-drawer__panel {
      transition-duration: 0.01ms;
    }

    .custom-cart-drawer__close,
    .custom-cart-drawer__remove,
    .custom-cart-drawer__quantity-button,
    .custom-cart-drawer__quantity-input,
    .custom-cart-drawer__image,
    .custom-cart-drawer__item-title,
    .custom-cart-drawer__accessory-title,
    .custom-cart-drawer__empty-link,
    .custom-cart-drawer__accessory-image,
    .custom-cart-drawer__accessory-add,
    .custom-cart-drawer__checkout,
    .custom-cart-drawer__discount input,
    .custom-cart-drawer__discount > button,
    .custom-cart-drawer__discount-clear,
    .custom-cart-drawer__continue,
    .custom-cart-drawer__additional-checkout shopify-accelerated-checkout,
    .custom-cart-drawer__additional-checkout shopify-accelerated-checkout-cart {
      transition: none;
    }

    .custom-cart-drawer__accessories {
      transition: none;

      &.custom-cart-drawer__accessories--entering,
      &.custom-cart-drawer__accessories--visible {
        opacity: 1;
        transform: none;
      }
    }
  }

  &.custom-cart-drawer--empty {
    & .custom-cart-drawer__header {
      border-bottom: 0;
      padding-bottom: 0;
    }

    & .custom-cart-drawer__header-row {
      justify-content: flex-end;
    }

    & .custom-cart-drawer__title,
    & .custom-cart-drawer__reservation {
      display: none;
    }

    & .custom-cart-drawer__body {
      display: flex;
      overflow: hidden;
    }

    & .custom-cart-drawer__content {
      display: flex;
      flex: 1 1 auto;
      flex-direction: column;
      min-height: 0;
      width: 100%;
    }
  }

  .custom-cart-drawer__empty {
    align-items: center;
    box-sizing: border-box;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    min-height: 0;
    padding: 30px 20px;
    text-align: center;
    width: 100%;

    .custom-cart-drawer__empty-text {
      color: #000;
      font-family: Inter, sans-serif;
      font-size: 16px;
      font-weight: 400;
      line-height: 19.5px;
      margin: 0;
    }

    .custom-cart-drawer__empty-link {
      color: #000;
      font-family: Inter, sans-serif;
      font-size: 14px;
      font-weight: 700;
      line-height: 17px;
      margin: 0;
      text-decoration: underline;
      transition: color 0.3s ease;
    }
  }

  @media (max-width: 479px) {
    .custom-cart-drawer__item {
      grid-template-columns: 76px 1fr;
    }

    .custom-cart-drawer__accessory {
      grid-template-columns: 80px minmax(0, 1fr);
    }
  }
}

@keyframes custom-cart-drawer-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes custom-cart-drawer-title-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes custom-cart-drawer-remove-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}
