/* dictPopup.css — FINAL (fade-in / fade-out, clear animation) */

/* hidden = removed */
.dict-popover.hidden {
  display: none;
}

/* full-screen overlay root */
.dict-popover {
  position: fixed;
  inset: 0;
  z-index: 9999;

  /* we toggle this on open */
  pointer-events: none;
}

/* BACKDROP */
.dict-popover::before {
  content: "";
  position: absolute;
  inset: 0;

  /* stronger + more evident */
  background: rgba(2, 6, 23, 0.32);

  /* fade */
  opacity: 0;
  transition: opacity 220ms ease;
}

/* CARD (shared) */
.dict-card {
  pointer-events: auto;

  width: min(272px, calc(100vw - 24px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 18px;
  box-shadow: 0 22px 52px rgba(2, 6, 23, 0.22);
  backdrop-filter: blur(12px);
  overflow: hidden;

  opacity: 0;
  transform: translate3d(0, 14px, 0) scale(0.97);
  transition:
    opacity 240ms ease,
    transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1);
  will-change: opacity, transform;
}

/* OPEN STATE */
.dict-popover.is-open {
  pointer-events: auto;
}
.dict-popover.is-open::before {
  opacity: 1;
}
.dict-popover.is-open .dict-card {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

/* ===== Anchored (desktop popover next to word) ===== */
.dict-popover.is-anchored .dict-card {
  position: absolute; /* JS sets left/top */
}

/* Arrow (anchored only) */
.dict-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.94);
  border-left: 1px solid rgba(15, 23, 42, 0.12);
  border-top: 1px solid rgba(15, 23, 42, 0.12);
  transform: rotate(45deg);
  pointer-events: none;
}
.dict-popover.is-anchored .dict-arrow {
  display: block;
}
.dict-popover.is-sheet .dict-arrow {
  display: none;
}

/* ===== Sheet (phones / fallback) — centered modal ===== */
.dict-popover.is-sheet {
  display: grid;
  place-items: center;
}

.dict-popover.is-sheet .dict-card {
  position: relative;

  /* almost full width on phones */
  width: min(560px, calc(100vw - 24px));
  border-radius: 20px;

  /* a bit more "modal" feel */
  transform: translate3d(0, 18px, 0) scale(0.98);
}

/* little handle (kid-friendly) */
.dict-popover.is-sheet .dict-head::before {
  content: "";
  display: block;
  width: 46px;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
  margin: 0 auto 8px;
}

/* ===== Content styling ===== */
.dict-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  background: linear-gradient(
    90deg,
    rgba(217, 198, 249, 0.22),
    rgba(199, 180, 232, 0.18)
  );
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.dict-word {
  font-weight: 900;
  font-size: 16px;
  color: rgba(38, 14, 71, 0.92);
  letter-spacing: 0.2px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dict-close {
  border: 0;
  background: rgba(109, 40, 217, 0.1);
  color: rgba(38, 14, 71, 0.78);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.dict-body {
  padding: 10px 12px 12px;
}

.dict-meanings {
  margin: 0;
  padding-left: 18px;
  color: rgba(15, 23, 42, 0.88);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
}

.dict-meanings li {
  margin: 6px 0;
}

.dict-meanings.hidden {
  display: none;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .dict-popover::before,
  .dict-card {
    transition: none !important;
  }
  .dict-card {
    transform: none !important;
  }
}

/* Screen lock while dict is loading (popover still clickable) */
body.dict-busy #mainContainer {
  pointer-events: none;
}

/* allow popover interactions even when locked */
body.dict-busy #dictPopover,
body.dict-busy #dictPopover * {
  pointer-events: auto;
}

/* loading state */
#dictPopover.is-loading .dict-card {
  opacity: 0.95;
}

#dictPopover.is-loading .dict-meanings {
  opacity: 0.75;
}

/* single meaning: no numbering */
#dictPopover .dict-meanings.is-single {
  list-style: none;
  padding-left: 0;
  margin-left: 0;
}
#dictPopover .dict-meanings.is-single li {
  padding-left: 0;
}

.dict-divider {
  height: 1px;
  background: rgba(15, 23, 42, 0.12);
  margin: 10px 0;
  border-radius: 999px;
}

#dictMeanings.is-single {
  list-style: none;
  padding-left: 0;
}

/* if a language section has exactly 1 meaning: hide marker for that li */
#dictMeanings li.no-num::marker {
  content: "";
}

/* if you prefer fully removing the space too */
#dictMeanings li.no-num {
  margin-left: 0;
}

#dictMeanings {
  padding-left: 28px;
}

/* Language header aligns with the numbers column */
.dict-lang {
  margin: 6px 0 8px 0;
  padding-left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  left: 6px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  color: rgba(38, 14, 71, 0.86);
  opacity: 0.92;
  white-space: nowrap;
}

.dict-lang img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border: 0px;
}

.dict-card {
  width: min(520px, calc(100vw - 64px)); /* ✅ desktop daha geniş */
}

/* mobile: neredeyse tam ekran */
@media (max-width: 640px) {
  .dict-card {
    width: calc(100vw - 16px); /* ✅ full width */
    border-radius: 18px;
  }
  /* popover containerı da full */
  .dict-popover {
    left: 8px !important;
    right: 8px !important;
  }
}

/* outer list (senin ana <ol id="dictMeanings"> ) */
.dict-meanings {
  margin: 0;
  padding-left: 22px; /* ✅ daha az gap */
}

/* her dil için oluşturduğumuz inner ol */
.dict-lang-list {
  margin: 6px 0 12px 22px;
  padding: 0;
}

/* list item spacing */
.dict-meanings li,
.dict-lang-list li {
  margin: 6px 0;
}

.dict-body {
  padding: 12px 12px 14px;
}

.dict-character {
  display: flex;
  align-items: flex-start; /* ✅ bubble yukarı */
  gap: 10px;
  margin-bottom: 10px;
}

.dict-character-img {
  width: auto;
  height: auto;
  max-width: 92px;
  max-height: 92px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 10px 18px rgba(38, 14, 71, 0.14));
  margin-top: 2px; /* ✅ daha tatlı hizalama */
}

@media (max-width: 640px) {
  .dict-character-img {
    max-width: 80px;
    max-height: 80px;
  }
}

/* bubble */
.dict-bubble {
  position: relative;
  flex: 1;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(109, 40, 217, 0.14);
  box-shadow: 0 16px 34px rgba(38, 14, 71, 0.1);
  backdrop-filter: blur(10px);

  transform: translateY(-4px); /* ✅ bubble biraz yukarı */
}

/* tail: yukarı hizala */
.dict-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px; /* ✅ bottom yerine top */
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.92);
  border-left: 1px solid rgba(109, 40, 217, 0.14);
  border-bottom: 1px solid rgba(109, 40, 217, 0.14);
  transform: rotate(45deg);
}

/* star + text line */
.dict-bubble-text {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  color: rgba(38, 14, 71, 0.86);
}

.dict-star {
  flex: 0 0 auto;
  margin-top: 1px;
}

/* readability */
.dict-meanings {
  color: rgba(38, 14, 71, 0.88);
}

@media (max-width: 640px) {
  .dict-bubble {
    transform: translateY(-2px);
  }
}

/* reader-shell relative olmalı ki absolute overlay onun içinde çalışsın */
#reader-shell {
  position: relative;
}

/* hidden */
.dict-popover.hidden {
  display: none;
}

/* overlay artık fixed değil, reader-shell içinde absolute */
.dict-popover {
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;

  /* ✅ always centered */
  display: grid;
  place-items: center;
}

/* backdrop */
.dict-popover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.32);
  opacity: 0;
  transition: opacity 220ms ease;
}

/* card */
.dict-card {
  pointer-events: auto;
  position: relative;

  width: min(560px, calc(100% - 24px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 20px;
  box-shadow: 0 22px 52px rgba(2, 6, 23, 0.22);
  backdrop-filter: blur(12px);
  overflow: hidden;

  opacity: 0;
  transform: translate3d(0, 14px, 0) scale(0.97);
  transition:
    opacity 240ms ease,
    transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1);
  will-change: opacity, transform;
}

/* open */
.dict-popover.is-open {
  pointer-events: auto;
}
.dict-popover.is-open::before {
  opacity: 1;
}
.dict-popover.is-open .dict-card {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

/* arrow artık yok */
.dict-arrow {
  display: none !important;
}

/* mobile: almost full */
@media (max-width: 640px) {
  .dict-card {
    width: calc(100% - 16px);
    border-radius: 18px;
  }
}

/* ---------- Dictionary guided hand demo ---------- */
.dict-demo-hand {
  position: fixed;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  z-index: 10040;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 0) scale(0.96);
  will-change: transform, opacity;
}

.dict-demo-hand.hidden {
  display: none !important;
}

.dict-demo-hand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 10px 18px rgba(2, 6, 23, 0.22));
}

.dict-demo-hand.is-visible {
  opacity: 1;
  transition:
    opacity 180ms ease,
    transform 220ms ease;
}

.dict-demo-hand.is-tap {
  transition:
    transform 120ms ease,
    opacity 180ms ease;
  transform: translate3d(var(--dx, 0), var(--dy, 0), 0) scale(0.88);
}

@media (max-width: 640px) {
  .dict-demo-hand {
    width: 58px;
    height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dict-demo-hand,
  .dict-demo-hand.is-visible,
  .dict-demo-hand.is-tap {
    transition: none !important;
  }
}
