/* ==========================================================================
   PlanWorkouts Community & Q&A Forum — Ultra-Premium HD Design System
   ========================================================================== */

/* --- Atmosphere & Hero Layout --- */
.comm-hero {
  position: relative;
  background: 
    radial-gradient(circle at 85% -10%, rgba(255, 59, 47, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 10% 110%, rgba(255, 59, 47, 0.08) 0%, transparent 50%),
    var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 36px 32px;
  margin-bottom: 36px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}

.comm-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.6;
}

.comm-title-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
}

.comm-headline {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text-color, #ffffff);
  margin-bottom: 8px;
}

.comm-subhead {
  font-size: 1.05rem;
  color: var(--muted, #8a96a3);
  max-width: 640px;
  line-height: 1.5;
}

/* --- Community Stats Bar --- */
.comm-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  background: rgba(15, 20, 26, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.comm-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comm-stat-val {
  font-family: var(--font-mono, monospace);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--signal, #ff3b2f);
  letter-spacing: -0.02em;
}

.comm-stat-label {
  font-size: 0.78rem;
  color: var(--muted, #8a96a3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* --- Category Topic Grid Cards --- */
.comm-categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.comm-cat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
  background: var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease,
              box-shadow 0.25s ease;
}

.comm-cat-card:hover, .comm-cat-card.active {
  transform: translateY(-4px);
  border-color: var(--signal, #ff3b2f);
  box-shadow: 0 12px 28px -6px rgba(255, 59, 47, 0.15);
  background: var(--paper-elevated, #1c2430);
}

.comm-cat-card.active {
  border-color: var(--signal, #ff3b2f);
  background: rgba(255, 59, 47, 0.06);
}

.comm-cat-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 59, 47, 0.12);
  color: var(--signal, #ff3b2f);
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.comm-cat-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-color, #ffffff);
}

.comm-cat-desc {
  font-size: 0.8rem;
  color: var(--muted, #8a96a3);
  line-height: 1.4;
}

/* --- Search & Filter Controls --- */
.comm-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.comm-search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

.comm-search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-color, #ffffff);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comm-search-input:focus {
  border-color: var(--signal, #ff3b2f);
  box-shadow: 0 0 0 3px rgba(255, 59, 47, 0.15);
}

.comm-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted, #8a96a3);
  pointer-events: none;
}

.comm-filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.comm-pill {
  padding: 8px 14px;
  background: var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted, #8a96a3);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.comm-pill:hover, .comm-pill.active {
  background: var(--paper-elevated, #202833);
  color: #ffffff;
  border-color: var(--signal, #ff3b2f);
}

/* --- High-Definition Thread Cards --- */
.comm-thread-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 20px;
  align-items: flex-start;
  background: var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease,
              box-shadow 0.25s ease;
}

.comm-thread-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 59, 47, 0.4);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.4);
}

/* Upvote Component */
.comm-vote-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.comm-vote-box:hover {
  background: rgba(255, 59, 47, 0.12);
  border-color: rgba(255, 59, 47, 0.3);
}

.comm-vote-box.voted {
  background: rgba(255, 59, 47, 0.18);
  border-color: var(--signal, #ff3b2f);
}

.comm-vote-btn {
  background: none;
  border: none;
  color: var(--muted, #8a96a3);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}

.comm-vote-box:hover .comm-vote-btn,
.comm-vote-box.voted .comm-vote-btn {
  color: var(--signal, #ff3b2f);
  transform: scale(1.15);
}

.comm-vote-count {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-color, #ffffff);
}

/* Thread Main Details */
.comm-thread-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comm-thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.comm-avatar-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff3b2f, #ff7a00);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.comm-author-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--paper-raised-text, #ffffff);
}

.comm-author-role {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted, #8a96a3);
}

.comm-thread-title {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--text-color, #ffffff);
  cursor: pointer;
  transition: color 0.15s ease;
}

.comm-thread-title:hover {
  color: var(--signal, #ff3b2f);
}

.comm-thread-snippet {
  font-size: 0.92rem;
  color: var(--muted, #a0aec0);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.comm-thread-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--muted, #8a96a3);
  margin-top: 4px;
  flex-wrap: wrap;
}

/* Badges */
.comm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 59, 47, 0.1);
  color: var(--signal, #ff3b2f);
  border: 1px solid rgba(255, 59, 47, 0.25);
}

.comm-badge-accepted {
  background: rgba(46, 204, 113, 0.12);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.comm-answer-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  color: var(--muted, #8a96a3);
}

/* --- Contextual Q&A Widget on Exercise Pages --- */
.exercise-qa-widget {
  margin-top: 56px;
  padding: 36px 32px;
  background: radial-gradient(circle at 100% 0%, rgba(255, 59, 47, 0.08), transparent 60%), var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.35);
}

.qa-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.qa-ask-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--signal, #ff3b2f);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.qa-ask-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 59, 47, 0.35);
}

.qa-ask-form-wrapper {
  background: rgba(15, 20, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  animation: qaFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes qaFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.qa-input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--paper-elevated, #202833);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qa-input-field:focus {
  border-color: var(--signal, #ff3b2f);
  box-shadow: 0 0 0 3px rgba(255, 59, 47, 0.15);
}

.qa-textarea {
  min-height: 100px;
  resize: vertical;
}

/* --- Interactive Thread Detail Modal --- */
.comm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 14, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.comm-modal-card {
  position: relative;
  background: var(--paper-raised, #161c24);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.comm-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--muted, #8a96a3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.comm-modal-close:hover {
  background: var(--signal, #ff3b2f);
  color: #ffffff;
}

/* Answers in Modal */
.comm-answer-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 20px;
  margin-top: 14px;
}

.comm-answer-item.accepted {
  border-color: rgba(46, 204, 113, 0.4);
  background: rgba(46, 204, 113, 0.04);
}

/* --- Toast Feedback Container --- */
.comm-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--paper-elevated, #202833);
  border: 1px solid var(--signal, #ff3b2f);
  border-radius: 12px;
  padding: 14px 20px;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .comm-thread-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .comm-vote-box {
    flex-direction: row;
    justify-content: flex-start;
    padding: 6px 12px;
    width: fit-content;
  }
  .comm-hero {
    padding: 24px 18px;
  }
  .comm-modal-card {
    padding: 20px;
  }
}
