/* concrete.css sets --fg and --bg, these follow the same light/dark switch */
:root {
    --surface: #f8f9fa;
    --reaction-bg: #e9ecef;
    --reaction-border: #cbd0d5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fg: #e4e4e4;
        --surface: #1c1d1f;
        --reaction-bg: #2a2c2f;
        --reaction-border: #45484c;
    }
}

body {
    font-size: 16px;
}

button,
input[type="submit"] {
    font-size: 16px;
}

body > header {
    padding-top: 1em;
    padding-bottom: 1em;
}

h1 {
    font-size: 1em;
}

body > header .row {
    align-items: center;
}

.no-border {
    border: 0;
}

.controls {
    align-items: center;
}

.controls > div {
    display: flex;
    align-items: center;
    gap: .75em;
}

.controls > .align-right {
    justify-content: flex-end;
}

.controls button {
    margin-bottom: 0;
}

.controls form {
    margin: 0;
}

.reply-count-link {
    display: inline-flex;
    align-items: center;
    gap: .25em;
}

.reply-summary {
    align-items: center;
}

.reply-summary .reply-count-link {
    justify-self: end;
}

/* messages */

.messages {
    list-style: none;
    margin: 1em 0 2em;
    padding: 0;
}

.messages li {
    padding: 1em;
    width: 100%;
    line-height: 2.0em;
}

.messages li.info, .messages li.debug {
    background-color: #d0ebff;
}

.messages li.success {
    background-color: #b2f2bb;
}

.message li.warning {
    background-color: #ffec99;
}

.messages li.error {
    background-color: #ffe3e3;
}

/* threads */
.author {
    margin-bottom: .5em;
    font-size: .875em;
    line-height: 1.4;
}

.author .name {
    font-weight: 700;
}

.author .action {
    opacity: .65;
}

.thread .message .author {
    display: flex;
    align-items: center;
    gap: .25em;
}

.author .preview {
    display: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* in line with the author, the chevron itself lines up with the message's 1em padding */
.thread-actions {
    display: flex;
    align-items: center;
    margin: 0 -.375rem 0 auto;
}

.thread-link,
.collapse-toggle {
    display: inline-flex;
    margin: 0;
    padding: .25em;
    border: 0;
    background: none;
    color: inherit;
    opacity: .65;
}

.thread-link:hover,
.collapse-toggle:hover {
    opacity: 1;
}

.collapse-toggle[aria-expanded="false"] svg {
    transform: rotate(180deg);
}

.thread.collapsed {
    padding: 1rem 0;
}

.thread.collapsed .author .preview {
    display: block;
}

.thread.collapsed .message > :not(.author),
.thread.collapsed .replies,
.thread.collapsed .controls,
.thread.collapsed [id^="reply-form-"] {
    display: none;
}

.thread {
    border-bottom: 1px solid var(--fg);
    padding: 2rem 0;
}

.thread .message {
    background-color: var(--surface);
    padding: 0.4em 1em;
    margin-bottom: 0.4em;
}

.replies {
    margin-left: 1em;
    margin-bottom: 1em;
    border-left: 1px solid var(--fg);
}

.replies .reply {
    padding: .4em 1em;
    border-bottom: 1px dashed var(--fg);
}

.replies .reply-summary {
    padding: 1em 0 1em 1em;
}

.replies .reply:last-of-type {
    border-bottom: none;
}

.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: .375em;
}

.reactions .reaction {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25em;
    min-height: 1.75em;
    padding: .2em .55em;
    border: 1px solid var(--reaction-border);
    border-radius: 999px;
    background-color: var(--reaction-bg);
    line-height: 1;
    white-space: nowrap;
}

/* live updates */

/* scroll position is kept by threads.js so it behaves the same in every browser */
html {
    overflow-anchor: none;
}

/* hold the highlight for a few seconds, then fade out */
@keyframes fresh {
    0%, 60% {
        background-color: rgb(255 212 59 / .18);
    }
}

.fresh {
    animation: fresh 10s ease-out;
}

.message,
.reply {
    scroll-margin-top: 2em;
}

#new-messages {
    position: fixed;
    right: 1.5em;
    bottom: 1.5em;
    margin: 0;
    padding: .5em 1.1em;
    border-radius: 999px;
    background-color: var(--fg);
    color: var(--bg);
    box-shadow: 0 2px 8px rgb(0 0 0 / .2);
}

#new-messages[hidden] {
    display: none;
}

/* auth */

form.logout {
    display: inline;
    margin: 0;
}

.login {
    max-width: 24em;
}
