/* design tokens (locked)
   palette: reddit's own production colors, not the ui-ux-pro-max community-purple default -
   the brief asks for the real thread furniture, so the real palette is the honest fit.
   page bg #DAE0E6, card #FFFFFF, border #EDEFF1, text #1A1A1B, meta #787C7E,
   upvote orange #FF4500 (brief's own ground color), downvote violet #7193FF, link blue #0079D3.
   type: IBM Plex Sans / IBM Plex Mono, reddit's actual production font, not a decorative pick.
   spacing scale: 4/8/12/16/20/24/32px. radius: 4px controls, 24px pill buttons, 50% avatar.
*/

:root {
  --bg: #dae0e6;
  --card: #ffffff;
  --border: #edeff1;
  --border-strong: #ccc;
  --text: #1a1a1b;
  --meta: #787c7e;
  --meta-light: #a5a7a8;
  --orange: #ff4500;
  --orange-dark: #d93a00;
  --violet: #7193ff;
  --link: #0079d3;
  --green: #46d160;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-pill: 24px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

code { font-family: "IBM Plex Mono", monospace; }

.app {
  max-width: 1064px;
  margin: 0 auto;
}

/* ---- header ---- */

.sub-header {
  background: var(--card);
  border-bottom: 1px solid var(--border-strong);
}

.banner {
  width: 100%;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  background: var(--orange);
}

.banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sub-header-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  max-width: 1064px;
  margin: 0 auto;
  padding: 0 var(--sp-4) var(--sp-4);
  transform: translateY(-24px);
}

.community-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid var(--card);
  background: var(--orange);
  display: block;
  flex-shrink: 0;
}

.sub-titles {
  flex: 1;
  min-width: 0;
  padding-top: 24px;
}

.sub-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.tagline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--meta);
}

.join-btn {
  margin-top: 24px;
  flex-shrink: 0;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-pill);
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  transition: background 150ms ease, transform 150ms ease;
}

.join-btn:hover { background: var(--orange-dark); }
.join-btn:active { transform: scale(0.97); }

.join-btn[data-joined="true"] {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.join-btn[data-joined="true"]:hover {
  border-color: #ff4500;
  color: var(--orange);
  background: #fff5f0;
}

/* ---- sort row ---- */

.sort-row {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  max-width: 1064px;
  margin: 0 auto;
  overflow-x: auto;
}

.sort-btn {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--meta);
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}

.sort-btn:hover { background: var(--border); }

.sort-btn.active {
  background: #ffece5;
  color: var(--orange-dark);
}

.karma-canary {
  margin-left: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--meta);
  white-space: nowrap;
  padding-left: var(--sp-3);
}

.karma-canary span { color: var(--orange-dark); font-weight: 600; }

/* ---- layout ---- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: var(--sp-4);
  padding: var(--sp-4);
}

.feed {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

/* ---- vote arrows ---- */

.votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) 0;
  flex-shrink: 0;
}

.vote-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--meta-light);
  transition: background 120ms ease, color 120ms ease;
}

.vote-btn svg { fill: currentColor; }

.vote-btn:hover { background: var(--border); }
.vote-btn.up:hover { color: var(--orange); }
.vote-btn.down:hover { color: var(--violet); }

.votes[data-vote-state="up"] .vote-btn.up { color: var(--orange); }
.votes[data-vote-state="up"] .score { color: var(--orange); }
.votes[data-vote-state="down"] .vote-btn.down { color: var(--violet); }
.votes[data-vote-state="down"] .score { color: var(--violet); }

.score {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  min-width: 24px;
  text-align: center;
}

/* ---- posts ---- */

.post, .post-teaser {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.post-row, .post-teaser {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.pinned-badge {
  padding: var(--sp-2) var(--sp-3) 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

.post-body-wrap, .teaser-body {
  flex: 1;
  min-width: 0;
}

.post-meta, .comment-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  color: var(--meta);
  flex-wrap: wrap;
}

.flair {
  background: #ffece5;
  color: var(--orange-dark);
  font-weight: 600;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
}

.dot { color: var(--meta-light); }

.post-title {
  margin: var(--sp-2) 0 var(--sp-2);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.teaser-title {
  margin: var(--sp-1) 0 var(--sp-2);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.post-text {
  margin: 0 0 var(--sp-3);
  font-size: 14px;
  color: var(--text);
}

.post-image {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--orange);
  max-width: 480px;
  margin-bottom: var(--sp-3);
}

.post-image img {
  width: 100%;
  display: block;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.action-item {
  font-size: 12px;
  font-weight: 700;
  color: var(--meta);
  padding: var(--sp-1) var(--sp-2);
}

.link-btn {
  font-size: 12px;
  font-weight: 700;
  color: var(--meta);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background 120ms ease;
}

.link-btn:hover { background: var(--border); }

/* ---- comments ---- */

.comments {
  border-top: 1px solid var(--border);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.comment-row { display: flex; gap: var(--sp-2); }

.comment-body-wrap {
  flex: 1;
  min-width: 0;
  border-left: 2px solid transparent;
  padding-left: var(--sp-2);
  transition: border-color 150ms ease;
}

.comment:hover > .comment-row > .comment-body-wrap {
  border-color: var(--border-strong);
}

.collapse-toggle {
  font-size: 11px;
  color: var(--meta-light);
  font-weight: 700;
  width: 16px;
}

.comment-author {
  font-weight: 700;
  color: var(--text);
}

.comment-author.is-mod { color: var(--green); }
.comment-author.is-op { color: var(--link); }

.tag {
  font-size: 10px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 3px;
  color: #fff;
}

.tag-mod { background: var(--green); }
.tag-op { background: var(--link); }

.comment-text {
  margin: var(--sp-1) 0 var(--sp-1);
  font-size: 14px;
}

.comment-actions { display: flex; gap: 0; }

.comment-replies {
  margin-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.comment.collapsed .comment-text,
.comment.collapsed .comment-actions,
.comment.collapsed .comment-replies {
  display: none;
}

.comment.collapsed .collapse-toggle::before { content: ""; }

.buried-notice { margin: var(--sp-1) 0; }

.buried-reveal {
  font-size: 12px;
  color: var(--meta-light);
  font-style: italic;
}

.buried-reveal:hover { color: var(--meta); }

.comment.buried .comment-text,
.comment.buried .comment-actions {
  display: none;
}

.comment.buried.revealed .comment-text,
.comment.buried.revealed .comment-actions {
  display: block;
}

.comment.buried.revealed .buried-notice {
  display: none;
}

.comment.buried .comment-body-wrap {
  opacity: 0.6;
}

/* ---- post list ---- */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ---- sidebar ---- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}

.card-title {
  margin: 0 0 var(--sp-2);
  font-size: 15px;
  font-weight: 700;
}

.card-subtitle {
  margin: var(--sp-3) 0 var(--sp-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--meta);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.about-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.about-stats {
  display: flex;
  gap: var(--sp-5);
  margin-top: var(--sp-4);
}

.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 16px; }
.stat span { font-size: 11px; color: var(--meta); }

.about-created {
  margin: var(--sp-3) 0 0;
  font-size: 11px;
  color: var(--meta-light);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-3) 0 0;
}

.rules-list, .mods-list {
  margin: 0;
  padding-left: var(--sp-4);
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.mods-list { list-style: none; padding-left: 0; }
.mods-list li { color: var(--link); }

.bookmark-link {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.bookmark-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--border);
  color: var(--meta);
  flex-shrink: 0;
}

.bookmark-link:hover .bookmark-icon { background: #ffece5; color: var(--orange); }
.bookmark-link:hover { text-decoration: none; color: var(--orange); }

.verify-status {
  margin: 0 0 var(--sp-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--orange-dark);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ca-box {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
}

.ca-box code {
  font-size: 11.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ca-copy-flag {
  font-size: 11px;
  font-weight: 700;
  color: var(--link);
  flex-shrink: 0;
}

.ca-box.copied .ca-copy-flag { color: var(--green); }

/* ---- footer ---- */

.site-footer {
  text-align: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-8);
  font-size: 12px;
  color: var(--meta);
}

/* ---- responsive ---- */

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
  }

  .about-card .about-desc,
  .about-card .rules-list,
  .about-card .mods-list,
  .about-card .card-subtitle,
  .about-card hr,
  .about-card .about-created { display: none; }

  .card.about-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }

  .card.about-card .card-title { margin: 0; }
}

@media (max-width: 480px) {
  .sub-header-row {
    flex-wrap: wrap;
  }

  .join-btn {
    margin-left: auto;
  }

  .post-title { font-size: 17px; }
  .karma-canary { display: none; }
}
