/* site.css - Page-level layout rules only (no hard-coded colors/fonts, uses tokens and pd- components) */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

/* Admin shell layout enhancements for consistency across all screens */
.pd-admin {
  min-height: 100vh;
  align-items: stretch;
}

.pd-side {
  flex: 0 0 240px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.pd-main {
  flex: 1 1 0;
  min-width: 0;
  padding: 32px clamp(16px, 3vw, 40px) 56px;
}

@media (max-width: 768px) {
  .pd-side {
    position: static;
    min-height: auto;
    width: 100%;
    flex: 1 1 100%;
  }
}

/* Sticky buy bar (product page, phones and small tablets up to 1024px; none on desktop). */
.pd-buybar { display: none; }
@media (max-width: 1024px) {
  .pd-buybar {
    --pd-buybar-h: 76px;
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--card);
    border-top: var(--stroke) solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .pd-buybar.is-visible { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .pd-buybar__in { max-width: 1200px; margin: 0 auto; min-height: var(--pd-buybar-h); box-sizing: border-box; padding: var(--space-3) var(--space-5); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
  .pd-buybar__info { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
  .pd-buybar__price { font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; }
  .pd-buybar__meta { font-size: 15px; font-weight: 700; color: var(--ink-muted); white-space: nowrap; }
  .pd-buybar__btn { flex: 0 0 auto; white-space: nowrap; }
  /* The footer ends above the bar (reserved from the first paint, so nothing shifts). */
  .pd-has-buybar .pd-footer { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  /* Keyboard focus scrolls an element clear of the bar (bar height + safe area + 20px; WCAG 2.4.11). */
  html:has(> body.pd-has-buybar) { scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
/* Below 560px only the full-width "Buy for $N" button (it already says the price; the separate
   price repeated it, and the "20 pages · US Letter + A4" note was cut off at 420px). */
@media (max-width: 559.98px) {
  .pd-buybar__in { padding-inline: var(--space-4); }
  .pd-buybar__info { display: none; }
  .pd-buybar__btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .pd-buybar, .pd-buybar.is-visible { transition: none; }
}

/* Home hero layout */
.pd-hero {
  padding-top: var(--space-7);
  padding-bottom: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-7);
}

.pd-hero__col {
  flex: 1 1 460px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  container-type: inline-size; /* the h1 size follows this column (cqi), not the viewport */
}

.pd-hero__h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  /* "fresh printables," and "dropped weekly." are kept whole with &nbsp; in home.php; the size
     keeps the longer one (about 7.5em) inside the column, so no line is a single word. */
  font-size: clamp(44px, 7vw, 84px);
  font-size: clamp(32px, 12.5cqi, 84px);
  line-height: 0.95;
  letter-spacing: -2px;
  text-wrap: balance;
}

.pd-hero__lead {
  margin: 0;
  font-size: 20px;
  line-height: 1.55;
  max-width: 520px;
  color: var(--ink);
  text-wrap: pretty;
}

.pd-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
}

.pd-hero__card {
  flex: 1 1 380px;
  min-width: 0;
  text-decoration: none;
  color: var(--ink);
  display: block;
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
}

.pd-hero__frame {
  background: var(--card);
  border: var(--stroke) solid var(--line);
  border-radius: 14px;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(var(--tilt-page));
  overflow: hidden;
}

/* Home section layouts */
.pd-section-latest {
  padding-top: var(--space-5);
  padding-bottom: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.pd-latest-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.pd-drops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

.pd-lanes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.pd-lane-tile {
  text-decoration: none;
  color: var(--ink);
  border: var(--stroke) solid var(--line);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  container-type: inline-size; /* the h3 fits this width (100cqi) */
}

.pd-lane-tile h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  /* Titles are joined with &nbsp; (no one-word lines); the size shrinks until the longest,
     "coloring pages" (14 characters), fits the tile, e.g. 3 tiles in a row at 600px. */
  font-size: clamp(20px, min(8.7vw, calc(100cqi / 7.7)), 30px);
}

/* Styleguide layout styles */
.sg-section {
  margin-block: var(--space-7);
}

.sg-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}

.sg-palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.sg-swatch {
  height: 90px;
  border-radius: var(--radius-md);
  border: var(--stroke) solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-2);
  font-size: 12px;
  font-weight: 700;
}

.sg-theme-picker {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-3);
  background: var(--card);
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-pill);
  align-items: center;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

/* Product Hero Layout: gallery top left, "about this pack" under it, the sidebar (buy card and
   free box) spans both rows on the right. Row 2 is 1fr so a tall sidebar never opens a gap
   between the gallery and the about section. Phones use the flex column further down. */
.pd-prod-hero {
  padding-top: 24px;
  padding-bottom: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-rows: auto 1fr;
  column-gap: 40px;
  row-gap: 40px;
  align-items: start;
}

.pd-prod-gallery { grid-column: 1; grid-row: 1; }
.pd-prod-sidebar { grid-column: 2; grid-row: 1 / span 2; }
.pd-prod-about { grid-column: 1; grid-row: 2; min-width: 0; }

.pd-prod-gallery {
  flex: 1 1 480px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pd-prod-preview-box {
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-lg);
  height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pd-prod-sticker {
  position: absolute;
  top: 20px;
  left: 20px;
}

.pd-prod-preview-frame {
  width: 300px;
  height: 388px;
  background: var(--card);
  border: var(--stroke) solid var(--line);
  border-radius: 12px;
  transform: rotate(var(--tilt-page));
  overflow: hidden;
}

.pd-prod-preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--card);
}

/* Gallery thumbnails: real images, fixed size, one row that scrolls sideways when it is full */
.pd-prod-thumbs {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 4px 4px 8px;
  -webkit-overflow-scrolling: touch;
}

.gallery-thumb {
  flex: 0 0 auto;
  width: 80px;
  height: 96px;
  padding: 4px;
  border: var(--stroke-thin) solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.gallery-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  pointer-events: none;
}

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

.gallery-thumb.is-selected,
.gallery-thumb[aria-pressed="true"] {
  border: var(--stroke) solid var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  padding: 3px;
}

.gallery-thumb:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.pd-prod-sidebar {
  flex: 0 1 380px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pd-prod-buycard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  container-type: inline-size; /* the title scales to this width (100cqi) */
}

.pd-prod-crumbs {
  padding-top: 20px;
  font-size: 14px;
}

.pd-prod-lane {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-muted);
}

.pd-prod-title {
  margin: 0;
  text-wrap: balance;
  font-family: var(--font-display);
  font-weight: 800;
  /* --pd-fit (set by product.php from heading_groups) shrinks the title until its longest
     unbreakable run of words fits the card, so no line holds a single word. */
  font-size: clamp(22px, calc(100cqi / var(--pd-fit, 8)), 34px);
  line-height: 1.05;
  letter-spacing: -1px;
}

.pd-prod-short {
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
}

.pd-prod-price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 48px;
  line-height: 1;
}

/* Fact chips: small, one style, data-driven (page count, paper sizes, format) */
.pd-prod-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pd-prod-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: var(--stroke-thin) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

/* Copy sections from listing.json */
.pd-prod-section {
  padding-bottom: 48px;
}

.pd-prod-h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.1;
  text-wrap: balance;
}

.pd-prod-desc {
  max-width: 720px;
}

.pd-prod-desc p {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.65;
}

.pd-prod-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.pd-prod-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pd-prod-card ul,
.pd-prod-card ol {
  margin: 0;
  padding-left: 20px;
  font-size: 16px;
  line-height: 1.6;
}

.pd-prod-card li + li { margin-top: 6px; }

.pd-prod-card p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.pd-prod-faq {
  max-width: 760px;
  padding: 6px 22px;
}

.pd-prod-faq details {
  padding: 16px 0;
}

.pd-prod-faq details + details {
  border-top: 1.5px dashed var(--line);
}

.pd-prod-faq summary {
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
}

.pd-prod-faq p {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-muted);
}

.pd-prod-freebox {
  border: var(--stroke) dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
}

/* Mobile Product Layout (Review 02 item 2: gallery ~320px, buy card right after gallery before thumbnails) */
@media (max-width: 768px) {
  .pd-prod-hero {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 16px;
  }

  .pd-prod-about {
    order: 5;
    width: 100%;
    margin-top: 16px;
  }

  .pd-prod-gallery {
    flex: 0 0 auto; /* column layout: a flex-basis would become a height */
    width: 100%;
    order: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .pd-prod-preview-box {
    height: 320px;
  }

  .pd-prod-preview-frame {
    width: 190px;
    height: 246px;
  }

  .pd-prod-title {
    font-size: clamp(22px, calc(100cqi / var(--pd-fit, 8)), 32px);
  }

  .pd-prod-sidebar {
    width: 100%;
    order: 2;
    display: contents; /* Allows children to be reordered with thumbs */
  }

  .pd-prod-buycard {
    order: 2;
    width: 100%;
  }

  .pd-prod-thumbs {
    order: 3;
    width: 100%;
  }

  .gallery-thumb {
    width: 68px;
    height: 84px;
  }

  .pd-prod-freebox {
    order: 4;
    width: 100%;
    margin-top: 10px;
  }
}

/* Part C: Admin on phones (review-03 item 6: below 768px, sidebar becomes a compact top bar ~120px tall) */
@media (max-width: 768px) {
  .pd-admin {
    flex-direction: column;
  }

  .pd-side {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: 125px;
    padding: 10px 14px 12px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .pd-side > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .pd-side__brand {
    font-size: 17px;
    padding: 0;
  }

  .pd-side nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .pd-side nav a {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .pd-side a[href="/"] {
    display: none; /* Hide 'View store' in compact mobile top bar */
  }

  .pd-main {
    padding: 20px 14px 40px;
    gap: 16px;
  }
}

/* Quiver Studio: tile open button + full-screen design viewer */
.pd-tile__open { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; border-radius: var(--radius-sm); }
.pd-tile__open img { width: 100%; height: 100%; object-fit: contain; }
.pd-main .pd-select { width: 100%; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
.pd-tile__open:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.pd-viewer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); }
.pd-viewer[open] { display: flex; flex-direction: column; }
.pd-viewer::backdrop { background: transparent; }
.pd-viewer__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: var(--stroke) solid var(--line); }
.pd-viewer__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
.pd-viewer__title h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1.1; }
.pd-viewer__pos { font-size: 14px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.pd-viewer__stage { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); padding: var(--space-5); }
.pd-viewer__page { margin: 0; justify-self: center; height: 100%; max-height: 100%; aspect-ratio: 8.5 / 11; max-width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 6%; background: #FFFFFF; border: var(--stroke) solid var(--line); border-radius: var(--radius-sm); }
.pd-viewer__page img { width: 100%; height: 100%; object-fit: contain; }
.pd-viewer__arrow { width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); border: var(--stroke) solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.pd-viewer__arrow:hover:not([disabled]) { background: var(--sunny); }
.pd-viewer__arrow:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.pd-viewer__arrow[disabled] { opacity: 0.35; cursor: default; }
.pd-viewer__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-5); border-top: var(--stroke) solid var(--line); }
.pd-viewer__actions .pd-btn { min-width: 150px; }
.pd-viewer__actions #viewer-approve[aria-pressed="true"] { background: var(--tint-coloring); }
.pd-viewer__actions #viewer-reject[aria-pressed="true"] { background: var(--tint-danger); }
.pd-viewer__hint { flex-basis: 100%; margin: 0; text-align: center; font-size: 13px; color: var(--ink-muted); }

@media (max-width: 640px) {
  .pd-viewer__bar { padding: var(--space-3) var(--space-4); }
  .pd-viewer__title h2 { font-size: 20px; }
  .pd-viewer__stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: var(--space-4); }
  .pd-viewer__page { grid-column: 1; grid-row: 1; height: auto; width: 100%; max-height: 100%; }
  .pd-viewer__arrow { grid-row: 2; width: 48px; height: 48px; }
  #viewer-prev { grid-column: 1; justify-self: start; }
  #viewer-next { grid-column: 1; justify-self: end; }
  .pd-viewer__actions .pd-btn { flex: 1 1 0; min-width: 0; }
}
