@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;700&family=Nunito:wght@400;600;700;800&family=Patrick+Hand&display=swap');

:root {
  --ink: #2a332c;
  --ink-soft: #5c6b60;
  --paper: #f6f1e8;
  --cream: #fff9f0;
  --amber: #e8a54b;
  --amber-deep: #c47a2a;
  --leaf: #3d6b4f;
  --leaf-soft: #7fa88a;
  --bubble-child: #fff4e0;
  --bubble-parent: #e8f2ea;
  --page-w: 297mm;
  --page-h: 210mm;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: #2f3d34;
  color: var(--ink);
  line-height: 1.45;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.65rem 1.25rem;
  background: #1c2620;
  color: #f0e6d8;
  font-size: 0.9rem;
}
.toolbar a {
  color: #f0c987;
  text-decoration: none;
  font-weight: 700;
}
.toolbar .pdf-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6b2b 0%, #ff3d57 100%);
  color: #fff !important;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(255, 107, 43, 0.35);
}
.toolbar .pdf-btn:hover { filter: brightness(1.06); }
.toolbar strong {
  margin-left: 0.25rem;
}

.book {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 1rem 3rem;
}

.page {
  width: min(100%, 1100px);
  aspect-ratio: 297 / 210;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(232, 165, 75, 0.18), transparent 45%),
    radial-gradient(ellipse at 90% 100%, rgba(127, 168, 138, 0.22), transparent 40%),
    linear-gradient(165deg, #faf6f0 0%, #f1ebe2 55%, #e8e0d4 100%);
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  padding: 1.1rem 1.35rem;
  position: relative;
  overflow: hidden;
  page-break-after: always;
}

.page::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(196, 122, 42, 0.28);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}

/* COVER */
.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(61,107,79,0.2), transparent 42%),
    radial-gradient(ellipse at 50% 35%, #f0d9a8 0%, transparent 55%),
    linear-gradient(165deg, #dce9df 0%, #f0e2cc 45%, #d4c4a8 100%);
}
.cover-inner { position: relative; z-index: 1; max-width: 30rem; }
.series {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.7rem;
}
.cover h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-weight: 700;
  color: var(--leaf);
  line-height: 1.05;
  margin-bottom: 0.6rem;
}
.cover h1 span { color: var(--amber-deep); }
.subtitle {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin-bottom: 0.85rem;
}
.tagline {
  display: inline-block;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.35rem;
  color: var(--amber-deep);
  margin-bottom: 1rem;
}
.meta-line {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-bottom: 1.1rem;
}
.author {
  font-size: 0.95rem;
  color: var(--ink);
}

/* PARENT NOTE */
.parent-note h2,
.toc h2,
.closing h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--leaf);
  margin-bottom: 0.85rem;
}
.parent-note p,
.closing p {
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 0.65rem;
  max-width: 48rem;
}
.parent-note .lead { font-weight: 700; }

/* TOC */
.toc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.5rem;
  list-style: none;
  font-size: 0.95rem;
}
.toc-grid li {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed rgba(61,107,79,0.2);
}
.toc-grid .n {
  font-weight: 800;
  color: var(--amber-deep);
  min-width: 1.4rem;
}
.toc-grid .c {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-left: auto;
}

/* COUNTING SPREAD — photo first, talk on reveal */
.spread {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  gap: 0.75rem;
  height: 100%;
  position: relative;
  z-index: 1;
  transition: grid-template-columns 0.35s ease;
}

.spread.revealed {
  grid-template-columns: minmax(0, 1.45fr) minmax(220px, 0.7fr);
}

.photo-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, #f3ebe0, #ddd4c6 70%);
  min-height: 0;
  outline: none;
}

.photo-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  cursor: pointer;
  outline: none;
}
.photo-frame:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(196, 122, 42, 0.55);
}

.photo-panel img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.q-stamp {
  position: static;
  align-self: center;
  flex-shrink: 0;
  margin: 0.15rem 0 0.55rem;
  background: rgba(255,249,240,0.98);
  border: 2px solid var(--amber);
  border-radius: 999px;
  padding: 0.4rem 1.15rem;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--amber-deep);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  z-index: 1;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.2;
}
.q-stamp:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 6px 18px rgba(196, 122, 42, 0.28);
}
.q-stamp:active { transform: translateY(0); }
.spread.revealed .q-stamp {
  border-color: var(--leaf);
  color: var(--leaf);
}

.hint-tap {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255,249,240,0.88);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.25s ease;
}
.spread.revealed .hint-tap { opacity: 0; }

/* Talk panel: hidden until reveal — never overlays the photo */
.talk-panel {
  display: none;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(12px);
}
.spread.revealed .talk-panel {
  display: flex;
  animation: talkIn 0.35s ease forwards;
}
@keyframes talkIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.page-num {
  font-weight: 800;
  color: var(--amber-deep);
  font-size: 0.95rem;
}
.page-head h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.25rem;
  color: var(--leaf);
}
.concept {
  font-size: 0.75rem;
  color: var(--ink-soft);
  width: 100%;
}

.ask {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.15rem;
  color: var(--amber-deep);
}

.bubbles {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow: auto;
  padding-right: 0.15rem;
}
.bubble {
  position: relative;
  padding: 0.4rem 0.65rem;
  border-radius: 14px;
  font-size: 0.84rem;
  max-width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.bubble strong {
  display: inline-block;
  min-width: 2.2rem;
  font-size: 1.02rem;
  color: var(--amber-deep);
}
.bubble.count {
  background: var(--bubble-child);
  border: 1px solid rgba(232,165,75,0.45);
  align-self: flex-start;
}
.bubble.child {
  background: var(--bubble-child);
  border: 1px solid rgba(232,165,75,0.4);
  align-self: flex-start;
  font-family: 'Patrick Hand', cursive;
  font-size: 1rem;
}
.bubble.parent {
  background: var(--bubble-parent);
  border: 1px solid rgba(61,107,79,0.28);
  align-self: flex-end;
  font-size: 0.86rem;
}
.bubble .who {
  display: block;
  font-size: 0.68rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.1rem;
}

.tip {
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding-top: 0.3rem;
  border-top: 1px dashed rgba(61,107,79,0.25);
}

/* CLOSING */
.closing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.closing .cta {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.5rem;
  color: var(--amber-deep);
  margin-top: 0.75rem;
}
.sign-line {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

@media (max-width: 820px) {
  .page {
    aspect-ratio: auto;
    min-height: 70vh;
  }
  .spread.revealed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 55vh) auto;
  }
  .spread.revealed .talk-panel {
    max-height: none;
  }
}

@page {
  size: A4 landscape;
  margin: 0;
}

@media print {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  /* Screen chrome is dark (#2f3d34); do not print it. Pages keep their own cream. */
  html, body { background: #faf6f0 !important; }
  .toolbar { display: none !important; }
  .book { padding: 0; gap: 0; }
  .page {
    width: 297mm !important;
    height: 210mm !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    box-shadow: none;
    border-radius: 0;
    page-break-after: always;
    break-after: page;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  /* Print'te tıklanınca açılan metinler her zaman görünür */
  .spread {
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.75fr) !important;
  }
  .talk-panel {
    display: flex !important;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    overflow: visible !important;
  }
  .hint-tap { display: none !important; }
  .q-stamp {
    box-shadow: none;
    pointer-events: none;
  }
}
