/* Spec 022: printed books in the grown-ups area. Colours are tokens only (tokens.css); the
   preview's pages are SVG, painted here by class so no inline style is needed. */

.print-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.print-books,
.print-orders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}

/* Spec 164 (the owner, 2026-10-15: "very cluttered"; the printer icon "seems you can print the book yourself"): one row per
   finished book, the whole row one button: the cover, the title (whole, spec 127), the kid, and "Order a printed book" beside
   the open book; the chevron says it opens a page. */
.print-books,
.print-orders {
  gap: var(--space-3);
  /* Spec 164 (the owner: "pills should be same size"): every row of a list as tall as the tallest, titles at most two
     lines (.clamp-2), so the rows are one size. */
  grid-auto-rows: 1fr;
}

.print-book {
  display: flex;
}

.print-book-open {
  display: grid;
  grid-template-columns: 88px 1fr 22px;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  height: 100%;
  min-height: var(--touch-kid);
  padding: var(--space-3);
  border: 0;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.print-book-open:hover .print-book-title {
  text-decoration: underline;
}

.print-book-cover {
  width: 88px;
  height: 66px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-blue);
}

.print-book-words {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.print-book-open .print-book-title {
  overflow-wrap: break-word;
  hyphens: auto;
}


.print-book-action {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: var(--space-1);
  color: var(--accent-strong);
  font-weight: 700;
}

.print-book-action .icon {
  flex: none;
  width: 20px;
  height: 20px;
}

.print-book-chevron {
  width: 22px;
  height: 22px;
  color: var(--text-secondary);
}

.print-empty {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
}

.print-empty .icon {
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--accent-strong);
}

.print-lead {
  margin: 0;
  font-size: var(--font-md);
}

.print-facts {
  margin: 0;
}

.print-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.print-group > h2 {
  margin: 0;
}

/* Spec 164: an order's chip and day share a line that wraps; on its way, the four steps as a short bar. */
.print-order-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.print-order-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 160px;
  max-width: 100%;
  margin-top: 2px;
}

.print-order-steps > span {
  height: 6px;
  border-radius: 999px;
  background: var(--hairline);
}

.print-order-steps > span[data-done] {
  background: var(--accent-strong);
}

.print-book-title,
.print-order-title {
  margin: 0;
  font-weight: 700;
  color: var(--text);
}

.print-order {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Spec 164: compact rows, the phone's 12-point padding; the list's gap spaces them (no card margin on top of it). */
.print-orders .print-order,
.print-books .print-book-open {
  margin-bottom: 0;
  padding: var(--space-3);
}

.print-order p {
  margin: 0;
}

.print-order-error {
  color: var(--danger);
}

.print-order-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.print .button:not(.compact),
.print select,
.print-copies output {
  min-height: var(--touch-kid);
}

.print-copies {
  align-items: center;
  gap: var(--space-3);
}

.print-copies output {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-kid);
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text);
}

.print-copies .button {
  min-width: var(--touch-kid);
  font-size: var(--font-xl);
}

.print-price p {
  margin: 0 0 var(--space-1);
}

.print-total {
  font-weight: 700;
  font-size: var(--font-md);
}


/* The dedication box looks like the site's other fields (app.css styles input and select). */
.print textarea {
  min-height: calc(var(--touch-kid) * 1.5);
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  resize: vertical;
}

.print textarea:focus {
  border-color: var(--accent);
}

.print-pay {
  align-self: flex-start;
}

/* The preview: one sheet per printed page, scrolling sideways on a phone. */
.print-preview {
  /* Spec 142 (the owner on build 32: "the cover pages are not aligned with regular pages"): every sheet is this tall, the
     cover spread and the inside pages alike, each as wide as its own shape; they share one top and one foot. */
  --sheet-height: min(300px, 64vw);
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scroll-snap-type: x mandatory;
  /* Spec 205: the captions measure against the preview's own width (100cqi below). */
  container-type: inline-size;
}

.print-sheet {
  margin: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  /* The caption wraps to the sheet's width. */
  width: min-content;
  scroll-snap-align: start;
}

/* Spec 142: the paper's colour in every look (dark, bedtime): the preview is the book as printed. */
.print-sheet svg {
  display: block;
  height: var(--sheet-height);
  width: auto;
  max-width: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-raised);
  background: var(--print-paper);
}

.print-sheet figcaption {
  font-size: var(--font-xs);
  /* Spec 205: the cover spread is wider than a phone (571 px in a 366 px preview), so its caption ("the front is on the
     right, the back wraps…") ran past the edge; it wraps to what shows and stays at its left while the sheet scrolls. */
  max-width: 100cqi;
  position: sticky;
  left: 0;
}

/* Spec 116: the paper's colours are css/print-paper.css's pp- (fill) and ps- (stroke) classes, the same in every theme. */
.print-sheet .print-none {
  fill: none;
}

.print-sheet .print-text {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 600;
}

/* Spec 116: the book's three faces (css/print-fonts.css, and story-fonts.css's Patrick Hand cut). */
.print-sheet .print-face-display {
  font-family: "Xocana Print Display", "Baloo 2", system-ui, sans-serif;
  font-weight: 400;
}

.print-sheet .print-face-story {
  font-family: "Xocana Print Story", "Baloo 2", system-ui, sans-serif;
  font-weight: 400;
}

.print-sheet .print-face-accent {
  font-family: "Xocana Story Hand", "Baloo 2", system-ui, sans-serif;
  font-weight: 400;
}

/* Spec 127: the front cover's title and the spine's, in Luckiest Guy (one cut for both weights). */
.print-sheet .print-face-cover {
  font-family: "Xocana Print Cover", "Xocana Print Display", "Baloo 2", system-ui, sans-serif;
  font-weight: 400;
}

.print-sheet .print-bold {
  font-weight: 700;
}

.print-sheet .print-frame {
  fill: none;
  stroke-width: 2.5;
  stroke-dasharray: 8 6;
  stroke-linecap: round;
}

/* Spec 127: the cover's "Back" and "Front" above its halves, outside the picture (never on it, never printed). */
.print-sheet .print-cover-tags {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-2);
  /* Spec 142: one line tall on every sheet, an inside page's empty row too. */
  min-height: 1.5em;
  line-height: 1.5;
  width: 100%;
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
}

.print-sheet .print-cover-tag-spine:empty {
  display: none;
}

/* Spec 127: the cover title panel's soft shadow: the paper's navy, as the PDF paints it into the picture. */
.print-sheet .print-shadow {
  flood-color: var(--print-navy);
}

/* The cover's fold and cut lines (spec 102), drawn only in the preview; spec 127: only with "Show print margins". */
.print-sheet .print-trim {
  /* Spec 142: the paper's soft ink, not the look's (the lines sit on the paper). */
  stroke: var(--print-ink-soft);
  stroke-width: 2;
}

/* A colouring page prints as lines; the preview shows the picture faintly to say so. */
/* Spec 123: the line look is an SVG filter (views/print.js lineLook); kept a little light so it reads as a placeholder. */
.print-sheet .print-line-art {
  opacity: 0.75;
}

/* Spec 116: a story picture as the soft background of its words: blurred, under a veil of the paper's colour. */
.print-sheet .print-wash {
  filter: blur(14px);
}

.print-sheet .print-wash-veil {
  opacity: 0.58;
}

@media (prefers-reduced-motion: reduce) {
  .print-preview {
    scroll-behavior: auto;
  }
}

/* Spec 102: the two options, side by side (one above the other on a narrow phone); the whole card is the button. */
.print-formats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  /* Spec 123: every row as tall as the tallest card, so the two cards are the same size side by side and stacked. */
  grid-auto-rows: 1fr;
  gap: var(--space-3);
}

/* Spec 123: a new quote on its way keeps the old preview, a little faded, instead of any spinner. */
.print-preview[aria-busy="true"] {
  opacity: 0.6;
  transition: opacity 0.2s;
}

/* Spec 164: "Past orders (N)" is the page's last row, its chevron down while open. */
.print-past summary {
  list-style: none;
  cursor: pointer;
}

.print-past summary::-webkit-details-marker {
  display: none;
}

.print-past-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--touch-standard);
  padding: var(--space-2) 0;
  color: var(--accent-strong);
  font-weight: 700;
  border-top: 1px solid var(--hairline);
}

.print-past-chevron {
  width: 22px;
  height: 22px;
  transform: rotate(90deg);
  transition: transform 0.2s;
}

.print-past[open] .print-past-chevron {
  transform: rotate(-90deg);
}

.print-past[open] .print-orders {
  margin-top: var(--space-2);
}

@media (prefers-reduced-motion: reduce) {
  .print-past-chevron {
    transition: none;
  }
}

/* Spec 164 (the owner, 2026-10-15: "it is hard to understand which option is selected, hardcover or paperback. Make it
   more obvious"; the chosen card's pale fill matched the page, so the white one looked chosen). The app's choice card
   (spec 064) leads: the chosen card wears an accent header strip ("Selected"), a thick accent edge and the green check in
   its corner; the other is quiet: a hairline edge, no shadow, an empty radio circle. One card always wears the strip, so
   the page's height never changes with the choice. */
.print-format {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  min-height: var(--touch-kid);
  padding: var(--space-3) var(--space-4);
  overflow: hidden;
  border: 2px solid var(--hairline);
  background: var(--surface);
  box-shadow: none;
  text-align: start;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.print-format[aria-checked="true"] {
  padding-top: 0;
  border-color: var(--accent);
  /* A 4-point edge without moving the card: the border and a ring just inside it. */
  box-shadow: inset 0 0 0 2px var(--accent), var(--elevation-raised);
}

.print-format:focus-visible {
  outline: 3px solid var(--focus-ring, var(--accent));
  outline-offset: 3px;
}

.print-format-selected {
  align-self: stretch;
  margin: 0 calc(-1 * var(--space-4)) var(--space-2);
  padding: var(--space-1) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: var(--font-sm);
  letter-spacing: 0.02em;
  display: none;
}

.print-format[aria-checked="true"] .print-format-selected {
  display: block;
}

/* The radio: an empty circle, then the app's check badge (ChoiceCheck: the success colour, a surface ring). */
.print-format-radio {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  background: var(--surface);
  color: var(--on-accent);
}

.print-format-radio .icon {
  width: 20px;
  height: 20px;
  visibility: hidden;
}

.print-format[aria-checked="true"] .print-format-radio {
  top: calc(var(--space-1) * 2 + 1.5em + var(--space-2));
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface);
  background: var(--success);
  box-shadow: 0 0 0 1px var(--hairline);
  animation: choice-pop 0.22s ease-out;
}

.print-format[aria-checked="true"] .print-format-radio .icon {
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .print-format,
  .print-format[aria-checked="true"] .print-format-radio {
    transition: none;
    animation: none;
  }
}

/* Spec 164: "Preview: Paperback" over the preview, following the choice. */
.print-preview-format {
  align-self: flex-start;
  margin: 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: var(--font-sm);
}

.print-format:disabled {
  cursor: default;
}

.print-format-icon {
  width: 36px;
  height: 36px;
}

.print-format-name {
  font-weight: 700;
  font-size: var(--font-md);
}

.print-format-price {
  font-weight: 600;
  color: var(--accent-strong);
}

/* Spec 125: the order page's words about a free book's full story and the first Family book's offer; Settings' offer line;
   Home's printed-book card (no picture, so its words take the whole row). */
.print-full {
  font-weight: 700;
}

.print-discount,
.print-entry-offer {
  color: var(--accent-strong);
  font-weight: 700;
}

.print-full[hidden],
.print-discount[hidden] {
  display: none;
}

.home-print {
  grid-template-columns: minmax(0, 1fr);
  margin-block: var(--space-4);
}

/* Spec 112: the ways to a printed book where the book is. The End's card and My library's banner: a picture, the words,
   and the buttons wrapping under them. No price in kid mode. */
.print-offer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3) var(--space-4);
  align-items: center;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--elevation-rest);
  text-align: start;
}

.print-offer[hidden] {
  display: none;
}

.print-offer-art {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-purple);
}

.print-offer-art.friend {
  object-fit: contain;
  background: none;
}

.print-offer-words {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.print-offer-title {
  margin: 0;
  font-size: var(--font-lg);
  font-weight: 800;
}

.print-offer-line {
  margin: 0;
  color: var(--text-secondary);
}

.print-offer-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Upright, The End's parts are ordered (css/books.css): the card comes after the caption (the same order, later in the
   page) and before the buttons, so it never interrupts the celebration. */
.end-print {
  order: 4;
  width: min(100%, 34rem);
  margin: 0 auto;
}

/* Spec 112: the video page's small "Order a printed book" at its foot. */
.video-print {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: var(--space-2);
}

.video-print[hidden] {
  display: none;
}

.video-print .icon {
  width: 22px;
  height: 22px;
}

/* Spec 136 (the owner on build 31: "the title of the book plus the cover thumbnail centred above the Hardcover and other
   option"): the cover, a crayon book until it is known, and the title under it, centred. */
.print-book-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-3);
  text-align: center;
}

.print-book-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 168px;
  height: 130px;
  overflow: hidden;
  border: 3px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--crayon-blue);
  color: var(--on-crayon);
  box-shadow: var(--elevation-raised);
}

.print-book-thumb .icon {
  width: 48px;
  height: 48px;
}

.print-book-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.print-book-thumb img[hidden] {
  display: none;
}

.print-book-hero .print-book-name {
  max-width: 30rem;
  margin: 0;
  color: var(--text);
  font-size: var(--font-lg);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.print-book-hero .print-book-name[hidden] {
  display: none;
}

/* Spec 164 (the owner: "not so many vertical gaps between text describing the book"): a block of short paragraphs at
   normal paragraph spacing, one gap of the page between blocks. */
.print-about {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.print-about p {
  margin: 0;
}

.print-dedication textarea[aria-invalid="true"] {
  background: var(--surface);
}

/* Spec 225: wrap the page cards without horizontal scrolling; native radio keyboard behavior. */
.print-gifts { border: 0; padding: 0; min-width: 0; }
.print-gift-choices { margin-block: 8px 12px; }
.print-gift-names { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 var(--space-3); }
.print-gift-names .print-gift-rules { grid-column: 1 / -1; margin: 0 0 var(--space-2); }

/* Spec 225 amendment 2026-10-26: the dedication styles as chips, each a crayon icon and its name, wrapping onto as many rows
   as the width needs (two on a phone), so every style shows at once. The chosen chip takes the accent edge, a tint and a check. */
.gift-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px;
}
.gift-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 10px 4px 4px;
  border: 2px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-sm);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.gift-chip:hover { background: var(--surface-muted); }
.gift-chip[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.gift-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.gift-chip:disabled { opacity: 0.6; cursor: default; }
.gift-chip-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--on-crayon); }
.gift-chip-icon .icon { width: 18px; height: 18px; }
.gift-chip-classic .gift-chip-icon { background: var(--crayon-blue); }
.gift-chip-gift .gift-chip-icon { background: var(--crayon-pink); }
.gift-chip-birthday .gift-chip-icon { background: var(--crayon-orange); }
.gift-chip-winter .gift-chip-icon { background: var(--crayon-teal); }
.gift-chip-christmas .gift-chip-icon { background: var(--crayon-green); }
