/* -------------------- BASKET POP-UP -------------------- */
/* All sizes: slides in from the right, with the page dimmed behind it.
   Desktop: a panel on the right. Mobile and tablet (768px and below): covers the whole screen. */

.basket-overlay {
  position: fixed;
  inset: 0;
  /* inset: 0 = top, right, bottom and left all 0, so it covers the whole screen */
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.basket-overlay[data-visible="true"] {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease;
}

.basket-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 26rem;
  background-color: var(--colour-surface);
  color: var(--colour-text);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  /* Starts just off the RIGHT edge of the screen */
  visibility: hidden;
  /* Also hides it from keyboard users while it's closed */
  transition: transform 0.3s ease, visibility 0s 0.3s;
  /* When closing, it slides out first, then hides once the slide has finished */
}

.basket-panel[data-visible="true"] {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s ease;
}

.basket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--colour-border);
}

.basket-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.basket-close {
  display: flex;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.basket-close svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: var(--colour-text);
  stroke-width: 2;
  stroke-linecap: round;
}

.basket-items {
  flex-grow: 1;
  overflow-y: auto;
  /* Only the list scrolls, so the total and checkout button stay in view */
  padding: 0 1.5rem;
}

/* -------------------- ONE BASKET ITEM -------------------- */

.basket-item {
  display: flex;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--colour-border);
}

.basket-item-image {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.basket-item-details {
  flex-grow: 1;
}

.basket-item-details p {
  margin: 0 0 0.25rem;
}

.basket-item-name {
  font-weight: bold;
}

.basket-item-variant {
  color: var(--colour-text-soft);
  font-size: 0.9rem;
}

.basket-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.basket-item-remove {
  padding: 0;
  background: none;
  border: none;
  color: var(--colour-text-soft);
  text-decoration: underline;
  font-size: 0.9rem;
  cursor: pointer;
}

/* -------------------- EMPTY BASKET -------------------- */

.basket-empty {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
}

.basket-empty p {
  margin: 0;
}

/* -------------------- TOTAL AND CHECKOUT -------------------- */

.basket-footer {
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--colour-border);
}

.basket-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

/* Its outline and shape come from ROUNDED BUTTONS in index.css */
.basket-checkout {
  width: 100%;
  padding: 0.9rem;
  background-color: var(--colour-button);
  color: var(--colour-text-on-dark);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

.basket-checkout:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -------------------- MOBILE AND TABLET (768px and below) -------------------- */

@media(max-width: 768px) {
  .basket-panel {
    width: 100%;
    /* Full screen, to make the most of the space. The slide comes from the rules above. */
  }
}