/* ==========================================================================
   French Audio Studio - Word popover, shared by /study and /review
   (see static/word-popover.js)
   ========================================================================== */

.floating-word-popover {
    position: fixed;
    z-index: 9999;
    width: 290px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    animation: popoverFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center bottom;
}

.floating-word-popover.arrow-top {
    transform-origin: center top;
    animation-name: popoverFadeInBelow;
}

.floating-word-popover[hidden] {
    display: none !important;
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popoverFadeInBelow {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popover-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.floating-word-popover.arrow-top .popover-arrow {
    bottom: auto;
    top: -6px;
    transform: translateX(-50%) rotate(-135deg);
}

.popover-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.popover-meta,
.popover-main-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.popover-word-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.popover-word {
    font-size: 20px;
    font-weight: 750;
    color: var(--ink, var(--ink));
    font-family: var(--font-sans);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.btn-popover-star-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--line-strong);
    border-radius: 6px;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-popover-star-icon:hover {
    color: var(--accent);
    transform: scale(1.18);
}

.btn-popover-star-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: transparent;
    transition: all 0.15s ease;
}

.btn-popover-star-icon.active {
    color: var(--accent);
}

.btn-popover-star-icon.active svg {
    fill: var(--accent);
    stroke: var(--accent);
    filter: drop-shadow(0 1px 3px rgba(245, 158, 11, 0.45));
}

.popover-phonetic-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.btn-popover-speak-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-popover-speak-inline:hover {
    color: var(--primary);
    transform: scale(1.15);
}

.btn-popover-speak-inline svg {
    width: 18px;
    height: 18px;
}

.popover-phonetic {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    letter-spacing: 0.015em;
    cursor: pointer;
    user-select: text;
    transition: color 0.15s ease;
}

.popover-phonetic:hover {
    color: var(--primary);
}

.popover-close-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.popover-close-btn:hover {
    background: var(--surface-subtle);
    color: var(--ink);
}

.popover-close-btn svg {
    width: 14px;
    height: 14px;
}

.popover-body {
    min-height: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.popover-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--muted);
    padding: 4px 0;
}

.popover-loading[hidden],
#popover-loading[hidden] {
    display: none !important;
}

.popover-content[hidden],
#popover-content[hidden] {
    display: none !important;
}

.popover-loading svg {
    width: 14px;
    height: 14px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.popover-cn-text {
    font-size: 13.5px;
    font-weight: 550;
    color: var(--ink);
    line-height: 1.45;
}

.popover-en-text {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    margin-top: 2px;
}

.popover-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--surface-muted);
}

.btn-popover-star {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-popover-star.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-popover-star.active svg {
    fill: var(--accent);
    stroke: var(--accent);
}

/* Word importance (1-5 stars, like Eudic's word book) */
.popover-importance {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--muted);
}

.importance-stars button {
    border: none;
    background: none;
    padding: 0 1px;
    font-size: 18px;
    line-height: 1;
    color: var(--line-strong);
    cursor: pointer;
}

.importance-stars button.filled {
    color: var(--accent);
}

/* Tags inside the popover (the study page also styles these in its tables) */
.floating-word-popover .pos-tag {
    background: var(--surface-muted);
    color: var(--muted);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--line);
    font-family: ui-monospace, monospace;
    font-weight: 600;
}

.floating-word-popover .lemma-tag {
    color: var(--primary);
    font-weight: 600;
}

/* French words throughout the popup share lookup and back navigation. */
.popover-lookup-word {
    display: inline;
    padding: 2px 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--primary);
    font: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    cursor: pointer;
    touch-action: manipulation;
}
.popover-lookup-word:hover { background: var(--primary-soft); }
.popover-back {
    align-self: flex-start;
    max-width: 100%;
    min-height: 32px;
    padding: 2px 4px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.popover-back:hover { background: var(--primary-soft); }

.popover-word .popover-lookup-word { color: inherit; }
.popover-lookup-word:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
