/* The room under a page.
   Same materials as the page: monospace, the site's own accent (green, #4caf50 — the colour every other page on
   snofl uses for a control, a link and an active state) for anything that is a control, hairline rules instead of
   boxes, and no animation that pretends to be progress. The mining indicator is text because it is a number, not a
   mood. The room carried its own orange (#ff6600) and read as a different site bolted under the page. */

/* This page scales its root font with the viewport — `html { font-size: calc(1vw + 1vh + 0.5vmin) }`,
   which is ~34px on a desktop window. So `rem` here is not 16px, and a room sized in rem came out
   1563px wide: a full-bleed strip instead of a column. Everything below is px on purpose. */
.room {
    /* The column is fixed in px (see above) but the type is not: this page's body is ~34px, and a 16px
       room beside it read like fine print. 0.58rem tracks the page's scale, clamped so it never gets
       tiny on a phone or absurd on a television. */
    font-size: clamp(15px, 0.58rem, 21px);
    margin: 32px auto 0;
    max-width: 720px;
    width: calc(100% - 32px);
    text-align: left;
    color: var(--room-ink, #fff);
}

.room__header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--room-rule, #333);
    padding-bottom: 8px;
}

.room__title {
    /* "Let's debate about: <the page's title>" is a sentence, so it is set as one: the old label was two words and
       could carry 0.18em of tracking in capitals, which turns a whole question into a shout. */
    font-weight: bold;
    letter-spacing: 0.01em;
    text-transform: none;
    font-size: 14px;
    line-height: 1.35;
}

.room__meta,
.room__count {
    font-size: 11.52px;
    opacity: 0.65;
}

.room__count {
    margin-left: auto;
}

.room__list {
    padding: 12px 0 4px;
}

.room__empty,
.room__error {
    font-size: 12.8px;
    opacity: 0.7;
    padding: 8px 0;
}

.room__error {
    color: #ff6b6b;
    opacity: 1;
}

.room__message {
    padding: 8.8px 0 10.4px;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.12);
}

.room__message-head {
    display: flex;
    align-items: baseline;
    gap: 9.6px;
    font-size: 10.88px;
    letter-spacing: 0.05em;
    opacity: 0.75;
    margin-bottom: 4px;
}

.room__author {
    color: var(--room-accent, #4caf50);
}

.room__pow {
    margin-left: auto;
    opacity: 0.6;
}

.room__text {
    font-size: 13.76px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.room__composer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--room-rule, #333);
    padding-top: 12px;
    margin-top: 8px;
}

.room__input {
    width: 100%;
    resize: vertical;
    background: transparent;
    color: inherit;
    border: 1px solid var(--room-rule, #333);
    border-radius: 0;
    padding: 8px 9.6px;
    font-family: inherit;
    font-size: 13.76px;
    line-height: 1.45;
}

.room__input:focus-visible {
    outline: 2px solid var(--room-accent, #4caf50);
    outline-offset: 1px;
}

.room__send {
    align-self: flex-start;
    background: transparent;
    color: var(--room-accent, #4caf50);
    border: 1px solid var(--room-accent, #4caf50);
    border-radius: 0;
    padding: 6.4px 14.4px;
    font-family: inherit;
    font-size: 11.52px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.room__send:hover:not(:disabled),
.room__send:focus-visible:not(:disabled) {
    background: var(--room-accent, #4caf50);
    color: #000;
}

.room__send:disabled {
    opacity: 0.45;
    cursor: progress;
}

.room__status {
    font-size: 11.52px;
    min-height: 1.1em;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

/* The white theme, when the page is in it: the room follows the page, not the other way round. */
[data-theme="light"] .room {
    --room-ink: #000;
    --room-rule: #d4d4d4;
    --room-accent: #2e7d32;   /* #4caf50 on white is ~2.8:1; this is ~5.1:1 and still the site's green */
}

[data-theme="light"] .room__message {
    border-bottom-color: rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
    .room {
        margin-top: 20px;
    }

    .room__meta {
        flex-basis: 100%;
    }

    .room__count {
        margin-left: 0;
    }

    .room__pow {
        display: none;
    }
}

/* Sorting: New (chronological) or Top (most upvotes). Two small buttons rather than a dropdown, because
   the room is a chat and a chat's order should be one press away from changing. */
.room__sorting {
    display: inline-flex;
    gap: 2px;
    margin-left: auto;
}

.room__sort {
    background: none;
    border: 1px solid transparent;
    color: inherit;
    font: inherit;
    font-size: 0.68em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
    opacity: 0.55;
    cursor: pointer;
}

.room__sort:hover,
.room__sort:focus-visible {
    opacity: 1;
}

.room__sort.is-on {
    opacity: 1;
    /* one green, the site's: a neon #00ff55 beside the accent read as a second, louder green in the same bar */
    color: var(--room-accent, #4caf50);
    border-color: color-mix(in srgb, var(--room-accent, #4caf50) 45%, transparent);
}

.room__count {
    margin-left: 0.5em;
}

/* Votes on a note. The count is the number of people, not the sum: two up and one down reads "2 / 1",
   which is what a reader can check, where "+1" hides how many disagreed. */
.room__votes {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}

.room__vote {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    color: inherit;
    font: inherit;
    /* a thumb is an emoji and needs a font that has one, or the button shows a box */
    font-family: inherit, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Twemoji Mozilla", sans-serif;
    font-size: 0.78em;
    line-height: 1;
    /* 34px tall: a thumb on a phone is a tap target, not a glyph */
    min-width: 46px;
    min-height: 30px;
    padding: 5px 9px;
    cursor: pointer;
    opacity: 0.75;
}

.room__vote:hover,
.room__vote:focus-visible {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.4);
}

.room__vote.is-mine {
    opacity: 1;
    /* your own vote is an active state, and this site marks active states green */
    border-color: color-mix(in srgb, var(--room-accent, #4caf50) 75%, transparent);
    color: var(--room-accent, #4caf50);
}

/* The note's own id and text are copyable: a note is a Nostr event, and an event with no id to quote
   is a dead end. */
.room__note-id,
.room__copy {
    background: none;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 3px;
    color: inherit;
    font: inherit;
    font-size: 0.64em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.02em;
    padding: 2px 5px;
    opacity: 0.6;
    cursor: pointer;
}

.room__note-id:hover,
.room__copy:hover,
.room__note-id:focus-visible,
.room__copy:focus-visible {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.45);
}

.room__copy.is-done {
    opacity: 1;
    color: #00ff55;
    border-color: rgba(0, 255, 85, 0.5);
}

.room__buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Mining is cancellable, and the cancel button says so in the same place the post button was. */
.room__cancel {
    background: none;
    border: 1px solid rgba(255, 107, 107, 0.6);
    border-radius: 3px;
    color: #ff6b6b;
    font: inherit;
    font-size: 0.72em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 8px 14px;
    cursor: pointer;
}

.room__cancel:hover,
.room__cancel:focus-visible {
    background: rgba(255, 107, 107, 0.12);
}

.room__cancel:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---------------------------------------------------------------- the poll
 *
 * A NIP-88 poll carried inside the room's own NIP-44 envelope, drawn in the room's materials: monospace,
 * hairlines, the site accent for anything that is a control. The bar behind an option is the share of the
 * answers so far - a number made visible, not a mood - and it is the only filled area in the room. */
.room__poll {
    margin: 16px 0 4px;
    padding: 12px 0 14px;
    border-top: 1px solid var(--room-rule, #333);
    border-bottom: 1px solid var(--room-rule, #333);
}

.room__poll-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.room__poll-tag {
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--room-accent, #4caf50);
    border: 1px solid var(--room-accent, #4caf50);
    padding: 1px 6px;
}

.room__poll-meta {
    font-size: 11px;
    opacity: 0.72;
}

.room__poll-question {
    margin: 9px 0 11px;
    font-size: 15.5px;
    font-weight: bold;
    line-height: 1.35;
}

.room__poll-options {
    display: grid;
    gap: 6px;
}

.room__poll-option {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid var(--room-rule, #333);
    border-radius: 0;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}

.room__poll-option:hover:not(:disabled),
.room__poll-option:focus-visible:not(:disabled) {
    border-color: var(--room-accent, #4caf50);
    outline: none;
}

.room__poll-option.is-chosen {
    border-color: var(--room-accent, #4caf50);
}

.room__poll-option.is-closed,
.room__poll-option:disabled {
    cursor: default;
}

/* The share. It sits behind the label, so the row still reads as text first and as a chart second. */
.room__poll-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--room-accent, #4caf50);
    opacity: 0.16;
    pointer-events: none;
}

.room__poll-bar.is-mine {
    opacity: 0.32;
}

.room__poll-label {
    position: relative;
    font-size: 13.5px;
}

.room__poll-count {
    position: relative;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.room__poll-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.room__poll-note {
    font-size: 11px;
    opacity: 0.75;
}

.room__poll-voters {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
}

/* Starting one: a quiet control beside Post, and a small form that replaces nothing. */
.room__poll-open,
.room__poll-add,
.room__poll-cancel {
    align-self: flex-start;
    background: transparent;
    color: var(--room-accent, #4caf50);
    border: 1px dashed var(--room-rule, #333);
    border-radius: 0;
    padding: 5px 11px;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.room__poll-open:hover,
.room__poll-add:hover:not(:disabled),
.room__poll-cancel:hover,
.room__poll-open:focus-visible,
.room__poll-add:focus-visible:not(:disabled),
.room__poll-cancel:focus-visible {
    border-color: var(--room-accent, #4caf50);
    outline: none;
}

.room__poll-add:disabled {
    opacity: 0.4;
    cursor: default;
}

/* `display: grid` beats the `hidden` attribute (the UA rule loses to any author rule), so a form with no
   `[hidden]` counterpart stays on screen from the first paint. Both the form and the panel need it. */
.room__poll-open[hidden],
.room__poll-form[hidden],
.room__poll[hidden] {
    display: none;
}

.room__poll-form {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
    padding: 12px;
    border: 1px solid var(--room-rule, #333);
}

.room__poll-form input[type="text"],
.room__poll-form select {
    width: 100%;
    padding: 7px 9px;
    background: transparent;
    color: inherit;
    border: 1px solid var(--room-rule, #333);
    border-radius: 0;
    font-family: inherit;
    font-size: 13px;
}

.room__poll-form input[type="text"]:focus-visible,
.room__poll-form select:focus-visible {
    outline: 2px solid var(--room-accent, #4caf50);
    outline-offset: -1px;
}

.room__poll-fields {
    display: grid;
    gap: 6px;
}

.room__poll-selects {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.room__poll-selects select {
    flex: 1 1 140px;
}

.room__poll-form-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .room__poll-question {
        font-size: 14.5px;
    }

    .room__poll-label {
        font-size: 13px;
    }
}

/* The + that extends the option list: square, the same dashed hairline as the other quiet controls, and
   quiet again at the ceiling rather than disappearing (a control that vanishes reads as a bug). */
.room__poll-add {
    align-self: flex-start;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
}

.room__poll-add:disabled {
    opacity: 0.35;
    cursor: default;
    border-color: var(--room-rule, #333);
    color: var(--room-rule, #333);
}
