/* ============================================
   Viewer — side panel, social tooltips, toast
   Split from viewer.css (800-line rule); load order viewer.css → viewer-panel.css → viewer-dialogs.css
   ============================================ */
/* ============================================
   Side panel (stats + tabs + comments/leaderboard + composer)
   ============================================ */
.chat-panel {
    position: sticky;
    top: calc(var(--topbar-height) + var(--viewer-gutter));
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--viewer-panel-width);
    height: calc(100vh - var(--topbar-height) - var(--viewer-gutter) * 2);
    margin-top: var(--viewer-gutter);
    margin-right: var(--viewer-gutter);
    align-self: start;
    overflow: hidden;
    background: rgba(19, 14, 46, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--line-1);
    border-radius: var(--radius-2xl);
}

/* Guest banner — compact card at the top of the panel */
.guest-banner {
    margin: 12px 12px 0;
    padding: 10px 10px 10px 14px;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.18), rgba(99, 102, 241, 0.06) 80%);
    border: 1px solid var(--line-accent);
    border-radius: var(--radius-xl);
}

.guest-banner__content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.guest-banner__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-tertiary);
}

.guest-banner__text strong {
    font-size: 13px;
    font-weight: 800;
    color: var(--accent-300);
}

.guest-banner .guest-banner__login {
    flex-shrink: 0;
    height: 32px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: filter var(--duration-fast) ease;
}

.guest-banner .guest-banner__login:hover {
    filter: brightness(1.08);
}

/* Tabs: underline style — present but quiet */
.chat-tabs {
    display: flex;
    gap: 4px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line-1);
}

.chat-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 46px;
    padding: 0 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--text-muted);
    font-family: var(--font-primary);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

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

.chat-tab--active {
    color: #fff;
    border-bottom-color: var(--accent-400);
}

.chat-tab__count {
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.chat-tab--active .chat-tab__count {
    background: var(--accent-soft);
    color: var(--accent-300);
}

/* Comment tooltip (simple version) */
.simple-tooltip {
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
    border: 1px solid var(--line-2);
    color: #fff;
    font-size: 12.5px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    animation: viewer-fade 0.3s ease;
}

@keyframes viewer-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.simple-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--surface-solid);
}

/* Scrolling content */
.chat-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(167, 139, 250, 0.3) transparent;
}

/* ---------- Comments ---------- */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comment-item {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-xl);
    transition: background var(--duration-fast) ease;
}

.comment-item:hover {
    background: var(--surface-1);
}

.comment-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.comment-author {
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
}

.comment-time {
    font-size: 11.5px;
    color: var(--text-muted);
}

.comment-menu-btn {
    margin-left: auto;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--duration-fast) ease, background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.comment-item:hover .comment-menu-btn,
.comment-menu-btn:focus-visible {
    opacity: 1;
}

.comment-menu-btn:hover {
    background: var(--surface-3);
    color: #fff;
}

.comment-dropdown {
    position: absolute;
    right: 10px;
    top: 38px;
    z-index: 100;
    min-width: 128px;
    padding: 4px;
    background: var(--surface-solid);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
}

.comment-delete-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #fca5a5;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.comment-delete-btn:hover {
    background: rgba(240, 82, 95, 0.14);
}

.comment-menu {
    margin-left: auto;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
}

.comment-text {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

/* Empty states (comments + leaderboard) */
.empty-comments,
.leaderboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 0;
    padding: 24px 16px;
    border: 1px dashed var(--line-2);
    border-radius: var(--radius-2xl);
    background: radial-gradient(60% 80% at 50% 0%, var(--accent-softer), transparent 70%);
    color: var(--text-tertiary);
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
}

.empty-comments::before {
    content: '💬';
    display: block;
    font-size: 24px;
}

.empty-comments p {
    margin: 0;
}

/* First comment toast */
.toast-notification {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    box-shadow: var(--glow-accent);
    color: white;
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: all 0.4s var(--ease-out);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-16px);
}

.toast-icon {
    font-size: 18px;
    line-height: 1;
}

/* Composer */
.message-input-container {
    position: relative;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line-1);
    background: rgba(0, 0, 0, 0.14);
}

.message-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 5px 5px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-full);
    transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.message-input-row:focus-within {
    border-color: var(--line-accent);
    box-shadow: var(--focus-ring);
}

.message-input {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-family: var(--font-primary);
    font-size: 13.5px;
}

.message-input:focus {
    outline: none;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    height: 34px;
    padding: 0 16px;
    background: var(--gradient-primary);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-full);
    color: white;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: filter var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.btn-send:hover {
    filter: brightness(1.08);
}

.btn-send:active {
    transform: scale(0.96);
}

/* Create-your-first-game CTA */
.cta-create-section {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--line-1);
    background: var(--surface-1);
}

.btn-create-first-game {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--gradient-primary);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-xl);
    color: white;
    font-family: var(--font-primary);
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    transition: filter var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.btn-create-first-game:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.cta-subtitle {
    margin: 6px 0 0;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ---------- Leaderboard ---------- */
.leaderboard-content {
    padding: 0;
}

#leaderboardRows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 12px 8px 8px;
    border-radius: var(--radius-xl);
    background: var(--surface-1);
    border: 1px solid transparent;
    transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.leaderboard-row:hover {
    background: var(--surface-2);
    border-color: var(--line-1);
}

.leaderboard-rank {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
}

/* Top 3 medals */
.leaderboard-row--rank-1 {
    background: linear-gradient(90deg, rgba(252, 211, 77, 0.14), rgba(255, 255, 255, 0.02) 70%);
    border-color: rgba(252, 211, 77, 0.3);
}

.leaderboard-row--rank-2 {
    background: linear-gradient(90deg, rgba(203, 213, 225, 0.12), rgba(255, 255, 255, 0.02) 70%);
    border-color: rgba(203, 213, 225, 0.22);
}

.leaderboard-row--rank-3 {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.14), rgba(255, 255, 255, 0.02) 70%);
    border-color: rgba(217, 119, 6, 0.28);
}

.leaderboard-rank--top {
    color: #3b2604;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 10px -4px rgba(0, 0, 0, 0.6);
}

.leaderboard-row--rank-1 .leaderboard-rank--top {
    background: linear-gradient(135deg, #fef08a, #f59e0b);
}

.leaderboard-row--rank-2 .leaderboard-rank--top {
    background: linear-gradient(135deg, #f1f5f9, #94a3b8);
    color: #1e293b;
}

.leaderboard-row--rank-3 .leaderboard-rank--top {
    background: linear-gradient(135deg, #fdba74, #b45309);
    color: #2a1603;
}

.leaderboard-player {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.leaderboard-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.leaderboard-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-score {
    font-size: 14px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fde68a;
}

/* Rank-change column is a placeholder ("—") — kept in the DOM, not shown */
.leaderboard-change {
    display: none;
}

.leaderboard-change--up {
    color: var(--accent-green);
}

.leaderboard-change--down {
    color: #f87171;
}

/* Hidden Elements */
.hidden {
    display: none !important;
}

/* ============================================
   Social tooltips (fixed; JS positions them)
   ============================================ */
.tooltip {
    position: fixed;
    padding: 8px 30px 8px 12px;
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-pop);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 99999;
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

.tooltip.show {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--surface-solid);
}

.tooltip--left {
    transform: translateY(-50%) !important;
    margin-top: 0;
}

.tooltip--left::after {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: var(--surface-solid);
    border-top-color: transparent;
}

/* ============================================
   Toast (viewer-auth.js showToast)
   ============================================ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: var(--radius-full);
    background: rgba(23, 18, 54, 0.97);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-pop);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    transform: translateX(-50%);
    animation: viewer-toast-in 0.3s var(--ease-out);
}

.toast::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
}

.toast-error::before {
    background: var(--accent-red);
    box-shadow: 0 0 10px rgba(240, 82, 95, 0.8);
}

.toast.is-leaving {
    animation: viewer-toast-out 0.3s ease forwards;
}

@keyframes viewer-toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes viewer-toast-out {
    to { opacity: 0; transform: translate(-50%, 12px); }
}
