/* Jackdaw Book — "The Book": a simple picture-book interface for children
   and grandparents. Loaded after styles.css; reuses its design tokens
   (--ink, --paper, --steel, --iris, --clay, --line, --muted, --slate) rather
   than inventing new ones. No network requests happen from this stylesheet
   or the page it styles. */

.book-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}

#bigtext-toggle { flex: 0 0 auto; min-height: 52px; }
#bigtext-toggle[aria-pressed="true"] { background: var(--steel); border-color: var(--steel); }

/* Bigger text: scale the shared type tokens rather than the whole page, so
   layout stays intact and every element that already reads var(--step-*)
   grows with it. */
body.bigtext {
  --step--1: 1.05rem;
  --step-0: 1.2rem;
  --step-1: 1.55rem;
  --step-2: 2rem;
  --step-3: 2.6rem;
  --step-4: 3.4rem;
}
body.bigtext .book-name { font-size: clamp(2.4rem, 7vw, 3.4rem); }
body.bigtext .book-portrait { width: 220px; height: 220px; }
body.bigtext .quiz-portrait { width: 220px; height: 220px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- tabs ---------- */

.book-tabs {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.5rem 0 1.5rem;
}
.book-tab {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 52px;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
  padding: 0.6rem 1.3rem; border-radius: 100px;
}
.book-tab:hover { border-color: var(--steel); }
.book-tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.book-panel[hidden] { display: none; }

/* ---------- read screen ---------- */

.book-stage { perspective: 1200px; margin-bottom: 1.25rem; }

.book-page {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; min-height: 22rem;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transform-style: preserve-3d;
}
.book-page.flip-next { animation: bookFlipNext 0.42s ease; }
.book-page.flip-prev { animation: bookFlipPrev 0.42s ease; }
@keyframes bookFlipNext {
  0% { transform: rotateY(0deg); opacity: 1; }
  45% { transform: rotateY(-14deg); opacity: 0.4; }
  55% { transform: rotateY(14deg); opacity: 0.4; }
  100% { transform: rotateY(0deg); opacity: 1; }
}
@keyframes bookFlipPrev {
  0% { transform: rotateY(0deg); opacity: 1; }
  45% { transform: rotateY(14deg); opacity: 0.4; }
  55% { transform: rotateY(-14deg); opacity: 0.4; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

.book-portrait {
  width: 180px; height: 180px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: #eceeef; border: 4px solid var(--line);
  font-size: 4.5rem; font-weight: 700; color: #fff; margin-bottom: 1.25rem; flex: 0 0 auto;
}
.book-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

.book-name {
  font-family: "Bricolage Grotesque", "Public Sans", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700; font-size: clamp(2rem, 6vw, 2.9rem); line-height: 1.1; margin: 0;
}
.book-relationship { font-size: var(--step-1); color: var(--slate); margin: 0.4rem 0 1rem; }

.book-tag {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: #fff; border: 1px solid var(--line); border-radius: 100px;
  padding: 0.35rem 0.9rem; font-size: var(--step--1); color: var(--slate); margin-bottom: 1rem;
}
.book-tag i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

.book-fact { font-size: var(--step-0); color: var(--muted); margin: 0.2rem 0; max-width: 30rem; }

.book-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.book-nav[hidden] { display: none; }
.btn-row[hidden] { display: none; }
.book-nav-btn { min-height: 52px; min-width: 8rem; font-size: var(--step-0); }
.book-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--ink); border-color: var(--ink); }
.book-counter { margin: 0; font-size: var(--step--1); color: var(--muted); }

.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: var(--steel);
  text-decoration: underline; cursor: pointer;
}

/* ---------- add a page ---------- */

.add-step { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 2rem; }
.step-num {
  flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: var(--step-0); margin: 0;
}
.step-body { flex: 1 1 auto; min-width: 0; }
.step-body > label, .step-label {
  display: block; font-weight: 600; font-size: var(--step-0); color: var(--slate);
  margin-bottom: 0.6rem;
}
#ap-name { font-size: var(--step-1); min-height: 52px; }

.choice-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.choice-btn {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 52px;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
  padding: 0.6rem 1.1rem; border-radius: 100px;
}
.choice-btn:hover { border-color: var(--steel); }
.choice-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.more-choices { margin-top: 0.75rem; }
.more-choices summary {
  cursor: pointer; font-weight: 600; color: var(--steel); min-height: 44px;
  display: flex; align-items: center;
}
.more-choices .choice-grid { margin-top: 0.75rem; }

.face-preview {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: #eceeef; border: 3px solid var(--line);
  font-size: 2.6rem; margin-bottom: 0.9rem;
}
.face-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.emoji-grid .choice-btn {
  min-width: 52px; min-height: 52px; padding: 0.4rem; font-size: 1.5rem;
  display: grid; place-items: center;
}

.photo-btn { display: inline-block; margin-top: 0.85rem; min-height: 52px; }

.book-save { font-size: var(--step-1); min-height: 52px; width: 100%; margin-top: 0.5rem; }
.book-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- who is this? ---------- */

.quiz-score { font-weight: 600; color: var(--slate); }
.quiz-portrait {
  width: 180px; height: 180px; border-radius: 50%; overflow: hidden; margin: 0 auto 1.25rem;
  display: grid; place-items: center; background: #eceeef; border: 4px solid var(--line);
  font-size: 4.5rem; font-weight: 700; color: #fff;
}
.quiz-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.quiz-question { text-align: center; font-size: var(--step-2); font-weight: 700; margin: 0 0 1.25rem; }
.quiz-choices { justify-content: center; }
.quiz-choices .choice-btn { min-width: 9rem; font-size: var(--step-0); }
.quiz-choices .choice-btn.is-correct { background: var(--steel); color: #fff; border-color: var(--steel); }
.quiz-choices .choice-btn.is-wrong { background: var(--clay); color: #fff; border-color: var(--clay); }
.quiz-choices .choice-btn:disabled { cursor: default; opacity: 1; }

#panel-quiz .msg { text-align: center; font-size: var(--step-0); }

@media (max-width: 600px) {
  .book-nav { flex-wrap: wrap; }
  .book-nav-btn { flex: 1 1 auto; }
}
