/**
 * sentiment_toggle.css
 * BEM namespace: .sentiment-toggle
 * Scope: this file only. Do not reuse class names elsewhere.
 *
 * Two surfaces:
 *   .sentiment-toggle                -- interactive segmented control (compose)
 *   .sentiment-toggle--display       -- read-only chip on rendered posts
 */

.sentiment-toggle {
    --st-track-h: 32px;
    --st-radius: 999px;
    --st-thumb-pad: 3px;

    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 0;
    height: var(--st-track-h);
    min-width: 168px;
    padding: 0;
    border-radius: var(--st-radius);
    background: var(--surface-2, rgba(15, 17, 21, 0.06));
    border: 1px solid var(--hairline, rgba(15, 17, 21, 0.08));
    user-select: none;
    isolation: isolate;
}

.sentiment-toggle__thumb {
    position: absolute;
    top: var(--st-thumb-pad);
    left: var(--st-thumb-pad);
    width: calc(50% - var(--st-thumb-pad));
    height: calc(100% - 2 * var(--st-thumb-pad));
    border-radius: var(--st-radius);
    background: transparent;
    transform: translateX(0);
    transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1),
                background-color 220ms ease,
                box-shadow 220ms ease,
                opacity 180ms ease;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
}

.sentiment-toggle[data-value="bullish"] .sentiment-toggle__thumb {
    background: linear-gradient(135deg, #00b970 0%, #00d985 100%);
    box-shadow: 0 1px 2px rgba(0, 185, 112, 0.18),
                0 6px 18px rgba(0, 185, 112, 0.28);
    transform: translateX(0);
    opacity: 1;
}

.sentiment-toggle[data-value="bearish"] .sentiment-toggle__thumb {
    background: linear-gradient(135deg, #ef4444 0%, #ff6464 100%);
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.18),
                0 6px 18px rgba(239, 68, 68, 0.28);
    transform: translateX(calc(100% + var(--st-thumb-pad)));
    opacity: 1;
}

.sentiment-toggle__option {
    position: relative;
    z-index: 2;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    margin: 0;
    padding: 0 14px;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-2, #5a5d66);
    cursor: pointer;
    border-radius: var(--st-radius);
    transition: color 180ms ease, transform 180ms ease;
}

.sentiment-toggle__option:focus-visible {
    outline: 2px solid var(--iris, #6366f1);
    outline-offset: 2px;
}

.sentiment-toggle__option:hover:not(.sentiment-toggle__option--active) {
    color: var(--text, #0a0d1a);
}

.sentiment-toggle__option--active {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.sentiment-toggle__icon {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.sentiment-toggle__label {
    white-space: nowrap;
}

/* Required-but-unset state: gentle pulse to hint that the user must pick one. */
.sentiment-toggle[data-value="unset"][data-required="true"] {
    animation: sentimentTogglePulse 2.4s ease-in-out infinite;
}
@keyframes sentimentTogglePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.0); }
    50%      { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12); }
}

/* Compact size variant - for tight spaces on the compose chip row. */
.sentiment-toggle--compact {
    --st-track-h: 28px;
    min-width: 152px;
}
.sentiment-toggle--compact .sentiment-toggle__option {
    font-size: 12px;
    padding: 0 10px;
}

/* ----------------- Read-only display chip -----------------
   Used inside post_card to show the author's chosen sentiment.
   Single-segment pill, smaller, non-interactive. */
.sentiment-toggle--display {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}
.sentiment-toggle--display.sentiment-toggle--bullish {
    color: var(--green-2, #009d5f);
    background: var(--green-tint, rgba(0, 185, 112, 0.12));
    border-color: rgba(0, 185, 112, 0.22);
}
.sentiment-toggle--display.sentiment-toggle--bearish {
    color: #d1383d;
    background: var(--red-tint, rgba(239, 68, 68, 0.10));
    border-color: rgba(239, 68, 68, 0.22);
}
:root[data-theme="dark"] .sentiment-toggle--display.sentiment-toggle--bullish {
    color: #4ee0a0;
}
:root[data-theme="dark"] .sentiment-toggle--display.sentiment-toggle--bearish {
    color: #ff8a8a;
}
.sentiment-toggle--display .sentiment-toggle__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
    box-shadow: 0 0 0 0 currentColor;
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .sentiment-toggle__thumb,
    .sentiment-toggle__option {
        transition: none !important;
    }
    .sentiment-toggle[data-value="unset"][data-required="true"] {
        animation: none !important;
    }
}
