/* bukkid — "Your book preview" (assets/js/childpreview.js).
   One light card, the same on the cream bookshelf, the navy Character Studio and the web app's
   phone column — so it pins its own ink rather than inheriting a page's text colour. Tokens are
   app.css's; nothing here restyles a page's own classes (everything is cp-). */

.cp-host[hidden] { display: none; }
.cp {
  margin-top: 18px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink-12); border-radius: 26px;
  padding: clamp(16px, 3vw, 28px); box-shadow: 0 12px 26px rgba(26, 36, 64, .08);
}
/* Only the FIRST paint fades in: the panel repaints when a page lands, and a panel that blinks each
   time is one a parent reads as broken. */
.cp.cp--fresh { animation: fadeUp .45s ease-out both; }
@keyframes cpFade { from { opacity: 0; } to { opacity: 1; } }
.cp-head { display: grid; gap: 6px; justify-items: start; }
.cp-eyebrow {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink); background: var(--amber);
  border-radius: var(--r-pill); padding: 3px 10px;
}
.cp-title { margin: 2px 0 0; font: 800 clamp(19px, 2vw, 24px)/1.15 var(--display); color: var(--ink); }
.cp-lede { margin: 0; max-width: 64ch; font-size: 13.5px; line-height: 1.55; color: var(--ink-68); }
.cp-error {
  margin-top: 12px; border: 2px solid var(--ink); border-radius: var(--r-field);
  background: var(--bad-bg); padding: 10px 13px; font-size: 13.5px; font-weight: 500; line-height: 1.5;
}

/* ----------------------------------------------------------- buttons */
.cp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--amber); color: var(--ink); border: 2.5px solid var(--ink);
  border-radius: var(--r-pill); box-shadow: 3px 3px 0 var(--ink);
  font: 800 16px/1.1 var(--display); padding: 13px 24px; cursor: pointer; text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.cp-btn:hover:not(:disabled) { color: var(--ink); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.cp-btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.cp-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.cp-btn--ghost { background: transparent; border-width: 2px; box-shadow: none; }
.cp-btn--ghost:hover:not(:disabled) { box-shadow: 3px 3px 0 var(--amber); }
.cp-btn--sm { font-size: 13.5px; padding: 9px 15px; }
.cp-head .cp-btn { margin-top: 6px; }
.cp-btn:focus-visible, .cp-open:focus-visible, .cp-zoom-close:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 3px;
}

/* ------------------------------------------------------ the two pages */
.cp-books {
  display: grid; gap: 16px; margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}
.cp-book { display: grid; gap: 8px; align-content: start; min-width: 0; }
.cp-book-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cp-book-head strong { font: 800 15px/1.25 var(--display); }
.cp-book-head span { flex: none; font-size: 12px; font-weight: 700; color: var(--ink-55); }
.cp-book-say { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-62); }

.cp-open {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: none;
  cursor: zoom-in; border-radius: 14px; font: inherit; color: inherit;
}
.cp-stage {
  position: relative; width: 100%; overflow: hidden; border-radius: 14px;
  background: #F2EDE3; box-shadow: 0 0 0 1.5px var(--ink-12), 0 12px 24px rgba(26, 36, 64, .12);
}
.cp-stage > .cp-art {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: fill;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.cp-stage.is-loading {
  background: linear-gradient(90deg, #F2EDE3 0, #FBF7EE 50%, #F2EDE3 100%) 0 0 / 600px 100%;
  animation: shimmer 1.3s linear infinite;
}
.cp-stage.is-loading > .cp-art { opacity: 0; }
.cp-stage.is-missing::before {
  content: 'This page did not load — reload to try again'; position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center; padding: 12%; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--ink-55);
}
.cp-stage > .cp-art { transition: opacity .25s ease; }
.cp-zoomhint {
  position: absolute; right: 10px; bottom: 10px; z-index: 40;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border-radius: var(--r-pill); background: rgba(26, 36, 64, .82); color: var(--cream);
  font-size: 12px; font-weight: 700; pointer-events: none;
}

/* waiting / drawing / failed: the page's own shape, holding the words for it */
.cp-ph {
  width: 100%; border-radius: 14px; display: grid; place-items: center; padding: 18px;
  background: repeating-linear-gradient(135deg, #F6EFE0 0 14px, #F1E8D6 14px 28px);
  border: 2px dashed var(--ink-35);
}
.cp-book--drawing .cp-ph { border-color: var(--coral); border-style: solid; }
.cp-book--failed .cp-ph { background: var(--bad-bg); border-style: solid; border-color: rgba(26, 36, 64, .25); }
.cp-ph-in {
  display: grid; gap: 8px; justify-items: center; text-align: center; max-width: 30ch;
  font-size: 13px; line-height: 1.5; color: var(--ink-72);
}
.cp-ph-in strong { font: 800 15px/1.3 var(--display); color: var(--ink); }
.cp-ph-lock {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 2px solid var(--ink); color: var(--ink);
}
.cp-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--ink-12); border-top-color: var(--coral);
  animation: spin .8s linear infinite;
}

/* ------------------------------------------- the wait (assets/js/drawingwait.js)
   While a child is drawn: the percentage, the step in words, and the books' reference family
   painted in one by one from the feet up, each hopping once in colour. The phone's
   components/drawingwait.tsx draws the same. */
.dw {
  width: 100%; display: grid; gap: 8px; justify-items: center; text-align: center;
  padding: 16px 14px 14px; border-radius: 14px; background: #DDEFF9;
}
.dw-num { display: flex; align-items: flex-start; font: 800 50px/1 var(--display); color: var(--ink); }
.dw-num-n { font-variant-numeric: tabular-nums; }
.dw-num small { font-size: 22px; line-height: 1.2; color: var(--coral); margin-left: 2px; }
.dw-label { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.dw-track {
  display: block; width: 100%; height: 8px; margin-top: 2px; border-radius: 4px; overflow: hidden;
  background: rgba(26, 36, 64, .1);
}
.dw-fill { display: block; width: 0; height: 100%; border-radius: 4px; background: var(--coral); transition: width .4s ease-out; }
.dw-row {
  --dw-h: 96px;
  width: 100%; height: calc(var(--dw-h) + 8px); margin-top: 8px; display: flex; align-items: flex-end;
  justify-content: center; gap: 4px; border-bottom: 3px solid rgba(26, 36, 64, .12);
}
.dw-fig {
  position: relative; flex: none;
  height: calc(var(--dw-h) * var(--s, 1)); width: calc(var(--dw-h) * var(--s, 1) * var(--a, .35));
  transform-origin: 50% 100%;
}
.dw-fig img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
/* waiting their turn: a faint shadow of them */
.dw-shadow { filter: brightness(0); opacity: .12; }
/* painted in from the feet up */
.dw-colour { clip-path: inset(100% 0 0 0); transition: clip-path .9s cubic-bezier(.65, 0, .35, 1); }
.dw-fig.is-in .dw-colour { clip-path: inset(0 0 0 0); }
.dw-edge {
  position: absolute; left: -2px; right: -2px; bottom: 0; height: 3px; border-radius: 2px;
  background: var(--amber); opacity: 0;
}
.dw-fig.is-painting .dw-edge { animation: dwEdge .9s cubic-bezier(.65, 0, .35, 1) forwards; }
/* then a little hop now and then, the row taking turns */
.dw-fig.is-in { animation: dwHop 2.3s ease-in-out calc(.9s + var(--i, 0) * .18s) infinite; }
.dw-caption { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; line-height: 1.45; color: var(--ink-62); }
@keyframes dwEdge { 0% { bottom: 0; opacity: 1; } 92% { opacity: 1; } 100% { bottom: 100%; opacity: 0; } }
@keyframes dwHop {
  0%, 22%, 100% { transform: translateY(0) rotate(0deg); }
  10% { transform: translateY(-7px) rotate(var(--tilt, 3deg)); }
}

/* ------------------------------------------------------- locked pages */
.cp-locked {
  margin-top: 20px; padding-top: 16px; border-top: 1.5px dashed var(--ink-12);
  display: grid; gap: 12px;
}
.cp-locked-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cp-locked-head strong { font: 800 15px/1.2 var(--display); }
.cp-locked-head > span:last-child { flex-basis: 100%; font-size: 13px; font-weight: 600; color: var(--ink-62); }
.cp-lock-badge {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--amber);
}
.cp-locked-book { display: grid; gap: 6px; }
.cp-locked-title { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-55); }
.cp-locked-grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}
.cp-thumb {
  position: relative; overflow: hidden; border-radius: 10px; background: #E9E1D1;
  box-shadow: 0 0 0 1.5px var(--ink-12);
}
.cp-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* a veil, so a thumbnail reads as "not yet" even where the blur leaves a bright colour */
.cp-thumb::after { content: ''; position: absolute; inset: 0; background: rgba(251, 243, 227, .28); }
.cp-thumb-lock {
  position: absolute; left: 50%; top: 50%; z-index: 1; transform: translate(-50%, -58%);
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(26, 36, 64, .86); color: var(--cream); box-shadow: 0 6px 14px rgba(26, 36, 64, .25);
}
.cp-thumb-label {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 4px 6px;
  font-size: 10.5px; font-weight: 700; color: var(--ink); text-align: center;
  background: rgba(255, 253, 246, .82);
}

/* ------------------------------------------------------------ the order */
.cp-cta {
  margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.cp-cta-note { font-size: 13px; font-weight: 600; color: var(--ink-62); max-width: 44ch; }

/* ------------------------------------------------------ the page, large */
.cp-zoom {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(16, 24, 46, .88); animation: cpFade .2s ease-out both;
}
.cp-zoom-frame {
  margin: 0; width: min(94vw, calc((100dvh - 96px) * var(--cp-a, .707)));
  display: grid; gap: 10px; color: var(--cream);
}
.cp-zoom-frame .cp-stage { border-radius: 10px; box-shadow: 0 30px 60px -18px rgba(0, 0, 0, .7); }
.cp-zoom-frame figcaption { font-size: 13.5px; text-align: center; color: rgba(251, 243, 227, .8); }
.cp-zoom-frame figcaption strong { font-family: var(--display); color: var(--cream); }
.cp-zoom-close {
  position: fixed; top: 14px; right: 14px; z-index: 1; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--cream); color: var(--ink); border: 2px solid var(--ink);
}

/* ------------------------------------------------ the phone column (app.html) */
.cp--compact { margin: 14px 20px 0; border-radius: 20px; padding: 16px; }
.cp--compact .cp-books { grid-template-columns: 1fr; gap: 14px; }
.cp--compact .cp-locked-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cp--compact .cp-cta .cp-btn { width: 100%; }

@media (max-width: 520px) {
  .cp-locked-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cp-cta .cp-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .cp.cp--fresh, .cp-zoom { animation: none; }
  .cp-stage.is-loading { animation: none; }
  /* the wait: nobody hops, and a member is simply in colour */
  .dw-fig.is-in, .dw-fig.is-painting .dw-edge { animation: none; }
  .dw-colour, .dw-fill { transition: none; }
}
