/* The chat (includes/chat.php, js/chat.js): a launcher in the bookmaker page's header (the
   dashboard's, and the free picks page's) and a panel on the right, in the predictions
   board's colours. On wide screens the open panel sits beside the page; on phones it fills
   the screen. */

.rc,
.rc-panel {
    --rc-line: #1f3c2d;
    --rc-raised: #12291f;
    --rc-deep: #0b1712;
    --rc-bubble: #173424;
    --rc-text: #f3f6f2;
    --rc-muted: #9db3a6;
    --rc-up: #b9e660;
    --rc-like: #ff6b81;
    --rc-width: 380px;
}

.rc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- Launcher --- */

.dash-hello__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.rc-launch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid rgba(185, 230, 96, 0.45);
    border-radius: 999px;
    background: rgba(11, 23, 18, 0.55);
    color: var(--rc-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.rc-launch:hover,
.rc-launch[aria-expanded="true"] {
    border-color: var(--rc-up);
    background: rgba(11, 23, 18, 0.85);
}

.rc-launch:focus-visible {
    outline: 3px solid var(--rc-up);
    outline-offset: 2px;
}

.rc-launch .bi {
    color: var(--rc-up);
}

.rc-launch__online {
    color: var(--rc-muted);
    font-size: 13px;
    font-weight: 500;
}

.rc-launch__online:empty {
    display: none;
}

.rc-launch__unread {
    position: absolute;
    top: -7px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rc-like);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* --- Panel --- */

.rc-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: var(--rc-width);
    max-width: 100vw;
    border-left: 1px solid var(--rc-line);
    background: var(--rc-deep);
    color: var(--rc-text);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}

.rc-panel[hidden] {
    display: none;
}

/* Wide screens: the page makes room for the open chat instead of hiding under it (the
   dashboard's content and the free picks pages, whose fixed header stops short of it too).
   Laptops get a slightly narrower chat. Must match DOCK_FROM in js/chat.js. */
@media (min-width: 1024px) {
    .rc,
    .rc-panel,
    body {
        --rc-dock: 340px;
    }

    .rc-panel {
        width: var(--rc-dock);
        box-shadow: none;
    }

    body.rc-is-open .dash-main {
        margin-right: var(--rc-dock);
    }

    body.rc-is-open.site-body {
        padding-right: var(--rc-dock);
    }

    body.rc-is-open .site-header {
        right: var(--rc-dock);
    }
}

@media (min-width: 1280px) {
    .rc,
    .rc-panel,
    body {
        --rc-dock: 380px;
    }
}

.rc-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-bottom: 1px solid var(--rc-line);
    background: var(--rc-raised);
}

.rc-room {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.rc-room select {
    appearance: none;
    padding: 8px 32px 8px 14px;
    border: 1px solid var(--rc-line);
    border-radius: 999px;
    background: var(--rc-deep);
    color: var(--rc-text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.rc-room .bi {
    position: absolute;
    right: 12px;
    color: var(--rc-muted);
    font-size: 12px;
    pointer-events: none;
}

.rc-online {
    margin-right: auto;
    color: var(--rc-muted);
    font-size: 14px;
    white-space: nowrap;
}

.rc-online strong {
    color: var(--rc-up);
}

.rc-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: var(--rc-text);
    font-size: 16px;
    cursor: pointer;
}

.rc-icon:hover {
    background: rgba(255, 255, 255, 0.14);
}

.rc-icon--plain {
    background: transparent;
    color: var(--rc-muted);
    font-size: 20px;
}

.rc-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rc-panel :focus-visible {
    outline: 2px solid var(--rc-up);
    outline-offset: 2px;
}

/* --- Messages --- */

.rc-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px 8px 12px;
    overscroll-behavior: contain;
}

.rc-empty {
    margin: 40px 16px;
    color: var(--rc-muted);
    text-align: center;
}

.rc-msg {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 30px;
    gap: 10px;
    align-items: start;
    padding: 6px 0;
}

.rc-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, #23463a, #0f211a);
}

.rc-avatar svg {
    width: 30px;
    height: 30px;
}

.rc-msg__main {
    position: relative;
    min-width: 0;
}

.rc-msg__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 12px;
}

.rc-name {
    font-weight: 600;
}

.rc-msg__meta time {
    color: var(--rc-muted);
    font-variant-numeric: tabular-nums;
}

.rc-more {
    margin-left: auto;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--rc-muted);
    cursor: pointer;
    opacity: 0;
}

.rc-msg:hover .rc-more,
.rc-more:focus-visible,
.rc-more[aria-expanded="true"] {
    opacity: 1;
}

@media (hover: none) {
    .rc-more {
        opacity: 1;
    }
}

.rc-bubble {
    display: inline-block;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 4px 14px 14px 14px;
    background: var(--rc-bubble);
    font-size: 15px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.rc-msg.is-mine .rc-bubble {
    background: #23502f;
}

.rc-reported {
    margin: 4px 0 0;
    color: var(--rc-muted);
    font-size: 12px;
}

.rc-menu {
    position: absolute;
    top: 20px;
    right: 0;
    z-index: 2;
    display: grid;
    min-width: 200px;
    padding: 6px;
    border: 1px solid var(--rc-line);
    border-radius: 12px;
    background: var(--rc-raised);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.rc-menu[hidden] {
    display: none;
}

.rc-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--rc-text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.rc-menu button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.rc-msg__side {
    display: grid;
    justify-items: center;
    padding-top: 16px;
}

.rc-like {
    padding: 2px;
    border: 0;
    background: none;
    color: #5f7a6c;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.rc-like:hover,
.rc-like.is-liked {
    color: var(--rc-like);
}

.rc-like.is-own {
    color: #3a5446;
    cursor: default;
}

.rc-likes {
    min-height: 14px;
    color: var(--rc-muted);
    font-size: 11px;
}

.rc-jump {
    position: absolute;
    left: 50%;
    bottom: 150px;
    transform: translateX(-50%);
    padding: 6px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--rc-up);
    color: #0b1712;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.rc-jump[hidden] {
    display: none;
}

/* --- Rules --- */

.rc-rules {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5, 12, 9, 0.8);
}

.rc-rules[hidden] {
    display: none;
}

.rc-rules__card {
    padding: 22px;
    border: 1px solid var(--rc-line);
    border-radius: 18px;
    background: var(--rc-raised);
}

.rc-rules h3 {
    margin: 0 0 12px;
    font-size: 18px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.rc-rules ul {
    display: grid;
    gap: 8px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    font-size: 14px;
    line-height: 1.45;
}

.rc-rules li {
    display: flex;
    gap: 8px;
}

.rc-rules li .bi {
    flex: none;
    margin-top: 3px;
    color: var(--rc-like);
    font-size: 12px;
}

.rc-rules__ok {
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 999px;
    background: var(--rc-up);
    color: #0b1712;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* --- Writing a message --- */

.rc-compose {
    position: relative;
    margin: 0 10px 10px;
    padding: 10px 12px 8px;
    border: 1px solid var(--rc-line);
    border-radius: 16px;
    background: var(--rc-raised);
}

.rc-note,
.rc-error {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.4;
}

.rc-note {
    color: var(--rc-muted);
}

.rc-note a {
    color: var(--rc-up);
    font-weight: 600;
}

.rc-error {
    color: #ff8a7a;
}

.rc-error[hidden] {
    display: none;
}

.rc-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--rc-text);
    font: inherit;
    font-size: 15px;
    resize: none;
}

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

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

.rc-compose:focus-within {
    border-color: rgba(185, 230, 96, 0.5);
}

.rc-compose__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rc-count {
    color: var(--rc-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.rc-count.is-low {
    color: #f5c542;
}

.rc-send {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--rc-up);
    color: #0b1712;
    font-size: 16px;
    cursor: pointer;
}

.rc-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rc-emojis {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rc-line);
}

.rc-emojis[hidden] {
    display: none;
}

.rc-emojis button {
    padding: 4px 0;
    border: 0;
    border-radius: 8px;
    background: none;
    font-size: 20px;
    cursor: pointer;
}

.rc-emojis button:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Phones: the chat fills the screen */
@media (max-width: 560px) {
    .rc-panel {
        width: 100vw;
        border-left: 0;
    }

    .rc-launch__online {
        display: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .rc-panel {
        animation: rc-slide 0.2s ease-out;
    }

    @keyframes rc-slide {
        from { transform: translateX(24px); opacity: 0; }
        to { transform: none; opacity: 1; }
    }
}

/* The launcher on the free picks page, under the page's title */
.site-chat-launch {
    margin-top: 18px;
}

/* Someone typing: three bouncing dots under the last message, before theirs appears */
.rc-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 10px;
    color: var(--rc-muted);
    font-size: 13px;
}

.rc-typing[hidden] {
    display: none;
}

.rc-typing__dots {
    display: inline-flex;
    gap: 4px;
    padding: 9px 12px;
    border-radius: 14px;
    background: var(--rc-bubble);
}

.rc-typing__dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rc-muted);
    animation: rc-typing 1.2s infinite ease-in-out;
}

.rc-typing__dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.rc-typing__dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes rc-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* A message that just arrived */
.rc-msg.is-new {
    animation: rc-pop 0.25s ease-out;
}

@keyframes rc-pop {
    from { transform: translateY(6px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .rc-typing__dots span,
    .rc-msg.is-new {
        animation: none;
    }
}
