/* -------------------- TEXT SIZES (product pages) --------------------
   Product name:      2rem (1.6rem at 768px and below)
   Price:             1.25rem, bold
   Section headings:  1.15rem, bold, extra space above
   Body and bullets:  1rem (16px) on every device, line height 1.6
   Description width: matches the right column, about 55–60 characters per line
------------------------------------------------------------------- */

.product-page {
  max-width: 60rem;
  margin: auto;
  padding: 2rem 1rem;
}

.back-link {
  display: block;
  width: fit-content;
  /* Only as wide as its text */
  line-height: 1.5rem;
  /* A fixed height, so the photo's sticky position below can be worked out exactly */
  color: var(--colour-text-soft);
  text-decoration: none;
  position: sticky;
  top: 2rem;
  /* Keeps the same 2rem gap from the top of the screen as it has below the navbar */
}

/* -------------------- PAGE LAYOUT -------------------- */
/* Desktop: photos on the left, buying box then description on the right.
   The photos take up both rows, so they can stay in view while scrolling. */

.product-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "gallery info"
    "gallery description";
  column-gap: 3rem;
  row-gap: 3rem;
  align-items: start;
  margin-top: 1.5rem;
}

.product-gallery {
  grid-area: gallery;
  min-width: 0;
  /* Stops the carousel's row of photos from stretching the column */
  position: sticky;
  top: 5rem;
  /* 2rem gap + 1.5rem back link + 1.5rem space below it = exactly where it starts under the navbar */
}

.product-info {
  grid-area: info;
}

.product-description {
  grid-area: description;
  min-width: 0;
  font-size: 1rem;
  line-height: 1.6;
}

/* -------------------- BUYING BOX -------------------- */

.product-info h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.product-info .price {
  font-size: 1.25rem;
}

.product-summary {
  margin: 1rem 0 1.5rem;
  line-height: 1.6;
}

.field-label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

/* The colour dropdown. Its outline and shape come from ROUNDED BUTTONS in index.css */
.select-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 1.25rem;
  top: 50%;
  width: 0.9rem;
  height: 0.9rem;
  transform: translateY(-50%);
  background-color: var(--colour-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9l7 7 7-7' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9l7 7 7-7' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  /* Our own down arrow, drawn in the text colour, sitting comfortably inside the rounded edge */
  pointer-events: none;
  /* Lets clicks pass through the arrow to the dropdown underneath */
}

.variant-select {
  display: block;
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 1.25rem;
  /* Extra space on the right, so the text never runs under the arrow */
  font-size: 1rem;
  background-color: var(--colour-surface);
  color: var(--colour-text);
  -webkit-appearance: none;
  appearance: none;
  /* Hides the browser's own arrow, which sat too close to the rounded edge */
  cursor: pointer;
}

/* Quantity selector and Add to basket side by side */
.buy-row {
  display: flex;
  gap: 0.75rem;
}

/* Its outline and shape come from ROUNDED BUTTONS in index.css */
.basket-button {
  flex-grow: 1;
  /* Fills the rest of the row, so its right edge lines up with everything above */
  padding: 0 1.5rem;
  background-color: var(--colour-button);
  color: var(--colour-text-on-dark);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

/* -------------------- FULL DESCRIPTION (under the buying box) -------------------- */

.product-description h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

/* Section headings: "What Makes It Special?", "Thank You!" and the collapsible titles */
.description-content h3,
.thank-you h3,
.info-section summary {
  font-size: 1.15rem;
  font-weight: bold;
}

.description-content h3,
.thank-you h3 {
  margin: 1.75rem 0 0.5rem;
}

.description-content p,
.thank-you p {
  margin: 0 0 1rem;
}

.product-description ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.product-description li + li {
  margin-top: 0.5rem;
  /* Space between bullet points, but not above the first one */
}

/* -------------------- COLLAPSIBLE SECTIONS -------------------- */

.info-sections {
  margin-top: 2rem;
  border-bottom: 1px solid var(--colour-border);
}

.info-section {
  border-top: 1px solid var(--colour-border);
}

.info-section summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  cursor: pointer;
  list-style: none;
  /* Removes the browser's own little triangle, as we add a + / − instead */
}

.info-section summary::-webkit-details-marker {
  display: none;
  /* Removes the triangle in Safari too */
}

.info-section summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: normal;
}

.info-section[open] summary::after {
  content: "−";
  /* [open] is added by the browser when the section is open */
}

.info-section p {
  margin: 0 0 1rem;
}

.info-section p:last-child,
.info-section ul:last-child {
  margin-bottom: 1.25rem;
}

/* -------------------- 404 PAGE -------------------- */

.not-found-page {
  text-align: center;
  padding: 4rem 1rem;
}

/* -------------------- MOBILE AND TABLET (768px and below) -------------------- */

@media(max-width: 768px) {
  .product-details {
    grid-template-columns: 1fr;
    grid-template-areas:
      "gallery"
      "info"
      "description";
    /* One column: photos, then the buying box, then the description */
    row-gap: 2rem;
  }

  .back-link,
  .product-gallery {
    position: static;
    /* No sticking on mobile, as the photo would cover most of the screen */
  }

  .product-info h1 {
    font-size: 1.6rem;
  }
}