/* Global Styles */
:root, [data-theme="light"] {
  --primary-color: #5865F2;
  --background-color: #f9f9f9;
  --card-background: #ffffff;
  --text-color: #2e3338;
  --text-color-secondary: #5c6773;
  --border-color: #e3e5e8;
  --link-color: #006ce8;
  --tag-bg: #eef0f2;
  --tag-color: #3c4248;
  --spoiler-bg: #202225;
  --spoiler-revealed-bg: #e3e5e8;
  --code-bg: #f0f0f0;
  --pre-bg: #282c34;
  --pre-color: #abb2bf;
  --comment-bg: #fafafa;
  --embed-bg: #f9f9f9;
  --mention-bg: hsl(235, 86%, 97%);
}

[data-theme="dark"] {
  --primary-color: #7289DA;
  --background-color: #202225;
  --card-background: #2f3136;
  --text-color: #dcddde;
  --text-color-secondary: #96989d;
  --border-color: #40444b;
  --link-color: #7289DA;
  --tag-bg: #3a3c41;
  --tag-color: #b9bbbe;
  --spoiler-bg: #000000;
  --spoiler-revealed-bg: #4a4d53;
  --code-bg: #202225;
  --pre-bg: #1e1f22;
  --pre-color: #abb2bf;
  --comment-bg: #2a2d31;
  --embed-bg: #2b2d31;
  --mention-bg: rgba(114, 137, 218, 0.2);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 20px;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.loading, .empty-state, .error-state {
  text-align: center;
  padding: 40px;
  color: var(--text-color-secondary);
}
.error-state {
  color: #d93025;
}

/* Main Page (index.liquid) */
.main-header {
  text-align: center;
  margin-bottom: 2rem;
}
.main-header h1 {
  margin: 0;
}
.main-header p {
  color: var(--text-color-secondary);
  margin-top: 0.5rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.search-bar input[type="text"] {
  flex-grow: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
}
.search-bar button {
  padding: 0.75rem 1rem;
  border: 1px solid var(--primary-color);
  background-color: var(--primary-color);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
}
.search-bar button:hover {
  opacity: 0.9;
}

.feed-controls {
  margin-top: 1rem;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.tag-filter {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-color);
  background-color: var(--card-background);
  color: var(--text-color-secondary);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.tag-filter.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}
.tag-filter:not(.active):hover {
  background-color: #f0f0f0;
}

.global-feed {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feed-card {
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  transition: box-shadow 0.2s ease;
  display: block;
  text-decoration: none;
  color: inherit;
}
.feed-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}

.feed-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-color-secondary);
  margin-bottom: 0.5rem;
}
.feed-author {
  font-weight: 500;
  color: var(--text-color);
}
.feed-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  display: block;
}
.feed-summary {
  color: var(--text-color-secondary);
  margin: 0.5rem 0;
  /* [FIX] 긴 연속 문자열이 박스를 뚫고 나가는 현상 방지 */
  overflow-wrap: break-word;
  word-break: break-word;
  /* [FIX] 내용이 1줄이어도 2줄 높이 유지 (카드 높이 통일) */
  line-height: 1.6;
  min-height: 3.2em; /* 1.6 * 2 lines */
  /* [NEW] 요약문의 높이를 2줄로 제한하여 카드 높이를 일정하게 유지 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.feed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.feed-tag {
  background-color: var(--tag-bg);
  color: var(--tag-color);
  padding: 2px 8px;
  border-radius: 12px;
}
.feed-stats {
  color: var(--text-color-secondary);
}

/* Post Page (post.liquid) */
.post header { margin-bottom: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.post-tags { margin-top: 0.5rem; }
.tag { display: inline-block; background: var(--tag-bg); padding: 2px 8px; border-radius: 12px; font-size: 0.85rem; color: var(--tag-color); margin-right: 5px; }

.timeline { margin-top: 1rem; }
.timeline-item { padding: 1.5rem 0; border-bottom: 1px solid var(--border-color); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item.type-comment { background-color: var(--comment-bg); padding: 1.5rem; border-radius: 8px; margin-top: 1rem; margin-bottom: 1rem; }

.item-meta { margin-bottom: 0.8rem; display: flex; align-items: center; gap: 0.5rem; }
.item-author-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.item-author-link:hover .item-author {
  text-decoration: underline;
}
.item-author-avatar { display: inline-block; width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; background-color: #eee; }
.item-author { font-weight: bold; color: var(--text-color); }
.item-date { color: #888; font-size: 0.85rem; }

/* Subheading Style */
.subheading {
  font-size: 0.9em;
  color: #57606a;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}

/* Discord Markdown Styles */
.spoiler { background-color: var(--spoiler-bg); color: var(--spoiler-bg); border-radius: 3px; cursor: pointer; user-select: none; padding: 0 2px; }
.spoiler.revealed { background-color: var(--spoiler-revealed-bg); color: inherit; }
.mention, .internal-link, .file-download-link { background-color: var(--mention-bg); color: var(--primary-color); padding: 0 2px; border-radius: 3px; font-weight: 500; text-decoration: none; transition: background-color 0.1s ease, color 0.1s ease; }
.mention:hover, .internal-link:hover, .file-download-link:hover {
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
}

.mention.role { font-weight: 500; }
img.emoji { height: 1.25em; width: 1.25em; margin: 0 0.05em 0 0.1em; vertical-align: -0.2em; }
blockquote { border-left: 4px solid var(--border-color); padding-left: 1em; margin-left: 0; color: var(--text-color-secondary); }
pre { background-color: var(--pre-bg); color: var(--pre-color); padding: 1em; border-radius: 6px; overflow-x: auto; }
code { font-family: "Consolas", "Monaco", monospace; background-color: var(--code-bg); padding: 2px 4px; border-radius: 3px; font-size: 0.9em; }
pre code { background-color: transparent; padding: 0; }

/* Embeds Style */
.embeds-container { margin-top: 0.8rem; }
.embed-item { border-left: 4px solid var(--border-color); padding-left: 1rem; margin-bottom: 0.5rem; }
.embed-item.type-rich { background-color: var(--embed-bg); border-radius: 4px; padding: 1rem; padding-left: 1rem; }
.embed-provider { font-size: 0.8rem; color: #666; margin-bottom: 0.2rem; }
.embed-title { font-weight: bold; }
.embed-title a { text-decoration: none; color: var(--link-color); }
.embed-description { font-size: 0.9rem; color: #333; margin: 0.5rem 0; white-space: pre-wrap; }
.embedded-image { max-width: 100%; max-height: 400px; border-radius: 5px; margin-top: 0.5rem; }
.embed-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 1rem; }
.embed-field { font-size: 0.9rem; }
.embed-field-name { font-weight: bold; margin-bottom: 0.2rem; }
.embed-field-value { white-space: pre-wrap; }
.embed-footer { font-size: 0.8rem; color: #666; margin-top: 1rem; display: flex; align-items: center; gap: 0.3rem; }
.embed-footer-icon { width: 20px; height: 20px; border-radius: 50%; }

/* Profile Page (profile.liquid) */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-color: #eee;
}
.profile-info h1 {
  margin: 0;
  font-size: 2rem;
}
.profile-info .username {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-color-secondary);
}

.activity-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.activity-item {
  /* Wrapper only */
  display: block;
  padding: 0;
  border: none;
  background: none;
}
.activity-card {
  display: block;
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s ease;
}
.activity-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}
.activity-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-color-secondary);
  margin-bottom: 0.5rem;
}
.activity-title {
  font-weight: 600;
  color: var(--text-color); /* or var(--link-color) if preferred */
}
.activity-summary {
  font-size: 0.9rem;
  color: var(--text-color-secondary);
  margin: 0.5rem 0 0 0;
  /* [FIX] 긴 연속 문자열이 박스를 뚫고 나가는 현상 방지 */
  overflow-wrap: break-word;
  word-break: break-word;
  /* [FIX] 내용이 1줄이어도 2줄 높이 유지 (카드 높이 통일) */
  line-height: 1.6;
  min-height: 3.2em; /* 1.6 * 2 lines */
  /* [NEW] 요약문의 높이를 2줄로 제한하여 카드 높이를 일정하게 유지 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Infinite Scroll Sentinel */
.infinite-scroll-sentinel {
  height: 50px;
}

/* Reactions */
.reactions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reaction-item {
  display: flex;
  align-items: center;
  gap: 0.3rem; /* Use gap for spacing */
  background-color: var(--tag-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 4px 8px;
  cursor: default; /* Not clickable for now */
  transition: background-color 0.2s ease;
}

.reaction-emoji {
  /* This ensures both <img> and <span> emojis are boxed and centered consistently */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1rem;
  width: 1rem;
  object-fit: contain;
  font-size: 1rem; /* For standard text emojis */
}

.reaction-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color-secondary);
  /* margin-left is replaced by gap on parent */
}

/* --- Responsive Design for Mobile --- */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  .container {
    padding: 15px;
  }
  .profile-header {
    flex-direction: column;
    align-items: center; /* Center items when stacked */
    text-align: center;
  }
  .search-bar {
    flex-direction: column;
  }
}