/* =============================================================================
   report-tweet-share.css
   Tweet Highlight / Share on X — floating toolbar + per-section buttons
   Follows the StackAlpha design system (--bg-surface, --border-base, etc.)
   ============================================================================= */


/* ── Floating Selection Toolbar ─────────────────────────────────────────────── */

#sa-tweet-toolbar {
    position: fixed;
    z-index: 9100;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-strong, #CBD5E1);
    border-radius: var(--radius-md, 4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
    white-space: nowrap;

    /* Hidden by default */
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

/* Arrow pointing down (toolbar above selection) */
#sa-tweet-toolbar::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 8px;
    height: 8px;
    background: var(--bg-surface, #ffffff);
    border-right: 1px solid var(--border-strong, #CBD5E1);
    border-bottom: 1px solid var(--border-strong, #CBD5E1);
}

/* Arrow pointing up (toolbar below selection) */
#sa-tweet-toolbar.sa-tweet-toolbar--below::after {
    bottom: auto;
    top: -5px;
    border-right: none;
    border-bottom: none;
    border-left: 1px solid var(--border-strong, #CBD5E1);
    border-top: 1px solid var(--border-strong, #CBD5E1);
}

#sa-tweet-toolbar.sa-tweet-toolbar--visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}


/* ── Toolbar Buttons ─────────────────────────────────────────────────────────── */

.sa-tweet-toolbar__btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-primary, #0F172A);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.sa-tweet-toolbar__btn:hover {
    background: var(--bg-subtle, #F1F5F9);
    color: var(--accent-action, #2563EB);
}

.sa-tweet-toolbar__btn:focus-visible {
    outline: 2px solid var(--accent-action, #2563EB);
    outline-offset: 1px;
}

/* Icon-only copy button */
.sa-tweet-toolbar__btn--icon {
    padding: 5px 7px;
    color: var(--text-muted, #94A3B8);
}

.sa-tweet-toolbar__btn--icon:hover {
    color: var(--accent-action, #2563EB);
    background: var(--bg-subtle, #F1F5F9);
}

/* Copied state */
.sa-tweet-toolbar__btn--copied {
    color: var(--accent-success, #16A34A) !important;
}

/* Divider between primary + icon button */
.sa-tweet-toolbar__sep {
    width: 1px;
    height: 18px;
    background: var(--border-base, #E2E8F0);
    flex-shrink: 0;
    margin: 0 2px;
}


/* ── Per-Section Share Buttons ───────────────────────────────────────────────── */

.inst-prose h2,
.inst-prose h3,
.inst-prose h4 {
    padding-right: 56px;
}

.sa-section-heading-actions {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sa-section-tweet-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: 0;
    border: 1px solid var(--border-base, #E2E8F0);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted, #94A3B8);
    cursor: pointer;
    vertical-align: middle;
    flex-shrink: 0;
    opacity: 0.68;
    transition: opacity 0.15s ease, border-color 0.15s ease,
                color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.inst-insight-header > .sa-section-tweet-btn,
.inst-insight-card > .sa-section-tweet-btn,
blockquote > .sa-section-tweet-btn {
    opacity: 0;
}

.inst-insight-header:hover > .sa-section-tweet-btn,
.inst-insight-card:hover > .sa-section-tweet-btn,
blockquote:hover > .sa-section-tweet-btn {
    opacity: 1;
}

.sa-section-tweet-btn:hover {
    opacity: 1 !important;
    border-color: var(--accent-primary, #0F172A);
    color: var(--accent-primary, #0F172A);
    background: var(--bg-subtle, #F1F5F9);
    transform: translateY(-1px);
}

.sa-section-tweet-btn:focus-visible {
    opacity: 1;
    outline: 2px solid var(--accent-action, #2563EB);
    outline-offset: 2px;
}

.sa-section-tweet-btn--copied {
    opacity: 1 !important;
    border-color: var(--accent-success, #16A34A);
    color: var(--accent-success, #16A34A);
    background: rgba(22, 163, 74, 0.08);
}

/* Blockquote button: absolute-positioned in top-right corner */
.sa-section-tweet-btn--quote {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    margin-left: 0;
}


/* ── Dark Mode ───────────────────────────────────────────────────────────────── */

[data-theme="dark"] #sa-tweet-toolbar {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.3);
}


/* ── Mobile / Touch Devices ──────────────────────────────────────────────────── */

/* On touch devices: always show section buttons (no hover) and
   move the floating toolbar to the bottom of the screen */
@media (hover: none) {
    .sa-section-tweet-btn {
        opacity: 0.55;
    }

    #sa-tweet-toolbar {
        /* Override JS-computed top; pin to bottom of viewport */
        top: auto !important;
        bottom: 72px;
        left: 50% !important;
        transform: translateX(-50%) translateY(8px);
        max-width: calc(100vw - 32px);
    }

    #sa-tweet-toolbar.sa-tweet-toolbar--visible {
        transform: translateX(-50%) translateY(0);
    }

    /* Hide the arrow on mobile (no relation to selection position) */
    #sa-tweet-toolbar::after,
    #sa-tweet-toolbar.sa-tweet-toolbar--below::after {
        display: none;
    }
}
