/* Book page (WS-02, single-product.php). Colours only via tokens.css.
   Wide: cover | title + about | buy box. Tablets: two columns. Phones
   (≤720px): one column and a sticky buy bar. */

.book-main {
  padding-top: 16px;
  padding-bottom: 48px;
}

/* ---------- Layout ---------- */

.book {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr) minmax(0, 340px);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "media head buy"
    "media about buy";
  gap: 24px 36px;
  align-items: start;
}

.book__media {
  grid-area: media;
}

.book__head {
  grid-area: head;
}

.buybox {
  grid-area: buy;
}

.book__about {
  grid-area: about;
}

@media (max-width: 1080px) {
  .book {
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "media head"
      "media buy"
      "about about";
  }
}

@media (max-width: 720px) {
  .book {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas:
      "media"
      "head"
      "buy"
      "about";
    gap: 20px;
  }
}

/* ---------- Cover, page thumbs, look inside ---------- */

.book__media {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.book__thumbs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 64px;
  flex: none;
  margin: 0;
  padding: 0;
  list-style: none;
}

.book__thumbs a {
  display: block;
  border-radius: 4px;
  outline: 1px solid var(--cover-outline);
}

.book__thumbs a:hover {
  outline: 2px solid var(--accent);
}

.book__thumbs img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
}

.book__cover {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book__look {
  min-height: 44px;
  font-size: 15px;
}

@media (max-width: 720px) {
  .book__thumbs {
    display: none;
  }

  .book__cover {
    flex: none;
    width: min(220px, 62%);
    margin: 0 auto;
  }

  .book__cover .book-cover--lg .book-cover__title {
    font-size: 22px;
  }
}

/* ---------- Title and credits ---------- */

.book__head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.book__title {
  margin: 0;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.25;
}

.book__other {
  margin: -10px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.credits {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  font-size: 15px;
}

.credits > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
}

.credits dt {
  color: var(--muted);
}

.credits dt::after {
  content: ":";
}

.credits dd {
  margin: 0;
  font-weight: 600;
}

.book__lead {
  font-size: 17px;
  line-height: 1.75;
}

.book__lead > *,
.book__text > :first-child {
  margin-top: 0;
}

.book__lead > :last-child,
.book__text > :last-child {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .book__title {
    font-size: 26px;
  }

  .book__lead {
    font-size: 16px;
  }
}

/* ---------- Buy box ---------- */

.buybox {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Wide screens: stays in view beside a long description */
@media (min-width: 1081px) {
  .buybox {
    position: sticky;
    top: calc(16px + var(--wp-admin--admin-bar--height, 0px));
  }
}

.buybox__offer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.buybox__label {
  font-size: 14px;
  font-weight: 600;
}

/* Price block: price · MRP struck · % off; "MRP … · inclusive of all taxes" */
.price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
}

.price__now {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.price__mrp {
  color: var(--muted);
}

.price__note {
  margin: -6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.stock {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.stock .ic {
  width: 18px;
  height: 18px;
}

.stock--out {
  color: var(--muted);
}

/* Binding: Paperback / Hardback, each with its price */
.bindings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.bindings__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: start;
}

.opt:hover {
  border-color: var(--accent);
}

.opt[aria-pressed="true"] {
  padding: 0 13px;
  border: 2px solid var(--accent);
  background: var(--tint);
}

.opt__dot {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.opt[aria-pressed="true"] .opt__dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--tint);
}

.opt__name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.opt__price {
  font-weight: 600;
}

/* Pincode check */
.pin {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.pin__row {
  display: flex;
  gap: 8px;
}

.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--tint);
}

.field .ic {
  width: 18px;
  height: 18px;
}

.field input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.field input::placeholder {
  color: var(--muted);
}

.pin__check {
  min-height: 44px;
  padding: 0 16px;
}

.pin__result {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}

.pin__result:empty {
  display: none;
}

.pin__result.is-error {
  color: var(--sale);
}

/* Add to cart + Buy now. After an add, WooCommerce puts a "View cart"
   link after the button; it takes the button's place. */
.buybox__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.buybox__actions .add_to_cart_button.added,
.buybar .add_to_cart_button.added {
  display: none;
}

.buybox__actions .added_to_cart,
.buybar .added_to_cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--tint);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

.buybox__actions .added_to_cart:hover,
.buybar .added_to_cart:hover {
  text-decoration: none;
}

/* ---------- About + details ---------- */

.book__about {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.book__h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
}

.book__text {
  font-size: 17px;
  line-height: 1.75;
}

.details {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.details__row {
  display: grid;
  grid-template-columns: minmax(96px, 36%) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.details__row:last-child {
  border-bottom: 0;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .book__h2 {
    font-size: 20px;
  }

  .book__text {
    font-size: 16px;
  }
}

/* ---------- More books ---------- */

.book-main .book-rail {
  margin-top: 48px;
}

@media (max-width: 720px) {
  .book-main .book-rail {
    margin-top: 32px;
  }
}

/* ---------- Phone buy bar: Add to cart | Buy now · price ---------- */

.buybar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.buybar__row {
  display: flex;
  gap: 10px;
}

.buybar .btn,
.buybar .added_to_cart {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 10px;
  font-size: 15px;
}

/* ---------- Look inside (dialog) ---------- */

.look {
  width: min(760px, 100%);
  max-width: 100%;
  height: min(92vh, 1100px);
  max-height: 100%;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--bg);
  color: var(--ink);
}

.look[open] {
  display: flex;
  flex-direction: column;
}

.look::backdrop {
  background: var(--overlay);
}

html:has(.look[open]) {
  overflow: hidden;
}

.look__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 20px;
  border-bottom: 1px solid var(--line);
}

.look__title {
  margin: 0;
  font-size: 18px;
}

.look__pages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--soft);
}

.look__page {
  margin: 0;
}

.look__page img {
  display: block;
  width: 100%;
  height: auto;
  outline: 1px solid var(--cover-outline);
}

@media (max-width: 720px) {
  .look {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
}
