/* Sesli dijital kitap - arayüz
   Kitap ölçüsü 1116x600 (js/app.js -> BOOK_W / BOOK_H)                */

:root {
  --bg-1: #241d2b;
  --bg-2: #14111a;
  --ink: #f3eef7;
  --ink-soft: #b9aec6;
  --accent: #ffb43d;
  --accent-2: #ff7a59;
  --panel: rgba(24, 19, 31, .78);
  --panel-line: rgba(255, 255, 255, .12);
  --page-h: 600px;      /* JS günceller */
  --page-w: 558px;      /* JS günceller */
  --bar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, var(--bg-2) 70%) fixed;
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#stage { position: fixed; inset: 0; }

#bookArea {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#flipWrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#flipbook { position: relative; margin: 0 auto; touch-action: pan-y; }

/* kitabın dış gölgesi (sayfaların arkasında) */
#flipbook::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .62), 0 4px 14px rgba(0, 0, 0, .45);
}
#flipbook.is-ready { animation: bookIn .5s ease both; }
@keyframes bookIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* StPageFlip: .stf__block ölçüsünü wrapper'dan alır */
#flipbook .stf__wrapper { position: relative; width: 100%; height: 100%; }

/* ---------- yarım sayfalar ---------- */
.page {
  background: #0f0d13;
  overflow: hidden;
}
.page-inner { position: absolute; inset: 0; overflow: hidden; }

/* görsel iki yarıma bölünür: her yarım, çift sayfanın kendi penceresi */
.page-img {
  position: absolute;
  top: 0;
  height: 100%;
  width: 200%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.page-img.left  { left: 0; }
.page-img.right { left: -100%; }

/* kâğıdın orta kırıma doğru hafif kıvrımı */
.paper-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.half-left .paper-shade {
  background: linear-gradient(to right,
      rgba(255, 255, 255, .05) 0%,
      rgba(255, 255, 255, 0) 12%,
      rgba(0, 0, 0, .10) 78%,
      rgba(0, 0, 0, .22) 100%);
}
.half-right .paper-shade {
  background: linear-gradient(to left,
      rgba(255, 255, 255, .05) 0%,
      rgba(255, 255, 255, 0) 12%,
      rgba(0, 0, 0, .10) 78%,
      rgba(0, 0, 0, .22) 100%);
}

/* orta kırım (cilt payı) izi */
.spine-shade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7%;
  pointer-events: none;
}
.half-left .spine-shade {
  right: 0;
  background: linear-gradient(to right,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, .30) 62%,
      rgba(0, 0, 0, .58) 92%,
      rgba(255, 255, 255, .10) 100%);
}
.half-right .spine-shade {
  left: 0;
  background: linear-gradient(to left,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, .30) 62%,
      rgba(0, 0, 0, .58) 92%,
      rgba(255, 255, 255, .10) 100%);
}

/* dış kenarda kâğıt kalınlığı hissi */
.edge-shade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  pointer-events: none;
}
.half-left .edge-shade {
  left: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, .30), rgba(0, 0, 0, 0));
}
.half-right .edge-shade {
  right: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, .30), rgba(0, 0, 0, 0));
}

/* ---------- metin (sağ sayfa) ---------- */
.page-scrim {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 56%;
  background: linear-gradient(to top,
      rgba(6, 4, 10, .90) 0%,
      rgba(6, 4, 10, .74) 30%,
      rgba(6, 4, 10, .40) 60%,
      rgba(6, 4, 10, .12) 84%,
      rgba(6, 4, 10, 0) 100%);
  pointer-events: none;
}
.page-text {
  position: absolute;
  left: 7%;
  right: 7%;
  color: #fff;
  font-size: calc(var(--page-h) * .0345);
  line-height: 1.45;
  letter-spacing: .1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .75), 0 1px 2px rgba(0, 0, 0, .9);
  text-wrap: pretty;
}
/* metin sunumdaki konumuna göre üstte ya da altta (boyutu JS sığdırır) */
.pos-bottom .page-text { bottom: 8%; }
.pos-top .page-text { top: 7%; }
.pos-top .page-scrim {
  top: 0;
  bottom: auto;
  background: linear-gradient(to bottom,
      rgba(6, 4, 10, .90) 0%,
      rgba(6, 4, 10, .74) 30%,
      rgba(6, 4, 10, .40) 60%,
      rgba(6, 4, 10, .12) 84%,
      rgba(6, 4, 10, 0) 100%);
}
.page-text p { margin: 0 0 .5em; }
.page-text p:last-child { margin-bottom: 0; }
.page-text b { font-weight: 700; color: #ffe6b0; }

.page-num {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--page-h) * .022);
  min-width: calc(var(--page-h) * .046);
  padding: calc(var(--page-h) * .006) calc(var(--page-h) * .014);
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  font-size: calc(var(--page-h) * .024);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

/* çalan sayfa göstergesi (sol sayfada) */
.page-speaker {
  position: absolute;
  top: calc(var(--page-h) * .035);
  left: calc(var(--page-h) * .035);
  width: calc(var(--page-h) * .07);
  height: calc(var(--page-h) * .07);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255, 255, 255, .22);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.page-speaker svg { width: 58%; height: 58%; fill: #fff; }
/* sağ yarıdaysa dış (sağ üst) köşeye */
.half-right .page-speaker { left: auto; right: calc(var(--page-h) * .035); }
.is-speaking .page-speaker { opacity: 1; }
.is-speaking .page-speaker::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 180, 61, .8);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  from { transform: scale(1); opacity: .85; }
  to   { transform: scale(1.45); opacity: 0; }
}

/* ---------- üst şerit (kitabın üzerinde) ---------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(10px, 2vw, 18px);
  z-index: 10;
  transition: opacity .35s;
  background: linear-gradient(to bottom, rgba(10, 8, 14, .55), rgba(10, 8, 14, 0));
}
.book-title {
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 600;
  letter-spacing: .2px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- yan oklar ---------- */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(34px, 3.2vw, 46px);
  height: clamp(50px, 4.8vw, 70px);
  border: 1px solid var(--panel-line);
  background: rgba(20, 16, 26, .5);
  backdrop-filter: blur(8px);
  color: var(--ink);
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 10;
  transition: background .18s, opacity .35s;
}
.nav-arrow.left { left: clamp(6px, 1.4vw, 18px); }
.nav-arrow.right { right: clamp(6px, 1.4vw, 18px); }
.nav-arrow svg { width: 24px; height: 24px; }
.nav-arrow:hover { background: rgba(255, 180, 61, .26); }
.nav-arrow:disabled { opacity: .22; cursor: default; }
@media (max-width: 720px) { .nav-arrow { display: none; } }

/* ---------- alt kontrol çubuğu (kitabın üzerinde yüzer) ---------- */
#controls {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--bar-h);
  padding: 0 12px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
  z-index: 10;
  transition: opacity .35s, transform .35s;
}
.bar-sep {
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: rgba(255, 255, 255, .14);
}

/* hareketsizken arayüz kaybolur, kitap tamamen görünür */
html.idle #controls { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
html.idle #topbar { opacity: 0; pointer-events: none; }
html.idle .nav-arrow { opacity: 0; pointer-events: none; }

.icon-btn {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.icon-btn svg { width: 21px; height: 21px; fill: currentColor; }
svg.stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { background: rgba(255, 255, 255, .10); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.on { color: #17131c; background: var(--accent); border-color: var(--accent); }

.play-btn {
  width: 46px; height: 46px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1b1420;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(255, 140, 60, .38);
  transition: transform .16s;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn svg { width: 24px; height: 24px; fill: currentColor; grid-area: 1 / 1; }
.play-btn .ico-pause { display: none; }
.play-btn.playing .ico-play { display: none; }
.play-btn.playing .ico-pause { display: block; }

.page-badge {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  padding: 6px 8px;
}
.page-badge .sep { opacity: .5; margin: 0 2px; }

/* ---------- küçük resimler ---------- */
#thumbsPanel {
  position: fixed;
  inset: auto clamp(8px, 2vw, 22px) calc(var(--bar-h) + 22px) clamp(8px, 2vw, 22px);
  max-height: 52vh;
  background: rgba(18, 14, 24, .96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .55);
  padding: 14px clamp(10px, 2vw, 22px) 16px;
  z-index: 40;
  overflow: auto;
  animation: sheetIn .26s ease both;
}
@keyframes sheetIn { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.thumbs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 12px;
}
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.thumb {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  background: #0d0b11;
  cursor: pointer;
  aspect-ratio: 1116 / 600;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span {
  position: absolute;
  bottom: 6px; left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.thumb.current { border-color: var(--accent); }

/* ---------- perde ---------- */
#curtain {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(90% 70% at 50% 30%, rgba(48, 34, 62, .96), rgba(12, 10, 16, .98));
  backdrop-filter: blur(6px);
  transition: opacity .4s;
}
#curtain.hide { opacity: 0; pointer-events: none; }
.curtain-card {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 40px);
  max-width: 940px;
  width: 100%;
}
.cover-frame {
  flex: 1 1 52%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
  aspect-ratio: 1116 / 600;
  background: #0d0b11;
}
.cover-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.curtain-text { flex: 1 1 48%; }
.kicker {
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}
#curtainTitle {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.4vw, 40px);
  line-height: 1.15;
  font-weight: 700;
}
.meta { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; }
.curtain-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1b1420;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(255, 140, 60, .34);
  transition: transform .16s;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary svg { width: 20px; height: 20px; fill: currentColor; }
.btn-ghost {
  padding: 13px 20px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  transition: background .16s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
@media (max-width: 760px) {
  .curtain-card { flex-direction: column; text-align: center; }
  .curtain-actions { justify-content: center; }
}

/* ---------- ipuçları ---------- */
#hint {
  position: fixed;
  left: 50%;
  top: 54px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .58);
  border: 1px solid var(--panel-line);
  color: var(--ink-soft);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s;
  z-index: 30;
}
#hint.show { opacity: 1; }

#rotateTip {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 30px);
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(18, 14, 24, .92);
  border: 1px solid var(--panel-line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color: var(--ink);
  font-size: 13px;
  z-index: 45;
  max-width: 92vw;
}
#rotateTip svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 1.8; }
#rotateTip button {
  margin-left: 4px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
@media (max-width: 700px) and (orientation: portrait) {
  #rotateTip.show { display: flex; }
}

/* ---------- kısa ekranlar ---------- */
@media (max-height: 520px) {
  #controls { height: 48px; bottom: 8px; }
  #controls .icon-btn { width: 34px; height: 34px; }
  #controls .play-btn { width: 40px; height: 40px; }
  #topbar { padding: 6px 10px; }
}

/* ---------- kapaklar (sert kapak) ---------- */
.page-img.full { left: 0; width: 100%; }

.page.cover { background: #17121d; }
/* kapakta hafif parlaklık */
.cover-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(118deg,
      rgba(255, 255, 255, .12) 0%,
      rgba(255, 255, 255, .03) 22%,
      rgba(255, 255, 255, 0) 46%);
}

/* kapaklarda sayfa numarası yerine etiket */
.page-badge.is-cover .sep,
.page-badge.is-cover #pageTotal { display: none; }

/* arka kapakta yazar çocukların adları */
.cover-credit {
  position: absolute;
  left: 8%;
  bottom: 6%;
  max-width: 80%;
  padding: calc(var(--page-h) * .012) calc(var(--page-h) * .024);
  border-radius: calc(var(--page-h) * .02);
  background: rgba(10, 8, 16, .58);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: calc(var(--page-h) * .03);
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
  backdrop-filter: blur(3px);
}
.cover-credit span {
  display: block;
  font-size: .62em;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .15em;
}

/* önizleme modu (?onizleme=N): yalnız kitap */
html.onizleme #controls,
html.onizleme #topbar,
html.onizleme .nav-arrow,
html.onizleme #hint,
html.onizleme #rotateTip,
html.onizleme #curtain { display: none !important; }
html.onizleme #flipbook.is-ready { animation: none; }
