/* Prism Translate — injected page styles. Scoped under .prism-* to avoid host clashes. */

.prism-translation {
  display: block;
  /* Chinese typography: keep words intact, balance lines, hang punctuation. */
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: pretty;
  hanging-punctuation: allow-end;
  color: inherit;
  font-size: inherit;
  line-height: 1.6;
  margin-top: 0.25em;
}

.prism-translation .prism-num {
  white-space: nowrap;
}

/* Display styles */
.prism-style-underline .prism-inner {
  border-bottom: 2px solid rgba(99, 102, 241, 0.45);
  padding-bottom: 1px;
}
.prism-style-dashed .prism-inner {
  border-bottom: 1px dashed rgba(99, 102, 241, 0.6);
  padding-bottom: 1px;
}
.prism-style-highlight .prism-inner {
  background: linear-gradient(transparent 60%, rgba(99, 102, 241, 0.22) 0);
}
.prism-style-dim .prism-inner {
  opacity: 0.78;
}
.prism-style-block {
  border-left: 3px solid rgba(99, 102, 241, 0.55);
  padding-left: 0.6em;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 3px;
}

.prism-pending .prism-inner {
  opacity: 0.5;
  font-style: italic;
}
.prism-pending .prism-inner::after {
  content: " ⋯";
  animation: prism-blink 1s steps(2) infinite;
}
.prism-error .prism-inner {
  color: #ef4444;
  font-size: 0.85em;
}
@keyframes prism-blink {
  50% { opacity: 0.2; }
}

/* ============ Floating overlays — liquid glass, gradient accents, choreographed motion ============ */
:root {
  --prism-glass: rgba(20, 17, 38, 0.66);
  --prism-glass-2: rgba(26, 22, 46, 0.74);
  --prism-rim: rgba(255, 255, 255, 0.14);
  --prism-grad: linear-gradient(135deg, #818cf8, #f472b6);
  --prism-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Selection bubble */
#prism-bubble {
  position: absolute;
  z-index: 2147483646;
  transform: translate(-50%, 0);
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--prism-glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  color: #f2effb;
  border: 1px solid var(--prism-rim);
  border-radius: 999px;
  padding: 7px 14px 7px 9px;
  font: 600 13px/1.4 -apple-system, "PingFang SC", system-ui, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 34px rgba(8, 6, 20, 0.5);
  cursor: pointer;
  user-select: none;
  animation: prism-pop 0.32s var(--prism-ease) both;
  transition: transform 0.14s var(--prism-ease), box-shadow 0.14s var(--prism-ease);
}
#prism-bubble:hover { transform: translate(-50%, -1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 14px 42px rgba(8, 6, 20, 0.62); }
#prism-bubble:active { transform: translate(-50%, 0) scale(0.97); }
#prism-bubble .prism-logo {
  width: 18px; height: 18px; border-radius: 6px;
  background: var(--prism-grad);
  box-shadow: 0 2px 9px rgba(244, 114, 182, 0.5);
  display: inline-block; position: relative; flex: none;
}
#prism-bubble .prism-logo::after { /* white prism triangle */
  content: ""; position: absolute; left: 50%; top: 53%; transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 7px solid rgba(255, 255, 255, 0.94);
}

/* Result popover */
#prism-popover {
  position: absolute;
  z-index: 2147483647;
  max-width: 400px;
  overflow: hidden;
  background: var(--prism-glass-2);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  color: #f2effb;
  border: 1px solid var(--prism-rim);
  border-radius: 16px;
  padding: 15px 17px 14px;
  font: 14px/1.75 -apple-system, "PingFang SC", system-ui, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 22px 60px rgba(8, 6, 20, 0.6);
  word-break: keep-all;
  text-wrap: pretty;
  animation: prism-rise 0.36s var(--prism-ease) both;
}
#prism-popover::before { /* gradient hairline along the top edge */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--prism-grad);
}
#prism-popover .prism-pop-src {
  color: #a39ec2;
  font-size: 12px;
  margin-bottom: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  max-height: 60px;
  overflow: hidden;
}
#prism-popover .prism-pop-body { font-size: 15px; line-height: 1.75; }
#prism-popover .prism-pop-meta {
  margin-top: 12px;
  font-size: 11px;
  color: #8b86a8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#prism-popover .prism-pop-meta b { color: #c4bfe0; font-weight: 600; }
#prism-popover .prism-pop-loading { color: #a39ec2; font-style: italic; }
#prism-popover .prism-copy {
  color: #c4b5fd; cursor: pointer; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(129, 140, 248, 0.14);
  transition: background 0.14s var(--prism-ease);
}
#prism-popover .prism-copy:hover { background: rgba(129, 140, 248, 0.26); }

/* Progress toast */
#prism-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  background: var(--prism-glass-2);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  color: #f2effb;
  border: 1px solid var(--prism-rim);
  border-radius: 14px;
  padding: 12px 16px;
  font: 600 13px/1.4 -apple-system, "PingFang SC", system-ui, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 16px 44px rgba(8, 6, 20, 0.5);
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 200px;
  animation: prism-rise 0.34s var(--prism-ease) both;
}
#prism-toast .prism-bar {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
#prism-toast .prism-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--prism-grad);
  transition: width 0.3s var(--prism-ease);
}
#prism-toast .prism-spin {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: conic-gradient(from 0deg, rgba(255, 255, 255, 0.1), #f472b6);
  -webkit-mask: radial-gradient(farthest-side, transparent 58%, #000 60%);
  mask: radial-gradient(farthest-side, transparent 58%, #000 60%);
  animation: prism-rot 0.8s linear infinite;
}
@keyframes prism-rot { to { transform: rotate(360deg); } }
@keyframes prism-pop { from { opacity: 0; transform: translate(-50%, 7px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes prism-rise { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@media (prefers-reduced-motion: reduce) {
  #prism-bubble, #prism-popover, #prism-toast { animation: none; }
}
