/* ============================================================
   WP Tooltip Popup — Frontend Styles
   Click to open / × to close
   ============================================================ */

/* ── Trigger (click-inviting design) ── */
.wttp-trigger {
    display: inline;
    color: #2563eb;
    cursor: pointer;
    line-height: inherit;
    border-bottom: 1.5px dashed #93c5fd;
    position: relative;
    transition: color .2s, border-color .2s;
    text-decoration: none;
}

/* ▼ indicator */
.wttp-trigger::after {
    content: '\25BC';
    display: inline-block;
    font-size: .55em;
    margin-left: 4px;
    vertical-align: middle;
    opacity: .5;
    transition: transform .2s, opacity .2s;
}

.wttp-trigger:hover {
    color: #1d4ed8;
    border-bottom-color: #3b82f6;
    border-bottom-style: solid;
}

.wttp-trigger:hover::after {
    opacity: .8;
    transform: translateY(1px);
}

.wttp-trigger.wttp-open {
    color: #1d4ed8;
    border-bottom-color: #3b82f6;
}

.wttp-trigger.wttp-open::after {
    transform: rotate(180deg);
    opacity: .8;
}

.wttp-trigger:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Popup (fixed, scrollable) ── */
.wttp-popup {
    display: none;
    position: fixed;
    z-index: 999999;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 14px rgba(0,0,0,.08);
    padding: 20px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: #1e293b;
    word-wrap: break-word;
    min-width: 260px;
    max-height: 60vh;
    overflow-y: auto;
    pointer-events: auto;
    white-space: normal;
}

.wttp-popup.wttp-visible {
    display: block;
    animation: wttpPopIn .2s ease;
}

/* ── Close button ── */
.wttp-popup-close {
    position: sticky;
    top: 0;
    float: right;
    width: 26px;
    height: 26px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: -4px -8px 4px 8px;
    z-index: 1;
    flex-shrink: 0;
}

.wttp-popup-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* ── Arrow ── */
.wttp-popup::before {
    content: '';
    position: absolute;
    border: 7px solid transparent;
    pointer-events: none;
}

.wttp-popup.wttp-pos-top::before {
    top: 100%;
    left: var(--wttp-arrow-left, 20px);
    border-top-color: #ffffff;
}

.wttp-popup.wttp-pos-bottom::before {
    bottom: 100%;
    left: var(--wttp-arrow-left, 20px);
    border-bottom-color: #ffffff;
}

/* ── Backdrop ── */
.wttp-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.1);
    z-index: 999998;
}

.wttp-backdrop.wttp-visible {
    display: block;
}

/* ── Animation ── */
@keyframes wttpPopIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Popup inner defaults ── */
.wttp-popup h1, .wttp-popup h2, .wttp-popup h3,
.wttp-popup h4, .wttp-popup h5, .wttp-popup h6 {
    margin: 0 0 8px;
    font-weight: 700;
    line-height: 1.3;
}

.wttp-popup p        { margin: 0 0 8px; }
.wttp-popup p:last-child { margin-bottom: 0; }

.wttp-popup ul,
.wttp-popup ol       { padding-left: 1.4em; margin: 0 0 8px; }
.wttp-popup li       { margin-bottom: 2px; }

.wttp-popup img      { max-width: 100%; height: auto; border-radius: 4px; }
.wttp-popup a        { color: #6366f1; text-decoration: underline; }

/* ── Scrollbar ── */
.wttp-popup::-webkit-scrollbar       { width: 6px; }
.wttp-popup::-webkit-scrollbar-track { background: transparent; }
.wttp-popup::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.wttp-popup::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .wttp-popup.wttp-visible { animation: none; }
    .wttp-trigger::after     { transition: none; }
}

/* ── Mobile: bottom sheet ── */
@media (max-width: 600px) {
    .wttp-popup.wttp-visible {
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        max-height: 70vh;
        border-radius: 14px 14px 10px 10px;
        animation: wttpSlideUp .25s ease;
    }
    .wttp-popup::before { display: none; }

    @keyframes wttpSlideUp {
        from { opacity: 0; transform: translateY(30px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}
