/* ===== Hostidex 3D Flipbook v1.6 — Frontend ===== */

.h3df-viewer {
  --h3df-height: 720px;
  --h3df-zoom: 1;
  width: 100%;
  margin: 22px auto;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(135deg, #111827, #1f2937);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .22);
  font-family: Inter, Arial, sans-serif;
  color: #fff;
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
}
.h3df-viewer * { box-sizing: border-box; }

/* ----- Toolbar ----- */
.h3df-toolbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(2, 6, 23, .94);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  position: relative;
  z-index: 20;
}
.h3df-title {
  font-size: 15px;
  font-weight: 700;
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.h3df-counter {
  font-size: 13px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, .08);
  padding: 7px 10px;
  border-radius: 999px;
}
.h3df-counter em { font-style: normal; }

.h3df-btn, .h3df-download {
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: .18s ease;
  line-height: 1;
}
.h3df-btn:hover, .h3df-download:hover {
  transform: translateY(-1px);
  background: #f59e0b;
  color: #111827;
}

/* "İlk / Son" butonlarını disabled göster */
.h3df-at-first [data-h3df-action="first"],
.h3df-at-first [data-h3df-action="prev"],
.h3df-at-last  [data-h3df-action="next"],
.h3df-at-last  [data-h3df-action="last"] {
  opacity: .35;
  pointer-events: none;
}

/* ----- Stage ----- */
.h3df-stage {
  height: var(--h3df-height);
  min-height: 420px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(circle at center, #475569 0, #1f2937 48%, #020617 100%);
  overflow: hidden;
}

/* ----- Sayfa elementleri (loadFromHTML modu) ----- */
/* loadFromHTML: StPageFlip bunları CSS 3D transform ile döndürür.
   Tarayıcı render eder → Retina/DPR tam çözünürlük, canvas pikselleşmesi yok. */
.h3df-pf-page {
  display: block;
  width:   100%;
  height:  100%;
  overflow: hidden;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}
.h3df-pf-page img {
  display: block;
  width:   100%;
  height:  100%;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ----- Hint metni ----- */
.h3df-hint {
  margin: 0;
  padding: 7px 14px 11px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: .25px;
  color: rgba(255, 255, 255, .42);
  line-height: 1.4;
}
.h3df-hint-mobile  { display: none; }
.h3df-hint-desktop { display: inline; }

/* ----- Book container (StPageFlip renders inside here) ----- */
.h3df-pageflip-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
}

.h3df-book {
  position: relative;
  transform: scale(var(--h3df-zoom));
  transform-origin: center center;
  transition: transform .18s ease;
  /* StPageFlip kendi perspektifini yönetir — overflow serbest bırakılır */
}

/* ----- Loader / Error ----- */
.h3df-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, .74);
  backdrop-filter: blur(6px);
  font-weight: 800;
  letter-spacing: .2px;
  z-index: 50;
}
.h3df-error {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  background: #fee2e2;
  color: #991b1b;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  font-weight: 700;
  z-index: 60;
}
.h3df-shortcode-error {
  padding: 14px 16px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 12px;
  font-weight: 700;
}

/* ----- Thumbnail kartı ----- */
.h3df-thumb-card {
  border: 0;
  background: #fff;
  border-radius: 20px;
  padding: 14px;
  width: 230px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .14);
  cursor: pointer;
  text-align: left;
  transition: .22s ease;
  color: #111827;
  display: inline-block;
  font-family: Inter, Arial, sans-serif;
}
.h3df-thumb-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .2);
}
.h3df-thumb-cover {
  height: 300px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e5e7eb, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}
.h3df-thumb-cover canvas { width: 100%; height: 100%; object-fit: cover; }
.h3df-thumb-cover i {
  position: absolute;
  left: 10px;
  top: 10px;
  background: #111827;
  color: #fff;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.h3df-thumb-card strong { display: block; text-align: center; font-size: 15px; font-weight: 800; }

/* ----- Modal ----- */
.h3df-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: none;
  width: 100vw;
  height: 100vh;
}
.h3df-modal.is-open { display: block; }
.h3df-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .88);
  backdrop-filter: blur(8px);
  z-index: 1;
}
.h3df-modal-dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background: #020617;
  z-index: 2;
}
.h3df-modal-close {
  position: absolute;
  right: 18px;
  top: 13px;
  z-index: 80;
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #ef4444;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  font-weight: 300;
}
.h3df-modal .h3df-viewer {
  margin: 0;
  border-radius: 0;
  max-width: none !important;
  width: 100% !important;
  height: 100vh;
  box-shadow: none;
}
.h3df-modal .h3df-stage {
  height: calc(100vh - 62px);
  min-height: 0;
  border-radius: 0;
  padding: 10px;
}
.h3df-lock { overflow: hidden !important; }
.h3df-context-popup .h3df-toolbar { padding-right: 68px; }

/* ----- Responsive ----- */
@media (max-width: 780px) {
  .h3df-hint-desktop { display: none; }
  .h3df-hint-mobile  { display: inline; }

  /* Stage yüksekliği: A4 dikey oran (√2 ≈ 1.41) × tam genişlik, max 88vh */
  .h3df-viewer {
    --h3df-height: min(88vh, calc(100vw * 1.45));
    margin: 10px auto;
    border-radius: 14px;
  }

  .h3df-toolbar {
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 10px;
  }
  .h3df-title { flex: 1 0 100%; order: -1; font-size: 13px; }

  .h3df-stage {
    padding: 8px;
    align-items: center;
    justify-content: center;
  }

  /* Sayfa çevirme butonlarını küçült */
  .h3df-btn, .h3df-download { height: 34px; min-width: 34px; padding: 0 8px; font-size: 13px; }

  /* Modal: araç çubuğu wrap edilince daha yüksek olabilir */
  .h3df-modal .h3df-stage { height: calc(var(--dvh, 100vh) - 108px); }

  .h3df-thumb-card { width: 190px; }
  .h3df-thumb-cover { height: 250px; }
}

/* Yatay (landscape) mobil: ekran kısa olduğundan yüksekliği sınırla */
@media (max-width: 900px) and (orientation: landscape) {
  .h3df-viewer {
    --h3df-height: min(85vh, 520px);
  }
  .h3df-modal .h3df-stage { height: calc(var(--dvh, 100vh) - 62px); }
}

/* dvh desteği olmayan tarayıcılar için fallback */
@supports (height: 100dvh) {
  .h3df-modal .h3df-stage { height: calc(100dvh - 62px); }
  @media (max-width: 780px) {
    .h3df-modal .h3df-stage { height: calc(100dvh - 108px); }
  }
}
