/* feed — the home page card (tabs, composer, posts), a post's page with its comments, the posts on
   a profile, the Like button with its reaction picker, and the security notice. Tokens and shared
   components only (docs/DESIGN.md). */
@layer pages {
  .feed { --feed-pad: var(--sp-5); position: sticky; top: calc(60px + var(--sp-4)); display: flex; flex-direction: column;
    height: calc(100vh - 60px - var(--sp-8)); min-height: 480px; }
  @media (min-width: 900px) { .feed { --feed-pad: var(--sp-6); } }
  .feed > .card-head { margin: 0; padding: var(--feed-pad) var(--feed-pad) var(--sp-3); }
  .feed > .feed-tabs { margin: 0 var(--feed-pad) var(--sp-3); overflow-x: auto; }
  .feed-tabs .tab .flag { width: 24px; height: 16px; }
  .feed-tab-name { max-width: 14ch; }
  .feed-tabs .feed-tab-pic { flex: none; width: 20px; height: 20px; border-radius: var(--r-pill); overflow: hidden; display: grid; place-items: center; background: var(--surface-3); }
  .feed-tabs .feed-tab-pic img { width: 100%; height: 100%; object-fit: cover; }
  .feed-tabs .feed-tab-pic .initials { font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; }
  .feed-tabs .tab { flex: 1 1 auto; padding-inline: var(--sp-2); font-size: var(--fs-sm); white-space: nowrap; }
  .feed > .feed-composer { padding: 0 var(--feed-pad) var(--sp-4); }
  .feed-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--border-subtle); border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .feed-list > .empty { padding: var(--sp-8) var(--feed-pad); }

  /* The box for a post or a comment. */
  .feed-composer { display: flex; flex-direction: column; gap: var(--sp-2); }
  .feed-composer textarea { min-height: 72px; resize: none; }
  .feed-composer-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); }
  .feed-composer-foot .btn { margin-left: auto; }
  .feed-count.over { color: var(--red-text); }
  .as-unit { font-size: var(--fs-sm); color: var(--text-2); }

  /* One post. */
  .post { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
  .feed-list > .post, .feed-skeleton > .post { padding: var(--sp-4) var(--feed-pad); border-bottom: 1px solid var(--border-subtle); }
  .post.pinned { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
  .post.event { background: var(--surface-2); }
  .pin-note { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--brand-text); }
  .post-head { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
  .post-head .pic { width: 36px; height: 36px; }
  .post-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .post-names { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
  .post-names .who, .post-names b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-semibold); color: var(--text); }
  .post-sub { display: inline-flex; align-items: center; gap: var(--sp-2); }
  .post-sub .flag { width: 18px; height: 12px; }
  .post-head time { flex: none; }
  .post-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
  .post-medal { width: 56px; height: 64px; object-fit: contain; align-self: flex-start; filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--ink) 35%, transparent)); }
  .post-link { color: var(--brand-text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
  .post-link:hover { text-decoration-color: var(--brand); }
  .post-link.external::after { content: " ↗"; font-size: .85em; }
  .post-counts { display: flex; align-items: center; gap: var(--sp-3); min-height: 20px; }
  .post-counts:empty { display: none; }
  .reaction-summary { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); }
  .post-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1); margin-left: calc(-1 * var(--sp-3)); }
  .post-actions .btn.disabled, .comment-locked .btn.disabled { color: var(--text-3); cursor: not-allowed; opacity: .7; pointer-events: auto; }
  .post-delete { margin-left: auto; }

  /* The Like button: hover or focus it to pick a reaction. */
  .reaction { position: relative; display: inline-flex; }
  .like-btn.on { color: var(--brand-text); }
  .reaction-picker { position: absolute; z-index: 5; bottom: 100%; left: 0; display: flex; gap: var(--sp-1); padding: var(--sp-2); border-radius: var(--r-pill);
    background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-2); }
  .reaction-picker::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: var(--sp-2); }
  .reaction-option { display: grid; place-items: center; width: 36px; height: 36px; font-size: var(--fs-h2); line-height: 1; border-radius: 50%;
    transition: transform var(--t-fast) var(--ease), background-color var(--t-fast); }
  .reaction-option:hover, .reaction-option:focus-visible { transform: translateY(-3px) scale(1.2); background: var(--surface-2); }
  .reaction-option.chosen { background: var(--brand-soft); }

  /* A game article linked in a post. */
  .article-preview { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); }
  .article-preview:hover { border-color: var(--border-strong); }
  .article-preview-text { display: flex; flex-direction: column; min-width: 0; }
  .article-preview-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .article-preview-text small { color: var(--text-3); }

  /* The unit's daily order above its messages. */
  .daily-order { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-3) var(--feed-pad); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--brand-border); border-radius: var(--r-md); background: var(--brand-soft); color: var(--text); }
  .daily-order > span:not(.pill) { display: flex; flex-direction: column; flex: 1; }
  .daily-order small { color: var(--text-2); }


  .feed-skeleton .post .skeleton { width: 40%; height: 12px; }
  .feed-skeleton .post .skeleton + .skeleton { width: 88%; height: 14px; }

  /* A post's page. */
  .comment-list { display: flex; flex-direction: column; gap: var(--sp-5); margin: 0 0 var(--sp-5); padding: 0; list-style: none; }
  .feed-comment { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
  .comment-locked { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border-subtle); }

  /* On a profile. */
  .profile-post-list { display: flex; flex-direction: column; gap: var(--sp-5); }
  .profile-post-list .post { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border-subtle); }
  .profile-post-list .post:last-child { border-bottom: 0; padding-bottom: 0; }
  .share-medal { margin-top: var(--sp-2); }

  /* The security notice. */
  .security-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
  .security-card > .icon { color: var(--amber-text); }
  .security-url { display: block; max-width: 100%; padding: var(--sp-3); overflow-wrap: anywhere; border-radius: var(--r-md); background: var(--surface-sunken); border: 1px solid var(--border-subtle); }
  .security-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

  @media (max-width: 900px) { .feed { position: static; height: 680px; } }
  @media (max-width: 560px) { .feed .btn.sm { --btn-h: var(--h-md); } .feed { height: 640px; } .reaction-option { width: 40px; height: 40px; } }
}
