.book-buy {
  max-width: 100%;
  perspective: 900px;
}

.book-buy.is-ready {
  width: 10rem;
  transition: width 280ms ease;
}

.book-buy.is-open {
  width: 100%;
}

.book-buy__inner {
  position: relative;
  min-height: 2.75rem;
  transform-style: preserve-3d;
  transition: transform 500ms ease;
}

.book-buy.is-open .book-buy__inner {
  transform: rotateY(180deg);
}

.book-buy__front,
.book-buy__back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.book-buy__front {
  width: 100%;
  min-height: 2.75rem;
  justify-content: center;
  background: var(--accent, #f0a535);
  color: #17130d;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.book-buy__front:hover,
.book-buy__front:focus-visible {
  color: #17130d;
  transform: none;
}

.book-buy .book-buy__front:first-child svg { stroke: currentColor; }
.book-buy .book-buy__front:first-child svg path { fill: none; }

.book-buy__back {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem;
  border: 1px solid rgba(240, 165, 53, 0.4);
  border-radius: 1.6rem;
  background: #fff;
}

.book-buy.is-ready .book-buy__back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.book-buy.is-open .book-buy__back {
  position: relative;
}

.book-buy.is-open .book-buy__front {
  position: absolute;
  inset: 0;
  height: 100%;
}

.book-buy__retailer,
.book-buy__close {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  font: 700 0.75rem/1.2 var(--font-body, sans-serif);
  text-decoration: none;
  text-align: center;
}

.book-buy__retailer--amazon { background: #ff9900; color: #111827; }
.book-buy__retailer--kindle { background: #0077c8; color: #fff; }
.book-buy__retailer--flipkart { background: #2874f0; color: #fff; }
.book-buy__retailer--notion { background: #111827; color: #fff; }
.book-buy__close { min-width: 2.75rem; background: #eee; color: #111827; font-size: 1.35rem; cursor: pointer; }

.book-buy a:focus-visible,
.book-buy button:focus-visible {
  outline: 2px solid var(--accent, #f0a535);
  outline-offset: 3px;
}

.book-buy [hidden] { display: none; }

@media (max-width: 38rem) {
  .book-buy__back { grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 1.2rem; }
  .book-buy__close { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .book-buy.is-ready,
  .book-buy__inner { transition: none; }
}
