/* =========================
   Catalyst Drawer
========================= */

.catalyst-drawer{
  --cdrawer-w: 600px;

  /* tab transform vars */
  --cdrawer-tab-x: 0px;
  --cdrawer-tab-y: -50%;

  position: relative;
}

/* =========================
   Backdrop
========================= */
.catalyst-drawer__backdrop{
  position: fixed;
  inset: 0;
  z-index: 9980;
  background: rgba(0,0,0,.6);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity 400ms ease,
    visibility 0s linear 400ms;
}

/* =========================
   Panel
========================= */
.catalyst-drawer__panel{
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: var(--cdrawer-w);
  max-width: 92vw;

  z-index: 9990;
  background: var(--wp--preset--color--tertiary);
  color: var(--wp--preset--color--secondary);

  transform: translateX(100%);
  transition: transform 400ms ease;

  display: flex;
  flex-direction: column;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.catalyst-drawer__content{
  padding: 24px;
}

/* Close button */
.catalyst-drawer__close{
  position: sticky;
  top: 0;
  align-self: flex-end;
  margin: 12px 12px 0 0;

  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;

  background: rgba(255,255,255,.12);
  color: var(--wp--preset--color--secondary);
  font-size: 28px;
  line-height: 1;
}

.admin-bar .catalyst-drawer__close{
  top: 40px;
}

/* =========================
   Tab
========================= */
.catalyst-drawer__tab{
  position: fixed;
  right: 0;
  top: 30%;

  transform: translate(var(--cdrawer-tab-x), var(--cdrawer-tab-y));
  transition: transform 400ms ease;

  z-index: 9991;

  border: 0;
  cursor: pointer;

  background: var(--wp--preset--color--tertiary);
  color: var(--wp--preset--color--secondary);

  padding: 20px 10px;
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
  border-right: 1px solid var(--wp--preset--color--brand-pink);

  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

.catalyst-drawer__tab-text{
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* =========================
   OPEN STATE
========================= */
.catalyst-drawer.is-open .catalyst-drawer__panel{
  transform: translateX(0);
}

.catalyst-drawer.is-open .catalyst-drawer__backdrop{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;

  transition:
    opacity 400ms ease,
    visibility 400ms;
}
@media (prefers-reduced-motion: reduce){
  .catalyst-drawer__backdrop{
    transition: none;
  }
}

/* 👇 THIS IS THE IMPORTANT BIT */
/* Move tab LEFT with the drawer */
.catalyst-drawer.is-open{
  --cdrawer-tab-x: calc(-1 * var(--cdrawer-w));
}

/* =========================
   Mobile: full takeover
========================= */
@media (max-width: 900px){
  .catalyst-drawer__panel{
    width: 100vw;
    max-width: 100vw;
  }

  .catalyst-drawer.is-open{
    --cdrawer-tab-x: -100vw;
  }
}

/* =========================
   Reduced motion
========================= */
@media (prefers-reduced-motion: reduce){
  .catalyst-drawer__panel,
  .catalyst-drawer__tab{
    transition: none;
  }
}