/* The spaces (Forums, Video, Pulse, Feed, Photos) and the shared preference controls. */

/* ---------- Space tabs in the top bar ---------- */

.spaces {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 auto;
}

.spaces__group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}

.spaces__label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 10px;
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spaces__tab {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.spaces__tab:hover {
  color: var(--ink);
}

.spaces__tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.spaces__tab.is-active .icon {
  color: var(--accent);
}

.spaces__group--private .spaces__tab.is-active .icon {
  color: var(--accent);
}

/* The Feed stands alone in the middle, a touch bolder than its neighbours. */
.spaces__group--middle .spaces__tab {
  font-weight: 700;
}

@media (max-width: 1180px) {
  .spaces__label {
    display: none;
  }
}

@media (max-width: 980px) {
  .spaces__tab span {
    display: none;
  }
  .spaces__tab {
    padding: 0 12px;
  }
}

@media (max-width: 820px) {
  /* On phones the tabs get their own scrollable row under the top bar. */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding-top: 10px;
    padding-bottom: 8px;
    row-gap: 8px;
  }
  .spaces {
    order: 3;
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .spaces__tab span {
    display: inline;
  }
  /* Centred when they fit; when they don't, the auto margins shrink to nothing and the row
     scrolls from its first tab (plain centring would cut off the first one). */
  .spaces > :first-child {
    margin-left: auto;
  }
  .spaces > :last-child {
    margin-right: auto;
  }
  .topbar__search {
    display: none;
  }
}

@media (min-width: 821px) {
  /* Tablets and computers: logo | tabs | buttons, with the tabs in the true middle of the
     screen however wide the logo and the buttons are. */
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
  .topbar__logo {
    justify-self: start;
  }
  .topbar__actions {
    justify-self: end;
  }
}

/* ---------- Space pages ---------- */

.space-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.space-header__text {
  color: var(--ink-soft);
}

.back-link {
  justify-self: start;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--ink);
}

.paged-list,
.paged-list-wrap {
  display: grid;
  gap: 14px;
}

/* The small badges after names: verified, founder, business, creator. */
.account-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.account-badge--creator {
  background: #f6ecd2;
  color: #8a6416;
}

:root:is([data-theme="grey"], [data-theme="dark"]) .account-badge--creator {
  background: #3a301a;
  color: #e9c86f;
}

.account-badge--founder {
  background: #fde9d9;
  color: #b4521f;
  cursor: pointer;
}

.account-badge--founder:hover,
.account-badge--founder:focus-visible {
  background: #fbd9bf;
}

:root:is([data-theme="grey"], [data-theme="dark"]) .account-badge--founder {
  background: #42281a;
  color: #f2a774;
}

.account-badge--verified {
  background: #dcecfb;
  color: #1f5f9e;
}

:root:is([data-theme="grey"], [data-theme="dark"]) .account-badge--verified {
  background: #1d3247;
  color: #8cc2f2;
}

/* A family account whose parent is verified: same shield, softer. */
.account-badge--family {
  background: #e6f0ea;
  color: #2d6b48;
}

:root:is([data-theme="grey"], [data-theme="dark"]) .account-badge--family {
  background: #213429;
  color: #8fd1aa;
}

.account-badge + .account-badge {
  margin-left: 4px;
}

/* A Pulse topic's emoji-and-name label. */
.topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---------- Pulse ---------- */

.note {
  padding: 14px 16px 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.note:hover {
  background: var(--surface-muted);
}

.note--standalone {
  cursor: default;
}

.note--standalone:hover {
  background: var(--surface);
}

.note__reposted {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px 52px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  font-weight: 600;
}

.note__main {
  display: flex;
  gap: 12px;
}

.note__content {
  min-width: 0;
  flex: 1;
}

.note__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

.note__name {
  color: var(--ink);
  font-weight: 700;
}

.note__name:hover,
.note__time:hover {
  text-decoration: underline;
}

.note__body {
  margin-top: 4px;
  font-size: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note__body--large {
  font-size: 1.25rem;
  line-height: 1.45;
}

.note__body a {
  color: var(--accent-text);
}

.note__quote {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.note__quote-author {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
}

.note__actions {
  display: flex;
  gap: 4px;
  margin-left: 52px;
  padding: 4px 0;
}

.note__action {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 64px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.note__action:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.note__action--repost.is-active,
.note__action--repost:hover {
  color: var(--success);
}

.note__action--like.is-active,
.note__action--like:hover {
  color: var(--love);
}

.note__action--like.is-active .icon {
  fill: currentColor;
}

.note-composer__count {
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.note-composer__count.is-low {
  color: var(--danger);
  font-weight: 700;
}

.note-replies {
  display: grid;
  gap: 10px;
}

/* ---------- Votes ---------- */

.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 40px;
}

.vote--row {
  flex-direction: row;
  min-width: 0;
}

.vote__button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--ink-faint);
  transition: background 0.15s, color 0.15s;
}

.vote__button:hover {
  background: var(--surface-sunken);
}

.vote[data-vote="1"] .vote__button--up {
  background: var(--accent-soft);
  color: var(--accent);
}

.vote[data-vote="-1"] .vote__button--down {
  background: #e6e9f6;
  color: #4b5ba8;
}

.vote__score {
  min-width: 2ch;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.vote[data-vote="1"] .vote__score {
  color: var(--accent-text);
}

/* ---------- Forums ---------- */

.thread-row,
.thread {
  display: flex;
  gap: 12px;
  padding: 14px 16px 14px 10px;
}

.thread-row__main,
.thread__main {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.thread-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.thread-row__meta a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.thread-row__community {
  color: var(--ink);
  font-weight: 700;
}

.thread-row__title {
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.35;
}

.thread-row__title:hover {
  color: var(--accent-text);
}

.thread-row__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  color: var(--accent-text);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row__replies {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  margin-top: 2px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.thread-row__replies:hover {
  background: var(--surface-sunken);
}

.thread-row__footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.thread-row__footer .thread-row__replies {
  margin-top: 0;
}

.thread-row__share {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-faint);
}

.thread-row__share:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.thread__title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  line-height: 1.2;
}

.thread__body {
  font-size: 1.02rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thread__delete {
  justify-self: start;
  margin-top: 6px;
}

.reply-box {
  display: grid;
  gap: 8px;
}

.reply-box__input {
  min-height: 70px;
}

.reply-tree {
  display: grid;
  gap: 4px;
}

/* One forum reply, with votes, text and its own replies under it. */
.reply {
  display: grid;
}

.reply__row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
}

.reply__main {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.reply__body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reply__action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  font-weight: 600;
}

.reply__action:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

/* Each level of replies sits under a thin line, like a conversation thread. */
.reply-tree__children {
  margin-left: 15px;
  padding-left: 18px;
  border-left: 2px solid var(--line);
}

.reply-tree__children:empty {
  display: none;
}

.community-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.community-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 10px 16px 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s, transform 0.2s;
}

.community-chip:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.community-chip.is-joined {
  border-color: var(--accent);
}

.community-chip__emoji {
  font-size: 1.5rem;
}

.community-chip span:last-child {
  display: grid;
}

.community-chip small {
  color: var(--ink-faint);
}

/* The top of a community's page: its name, description and Join button. */
.community-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
}

.community-header__emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  font-size: 2rem;
}

.community-header__text {
  flex: 1;
  min-width: 0;
}

.community-header__slug {
  color: var(--ink-faint);
  font-size: 0.9rem;
}

.community-header__about {
  margin-top: 6px;
  color: var(--ink-soft);
}

.community-header__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-thread {
  padding: 20px;
}

@media (max-width: 560px) {
  .community-header {
    flex-wrap: wrap;
  }
  .community-header__actions {
    flex-direction: row;
    width: 100%;
  }
}

/* ---------- Video ---------- */

.video-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px 16px;
}

.video-card {
  display: grid;
  gap: 10px;
}

.video-card__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #111;
}

.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease-calm, ease);
}

.video-card:hover .video-thumb {
  transform: scale(1.04);
}

.video-card__topic {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.65);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.video-card__info {
  display: flex;
  gap: 10px;
}

.video-card__title {
  font-weight: 650;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card__meta {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.watch__player {
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
}

.watch__player video {
  width: 100%;
  max-height: 72vh;
  aspect-ratio: 16 / 9;
}

.watch__title {
  font-size: 1.4rem;
  line-height: 1.3;
}

.watch__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.watch__channel {
  display: grid;
}

.watch__channel a {
  font-weight: 700;
}

.watch__channel span {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.watch__description {
  padding: 16px 18px;
  white-space: pre-wrap;
}

.watch__comments {
  display: grid;
  gap: 16px;
  padding: 18px 20px;
}

.btn.is-liked {
  color: var(--love);
}

.btn.is-liked .icon {
  fill: currentColor;
}

.upload__drop {
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  cursor: pointer;
}

.upload__drop video {
  width: 100%;
  max-height: 420px;
  background: #000;
}

.upload__prompt {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--ink-soft);
}

.upload__prompt span {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* ---------- Photos ---------- */

.photo-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

/* One photo in the Photos grid. */
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-sunken);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.photo-tile:hover img {
  transform: scale(1.06);
}

.photo-tile__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.35), transparent 35%, transparent 65%, rgb(0 0 0 / 0.45));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s;
}

.photo-tile:hover .photo-tile__overlay,
.photo-tile:focus-visible .photo-tile__overlay {
  opacity: 1;
}

.photo-tile__author,
.photo-tile__stats,
.photo-tile__stats span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-tile__stats {
  gap: 14px;
}

/* ---------- Profiles ---------- */

.profile__limited {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

.profile__facts a {
  color: var(--accent-text);
  font-weight: 600;
}

/* ---------- Preference controls (setup wizard and Settings) ---------- */

.pref-stack {
  display: grid;
  gap: 14px;
}

.pref-note {
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.pref-note--lead {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.choices {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choices__legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
}

/* A big tappable choice card, used in setup and Settings. */
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.choice:hover {
  border-color: var(--line-strong);
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.choice input {
  flex: none;
  accent-color: var(--accent);
}

.choice__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-sunken);
  color: var(--accent-text);
}

.choice__text,
.toggle__text {
  display: grid;
  gap: 2px;
  flex: 1;
}

.choice__text span,
.toggle__text span {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

/* An on / off switch with its label and explanation. */
.toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle__track {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  transition: background 0.25s;
}

.toggle__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.toggle__input:checked + .toggle__track {
  background: var(--accent);
}

.toggle__input:checked + .toggle__track::after {
  transform: translateX(18px);
}

.toggle__input:focus-visible + .toggle__track {
  box-shadow: var(--focus-ring);
}

.topic-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.topic-chip:hover {
  transform: translateY(-1px);
}

.topic-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.settings__saved-note {
  margin-top: -8px;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

/* A profile you blocked: name, a note and the way back. */
.profile__blocked {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 20px;
  text-align: center;
}

/* Browse forums (/forums/browse): every community as a grid of chips. */
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.community-grid .community-chip {
  min-width: 0;
}

/* Browse forums: one card per category, with its busiest sub-forums as chips. */
.category-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.category-card:hover {
  box-shadow: var(--shadow-sm);
}

.subforums {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
