/* ===== Base forum layout (used by all themes) ===== */
:root {
  --forum-bg: #14161d;
  --forum-card: #1c2130;
  --forum-border: #2b3144;
  --forum-text: #e9ecf5;
  --forum-muted: #9fb1d4;
  --forum-accent: #00b0ff;
  --forum-link: #80d7ff;

  /* media sizing knobs */
  --content-max-img-width: 900px; /* hard cap for inline images on wide screens */
  --content-max-img-height: 70vh; /* vertical cap so they don’t fill the page */
  --emoji-size: 24px; /* default emoji size in posts/editor */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background: #0b0f1b;
}
.forum-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
  color: var(--forum-text);
}
a {
  color: var(--forum-link);
}
a:hover {
  opacity: 0.9;
}

/* ===== Categories grid ===== */
.forum-category {
  margin-bottom: 24px;
}
.forum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.forum-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--forum-border);
  border-radius: 12px;
  background: linear-gradient(180deg, #0e1423, #0b0f1b);
}
.forum-card .f-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #0f1322;
  border: 1px solid var(--forum-border);
}
.forum-card .f-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
}
.forum-card .f-desc {
  color: var(--forum-muted);
  font-size: 0.9rem;
}

/* ===== Topic list (forum view) ===== */
.topic-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--forum-border);
  border-radius: 12px;
  overflow: hidden;
  background: #0e1423;
}
.topic-row {
  display: grid;
  grid-template-columns: 1fr 140px 280px;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topic-title {
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
}
.topic-meta {
  font-size: 0.85rem;
  color: var(--forum-muted);
}
.topic-stats {
  text-align: center;
  color: var(--forum-muted);
  font-size: 0.9rem;
}
.topic-stats div {
  line-height: 1.1;
}
.topic-last {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  color: var(--forum-muted);
}
.topic-last .who {
  font-weight: 600;
  color: #dfe9ff;
}
.topic-last .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--forum-border);
}

/* ===== Topic (posts) ===== */
.post {
  border: 1px solid var(--forum-border);
  border-radius: 12px;
  background: #0e1423;
  margin-bottom: 12px;
  padding: 12px;
}
.post .post-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.post .post-head .avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--forum-border);
}
.post .post-head .user {
  font-weight: 700;
}
.post .post-head .when {
  color: var(--forum-muted);
  font-size: 0.85rem;
}

.post-content {
  margin-top: 6px;
  padding: 12px;
  background: #101523;
  border-radius: 8px;
  color: #dfe4f3;
}
.post-footer {
  font-size: 0.8rem;
  color: #8c94a9;
  margin-top: 8px;
}

/* ===== Editor helpers ===== */
.tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 10px;
}
#emojiPanel {
  display: none;
  border: 1px solid var(--forum-border);
  border-radius: 10px;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  background: #0f1320;
}
.tox .tox-toolbar__primary,
.tox .tox-menubar {
  background: rgba(255, 255, 255, 0.02);
}
.tox .tox-edit-area__iframe {
  background: #0e1220;
}

/* ===== IMAGES & EMBEDS IN POST BODY (key fix) ===== */
.post-content img {
  border: none;
}
.post-content img.emoji {
  width: var(--emoji-size) !important;
  height: var(--emoji-size) !important;
  vertical-align: middle;
  image-rendering: auto;
}
.post-content img:not(.emoji) {
  display: block; /* keeps layout clean */
  max-width: min(100%, var(--content-max-img-width)) !important;
  width: auto !important;
  height: auto !important;
  max-height: var(--content-max-img-height);
  object-fit: contain;
  margin: 8px auto; /* center large images */
}

/* Nuke inline width/height from pasted HTML that blows things up */
.post-content img[width]:not(.emoji),
.post-content img[height]:not(.emoji),
.post-content img[style*="width"]:not(.emoji),
.post-content img[style*="height"]:not(.emoji) {
  width: auto !important;
  height: auto !important;
  max-width: min(100%, var(--content-max-img-width)) !important;
  max-height: var(--content-max-img-height) !important;
}

/* Make iframes/videos responsive */
.post-content iframe,
.post-content video {
  display: block;
  width: 100% !important;
  max-width: 100%;
  aspect-ratio: 16/9;
  height: auto !important;
  border: 0;
}

/* Tiny emoji inside WYSIWYG preview as well */
.emoji {
  width: var(--emoji-size);
  height: var(--emoji-size);
  vertical-align: middle;
  image-rendering: auto;
}

/* ===== Pager, buttons, misc ===== */
.pagination {
  display: flex;
  gap: 6px;
  margin: 14px 0;
}
.pagination a {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  text-decoration: none;
}
.pagination a.active {
  font-weight: 700;
}
.btn {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}
.btn-primary {
  background: #3b82f6;
  color: #fff;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 0.9em;
}
.text-right {
  text-align: right;
}

/* Category & forum icons (explicit sizes so global img rules don’t affect them) */
.cat-icon,
.forum-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: #0f1322;
  border: 1px solid var(--forum-border, #2b3144);
}

/* ===== Poll — base styles ===== */
.poll-options {
  display: grid;
  gap: 10px;
}
.poll-option {
  display: block;
  cursor: pointer;
  position: relative;
}
.poll-option input[type="radio"] {
  position: absolute;
  left: -9999px;
}

/* rail */
.poll-track {
  position: relative;
  height: 34px;
  border-radius: 9999px;
  background: #131a33;
  border: 1px solid #2b3144;
  overflow: hidden;
}
.poll-track::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(10% - 1px),
    rgba(255, 255, 255, 0.07) calc(10% - 1px),
    rgba(255, 255, 255, 0.07) 10%
  );
  opacity: 0.4;
}

/* fill */
.poll-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #67a6ff, #57e0d0);
  transition: width 0.6s cubic-bezier(0.2, 0.6, 0.2, 1);
  z-index: 1;
}

/* labels */
.poll-label,
.poll-num,
.poll-pct {
  position: relative;
  z-index: 2;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.poll-label {
  margin-left: 12px;
  font-weight: 700;
  color: #e9ecf5;
}
.poll-num {
  margin-left: auto;
  font-weight: 700;
  color: #cfe2ff;
}
.poll-pct {
  width: 56px;
  text-align: right;
  color: #a9bddf;
  font-variant-numeric: tabular-nums;
}

.poll-option .poll-track {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
}
.poll-option:hover .poll-track {
  box-shadow: 0 0 0 1px rgba(128, 208, 255, 0.15) inset;
}

/* ===== Responsive tweaks ===== */
@media (max-width: 992px) {
  .forum-grid {
    grid-template-columns: 1fr;
  }
  .topic-row {
    grid-template-columns: 1fr 110px 180px;
    gap: 10px;
  }
}

/* compact pill counters for forum actions */
.chip-count {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 9999px;
  font-size: 12px;
  line-height: 1.3;
  background: linear-gradient(180deg, #18243f, #101628);
  color: #bcd2ff;
  border: 1px solid rgba(127, 168, 255, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.btn.btn-outline-success.active + .chip-count {
  /* when thanked by me */
  background: linear-gradient(180deg, #153a23, #0f2a19);
  color: #b6f2c7;
  border-color: rgba(120, 255, 180, 0.3);
}
