/* ============================================================
   Reactions — ReactionBar component (Facebook-style emoji picker)

   Two visual pieces:
     1. .reaction-bar — inline pill containing the "React" button,
        the small "•••" opener, and (when reactions exist) an
        aggregate strip showing top emojis + total count.
     2. .reaction-picker — floating 6-emoji palette that appears
        above the bar on hover / click.
   ============================================================ */

.reaction-bar {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* Aggregate strip — sits before the "React" button so a bystander
   sees the social proof first, then the CTA. Hidden when no
   reactions exist yet so we don't render an awkward "0". */
.reaction-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--color-text-muted, #6b7280);
    cursor: default;
}

.reaction-summary-emoji {
    font-size: 0.9rem;
    line-height: 1;
}

.reaction-summary-count {
    font-weight: 600;
    color: var(--color-text, #2c2c2c);
    margin-left: 0.15rem;
}

/* Default "React" button — the primary tap target. Full-width
   emoji + label on the left so the button reads as "act on this",
   not just "look at this". */
.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--color-text, #2c2c2c);
    cursor: pointer;
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

    .reaction-btn:hover {
        background: rgba(0, 0, 0, 0.04);
        transform: translateY(-1px);
    }

    .reaction-btn:disabled {
        opacity: 0.6;
        cursor: default;
    }

    /* Reacted state — tinted accent so the user knows their tap stuck. */
    .reaction-btn-reacted {
        background: var(--color-accent-soft, rgba(16, 185, 129, 0.12));
        border-color: var(--color-accent, #10b981);
        color: var(--color-accent, #0f766e);
        font-weight: 600;
    }

.reaction-btn-emoji {
    font-size: 1.05rem;
    line-height: 1;
}

.reaction-btn-label {
    line-height: 1;
}

/* Small "•••" opener — always visible so touch users have a
   deterministic tap target for the picker (hover isn't reliable
   on mobile). Kept subtle so desktop users just hover instead. */
.reaction-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.05em;
    transition: background 0.15s;
}

    .reaction-more-btn:hover {
        background: rgba(0, 0, 0, 0.06);
    }

/* Floating emoji palette — appears above the bar. Uses absolute
   positioning against .reaction-bar's relative anchor. z-index
   floats it above surrounding content (lightbox overlays, video
   modal chrome). */
.reaction-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    display: flex;
    gap: 0.15rem;
    padding: 0.35rem 0.55rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    z-index: 40;
    animation: reaction-picker-in 0.15s ease-out;
}

@keyframes reaction-picker-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.94);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.reaction-picker-item {
    background: transparent;
    border: none;
    padding: 0.25rem 0.35rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
    transition: transform 0.12s, background 0.12s;
}

    /* Facebook-style: hovering an emoji pops it up and enlarges it
       to preview the reaction before commit. */
    .reaction-picker-item:hover {
        transform: translateY(-4px) scale(1.35);
        background: rgba(0, 0, 0, 0.04);
    }

    .reaction-picker-item:disabled {
        opacity: 0.6;
        cursor: default;
    }

    /* Currently-selected emoji gets a subtle ring so the user sees
       which one is "theirs" when the picker is open. */
    .reaction-picker-item-active {
        background: rgba(0, 0, 0, 0.08);
        box-shadow: inset 0 0 0 2px var(--color-accent, #10b981);
    }

/* ── Dark-backdrop variant ─────────────────────────────────────
   The photo lightbox and video modal render against a near-black
   overlay, so the default light-mode chrome for the bar disappears.
   Wrap any ReactionBar inside a container with this class to swap
   the button chrome for a translucent-on-dark treatment while
   keeping the picker itself light (it sits above the backdrop, so
   readability is unchanged). */
.lightbox-reactions,
.vip-reactions,
.reaction-bar-on-dark {
    display: flex;
    justify-content: center;
    padding: 0.5rem 1rem;
}

    .lightbox-reactions .reaction-btn,
    .lightbox-reactions .reaction-more-btn,
    .vip-reactions .reaction-btn,
    .vip-reactions .reaction-more-btn,
    .reaction-bar-on-dark .reaction-btn,
    .reaction-bar-on-dark .reaction-more-btn {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.25);
        color: #fff;
    }

        .lightbox-reactions .reaction-btn:hover,
        .lightbox-reactions .reaction-more-btn:hover,
        .vip-reactions .reaction-btn:hover,
        .vip-reactions .reaction-more-btn:hover,
        .reaction-bar-on-dark .reaction-btn:hover,
        .reaction-bar-on-dark .reaction-more-btn:hover {
            background: rgba(255, 255, 255, 0.18);
        }

    .lightbox-reactions .reaction-btn-reacted,
    .vip-reactions .reaction-btn-reacted,
    .reaction-bar-on-dark .reaction-btn-reacted {
        background: var(--color-accent-soft, rgba(16, 185, 129, 0.25));
        border-color: var(--color-accent, #10b981);
        color: #fff;
    }

    .lightbox-reactions .reaction-summary,
    .vip-reactions .reaction-summary,
    .reaction-bar-on-dark .reaction-summary {
        background: rgba(255, 255, 255, 0.12);
        color: rgba(255, 255, 255, 0.85);
    }

        .lightbox-reactions .reaction-summary-count,
        .vip-reactions .reaction-summary-count,
        .reaction-bar-on-dark .reaction-summary-count {
            color: #fff;
        }

/* ============================================================
   Who reacted — clickable summary, dialog, and ReactorList
   (ReactorList is also used in the admin Photo details drawer;
   admin.css re-tints it for the dark admin theme).
   ============================================================ */

/* Summary strip as a button for signed-in visitors ("You and 4 others"). */
.reaction-summary-btn {
    border: none;
    font-family: inherit;
    cursor: pointer;
    max-width: 16rem;
}

    .reaction-summary-btn .reaction-summary-count {
        font-weight: var(--font-weight-medium);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .reaction-summary-btn:hover .reaction-summary-count {
        text-decoration: underline;
    }

    .reaction-summary-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--color-input-focus-ring);
    }

/* Dialog — z-index sits above the public photo lightbox and video
   modal, since it can be opened from inside either. */
.reactor-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--color-overlay);
}

.reactor-modal {
    width: min(26rem, 100%);
    max-height: min(32rem, 85vh);
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    text-align: left;
    outline: none;
}

.reactor-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider);
}

.reactor-modal-title {
    margin: 0;
    font-family: var(--font-family-heading);
    font-size: var(--text-card-title-size);
    font-weight: var(--text-card-title-weight);
    color: var(--color-heading);
}

.reactor-modal-close {
    width: calc(var(--space-6) + var(--space-1));
    height: calc(var(--space-6) + var(--space-1));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--color-text-muted);
    font-size: var(--font-size-md);
    cursor: pointer;
}

    .reactor-modal-close:hover {
        background: var(--color-primary-tint);
        color: var(--color-text);
    }

.reactor-modal-body {
    overflow-y: auto;
    padding: 0 var(--space-4) var(--space-3);
}

/* ReactorList */
.reactor-tabs {
    position: sticky;
    top: 0;
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    padding-top: var(--space-2);
    background: inherit;
    border-bottom: 1px solid var(--color-divider);
}

.reactor-modal-body .reactor-tabs {
    background: var(--color-surface);
}

.reactor-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    cursor: pointer;
}

    .reactor-tab:hover {
        color: var(--color-text);
    }

    .reactor-tab[aria-selected="true"] {
        color: var(--color-primary);
        border-bottom-color: var(--color-primary);
    }

.reactor-tab-count {
    font-weight: var(--font-weight-medium);
}

.reactor-rows {
    list-style: none;
    margin: 0;
    padding: var(--space-2) 0 0;
}

.reactor-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
}

/* Avatar — 2.5rem circle with the person's emoji tucked on the corner. */
.reactor-avatar {
    position: relative;
    flex: 0 0 auto;
    width: calc(var(--space-6) + var(--space-2));
    height: calc(var(--space-6) + var(--space-2));
}

    .reactor-avatar img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
        background: var(--color-surface-alt);
    }

.reactor-avatar-emoji {
    position: absolute;
    right: calc(var(--space-1) * -1);
    bottom: calc(var(--space-1) * -1);
    width: var(--space-5);
    height: var(--space-5);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    font-size: var(--font-size-xs);
    line-height: 1;
}

.reactor-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.reactor-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
}

a.reactor-name:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

.reactor-time {
    color: var(--color-text-subtle);
    font-size: var(--font-size-xs);
}

.reactor-empty {
    margin: 0;
    padding: var(--space-3) 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.reactor-view-all {
    margin-top: var(--space-1);
    padding: var(--space-1) 0;
    background: none;
    border: none;
    color: var(--color-link);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

    .reactor-view-all:hover {
        color: var(--color-link-hover);
        text-decoration: underline;
    }

/* Phones: the dialog becomes a bottom sheet with a grab handle. */
@media (max-width: 767px) {
    .reactor-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .reactor-modal {
        width: 100%;
        max-height: 80vh;
        padding-bottom: env(safe-area-inset-bottom);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: reactor-sheet-in 0.2s ease-out;
    }

        .reactor-modal::before {
            content: "";
            display: block;
            width: var(--space-7);
            height: var(--space-1);
            margin: var(--space-2) auto 0;
            border-radius: 999px;
            background: var(--color-border-strong);
        }
}

@keyframes reactor-sheet-in {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ============================================================
   Panel variant — <ReactionBar Variant="panel" /> (photo viewer)
   Full-width buttons, then an overview row: per-emoji counts and
   a "Kelanie, Tim and 18 others · See who reacted" button with
   an avatar stack, then (desktop) the first few people inline.
   ============================================================ */
.reaction-bar-panel {
    display: flex;
    width: 100%;
}

    .reaction-bar-panel .reaction-btn {
        flex: 1 1 auto;
        justify-content: center;
        padding: var(--space-2) var(--space-4);
        border-radius: var(--radius-sm);
        font-size: var(--text-button-size);
    }

    .reaction-bar-panel .reaction-more-btn {
        width: calc(var(--space-6) + var(--space-3));
        height: auto;
        align-self: stretch;
        border-radius: var(--radius-sm);
    }

    /* Open below the buttons so the panel's scroll area doesn't clip it. */
    .reaction-bar-panel .reaction-picker {
        top: calc(100% + var(--space-2));
        bottom: auto;
    }

.reaction-overview {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.reaction-overview-counts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.reaction-overview-count + .reaction-overview-count::before {
    content: "\2022";
    margin-right: var(--space-2);
    color: var(--color-text-subtle);
    font-weight: var(--font-weight-regular);
}

.reaction-overview-who {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

    .reaction-overview-who:hover {
        border-color: var(--color-border-strong);
    }

    .reaction-overview-who:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--color-input-focus-ring);
    }

.reaction-avatars {
    display: inline-flex;
    flex: 0 0 auto;
}

    .reaction-avatars img {
        width: var(--space-6);
        height: var(--space-6);
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid var(--color-surface-alt);
        background: var(--color-surface);
    }

        .reaction-avatars img + img {
            margin-left: calc(var(--space-2) * -1);
        }

.reaction-overview-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reaction-overview-names {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-sm);
}

.reaction-overview-link {
    color: var(--color-link);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.reaction-overview-who:hover .reaction-overview-link {
    text-decoration: underline;
}

.reaction-inline-list {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-divider);
}

.reaction-inline-title {
    margin: 0;
    font-family: var(--font-family-heading);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--color-heading);
}

/* Phones use "See who reacted" (bottom sheet) instead of the inline list. */
@media (max-width: 899px) {
    .reaction-inline-list {
        display: none;
    }
}

/* ── Panel / dialog on the dark photo viewer ──
   The dialog renders inside .lightbox-reactions, so it picks up
   the dark viewer chrome too (bottom sheet on phones). */
.lightbox-reactions .reaction-overview-counts,
.lightbox-reactions .reaction-overview-who,
.lightbox-reactions .reaction-inline-title,
.lightbox-reactions .reactor-modal-title,
.lightbox-reactions .reactor-name {
    color: var(--color-viewer-text);
}

.lightbox-reactions .reaction-overview-count + .reaction-overview-count::before,
.lightbox-reactions .reactor-time,
.lightbox-reactions .reactor-empty,
.lightbox-reactions .reactor-tab {
    color: var(--color-viewer-text-muted);
}

.lightbox-reactions .reaction-overview-who {
    background: var(--color-viewer-surface-raised);
    border-color: var(--color-viewer-border);
}

    .lightbox-reactions .reaction-overview-who:hover {
        border-color: var(--color-viewer-border-strong);
    }

.lightbox-reactions .reaction-avatars img {
    border-color: var(--color-viewer-surface-raised);
    background: var(--color-viewer-surface);
}

.lightbox-reactions .reaction-overview-link,
.lightbox-reactions .reactor-view-all,
.lightbox-reactions a.reactor-name:hover {
    color: var(--color-accent);
}

.lightbox-reactions .reaction-inline-list,
.lightbox-reactions .reactor-modal-head,
.lightbox-reactions .reactor-tabs {
    border-color: var(--color-viewer-border);
}

.lightbox-reactions .reactor-modal,
.lightbox-reactions .reactor-modal-body .reactor-tabs {
    background: var(--color-viewer-surface);
    color: var(--color-viewer-text);
}

.lightbox-reactions .reactor-modal {
    border: 1px solid var(--color-viewer-border);
}

    .lightbox-reactions .reactor-modal::before {
        background: var(--color-viewer-border-strong);
    }

.lightbox-reactions .reactor-modal-close {
    color: var(--color-viewer-text-muted);
}

    .lightbox-reactions .reactor-modal-close:hover {
        background: var(--color-viewer-hover);
        color: var(--color-viewer-text);
    }

.lightbox-reactions .reactor-tab:hover {
    color: var(--color-viewer-text);
}

.lightbox-reactions .reactor-tab[aria-selected="true"] {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.lightbox-reactions .reactor-avatar img,
.lightbox-reactions .reactor-avatar-emoji {
    background: var(--color-viewer-surface-raised);
}
