/* Newest collection — flippable book (page-turn) + admin */

.collection {
  padding: var(--section-padding) var(--space-lg);
  min-height: 60vh;
}

.collection__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.collection__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  margin: 0 0 var(--space-sm);
  color: var(--text-dark);
}

.collection__subtitle {
  font-size: 1rem;
  color: var(--text-soft);
  margin: 0 0 var(--space-xl);
}

/* Admin bar */
.collection-admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.collection-add-btn {
  display: inline-flex;
}

.collection-admin-bar .collection-add-btn[aria-hidden="true"] {
  display: none;
}

/* Book container */
.book-container {
  position: relative;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-soft);
}

.book-empty[aria-hidden="true"] {
  display: none;
}

.book-empty p {
  margin: 0 0 var(--space-xs);
}

.book[aria-hidden="true"] {
  display: none;
}

.book {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* 3D book: perspective and inner wrapper */
.book__inner {
  position: relative;
  width: 100%;
  height: 340px;
  perspective: 1600px;
  margin-bottom: var(--space-lg);
}

.book__pages {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

/* Spine (center line) */
.book__spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: linear-gradient(90deg, rgba(45,42,38,0.15) 0%, rgba(45,42,38,0.08) 100%);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}

/* One page (one leaf): right half of spread, rotates from left edge */
.book__page {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transition: transform 0.7s ease-in-out;
  transform-style: preserve-3d;
  z-index: 1;
}

.book__page:nth-child(1) { z-index: 1; }
.book__page:nth-child(2) { z-index: 2; }
.book__page:nth-child(3) { z-index: 3; }
.book__page:nth-child(4) { z-index: 4; }
.book__page:nth-child(5) { z-index: 5; }
.book__page:nth-child(6) { z-index: 6; }
.book__page:nth-child(7) { z-index: 7; }
.book__page:nth-child(8) { z-index: 8; }
.book__page:nth-child(9) { z-index: 9; }
.book__page:nth-child(10) { z-index: 10; }
.book__page:nth-child(n+11) { z-index: 11; }

/* Front = right side (product image + name); Back = left side (details) */
.book__page__front,
.book__page__back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 12px 12px 0;
  overflow: hidden;
  box-shadow: 2px 2px 12px rgba(45, 42, 38, 0.12);
  display: flex;
  flex-direction: column;
}

.book__page__front {
  background: linear-gradient(160deg, var(--accent-blush) 0%, var(--pastel-ice) 100%);
  border: 2px solid var(--bubble-pink-border);
  border-left: none;
  justify-content: flex-end;
  padding: var(--space-md);
}

.book__page__back {
  background: var(--white);
  border: 2px solid var(--pastel-mint);
  border-left: 1px solid rgba(45, 42, 38, 0.08);
  border-radius: 12px 0 0 12px;
  transform: rotateY(180deg);
  padding: var(--space-md);
  justify-content: space-between;
}

/* Page front: image + title */
.book__page__img {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-size: cover;
  background-position: center;
}

.book__page__img--uploaded {
  opacity: 0.95;
}

.book__page__img--1 { background-image: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-blush) 100%); }
.book__page__img--2 { background-image: linear-gradient(135deg, var(--pastel-mint) 0%, var(--pastel-aqua) 100%); }
.book__page__img--3 { background-image: linear-gradient(135deg, var(--accent-peach) 0%, var(--accent-blush) 100%); }
.book__page__img--4 { background-image: linear-gradient(135deg, var(--pastel-aqua) 0%, var(--pastel-ice) 100%); }
.book__page__img--5 { background-image: linear-gradient(135deg, #e8d5f2 0%, var(--accent-blush) 100%); }
.book__page__img--6 { background-image: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-peach) 100%); }

.book__page__name {
  position: relative;
  z-index: 1;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
  line-height: 1.3;
}

.book__page__hint {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: var(--space-xs);
}

/* Page back: details */
.book__page__back .book__page__name {
  font-size: 1rem;
  margin-bottom: var(--space-xs);
}

.book__page__brand {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0 0 var(--space-sm);
}

.book__page__description {
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.book__page__price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: var(--space-sm) 0;
}

.book__page__cta {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
  background: var(--bubble-pink);
  border: 2px solid var(--bubble-pink-border);
  border-radius: 100px;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}

.book__page__cta:hover {
  background: var(--bubble-pink-hover);
  border-color: var(--bubble-pink-hover);
  color: var(--white);
}

/* Admin actions on book page */
.book__page__admin {
  position: absolute;
  z-index: 2;
  top: var(--space-xs);
  right: var(--space-xs);
  display: flex;
  gap: var(--space-xs);
}

.book__page__back .book__page__admin {
  top: auto;
  bottom: var(--space-xs);
}

.book__page__edit,
.book__page__delete {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 6px;
  border: 1px solid rgba(45, 42, 38, 0.3);
  cursor: pointer;
  background: var(--white);
  color: var(--text-dark);
  transition: background 0.2s, color 0.2s;
}

.book__page__edit:hover,
.book__page__delete:hover {
  background: var(--pastel-mint);
  border-color: var(--pastel-mint);
}

.book__page__delete:hover {
  background: var(--accent-blush);
  border-color: var(--accent-coral);
}

/* Book navigation */
.book__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.book__nav-btn {
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 100px;
  border: 2px solid var(--bubble-pink-border);
  background: var(--bubble-pink);
  color: var(--white);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.book__nav-btn:hover:not(:disabled) {
  background: var(--bubble-pink-hover);
  transform: scale(1.02);
}

.book__nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.book__counter {
  font-size: 0.95rem;
  color: var(--text-soft);
  min-width: 4ch;
  text-align: center;
}

/* Form overlay (add/edit item with image upload) */
.collection-form-overlay {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: rgba(45, 42, 38, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.collection-form-overlay--on {
  opacity: 1;
  visibility: visible;
}

.collection-form-overlay--on .collection-form-wrap {
  transform: scale(1);
}

.collection-form-wrap {
  position: relative;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(45, 42, 38, 0.2);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.96);
  transition: transform 0.25s;
}

.collection-form-overlay__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.collection-form-overlay__close:hover {
  background: var(--pastel-ice);
  color: var(--text-dark);
}

.collection-form {
  padding: var(--space-xl);
}

.collection-form__heading {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 var(--space-md);
  color: var(--text-dark);
}

.collection-form__label {
  display: block;
  margin-bottom: var(--space-md);
}

.collection-form__label > span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: var(--space-xs);
}

.collection-form__image-preview {
  width: 100%;
  height: 140px;
  background: var(--pastel-ice);
  border: 2px dashed var(--pastel-mint);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  margin-bottom: var(--space-xs);
}

.collection-form__image-preview--has {
  border-style: solid;
  border-color: var(--pastel-mint);
}

.collection-form__file {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.collection-form__input,
.collection-form__textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 2px solid rgba(45, 42, 38, 0.2);
  border-radius: 8px;
  background: var(--white);
}

.collection-form__input:focus,
.collection-form__textarea:focus {
  outline: none;
  border-color: var(--accent-coral);
}

.collection-form__textarea {
  resize: vertical;
  min-height: 4rem;
}

.collection-form__actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

@media (max-width: 600px) {
  .book__inner {
    height: 300px;
  }

  .book__page__name {
    font-size: 0.95rem;
  }
}
