/* ============================================================
   Bookshelf — cozy shelf grid, covers, hover lift
   ============================================================ */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 60px 38px;
  max-width: 940px;
  margin: 44px auto 0;
  padding: 0 8px;
}

.book {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Stage holds the cover and aligns it to the shelf baseline */
.book__stage {
  height: 248px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  perspective: 700px;
}

.book__cover-link {
  display: block;
  transform-origin: bottom center;
  transition: transform 0.5s var(--ease);
}
.book:hover .book__cover-link {
  transform: translateY(-12px) rotate(-1.2deg);
}

.book__cover {
  max-height: 240px;
  width: auto;
  border-radius: 2px 5px 5px 2px;
  /* paper edge + spine highlight + soft drop shadow */
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.16),
    inset -2px 0 4px rgba(0, 0, 0, 0.18),
    var(--shadow-md);
  transition: box-shadow 0.5s var(--ease);
}
.book:hover .book__cover { box-shadow: inset 3px 0 0 rgba(255,255,255,0.16), inset -2px 0 4px rgba(0,0,0,0.18), var(--shadow-lg); }

/* Placeholder "cover" when no image is attached */
.book__cover--blank {
  width: 158px;
  height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 18px 16px;
  border-radius: 2px 5px 5px 2px;
  color: #fffaf2;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
}
.book__cover--blank.tint-1 { background: linear-gradient(150deg, #c06a4d, #a4543a); }
.book__cover--blank.tint-2 { background: linear-gradient(150deg, #8a9a7b, #5f7050); }
.book__cover--blank.tint-3 { background: linear-gradient(150deg, #6f8a9a, #46606f); }
.book__cover--blank.tint-4 { background: linear-gradient(150deg, #b08968, #8a6748); }
.book__cover--blank .blank-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.2;
}
.book__cover--blank .blank-author {
  margin-top: 8px;
  font-size: 0.78rem;
  opacity: 0.82;
}

/* Wooden shelf ledge under each book */
.book__shelf {
  height: 11px;
  margin-top: -1px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(var(--wood), var(--wood-edge));
  box-shadow: 0 16px 22px -10px var(--wood-shadow);
}

.book__caption {
  text-align: center;
  padding-top: 15px;
}
.book__title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 560;
  color: var(--ink);
  line-height: 1.25;
}
.book__author {
  display: block;
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.book__genre {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  color: var(--sage);
  background: rgba(138, 154, 123, 0.14);
  border-radius: 999px;
}

/* ---------- Empty state ---------- */

.shelf-empty {
  max-width: 460px;
  margin: 56px auto;
  text-align: center;
  color: var(--ink-soft);
}
.shelf-empty h2 { font-size: 1.5rem; margin-bottom: 8px; }

.shelf-actions {
  text-align: center;
  margin-top: 52px;
}

/* ============================================================
   Show + form pages
   ============================================================ */

.book-detail {
  max-width: 720px;
  margin: 40px auto 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  align-items: start;
}
.book-detail__cover img,
.book-detail__cover .book__cover--blank {
  border-radius: 3px 7px 7px 3px;
  box-shadow: var(--shadow-lg);
}
.book-detail__meta h1 { font-size: 2.2rem; margin: 0 0 6px; }
.book-detail__author { font-size: 1.1rem; color: var(--ink-soft); margin: 0 0 18px; }
.book-detail__actions { margin-top: 28px; display: flex; gap: 12px; }

@media (max-width: 620px) {
  .book-detail { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .book-detail__actions { justify-content: center; }
}

/* Form */
.book-form {
  max-width: 540px;
  margin: 40px auto 0;
  background: var(--paper);
  padding: 34px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.book-form .field { margin-bottom: 20px; }
.book-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.book-form input[type="text"],
.book-form input[type="file"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  padding: 11px 14px;
  background: #fffdf8;
  border: 1px solid #e0d4bd;
  border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.book-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 106, 77, 0.15);
}
.book-form .form-actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; }

.form-errors {
  background: #f7e3dd;
  border: 1px solid #e6c3b8;
  color: #8c3a26;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 0.9rem;
}
.form-errors ul { margin: 6px 0 0; padding-left: 20px; }

/* ============================================================
   Book detail modal (antd Modal shell + cozy two-pane content)
   ============================================================ */

/* antd positions/animates the dialog; we only cap width on small screens. */
.book-modal { max-width: calc(100vw - 32px); }

.modal__sheet {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  max-height: min(620px, 86vh);
  overflow: hidden;
  border-radius: 22px;
}

/* Left: cover on a soft stage */
.modal__visual {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(120% 90% at 50% 18%, #fdf8ee 0%, #ece1cd 100%);
}
.modal__cover {
  max-height: 420px;
  max-width: 100%;
  border-radius: 3px 8px 8px 3px;
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.18),
    inset -2px 0 5px rgba(0, 0, 0, 0.18),
    var(--shadow-lg);
}
.modal__visual .book__cover--blank {
  width: 200px;
  height: 300px;
  box-shadow: var(--shadow-lg);
}

/* Right: details */
.modal__body {
  position: relative;
  padding: 46px 42px 38px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.modal__close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink-soft);
  background: rgba(60, 44, 30, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.modal__close:hover { background: rgba(60, 44, 30, 0.12); color: var(--ink); transform: rotate(90deg); }
.modal__close:focus { outline: none; }
.modal__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal__title {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  margin: 6px 64px 4px 0;
}
.modal__author {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.modal__body .book__genre { align-self: flex-start; }
.modal__divider {
  height: 1px;
  background: var(--ink-faint);
  margin: 22px 0;
}
.modal__meta { margin: 0; }
.modal__meta dt {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.modal__meta dd { margin: 2px 0 0; font-size: 1rem; color: var(--ink); }

.modal__actions {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  gap: 12px;
}
.modal__actions form { margin: 0; }

@media (max-width: 680px) {
  .modal__sheet {
    grid-template-columns: 1fr;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal__visual { padding: 32px 32px 8px; }
  .modal__cover, .modal__visual .book__cover--blank { max-height: 260px; height: auto; }
  .modal__body { padding: 28px 28px 32px; }
}
