/* Word popup. Split from the single original stylesheet; zero visual change. */

/* Word popup (replaces the detail panel) — anchored popover on desktop */
.popup-backdrop {
  position: fixed; inset: 0; z-index: 50;
  /* Transparent: the orbit stays visible (spatial encoding preserved). */
  background: transparent;
}

.popup {
  background: var(--panel); border-radius: var(--radius);
  max-width: 380px; width: max-content; min-width: 280px;
  max-height: 70vh; overflow: auto; padding: 1.25rem 1.5rem; position: absolute;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18); border: 1px solid var(--line);
  animation: popup-in 0.18s ease-out;
}

/* Mobile: bottom sheet */
@media (max-width: 640px) {
  .popup {
    left: 0 !important; right: 0; top: auto !important; bottom: 0;
    max-width: none; width: auto; min-width: 0;
    max-height: 75vh; border-radius: var(--radius) var(--radius) 0 0;
  }
}

@keyframes popup-in { from { transform: translateY(10px) scale(0.98); opacity: 0.7; } to { transform: none; opacity: 1; } }

.popup-close {
  position: absolute; top: 0.6rem; right: 0.8rem;
  font: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--muted);
  min-width: 44px; min-height: 44px;
}

.popup-close:hover { color: var(--ink); }

#popup-word { font-size: 1.5rem; margin: 0 2.5rem 0 0; }

#popup-word:focus { outline: none; }

#popup-word:focus-visible { outline: 3px solid var(--focus); }

.popup-body { margin: 0.75rem 0; }

.popup-body > div { margin-bottom: 0.9rem; }

.popup-body dt { font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.popup-body dd { margin: 0.15rem 0 0; }

.popup-body dd ul { margin: 0.25rem 0; padding-left: 1.2rem; }

.popup-actions { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }

.synonym-chip {
  font: inherit; font-size: 0.9rem; cursor: pointer; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; padding: 0 0.8rem;
  margin: 0.15rem 0.25rem 0.15rem 0; min-height: 44px;
  display: inline-flex; align-items: center; box-sizing: border-box;
}

.synonym-chip:hover { border-color: var(--accent); }

.other-content { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }

.other-content summary { cursor: pointer; font-weight: 600; min-height: 44px; }

.other-entry {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 0.6rem 0.75rem; margin: 0.5rem 0;
}

.other-entry:hover { border-color: var(--accent); }

.other-entry .excerpt { font-size: 0.9rem; }

.other-entry .rank { font-size: 0.8rem; color: var(--muted); }

.skeleton { color: var(--muted); }

/* Mobile: bottom-sheet popup, tighter orbit */
@media (max-width: 640px) {
.popup {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    max-width: none; width: auto; max-height: 82vh;
    border-radius: 16px 16px 0 0; border-top: 3px solid var(--accent);
    box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
    animation: sheet-in 0.22s ease-out;
    margin: 0;
  }
/* Centered dialogs (.popup-centered, topbar.css) become bottom sheets
   on phone too. The sheet rules above never reset the desktop
   translate(-50%, -50%), so a centered dialog sat half off the left
   edge and half a height up — unusable on iOS (feedback, 2026-11-06).
   topbar.css loads after this file, so this needs the higher
   specificity (.popup.popup-centered) to win on transform/width. */
.popup.popup-centered {
    transform: none;
    width: auto;
    max-width: none;
  }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}
