/*
 * Product-reader and gallery craft layer for the local WithViv preview.
 * All selectors are component-scoped; colors map directly to the original
 * V3 paper, cocoa, terracotta, sage, sand, and charcoal palette.
 */

.product-reader,
.product-gallery-section {
  --product-paper: #FDF8F5;
  --product-ink: #5D4037;
  --product-coral: #C4756B;
  --product-sage: #C9D8C5;
  --product-sand: #F5E6D3;
  --product-charcoal: #2C2C2C;
  --product-line: rgba(93, 64, 55, .2);
}

.reader-layout.product-reader-layout {
  grid-template-columns: minmax(0, 1.32fr) minmax(240px, .68fr);
  gap: clamp(31px, 6vw, 90px);
  align-items: start;
}

.product-reader__book {
  min-width: 0;
}

.product-reader__stage-frame {
  position: relative;
  padding: clamp(10px, 1.5vw, 18px) clamp(11px, 1.7vw, 21px) clamp(16px, 2.3vw, 29px) 0;
}

.product-reader__stage-frame::before {
  position: absolute;
  inset: 14px 0 0 14px;
  z-index: 0;
  border: 1px solid var(--product-line);
  background: var(--product-paper);
  box-shadow: 9px 12px 0 var(--product-sand);
  content: '';
}

.product-reader__stage-frame .reader-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--product-paper);
  border: 1px solid var(--product-line);
  box-shadow: 14px 20px 34px rgba(93, 64, 55, .16);
  touch-action: pan-y;
}

.product-reader__stage-frame .reader-stage::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(93, 64, 55, .16), transparent);
  content: '';
  pointer-events: none;
}

.product-reader__stage-frame .reader-stage > img {
  position: relative;
  z-index: 1;
  background: var(--product-paper);
}

.product-reader__rail {
  margin: clamp(22px, 3.5vw, 38px) 0 0;
  border-top: 1px solid var(--product-line);
}

.product-reader__rail .reader-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-reader__rail .reader-choices button {
  min-height: 72px;
  padding: 14px 12px;
  border: 0;
  border-right: 1px solid var(--product-line);
  border-bottom: 1px solid var(--product-line);
  background: transparent;
  color: var(--product-ink);
  font-family: Outfit, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  transition: background-color 180ms ease, color 180ms ease;
}

.product-reader__rail .reader-choices button:first-child {
  border-left: 1px solid var(--product-line);
}

.product-reader__rail .reader-choices button > span {
  display: block;
  margin-bottom: 6px;
  color: var(--product-coral);
  font-family: Playfair, Georgia, serif;
  font-size: 17px;
  font-style: italic;
}

.product-reader__rail .reader-choices button > svg {
  display: none;
}

.product-reader__rail .reader-choices button[aria-pressed='true'] {
  padding-left: 12px;
  background: var(--product-sage);
  color: var(--product-charcoal);
}

.product-reader__rail .reader-choices button:hover:not([aria-pressed='true']) {
  background: var(--product-sand);
}

.reader-aside.product-reader__tools {
  display: flex;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  align-items: flex-start;
  padding-top: clamp(4px, 1vw, 12px);
}

.product-reader__status-line {
  width: 100%;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--product-line);
}

.product-reader__status-line .reader-status {
  min-height: 0;
  margin: 0;
  color: var(--product-ink);
  font-family: Outfit, Arial, sans-serif;
  font-size: 11px;
  letter-spacing: .04em;
  line-height: 1.5;
  text-transform: uppercase;
}

.product-reader__tools .reader-controls {
  margin: 20px 0 9px;
}

.product-reader__tools .circle-button {
  width: 52px;
  height: 52px;
  border-color: var(--product-line);
  background: var(--product-paper);
  color: var(--product-ink);
  transition: background-color 180ms ease, transform 180ms ease;
}

.product-reader__tools .circle-button:hover:not(:disabled) {
  background: var(--product-sand);
  transform: translateY(-2px);
}

.product-reader__tools > .text-link {
  max-width: 100%;
  margin-top: 9px;
  color: var(--product-ink);
  font-size: 12px;
}

.format-panel.product-reader__formats {
  max-width: 890px;
  margin-top: clamp(42px, 7vw, 74px);
  padding: clamp(22px, 3vw, 31px) 0 0;
  border-top-color: var(--product-line);
}

.product-reader__formats .format-choices button {
  border-color: var(--product-line);
  color: var(--product-ink);
}

.product-reader__formats .format-choices button[aria-pressed='true'] {
  border-color: var(--product-ink);
  background: var(--product-ink);
  color: var(--product-paper);
}

.product-reader__formats #format-info {
  color: var(--product-ink);
  font-size: 13px;
  line-height: 1.65;
}

.card-gallery.product-gallery {
  grid-template-columns: minmax(0, 1.34fr) minmax(220px, .66fr);
  gap: clamp(29px, 6vw, 86px);
  align-items: start;
}

.product-gallery__frame {
  min-width: 0;
}

.product-gallery__visual {
  position: relative;
  border: 1px solid var(--product-line);
  background: var(--product-paper);
  box-shadow: 11px 15px 0 var(--product-sand), 18px 25px 37px rgba(93, 64, 55, .12);
  touch-action: pan-y;
}

.product-gallery__visual::before {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  border: clamp(10px, 1.8vw, 21px) solid var(--product-paper);
  content: '';
  pointer-events: none;
}

.product-gallery__visual img {
  background: var(--product-paper);
}

.product-gallery__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--product-line);
}

.product-gallery__status-line .caption {
  margin: 0;
  color: var(--product-ink);
  font-family: Outfit, Arial, sans-serif;
  font-size: 10px;
  letter-spacing: .08em;
}

.product-pager {
  display: flex;
  gap: 8px;
}

.product-pager__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-height: 48px;
  border: 1px solid var(--product-line);
  border-radius: 50%;
  background: var(--product-paper);
  color: var(--product-ink);
  font-family: Inter, Arial, sans-serif;
  font-size: 20px;
  line-height: 1;
  transition: background-color 180ms ease, transform 180ms ease;
}

.product-pager__button:hover {
  background: var(--product-sage);
  transform: translateY(-2px);
}

.product-gallery .gallery-controls {
  display: grid;
  border-top: 1px solid var(--product-line);
}

.product-gallery .gallery-controls button {
  min-height: 74px;
  padding: 15px 0;
  border: 0;
  border-bottom: 1px solid var(--product-line);
  background: transparent;
  color: var(--product-ink);
  font-family: Outfit, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  transition: color 180ms ease, padding-left 180ms ease;
}

.product-gallery .gallery-controls button > span {
  min-width: 31px;
  color: var(--product-coral);
  font-family: Playfair, Georgia, serif;
  font-size: 19px;
  font-style: italic;
}

.product-gallery .gallery-controls button[aria-pressed='true'] {
  padding-left: 12px;
  background: transparent;
  color: var(--product-coral);
}

.product-gallery .gallery-controls button:hover:not([aria-pressed='true']) {
  padding-left: 8px;
  color: var(--product-coral);
}

@media (max-width: 800px) {
  .reader-layout.product-reader-layout,
  .card-gallery.product-gallery {
    grid-template-columns: 1fr;
    gap: 31px;
  }

  .product-reader__tools {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 22px;
    align-items: start;
  }

  .product-reader__status-line {
    grid-column: 1 / -1;
  }

  .product-reader__tools .reader-controls {
    grid-column: 1;
    margin: 17px 0 0;
  }

  .product-reader__tools > .text-link {
    grid-column: 2;
    align-self: center;
    margin-top: 17px;
    font-size: 11px;
  }

  .product-reader__tools > .text-link + .text-link {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
  }

  .format-panel.product-reader__formats {
    display: block;
  }

  .product-reader__formats #format-info {
    margin-top: 18px;
  }
}

@media (max-width: 560px) {
  .product-reader__stage-frame {
    padding: 7px 8px 16px 0;
  }

  .product-reader__stage-frame::before {
    inset: 9px 0 0 9px;
    box-shadow: 6px 8px 0 var(--product-sand);
  }

  .product-reader__rail {
    margin-top: 20px;
  }

  .product-reader__rail .reader-choices button {
    min-height: 66px;
    padding: 11px 8px;
    font-size: 11px;
  }

  .product-reader__rail .reader-choices button > span {
    font-size: 15px;
  }

  .product-reader__tools {
    grid-template-columns: 1fr !important;
  }

  .product-reader__tools .reader-controls,
  .product-reader__tools > .text-link,
  .product-reader__tools > .text-link + .text-link {
    grid-column: 1;
    grid-row: auto;
  }

  .product-reader__tools > .text-link {
    margin-top: 12px;
  }

  .product-gallery__toolbar {
    margin-top: 18px;
    padding-top: 14px;
  }

  .product-gallery .gallery-controls button {
    min-height: 62px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-reader__rail .reader-choices button,
  .product-reader__tools .circle-button,
  .product-pager__button,
  .product-gallery .gallery-controls button {
    transition: none;
  }

  .product-reader__tools .circle-button:hover:not(:disabled),
  .product-pager__button:hover {
    transform: none;
  }
}
