/* Bare elements and the small pieces every screen uses: buttons, fields,
   avatars, status dots, muted and error text. */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font: var(--text-base)/var(--line-height) var(--font);
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

button {
    font: inherit;
    color: var(--color-text);
    background: var(--color-fill);
    border: 0;
    border-radius: var(--radius-m);
    padding: var(--space-4) var(--space-7);
    cursor: pointer;
}

button:disabled {
    opacity: .5;
    cursor: default;
}

button.primary {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

button.link {
    background: none;
    color: var(--color-accent);
    padding: 0;
}

input, select {
    font: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-m);
    padding: var(--space-4) var(--space-6);
    width: 100%;
}

code {
    font-family: var(--font-mono);
    background: var(--color-bg);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-s);
    word-break: break-all;
}

/* A line standing alone on an empty page. Scoped to paragraphs: a message
   of the notice kind has a class of its own (notice-msg). */
.boot, .page-notice {
    color: var(--color-text-muted);
    padding: var(--space-10);
    text-align: center;
}

.error {
    color: var(--color-danger);
}

.text-small {
    font-size: var(--text-s);
    margin: var(--space-3) 0;
}

.auth-tabs {
    display: flex;
    gap: var(--space-4);
}

.auth-tabs button {
    flex: 1;
}

.auth-tabs button.on {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

label {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-s);
    color: var(--color-text-muted);
}

.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
}

.checkbox-label input {
    width: auto;
}

.hint {
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.dim {
    color: var(--color-text-muted);
}

.avatar {
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: var(--radius-avatar);
    object-fit: cover;
    flex: none;                     /* never squeezed by a crowded row */
}

.avatar.small {
    width: var(--avatar-size-small);
    height: var(--avatar-size-small);
    margin-right: var(--space-3);
    vertical-align: -3px;
}

.avatar.letter {
    background: hsl(var(--hue, 0), var(--avatar-saturation), var(--avatar-lightness));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-on-avatar);
    font-weight: 600;
    font-size: var(--text-s);
}

.avatar.big {
    width: var(--avatar-size-big);
    height: var(--avatar-size-big);
    font-size: var(--text-xxl);
}

.avatar.sender-avatar {
    width: var(--avatar-size-message);
    height: var(--avatar-size-message);
    font-size: var(--text-l);
}

/* A picture with what can be done to it beside it. */
.icon-row {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    font-size: var(--text-s);
    color: var(--color-text-muted);
}

/* ── choosing and adjusting a picture ──────────────────────────────────── */

/* The file field itself is the browser's; ours is a button over it. */
.picture-picker {
    flex-direction: row;
    cursor: pointer;
}

.picture-picker input {
    display: none;
}

.picture-picker .button {
    padding: var(--space-4) var(--space-7);
    border-radius: var(--radius-m);
    background: var(--color-fill);
    color: var(--color-text);
    font-size: var(--text-base);
}

.picture-picker:hover .button {
    filter: brightness(1.12);
}

.dialog-shade {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: var(--color-scrim);
}

.dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 21;
    transform: translate(-50%, -50%);
    width: min(24rem, calc(100vw - 2 * var(--space-8)));
    max-height: calc(100dvh - 2 * var(--space-8));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-8);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-l);
    box-shadow: 0 16px 48px var(--color-scrim);
    color: var(--color-text);
    font-size: var(--text-base);
}

.dialog h3, .dialog p {
    margin: 0;
}

/* A dialog's title is its own, wherever on a page the dialog was opened. */
div.dialog h3 {
    font-size: var(--text-l);
    color: var(--color-text);
    text-transform: none;
    letter-spacing: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-5);
}

.crop-frame {
    position: relative;
    align-self: center;
    width: var(--crop-side);
    max-width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-m);
    background: var(--color-media-bg);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.crop-frame:active {
    cursor: grabbing;
}

.crop-frame img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    transform-origin: 0 0;
    pointer-events: none;
}

/* What falls outside the shape the picture is shown in, dimmed. */
.crop-ring {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-avatar);
    box-shadow: 0 0 0 999px var(--color-scrim);
    outline: 1px solid var(--color-text-muted);
    outline-offset: -1px;
    pointer-events: none;
}

.crop-zoom {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.crop-zoom input {
    flex: 1;
    padding: 0;
    border: 0;
    background: none;
    accent-color: var(--color-accent);
}

.presence-dot {
    width: 9px;
    height: 9px;
    border-radius: var(--radius-round);
    display: inline-block;
    background: var(--color-text-muted);
}

.presence-dot.online {
    background: var(--color-success);
}

.presence-dot.unavailable {
    background: var(--color-warning);
}

.presence-dot.offline {
    background: var(--color-text-muted);
}

/* ── icons ─────────────────────────────────────────────────────────────── */

.icon {
    width: var(--icon-size);
    height: var(--icon-size);
    flex: none;
    vertical-align: -.25em;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke);
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Inside a line of text an icon is the size of the text. */
.dim > .icon, .hint > .icon, small > .icon, .attachment > .icon, .poll-q > .icon, .call-title > .icon, .call-member > .icon, .on-call > .icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -.18em;
}

/* A button, link or label that is only an icon: quiet until pointed at. */
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex: none;
    min-width: var(--control-size);
    height: var(--control-size);
    padding: 0 var(--space-3);
    background: none;
    color: var(--color-text-muted);
    border-radius: var(--radius-m);
    font-size: var(--text-s);
    cursor: pointer;
}

.icon-button:hover, .icon-button.on {
    background: var(--color-fill);
    color: var(--color-text);
}

.icon-button.danger:hover, button.danger {
    color: var(--color-danger);
}

.icon-button:disabled:hover {
    background: none;
    color: var(--color-text-muted);
}

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

/* Present for screen readers and tests, not for the eye. */
.hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* A filled button answers the pointer by lightening, whatever its colour. */
button:not(:disabled):not(.link):not(.icon-button):hover {
    filter: brightness(1.12);
}

button.link:not(:disabled):hover, a:hover {
    text-decoration: underline;
}

a.room-link:hover, a.space-link:hover, a.icon-button:hover, a.link-preview:hover, a.attachment:hover, a.search-hit:hover, .user-area a:hover {
    text-decoration: none;
}
