/* ═══════════════════════════════════════════════════
   Veridicity Vote v3.0 — per-paragraph popup styles
   ═══════════════════════════════════════════════════ */

:root {
    --vv-agree:    #16a34a;
    --vv-disagree: #dc2626;
    --vv-true:     #0891b2;
    --vv-false:    #d97706;
    --vv-accent:   #2563eb;
    --vv-bg:       #ffffff;
    --vv-border:   #e2e8f0;
    --vv-text:     #1e293b;
    --vv-muted:    #94a3b8;
    --vv-star:     #f59e0b;
    --vv-shadow:   0 8px 32px rgba(0, 0, 0, 0.13);
    --vv-radius:   8px;        /* trigger button radius */
    --vv-t:        0.15s ease;
}

/* ─────────────────────────────────────────────────
   Paragraph wrapper
───────────────────────────────────────────────── */
.vv-para-wrap {
    position: relative;
    /* Right padding makes room for the trigger button */
    padding-right: 52px;
    box-sizing: border-box;
}

/* ─────────────────────────────────────────────────
   Trigger wrap (anchors the button + popup)
───────────────────────────────────────────────── */
.vv-trigger-wrap {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

/* ─────────────────────────────────────────────────
   Trigger button — square, slightly rounded corners
───────────────────────────────────────────────── */
.vv-para-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 38px;
    height: 38px;
    border-radius: var(--vv-radius);   /* slightly rounded, as requested */
    border: 1.5px solid var(--vv-border);
    background: var(--vv-bg);
    color: var(--vv-muted);
    cursor: pointer;
    padding: 0;
    /* Hidden until paragraph is hovered or touch */
    opacity: 0;
    transform: scale(0.88);
    transition: opacity var(--vv-t), transform var(--vv-t), color var(--vv-t),
                border-color var(--vv-t), box-shadow var(--vv-t);
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* Show on paragraph hover (desktop) */
.vv-para-wrap:hover .vv-para-btn,
.vv-para-hovered .vv-para-btn,
.vv-para-btn:focus-visible {
    opacity: 1;
    transform: scale(1);
}

/* Always visible on touch devices */
@media (hover: none) {
    .vv-para-btn { opacity: 1; transform: scale(1); }
}

.vv-para-btn:hover {
    border-color: var(--vv-accent);
    color: var(--vv-accent);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.18);
}

.vv-para-btn[aria-expanded="true"] {
    border-color: var(--vv-accent);
    color: var(--vv-accent);
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.22);
}

.vv-para-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* Icon */
.vv-btn-svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Vote count badge */
.vv-para-count {
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Colour variants based on computed veracity */
.vv-trigger-wrap.vv-high .vv-para-btn { color: var(--vv-agree);    border-color: #bbf7d0; }
.vv-trigger-wrap.vv-mid  .vv-para-btn { color: var(--vv-accent);   border-color: #bfdbfe; }
.vv-trigger-wrap.vv-low  .vv-para-btn { color: var(--vv-disagree); border-color: #fecaca; }

.vv-trigger-wrap.vv-high .vv-para-btn:hover { border-color: var(--vv-agree); }
.vv-trigger-wrap.vv-mid  .vv-para-btn:hover { border-color: var(--vv-accent); }
.vv-trigger-wrap.vv-low  .vv-para-btn:hover { border-color: var(--vv-disagree); }

/* ─────────────────────────────────────────────────
   Popup panel
───────────────────────────────────────────────── */
.vv-popup {
    position: absolute;
    right: 46px;        /* opens to the LEFT of the trigger button */
    top: 50%;
    transform: translateY(-50%);
    width: 220px;
    background: var(--vv-bg);
    border: 1px solid var(--vv-border);
    border-radius: 12px;
    box-shadow: var(--vv-shadow);
    padding: 14px 14px 12px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: var(--vv-text);

    /* Animation */
    animation: vv-pop-in 0.16s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes vv-pop-in {
    from { opacity: 0; transform: translateY(-50%) scale(0.88); }
    to   { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* Arrow pointing to trigger button */
.vv-popup::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--vv-bg);
    border-right: 1px solid var(--vv-border);
    border-top: 1px solid var(--vv-border);
    transform: translateY(-50%) rotate(45deg);
}

/* Popup header: title + language toggle */
.vv-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

/* Popup title */
.vv-pop-title {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--vv-muted);
}

/* Language toggle (RO / EN) */
.vv-lang-toggle {
    display: inline-flex;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
}

.vv-lang-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--vv-muted);
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}

.vv-lang-btn + .vv-lang-btn {
    border-left: 1px solid #e2e8f0;
}

.vv-lang-btn:hover {
    color: #2563eb;
}

.vv-lang-btn.vv-lang-active {
    background: #2563eb;
    color: #fff;
}

.vv-lang-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* ─────────────────────────────────────────────────
   Reaction button rows
───────────────────────────────────────────────── */
.vv-pop-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.vv-pop-secondary {
    margin-bottom: 10px;
}

/* Individual reaction buttons */
.vv-pop-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 6px;
    border: 1.5px solid var(--vv-border);
    border-radius: 7px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--vv-text);
    transition: all var(--vv-t);
    white-space: nowrap;
}

.vv-pop-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.vv-pop-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.3);
}

.vv-pop-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.vv-pop-icon {
    font-size: 13px;
    line-height: 1;
}

/* Agree */
.vv-pop-btn.vv-agree  { color: var(--vv-agree); }
.vv-pop-btn.vv-agree:hover,
.vv-pop-btn.vv-agree.vv-sel  {
    background: #dcfce7;
    border-color: var(--vv-agree);
    color: var(--vv-agree);
}

/* Disagree */
.vv-pop-btn.vv-disagree { color: var(--vv-disagree); }
.vv-pop-btn.vv-disagree:hover,
.vv-pop-btn.vv-disagree.vv-sel {
    background: #fee2e2;
    border-color: var(--vv-disagree);
    color: var(--vv-disagree);
}

/* True */
.vv-pop-btn.vv-true  { color: var(--vv-true); }
.vv-pop-btn.vv-true:hover,
.vv-pop-btn.vv-true.vv-sel  {
    background: #cffafe;
    border-color: var(--vv-true);
    color: var(--vv-true);
}

/* False */
.vv-pop-btn.vv-false { color: var(--vv-false); }
.vv-pop-btn.vv-false:hover,
.vv-pop-btn.vv-false.vv-sel {
    background: #fef3c7;
    border-color: var(--vv-false);
    color: var(--vv-false);
}

/* ─────────────────────────────────────────────────
   Submit button
───────────────────────────────────────────────── */
.vv-pop-submit {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 7px;
    background: var(--vv-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--vv-t), transform var(--vv-t), opacity var(--vv-t);
    letter-spacing: 0.02em;
    margin-bottom: 10px;
}

.vv-pop-submit:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.vv-pop-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.vv-pop-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.35);
}

/* ─────────────────────────────────────────────────
   Stats line inside popup
───────────────────────────────────────────────── */
.vv-pop-stats {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--vv-muted);
    border-top: 1px solid var(--vv-border);
    padding-top: 8px;
    flex-wrap: wrap;
}

.vv-ps-score {
    font-weight: 700;
    color: var(--vv-accent);
}

.vv-ps-stars { letter-spacing: 1px; }
.vv-son  { color: var(--vv-star); }
.vv-soff { color: #d1d5db; }

.vv-ps-empty {
    font-style: italic;
    font-size: 11px;
}

/* ─────────────────────────────────────────────────
   Popup message (success / error)
───────────────────────────────────────────────── */
.vv-pop-msg {
    margin-top: 6px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.vv-msg-ok   { background: #dcfce7; color: var(--vv-agree); }
.vv-msg-err  { background: #fee2e2; color: var(--vv-disagree); }
.vv-msg-info { background: #e0f2fe; color: #075985; }

/* ─────────────────────────────────────────────────
   Admin labels
───────────────────────────────────────────────── */
.vv-admin-agree    { color: var(--vv-agree);    font-weight: 600; }
.vv-admin-disagree { color: var(--vv-disagree); font-weight: 600; }
.vv-admin-true     { color: var(--vv-true);     font-weight: 600; }
.vv-admin-false    { color: var(--vv-false);    font-weight: 600; }

/* ─────────────────────────────────────────────────
   Responsive — phones (Android + iOS)
   On narrow screens the popup becomes a centered
   "bottom sheet" pinned to the viewport, so it can
   never overflow off the right edge of the screen.
───────────────────────────────────────────────── */
@media (max-width: 600px) {
    .vv-para-wrap {
        padding-right: 48px;
    }

    .vv-popup {
        position: fixed;
        right: auto;
        left: 50%;
        top: auto;
        /* Respect iOS safe-area (home indicator) */
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        transform: translateX(-50%);
        width: min(92vw, 360px);
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        font-size: 15px;
    }

    /* No arrow in bottom-sheet mode */
    .vv-popup::after { display: none; }

    /* Larger, finger-friendly tap targets (~44px) */
    .vv-pop-btn {
        padding: 12px 8px;
        font-size: 14px;
    }

    .vv-pop-submit {
        padding: 13px 12px;
        font-size: 14px;
    }

    .vv-lang-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .vv-pop-title { font-size: 12px; }

    @keyframes vv-pop-in {
        from { opacity: 0; transform: translateX(-50%) translateY(12px); }
        to   { opacity: 1; transform: translateX(-50%) translateY(0); }
    }
}

/* ─────────────────────────────────────────────────
   Popup stat labels ("Scor" / "Notă")
───────────────────────────────────────────────── */
.vv-ps-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* ─────────────────────────────────────────────────
   Article footer — my votes + article-wide stats
───────────────────────────────────────────────── */
.vv-article-footer {
    margin: 32px 0 8px;
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    font-size: 14px;
    color: #111827;
}

.vv-af-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 800;
    color: var(--vv-accent);
}

.vv-af-overall {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 20px;
}

.vv-af-gauge {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35);
}

.vv-af-gauge .vv-af-pct { font-size: 18px; }
.vv-af-high { background: var(--vv-agree); }
.vv-af-mid  { background: #f59e0b; }
.vv-af-low  { background: var(--vv-disagree); }
.vv-af-none { background: #9ca3af; }

.vv-af-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.vv-af-label { font-weight: 700; }
.vv-af-stars { letter-spacing: 2px; font-size: 16px; }
.vv-af-count { font-size: 12px; color: #6b7280; }

.vv-af-sub {
    margin: 18px 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: #374151;
}

.vv-af-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.vv-af-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}

.vv-af-table th,
.vv-af-table td {
    padding: 8px 10px;
    text-align: center;
    border-bottom: 1px solid #eef1f4;
    white-space: nowrap;
}

.vv-af-table th {
    background: #f3f4f6;
    font-weight: 700;
    color: #374151;
}

.vv-af-table td:first-child,
.vv-af-table th:first-child { font-weight: 700; }

.vv-af-table tbody tr:last-child td { border-bottom: none; }

.vv-af-empty {
    margin: 4px 0 0;
    font-style: italic;
    color: #6b7280;
}

@media (max-width: 600px) {
    .vv-article-footer { padding: 14px; }
    .vv-af-overall { flex-direction: row; }
    .vv-af-gauge { width: 60px; height: 60px; }
    .vv-af-gauge .vv-af-pct { font-size: 15px; }
}
