/* Glampfire sidebar, on the app window: brand, General (Chats, Meetings, Search),
   Rooms and Direct messages (the cached #user_sidebar frame), then Settings and you.
   Replaces Campfire's sidebar.css (search-page rules at the end are kept from it). */

/* Brand: the account's logo (or the flame) and its name */
.sidebar__brand {
  align-items: center;
  border-radius: 12px;
  color: var(--gf-ink);
  display: flex;
  flex: none;
  gap: 10px;
  margin-block-end: 22px;
  padding: 4px 8px;
  text-decoration: none;

  &:focus-visible { outline: 2px solid var(--gf-mention); outline-offset: 2px; }
}

.sidebar__brand-logo {
  block-size: 30px;
  flex: none;
  inline-size: 30px;
}

.sidebar__brand-logo--account {
  border-radius: 9px;
  object-fit: cover;
  outline: 1px solid oklch(0% 0 0 / 0.1);
  outline-offset: -1px;
}

.sidebar__brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Section labels: small, sentence case */
.sidebar__label {
  color: var(--gf-ink-faint);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  margin: 0;
  padding-inline: 10px;
}

.sidebar__nav {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 2px;

  .sidebar__label { margin-block-end: 6px; }
}

/* Rows: nav links, rooms and pings share one look. The current one is a white pill. */
:is(.sidebar__link, #sidebar .room, #sidebar .direct) {
  align-items: center;
  background: transparent;
  block-size: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--gf-ink-subtle);
  cursor: pointer;
  display: flex;
  flex: none;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  gap: 10px;
  inline-size: 100%;
  padding: 0 10px;
  text-align: start;
  text-decoration: none;

  > .icon { block-size: 18px; flex: none; inline-size: 18px; }

  &:hover { background-color: oklch(var(--lch-black) / 0.04); color: var(--gf-ink); }
  &:focus-visible { outline: 2px solid var(--gf-mention); outline-offset: -2px; }

  &[aria-current="page"] {
    background-color: var(--gf-surface);
    box-shadow: 0 0 0 1px oklch(0% 0 0 / 0.04), 0 1px 3px oklch(0% 0 0 / 0.06);
    color: var(--gf-ink);
    font-weight: 600;

    @media (prefers-color-scheme: dark) { background-color: var(--gf-selected); box-shadow: none; }
  }

  &.unread {
    color: var(--gf-ink);
    font-weight: 650;
  }
}

.sidebar__link > span {
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rooms and pings: the frame scrolls between the nav and the footer */
#user_sidebar {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-block-start: 18px;
  min-block-size: 0;
}

.sidebar__container {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-block-size: 0;
}

.sidebar__scroll {
  flex: 1;
  margin-inline: -4px;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 4px 12px;
}

.sidebar__section + .sidebar__section { margin-block-start: 18px; }

.sidebar__section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-block-end: 4px;
  min-block-size: 28px;
}

.sidebar__icon-button {
  align-items: center;
  block-size: 28px;
  border-radius: 8px;
  color: var(--gf-ink-faint);
  display: inline-flex;
  inline-size: 28px;
  justify-content: center;

  .icon { block-size: 16px; inline-size: 16px; }
  &:hover { background-color: oklch(var(--lch-black) / 0.05); color: var(--gf-ink); }
  &:active { scale: 0.96; }
  &:focus-visible { outline: 2px solid var(--gf-mention); outline-offset: 1px; }
}

.rooms,
.directs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Settings and you, pinned to the bottom */
.sidebar__footer {
  border-block-start: 1px solid var(--gf-border);
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 2px;
  padding-block-start: 10px;
}

.sidebar__me img {
  block-size: 22px;
  border-radius: 50%;
  flex: none;
  inline-size: 22px;
  margin-inline: -2px;
  object-fit: cover;
  outline: 1px solid oklch(0% 0 0 / 0.1);
  outline-offset: -1px;
}

.room__icon {
  align-items: center;
  color: var(--gf-ink-faint);
  display: inline-flex;
  flex: none;
  inline-size: 18px;
  justify-content: center;

  .icon { block-size: 16px; inline-size: 16px; }

  [aria-current="page"] > & { color: var(--gf-ink-subtle); }
}

:is(.room__name, .direct__author) {
  flex: 1;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Unread: brand-colored dot at the end of the row */
.room__unread {
  display: none;
  flex: none;

  .unread > & {
    background-color: var(--gf-brand);
    block-size: 8px;
    border-radius: 50%;
    display: block;
    inline-size: 8px;
  }
}

/* Ping avatars */
#sidebar .direct {
  .avatar {
    --avatar-size: 24px;

    flex: none;

    img {
      outline: 1px solid oklch(0% 0 0 / 0.1);
      outline-offset: -1px;
    }
  }

  .avatar__group {
    --avatar-size: 12px;

    block-size: 24px;
    flex: none;
    gap: 0;
    inline-size: 24px;
  }
}

/* People you haven't pinged yet: quieter, below your pings */
#sidebar .direct--placeholder {
  color: var(--gf-ink-faint);

  .avatar { opacity: 0.75; }
  &:hover .avatar { opacity: 1; }
}

#sidebar form.button_to { margin: 0; }

/* New ping (autocomplete) inside the Direct messages section */
.directs--new {
  padding: 4px 0 8px;

  form { align-items: center; gap: 6px; }

  .btn {
    --btn-size: 34px;
    --hover-size: 0;

    flex: none;

    img { block-size: 16px; inline-size: 16px; }
  }

  .btn:not(.btn--reversed) {
    --btn-background: transparent;
    --btn-border-color: transparent;

    &:hover { --btn-background: var(--gf-hover); }
  }

  .autocomplete__container {
    --input-border-color: var(--gf-border-strong);
    --input-border-radius: var(--gf-radius-control);
    --hover-size: 0;

    min-block-size: 34px;
    min-inline-size: 0;

    &:focus-within {
      --input-border-color: var(--gf-ink-faint);

      box-shadow: 0 0 0 3px oklch(var(--lch-black) / 0.06);
    }
  }

  .autocomplete__input { font-size: 14px; padding: 4px 8px; }
}

.sidebar__toggle { display: none !important; }

/* Search page (kept from Campfire's sidebar.css until the search redesign) */
.searches {
  #nav {
    align-items: start;
  }

  .message--formatted .message__room {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    visibility: visible;
    white-space: nowrap;

    &::before { content: "→"; }
  }

  .message__actions {
    display: none !important;
    visibility: hidden !important;
  }
}

.searches__recents {
  --mask: linear-gradient(to left, oklch(0% 0 0 / 1) 97%, oklch(0% 0 0 / 0) 99%);

  -webkit-mask-image: var(--mask);
  display: none;
  mask-image: var(--mask);
  position: relative;

  @media (max-width: 100ch) { display: flex; }

  .room {
    max-inline-size: 20ch;

    &:first-child { margin-inline-start: var(--inline-space); }
  }

  .searches__btn { margin-inline-end: var(--inline-space-double); }
}

.searches__query {
  --btn-border-radius: 0.5em;

  min-block-size: var(--btn-size);
}

.searches__input:required:invalid {
  ~ .searches__reset {
    display: none;
    visibility: hidden;
  }
}

.directs--edit {
  display: grid;
  gap: var(--inline-space);
  grid-template-columns: repeat(auto-fit, minmax(33%, 1fr));
  grid-template-rows: min-content;
  place-items: center;

  .member {
    aspect-ratio: 1;
    block-size: auto;
    inline-size: 100%;
    margin-inline: auto;
    place-content: center;
  }
}
