/* Books, chapters, and gallery attachments.
   Kept separate from the main theme so local About/style customizations stay intact. */

.books-eyebrow {
  margin: 0 0 0.75rem;
  color: var(--green, #176a49);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.books-eyebrow::before {
  display: inline-block;
  width: 0.44rem;
  height: 0.44rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--orange, #e86c2f);
  box-shadow: 0 0 0 0.24rem rgba(232, 108, 47, 0.11);
  content: "";
  vertical-align: 0.04rem;
}

.books-index,
.book-detail,
.chapter-detail,
.books-admin,
.book-editor,
.chapter-editor {
  margin-top: clamp(2.2rem, 7vw, 5rem);
}

.books-index__header,
.book-detail__header,
.chapter-detail__header {
  max-width: 50rem;
  margin-bottom: clamp(2rem, 6vw, 4rem);
}

.books-index__header h1,
.book-detail__header h1,
.chapter-detail__header h1 {
  margin: 0;
  color: var(--ink, #17372c);
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(3rem, 9vw, 6.8rem);
  font-weight: 520;
  letter-spacing: -0.06em;
  line-height: 0.92;
}

.books-index__header > p:last-child,
.book-detail__description,
.chapter-detail__description {
  max-width: 44rem;
  margin: 1.3rem 0 0;
  color: var(--ink-soft, #315449);
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(1.05rem, 2.3vw, 1.28rem);
  line-height: 1.65;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 1.6rem);
}

.book-card {
  min-width: 0;
}

.book-card__link {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  min-height: 100%;
  overflow: hidden;
  padding: clamp(1.4rem, 3.5vw, 2.25rem);
  border: 1px solid rgba(23, 106, 73, 0.14);
  border-radius: clamp(1.2rem, 2.7vw, 1.9rem);
  background:
    radial-gradient(circle at 95% 4%, rgba(232, 108, 47, 0.12), transparent 13rem),
    linear-gradient(145deg, rgba(255, 253, 247, 0.93), rgba(217, 230, 217, 0.42));
  box-shadow: var(--shadow-soft, 0 18px 50px rgba(43, 64, 52, 0.08));
  color: inherit;
  text-decoration: none;
}

.book-card__link::after {
  position: absolute;
  right: -4rem;
  bottom: -5rem;
  z-index: -1;
  width: 12rem;
  height: 12rem;
  border: 1px solid rgba(23, 106, 73, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 1.8rem rgba(23, 106, 73, 0.025);
  content: "";
}

.book-card__link:hover {
  border-color: rgba(232, 108, 47, 0.32);
  color: inherit;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift, 0 24px 80px rgba(43, 64, 52, 0.13));
}

.book-card__number,
.book-chapter-card__number {
  color: var(--orange, #e86c2f);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.book-card__copy {
  min-width: 0;
}

.book-card h2,
.book-chapter-card h2 {
  margin: 0;
  color: var(--ink, #17372c);
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  font-weight: 520;
  letter-spacing: -0.045em;
  line-height: 1;
}

.book-card__copy > p:last-child {
  margin: 1rem 0 0;
  color: var(--ink-soft, #315449);
  line-height: 1.55;
}

.book-card__meta {
  grid-column: 2;
  color: var(--green, #176a49);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.books-empty {
  display: grid;
  place-items: center;
  min-height: 15rem;
  padding: 2.5rem;
  border: 1px dashed var(--line-strong, rgba(23, 55, 44, 0.26));
  border-radius: var(--radius-lg, 2rem);
  color: var(--ink-soft, #315449);
  text-align: center;
}

.books-empty span {
  color: var(--orange, #e86c2f);
  font-size: 2rem;
}

.book-detail,
.chapter-detail {
  width: min(100%, 920px);
  margin-inline: auto;
}

.book-detail__header,
.chapter-detail__header {
  position: relative;
  overflow: hidden;
  max-width: none;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid rgba(23, 106, 73, 0.14);
  border-radius: clamp(1.35rem, 3vw, 2.2rem);
  background:
    radial-gradient(circle at 92% 8%, rgba(232, 108, 47, 0.12), transparent 17rem),
    linear-gradient(135deg, rgba(217, 230, 217, 0.5), rgba(255, 253, 247, 0.8));
  box-shadow: 0 22px 68px rgba(43, 64, 52, 0.08);
}

.book-detail__back,
.chapter-detail__breadcrumb {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin: 0 0 clamp(2rem, 5vw, 4rem);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
  font-weight: 730;
  letter-spacing: 0.07em;
  text-decoration: none;
  text-transform: uppercase;
}

.book-chapters {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.book-chapter-card > a {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: clamp(1rem, 3vw, 1.5rem);
  align-items: start;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  border: 1px solid var(--line, rgba(23, 55, 44, 0.14));
  border-radius: 1.25rem;
  background: rgba(255, 253, 247, 0.68);
  color: inherit;
  text-decoration: none;
}

.book-chapter-card > a:hover {
  border-color: rgba(232, 108, 47, 0.3);
  background: rgba(255, 253, 247, 0.94);
  color: inherit;
  transform: translateX(3px);
}

.book-chapter-card__description {
  margin-top: 0.7rem;
  color: var(--ink-soft, #315449);
}

.book-chapter-card__pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0.9rem 0 0;
  padding: 0;
  color: var(--ink-soft, #315449);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  list-style: none;
}

.book-chapter-card__count {
  color: var(--green, #176a49);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  white-space: nowrap;
}

.chapter-detail__pieces {
  margin-top: 2rem;
}

.post-books,
.post-collections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
}

.post-books {
  margin-top: 0.55rem;
}

.post-books > span {
  color: var(--orange-deep, #b94c1c);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post-books a {
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(23, 106, 73, 0.14);
  border-radius: 999px;
  background: rgba(217, 230, 217, 0.32);
  font-size: 0.78rem;
  text-decoration: none;
}

.post-gallery-attachments {
  margin-top: clamp(3rem, 8vw, 6rem);
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line, rgba(23, 55, 44, 0.14));
}

.post-gallery-attachments__heading {
  margin-bottom: 1.4rem;
}

.post-gallery-attachments__heading p {
  margin: 0 0 0.25rem;
  color: var(--orange-deep, #b94c1c);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.post-gallery-attachments__heading h2 {
  margin: 0;
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 520;
  letter-spacing: -0.035em;
}

.post-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 1.6rem);
}

.post-gallery-card {
  min-width: 0;
  margin: 0;
}

.post-gallery-card a {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line, rgba(23, 55, 44, 0.14));
  border-radius: 1.25rem;
  background: var(--surface, rgba(255, 253, 247, 0.88));
  color: inherit;
  text-decoration: none;
}

.post-gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 300ms ease;
}

.post-gallery-card a:hover img {
  transform: scale(1.015);
}

.post-gallery-card figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--line, rgba(23, 55, 44, 0.14));
}

.post-gallery-card figcaption strong {
  font-family: var(--font-serif, Georgia, serif);
  font-weight: 560;
}

.post-gallery-card figcaption span {
  color: var(--ink-soft, #315449);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  text-transform: uppercase;
}

/* Admin */

.admin-book-list {
  display: grid;
  gap: 0.8rem;
}

.admin-book-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line, rgba(23, 55, 44, 0.14));
  border-radius: var(--radius-md, 1.3rem);
  background: var(--surface, rgba(255, 253, 247, 0.88));
}

.book-chapter-manager {
  margin-top: 2.5rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--line, rgba(23, 55, 44, 0.14));
  border-radius: var(--radius-lg, 2rem);
  background: rgba(217, 230, 217, 0.2);
}

.book-chapter-manager > ol {
  display: grid;
  gap: 0.65rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.book-chapter-manager > ol > li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line, rgba(23, 55, 44, 0.14));
  border-radius: 1rem;
  background: var(--surface-solid, #fffdf7);
}

.book-chapter-manager > ol > li > div:first-child {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.book-chapter-manager > ol > li > div:first-child > span {
  color: var(--orange, #e86c2f);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
}

.book-chapter-manager p,
.book-chapter-manager small {
  display: block;
  margin: 0;
}

.chapter-post-picker,
.post-gallery-picker {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line-strong, rgba(23, 55, 44, 0.26));
  border-radius: 1.2rem;
  background: rgba(255, 253, 247, 0.56);
}

.chapter-post-picker > legend,
.post-gallery-picker > legend {
  padding: 0 0.45rem;
  color: var(--ink, #17372c);
  font-weight: 700;
}

.chapter-post-row,
.post-gallery-picker__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line, rgba(23, 55, 44, 0.14));
}

.chapter-post-row:first-of-type,
.post-gallery-picker__item:first-of-type {
  border-top: 0;
}

.chapter-post-row > label:first-child,
.post-gallery-picker__item > label:first-child {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
  cursor: pointer;
}

.chapter-post-row strong,
.chapter-post-row small,
.post-gallery-picker__item strong,
.post-gallery-picker__item small {
  display: block;
}

.chapter-post-row small,
.post-gallery-picker__item small {
  color: var(--ink-soft, #315449);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
}

.chapter-post-row__order,
.post-gallery-picker__order {
  display: grid;
  gap: 0.2rem;
  color: var(--ink-soft, #315449);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.chapter-post-row__order input,
.post-gallery-picker__order input {
  width: 100%;
}

.post-gallery-picker__thumb {
  flex: 0 0 auto;
  overflow: hidden;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 0.7rem;
  background: var(--surface-tint, #ebe8dc);
}

.post-gallery-picker__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 760px) {
  .books-grid,
  .post-gallery-grid {
    grid-template-columns: 1fr;
  }

  .book-chapter-card > a {
    grid-template-columns: 1fr;
  }

  .book-chapter-card__count {
    white-space: normal;
  }

  .admin-book-row,
  .book-chapter-manager > ol > li {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .book-chapter-manager > ol > li {
    display: grid;
  }
}

@media (max-width: 520px) {
  .chapter-post-row,
  .post-gallery-picker__item {
    grid-template-columns: 1fr;
  }

  .chapter-post-row__order,
  .post-gallery-picker__order {
    width: 6rem;
  }

  .post-gallery-card figcaption {
    display: block;
  }

  .post-gallery-card figcaption span {
    display: block;
    margin-top: 0.25rem;
  }
}
