/* ==========================================================
   bbPress smartphone cleanup (phones)
   - tighter density
   - author stacked above content
   - remove non-essential clutter
   ========================================================== */

@media screen and (max-width: 600px) {

    /* Overall forum wrapper: less padding */
    #bbpress-forums {
        padding: 0.75rem 0.5rem 1rem;
    }

    /* Header/footer rows: compact */
    #bbpress-forums li.bbp-header,
    #bbpress-forums li.bbp-footer {
        padding: 0.45rem 0.6rem;
        font-size: 0.85rem;
        line-height: 1.2;
    }

    /* Topic/forum row density */
    #bbpress-forums li.bbp-body ul.topic,
    #bbpress-forums li.bbp-body ul.forum {
        padding: 0.4rem 0.25rem !important;
    }

    /* Topic/forum titles: readable but not huge */
    #bbpress-forums a.bbp-topic-permalink,
    #bbpress-forums a.bbp-forum-title {
        font-size: 1.05rem;
        line-height: 1.2;
    }

    /* Meta lines: tighter */
    #bbpress-forums .bbp-topic-title p.bbp-topic-meta,
    #bbpress-forums .bbp-topic-title .bbp-topic-started-by,
    #bbpress-forums .bbp-topic-title .bbp-topic-started-in,
    #bbpress-forums .bbp-topic-title .bbp-topic-freshness {
        font-size: 0.88rem;
        line-height: 1.25;
    }

    /* Reply/topic header (top of posts): compact */
    #bbpress-forums .bbp-reply-header,
    #bbpress-forums .bbp-topic-header {
        padding: 0.2rem 0.6rem;
        margin: 0 0 0.3rem;
        font-size: 0.80rem;
    }

    /* Ensure author block stacks above content on phones */
    #bbpress-forums .bbp-reply-author,
    #bbpress-forums .bbp-topic-author {
        float: none !important;
        width: 100% !important;
        margin: 0 0 0.35rem 0 !important;
        padding: 0.55rem 0.65rem !important;
        box-sizing: border-box;
    }

    /* Content card: reduce padding and margins */
    #bbpress-forums .bbp-reply-content,
    #bbpress-forums .bbp-topic-content {
        float: none !important;
        width: 100% !important;
        padding: 0.75rem 0.8rem !important;
        margin: 0 0 0.75rem !important;
        box-sizing: border-box;
    }

    /* Zebra tint stays subtle on phones */
    #bbpress-forums ul.bbp-replies > li:nth-child(even) div.bbp-reply-content,
    #bbpress-forums ul.bbp-topics  > li:nth-child(even) div.bbp-topic-content {
        background: #f0f4f7;
    }

    /* Pagination: smaller tap targets but still usable */
    #bbpress-forums .bbp-pagination-links a,
    #bbpress-forums .bbp-pagination-links span.current {
        padding: 0.22rem 0.45rem;
        font-size: 0.9rem;
    }

    /* Make long URLs/code wrap instead of forcing sideways scroll */
    #bbpress-forums .bbp-reply-content,
    #bbpress-forums .bbp-topic-content {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

/* ==========================================================
   bbPress: single-column list mode (<= 60px)
   - Show ONLY the first column (title/info)
   - Hide all secondary columns completely
   - Prevent overflow at 320–600px portrait widths
   ========================================================== */

  /* Topic list: hide all header columns except title */
  #bbpress-forums li.bbp-header li:not(.bbp-topic-title) {
    display: none !important;
  }

  /* Forum list: hide all header columns except forum info */
  #bbpress-forums li.bbp-header li:not(.bbp-forum-info) {
    display: none !important;
  }

  /* Ensure remaining header column spans full width */
  #bbpress-forums li.bbp-header li.bbp-topic-title,
  #bbpress-forums li.bbp-header li.bbp-forum-info {
    width: 100% !important;
    float: none !important;
    display: block !important;
    box-sizing: border-box !important;
  }
}

/* Topic rows: keep ONLY the title column */
  #bbpress-forums ul.topic > li:not(.bbp-topic-title) {
    display: none !important;
  }

  /* Forum rows: keep ONLY the forum info column */
  #bbpress-forums ul.forum > li:not(.bbp-forum-info) {
    display: none !important;
  }

  /* Force the remaining column to full width */
  #bbpress-forums ul.topic > li.bbp-topic-title,
  #bbpress-forums ul.forum > li.bbp-forum-info {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    box-sizing: border-box !important;
  }

  /* Prevent text overflow at narrow widths */
  #bbpress-forums ul.topic > li.bbp-topic-title a,
  #bbpress-forums ul.forum > li.bbp-forum-info a,
  #bbpress-forums .bbp-topic-meta {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* ==========================================================
   bbPress: roomy TWO-column layout (>= 601px)
   - Force wide title/info column
   - Force narrow freshness column
   - Hide count columns everywhere above phone width
   ========================================================== */
@media screen and (min-width: 601px) {

  /* Hide count columns (topics) */
  #bbpress-forums .bbp-topic-voice-count,
  #bbpress-forums .bbp-topic-reply-count {
    display: none !important;
  }

  /* Hide count columns (forums) */
  #bbpress-forums .bbp-forum-topic-count,
  #bbpress-forums .bbp-forum-reply-count {
    display: none !important;
  }

  /* Topics: force widths for Title + Freshness */
  #bbpress-forums li.bbp-header .bbp-topic-title,
  #bbpress-forums li.bbp-body   .bbp-topic-title {
    width: 76% !important;
  }

  #bbpress-forums li.bbp-header .bbp-topic-freshness,
  #bbpress-forums li.bbp-body   .bbp-topic-freshness {
    width: 24% !important;
    text-align: right;
    white-space: nowrap;
  }

  /* Forums: force widths for Info + Freshness */
  #bbpress-forums li.bbp-header .bbp-forum-info,
  #bbpress-forums li.bbp-body   .bbp-forum-info {
    width: 76% !important;
  }

  #bbpress-forums li.bbp-header .bbp-forum-freshness,
  #bbpress-forums li.bbp-body   .bbp-forum-freshness {
    width: 24% !important;
    text-align: right;
    white-space: nowrap;
  }

  /* Safety: prevent long titles from breaking layout */
  #bbpress-forums .bbp-topic-title a,
  #bbpress-forums .bbp-forum-info a {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* ==========================================================
   bbPress topic list: roomy 2-column layout (>= 601px)
   - Hide Voices/Posts columns
   - Topic wide, Last Post compact
   - Prevent 769px “snap narrow”
   ========================================================== */
@media screen and (min-width: 601px) {

  /* 1) Hide the 2 middle columns everywhere (header + rows) */
  #bbpress-forums .bbp-topic-voice-count,
  #bbpress-forums .bbp-topic-reply-count {
    display: none !important;
  }

  /* 2) Force header column widths (your header structure) */
  #bbpress-forums li.bbp-header ul.forum-titles {
    display: flex;
    align-items: center;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-title {
    flex: 0 1 78%;
    min-width: 0; /* allows wrapping instead of overflow */
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-freshness {
    flex: 0 0 22%;
    text-align: right;
    white-space: nowrap;
  }

  /* 3) Force row column widths (your topic row structure) */
  #bbpress-forums ul.topic {
    display: flex;
    align-items: flex-start;
  }

  #bbpress-forums ul.topic > li.bbp-topic-title {
    flex: 0 1 78%;
    min-width: 0;
  }

  #bbpress-forums ul.topic > li.bbp-topic-freshness {
    flex: 0 0 22%;
    text-align: right;
    white-space: nowrap;
  }

  /* 4) Wrap long titles safely without pushing layout wide */
  #bbpress-forums ul.topic > li.bbp-topic-title a.bbp-topic-permalink {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* 5) Reduce vertical density of meta blocks in the list */
  #bbpress-forums ul.topic > li.bbp-topic-title .bbp-topic-meta,
  #bbpress-forums ul.topic > li.bbp-topic-freshness .bbp-topic-meta {
    margin: 0.25rem 0 0 !important;
    line-height: 1.25;
  }

  /* 6) Avatar policy for lists/meta: hide tiny bpthumbs in topic lists */
  #bbpress-forums ul.topic img.avatar,
  #bbpress-forums ul.topic .bbp-author-avatar {
    display: none !important;
  }
}


/* ==========================================================
   bbPress topic list: breakpoint-correct columns
   <768     : 1 column (Topic only)
   768-1023 : 2 columns (Topic + Last Post)
   >=1024   : 4 columns (Topic + Voices + Posts + Last Post)
   ========================================================== */

/* ---------- A) <768px: Topic only (hide 2nd/3rd/4th columns) ---------- */
@media screen and (max-width: 767px) {

  /* Hide columns (header + rows) */
  #bbpress-forums .bbp-topic-voice-count,
  #bbpress-forums .bbp-topic-reply-count,
  #bbpress-forums .bbp-topic-freshness {
    display: none !important;
  }

  /* Prevent any “table/flex” layout from squeezing */
  #bbpress-forums ul.topic,
  #bbpress-forums li.bbp-header ul.forum-titles {
    display: block !important;
  }

  #bbpress-forums ul.topic > li.bbp-topic-title,
  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-title {
    width: 100% !important;
  }
}

/* ---------- B) 768–1023px: 2 columns (Topic + Last Post) ---------- */
@media screen and (min-width: 768px) and (max-width: 1023px) {

  /* Hide Voices + Posts (header + rows) */
  #bbpress-forums .bbp-topic-voice-count,
  #bbpress-forums .bbp-topic-reply-count {
    display: none !important;
  }

  /* Force header to 2-column flex */
  #bbpress-forums li.bbp-header ul.forum-titles {
    display: flex !important;
    align-items: center;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-title {
    flex: 0 1 78%;
    min-width: 0;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-freshness {
    display: block !important; /* explicitly re-enable */
    flex: 0 0 22%;
    text-align: right;
    white-space: nowrap;
  }

  /* Force rows to 2-column flex */
  #bbpress-forums ul.topic {
    display: flex !important;
    align-items: flex-start;
  }

  #bbpress-forums ul.topic > li.bbp-topic-title {
    flex: 0 1 78%;
    min-width: 0;
  }

  #bbpress-forums ul.topic > li.bbp-topic-freshness {
    display: block !important; /* explicitly re-enable */
    flex: 0 0 22%;
    text-align: right;
    white-space: nowrap;
  }
}

/* ---------- C) >=1024px: 4 columns (match headers to rows) ---------- */
@media screen and (min-width: 1024px) {

  /* Re-enable all columns (in case earlier rules hid them) */
  #bbpress-forums .bbp-topic-voice-count,
  #bbpress-forums .bbp-topic-reply-count,
  #bbpress-forums .bbp-topic-freshness {
    display: list-item !important;
  }

  /* Use 4-column flex consistently for header + rows */
  #bbpress-forums li.bbp-header ul.forum-titles,
  #bbpress-forums ul.topic {
    display: flex !important;
    align-items: center;
  }

  /* Column sizing: Topic wide, others compact */
  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-title,
  #bbpress-forums ul.topic > li.bbp-topic-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-voice-count,
  #bbpress-forums ul.topic > li.bbp-topic-voice-count {
    flex: 0 0 90px;
    text-align: center;
    white-space: nowrap;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-reply-count,
  #bbpress-forums ul.topic > li.bbp-topic-reply-count {
    flex: 0 0 90px;
    text-align: center;
    white-space: nowrap;
  }

  #bbpress-forums li.bbp-header ul.forum-titles > li.bbp-topic-freshness,
  #bbpress-forums ul.topic > li.bbp-topic-freshness {
    flex: 0 0 220px;
    text-align: right;
    white-space: nowrap;
  }
}
