/*
 * Styles for posts: the post box (composer), the feed explainer and rules, post cards,
 * reactions, comments, the end of a list, and #hashtags. Used by components/composer.js,
 * post-card.js, reactions.js, comments.js and the feed pages. Loaded on every page by
 * index.html.
 */

/* ---------- Composer ---------- */

.composer {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.composer__input {
  flex: 1;
  min-height: 44px;
  max-height: 50vh;
  padding: 9px 0;
  border: 0;
  background: none;
  font-size: 1.05rem;
  resize: none;
}

.composer__input:focus {
  outline: none;
}

.composer__input::placeholder {
  color: var(--ink-faint);
}

.composer__preview {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.composer__preview img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.composer__remove {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
}

.composer__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

.composer__audience {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
}

/* ---------- Feed explainer ---------- */

.explainer {
  overflow: hidden;
}

.explainer__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
}

.explainer__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.explainer__summary {
  flex: 1;
  font-size: 0.9rem;
}

.explainer__more {
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.explainer__body {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px 56px;
}

.explainer__lead {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.explainer__rules {
  display: grid;
  gap: 4px;
  padding-left: 20px;
  list-style: decimal;
  font-weight: 500;
}

.explainer .segmented {
  justify-self: start;
}

/* ---------- Feed rules ---------- */

.feed-rules__list {
  display: grid;
  gap: 8px;
}

.feed-rules__row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
  align-items: center;
}

.feed-rules__pattern {
  min-width: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.feed-rules__buttons,
.feed-rules__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Small rounded labels, like the starter rules you can add in one tap. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.chip:hover {
  color: var(--ink);
  border-color: var(--accent);
}

@media (max-width: 560px) {
  .feed-rules__row {
    grid-template-columns: 1fr 1fr auto;
  }
  .feed-rules__pattern {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

/* ---------- Post card ---------- */

.post-list {
  display: grid;
  gap: 16px;
}

.post-list-wrap {
  display: grid;
  gap: 16px;
}

.post-list__status:empty {
  display: none;
}

.post-list__status {
  display: grid;
  gap: 16px;
}

.post-list__sentinel {
  height: 1px;
}

.post {
  display: grid;
  overflow: hidden;
}

/* "Why you're seeing this": a small eye after the time; click it for the reason (components/why.js). */
.why-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.why {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--ink-faint);
  transition: background 0.15s, color 0.15s;
}

.why:hover,
.why[aria-expanded="true"] {
  background: var(--surface-sunken);
  color: var(--ink);
}

.why__text {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.post__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 0;
}

.post__byline {
  display: grid;
  flex: 1;
  min-width: 0;
}

.post__author {
  font-weight: 650;
}

a.post__author:hover,
.post__time:hover {
  text-decoration: underline;
}

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

.post__audience {
  display: inline-flex;
}

.post__content {
  padding: 10px 16px 12px;
}

.post__content:empty {
  padding: 6px 0 0;
}

.post__text {
  font-size: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post__text a,
.comment__body a {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post__image {
  display: block;
  border-block: 1px solid var(--line);
  background: var(--surface-sunken);
}

.post__image img {
  width: 100%;
  max-height: 640px;
  object-fit: contain;
}

.post__stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px;
  padding: 10px 0;
  color: var(--ink-faint);
  font-size: 0.875rem;
}

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

.post__comment-count {
  margin-left: auto;
}

.post__comment-count:hover {
  text-decoration: underline;
}

.post__actions {
  display: grid;
  /* Equal columns however many buttons there are (Share only shows on public posts). */
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  margin: 0 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
}

.post__action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

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

.post__action.is-active {
  color: var(--accent-text);
}

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

.post__action-emoji {
  font-size: 1.1rem;
  line-height: 1;
}

.post__edit {
  display: grid;
  gap: 10px;
}

.post__editor {
  font-size: 1rem;
}

.post__edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Reactions ---------- */

.reaction-button {
  position: relative;
  display: flex;
}

.reaction-button > .post__action:first-of-type {
  flex: 1;
}

.post__action--more {
  width: 32px;
  color: var(--ink-faint);
}

/* The pop-up row of reactions to choose from. */
.reaction-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: flex;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out;
}

.reaction-picker__option {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.6rem;
  transition: transform 0.12s, background 0.12s;
}

.reaction-picker__option:hover,
.reaction-picker__option:focus-visible {
  transform: translateY(-4px) scale(1.18);
}

.reaction-picker__option.is-active {
  background: var(--accent-soft);
}

/* The little row of reaction emoji and the count under a post. */
.reaction-summary {
  display: flex;
}

.reaction-summary__emoji {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: -5px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--surface-sunken);
  font-size: 0.75rem;
}

.reaction-summary__emoji:first-child {
  margin-left: 0;
}

/* ---------- Comments ---------- */

.comments {
  display: grid;
  gap: 10px;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--line);
}

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

.comments__older:hover {
  text-decoration: underline;
}

.comments__list {
  display: grid;
  gap: 10px;
}

/* One comment: avatar, name, text and time. */
.comment {
  display: flex;
  gap: 8px;
}

.comment__main {
  min-width: 0;
}

.comment__bubble {
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--surface-sunken);
}

.comment__author {
  font-size: 0.875rem;
  font-weight: 650;
}

.comment__author:hover {
  text-decoration: underline;
}

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

.comment__meta {
  display: flex;
  gap: 12px;
  padding: 3px 12px 0;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.comment__delete {
  font-weight: 600;
}

.comment__delete:hover {
  color: var(--danger);
}

.comments__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.comments__field {
  display: flex;
  align-items: flex-end;
  flex: 1;
  padding: 4px 4px 4px 14px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--surface-sunken);
}

.comments__field:focus-within {
  border-color: var(--line-strong);
  background: var(--surface);
}

.comments__input {
  flex: 1;
  max-height: 160px;
  padding: 6px 0;
  border: 0;
  background: none;
  resize: none;
}

.comments__input:focus {
  outline: none;
}

.comments__send {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--accent);
}

.comments__send:disabled {
  color: var(--ink-faint);
  opacity: 0.6;
}

/* ---------- End of list ---------- */

.end-of-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 16px;
  color: var(--ink-soft);
}

.end-of-list__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.end-of-list p {
  color: var(--ink-faint);
  font-size: 0.875rem;
}

/* #hashtags in post text (core/format.js richText) and a tag's page (pages/tag.js). */
.hashtag {
  color: var(--accent-text);
  font-weight: 600;
}

.hashtag:hover {
  text-decoration: underline;
}

.tag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
}

.tag-header__name {
  font-size: 1.5rem;
}

/* Phones: the post box's buttons wrap onto a second line instead of running off the card. */
@media (max-width: 820px) {
  .composer__toolbar {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .composer__toolbar > .btn--primary:last-child {
    margin-left: auto;
  }
}

/* "Display name @handle" on Pulse and Forums (avatar.js NameAndHandle). */
.name-handle__handle {
  color: var(--ink-faint);
  font-weight: 400;
}
