/* =============================================================================
   SwimKeep Community — community.css
   Extends site-pages.css variables. All community-specific styles are
   namespaced under .comm-* to avoid collisions with site-pages.css.
============================================================================= */

[hidden] {
  display: none !important;
}

/* -----------------------------------------------------------------------------
   Premium badge (nav)
----------------------------------------------------------------------------- */
.comm-premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.2s ease;
}

.comm-premium-badge:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
}

.comm-nav-cta {
  background: var(--text);
  color: #fff;
}

.comm-nav-cta:hover,
.comm-nav-cta.is-active {
  background: #0f172a;
  color: #fff;
}

.comm-nav-hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.comm-nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}

.comm-nav-hamburger[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.comm-nav-hamburger[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}

.comm-nav-hamburger[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.comm-nav-mobile {
  display: none;
  padding: 10px 0 14px;
  border-top: 1px solid var(--line);
  flex-direction: column;
  gap: 8px;
}

.comm-nav-mobile[aria-hidden='false'] {
  display: flex;
}

.comm-nav-mobile-link,
.comm-nav-mobile-cta {
  text-decoration: none;
  font-weight: 600;
  border-radius: 12px;
  padding: 10px 12px;
}

.comm-nav-mobile-link {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.comm-nav-mobile-link.is-active {
  background: rgba(255, 255, 255, 0.92);
}

.comm-nav-mobile-cta {
  margin-top: 2px;
  text-align: center;
  color: #fff;
  background: var(--text);
}

@media (max-width: 980px) {
  .site-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: 8px 0;
  }

  .site-nav-links {
    display: none;
  }

  .comm-nav-hamburger {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .site-logo-mark {
    width: 40px;
    height: 40px;
  }

  .site-logo-wordmark {
    font-size: 1.05rem;
  }

  .site-logo-tagline {
    font-size: 0.64rem;
    letter-spacing: 0.06em;
  }
}

/* -----------------------------------------------------------------------------
   Hero
----------------------------------------------------------------------------- */
.comm-hero {
  padding: 56px 0 36px;
  text-align: center;
}

.comm-hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.comm-hero-title {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
}

.comm-hero-title-brand {
  color: var(--muted);
  font-weight: 700;
}

.comm-hero-subtitle {
  margin: 0;
  max-width: 560px;
  font-size: 1.06rem;
  color: var(--muted);
  line-height: 1.65;
}

.comm-db-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.comm-db-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.comm-db-status--connected {
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}

.comm-db-status--connected .comm-db-status-dot {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.16);
}

.comm-db-status--disconnected {
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}

.comm-db-status--disconnected .comm-db-status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.14);
}

.comm-hero-actions {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
.comm-hero-actions:not([hidden]) {
  display: flex;
}

.comm-hero-premium-note {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.comm-hero-premium-note:not([hidden]) {
  display: inline-flex;
}

.comm-hero-premium-note a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.comm-hero-premium-note a:hover {
  text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   Buttons
----------------------------------------------------------------------------- */
.comm-btn-primary,
.comm-btn-secondary,
.comm-btn-ghost,
.comm-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 0.94rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.comm-btn-primary:hover,
.comm-btn-secondary:hover,
.comm-btn-ghost:hover,
.comm-btn-danger:hover {
  transform: translateY(-1px);
}

.comm-btn-primary {
  background: var(--accent);
  color: #fff;
}

.comm-btn-primary:hover {
  background: var(--accent-deep);
}

.comm-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.comm-btn-secondary {
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line);
  color: var(--text);
}

.comm-btn-secondary:hover {
  background: #fff;
}

.comm-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.comm-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
}

.comm-btn-danger {
  background: #ef4444;
  color: #fff;
}

.comm-btn-danger:hover {
  background: #dc2626;
}

.comm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.comm-icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.comm-icon-btn--danger:hover {
  background: #fef2f2;
  color: #ef4444;
}

/* -----------------------------------------------------------------------------
   How It Works
----------------------------------------------------------------------------- */
.comm-how-section {
  padding: 8px 0 48px;
}

.comm-section-title {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.comm-how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.comm-how-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px);
  gap: 10px;
}

.comm-how-card--highlighted {
  background: rgba(255, 248, 220, 0.88);
  border-color: rgba(245, 158, 11, 0.28);
}

.comm-how-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  margin-bottom: 4px;
}

.comm-how-card--highlighted .comm-how-icon {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.comm-how-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.comm-how-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* -----------------------------------------------------------------------------
   Posts section
----------------------------------------------------------------------------- */
.comm-posts-section {
  padding-bottom: 64px;
}

/* Filter bar */
.comm-filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.comm-filter-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.comm-filter-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.comm-filter-select {
  appearance: none;
  padding: 8px 36px 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.comm-filter-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.comm-filter-chevron {
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: var(--muted);
}

/* Post grid */
.comm-posts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Post card */
.comm-post-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 22px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.comm-post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(20, 35, 62, 0.1);
  border-color: rgba(13, 103, 222, 0.22);
}

/* Full-width card when grid has only one item or is explicitly flagged */
.comm-post-card--wide,
.comm-posts-grid .comm-post-card:nth-child(n+3) {
  grid-column: span 2;
}

/* Override: if only 0–2 cards, keep them in columns */
.comm-posts-grid:has(.comm-post-card:nth-child(3)) .comm-post-card:first-child,
.comm-posts-grid:has(.comm-post-card:nth-child(3)) .comm-post-card:nth-child(2) {
  grid-column: span 1;
}

.comm-post-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-self: flex-start;
}

.comm-post-type-badge--question {
  background: var(--accent-soft);
  color: var(--accent);
}

.comm-post-type-badge--tip {
  background: rgba(16, 185, 129, 0.1);
  color: #065f46;
}

.comm-post-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.comm-post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.comm-post-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 600;
}

.comm-post-tag-muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.comm-post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.comm-post-replies {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.comm-post-expiry {
  font-size: 0.78rem;
  color: var(--muted);
}

.comm-post-expiry--soon {
  color: #b45309;
  font-weight: 600;
}

/* Archive row */
.comm-archive-row {
  text-align: center;
  margin-top: 32px;
}

.comm-archive-link {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.comm-archive-link:hover {
  text-decoration: underline;
}

/* Empty & error states */
.comm-empty-state,
.comm-error-state {
  display: none;
}

.comm-empty-state:not([hidden]),
.comm-error-state:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}

.comm-empty-state h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.comm-empty-state p,
.comm-error-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* Skeleton loading */
.comm-skeleton {
  border-radius: 20px;
  background: linear-gradient(90deg, rgba(20, 35, 62, 0.06) 25%, rgba(20, 35, 62, 0.1) 50%, rgba(20, 35, 62, 0.06) 75%);
  background-size: 200% 100%;
  animation: comm-shimmer 1.4s ease infinite;
}

.comm-skeleton--card {
  min-height: 140px;
}

.comm-skeleton--wide {
  grid-column: span 2;
  min-height: 110px;
}

@keyframes comm-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -----------------------------------------------------------------------------
   Modals
----------------------------------------------------------------------------- */
.comm-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(14, 21, 36, 0.52);
  backdrop-filter: blur(4px);
  animation: comm-fade-in 0.15s ease;
}

.comm-modal-backdrop:not([hidden]) {
  display: flex;
}

@keyframes comm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.comm-modal {
  width: min(600px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 24px 64px rgba(14, 21, 36, 0.18);
  animation: comm-slide-up 0.2s ease;
}

.comm-modal--wide {
  width: min(760px, 100%);
}

.comm-modal--sm {
  width: min(440px, 100%);
}

@keyframes comm-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.comm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  border-radius: 24px 24px 0 0;
}

.comm-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.comm-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.comm-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.comm-modal-close:hover {
  background: rgba(20, 35, 62, 0.07);
  color: var(--text);
}

.comm-modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.comm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* -----------------------------------------------------------------------------
   Form fields
----------------------------------------------------------------------------- */
.comm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comm-field-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.comm-field-optional {
  font-weight: 400;
  color: var(--muted);
}

.comm-field-required {
  color: #ef4444;
}

.comm-input,
.comm-textarea {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--page-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.comm-input:focus,
.comm-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 103, 222, 0.12);
}

.comm-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.comm-char-count {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  align-self: flex-end;
}

/* Post type toggle */
.comm-type-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.comm-type-option {
  display: flex;
  align-items: center;
}

.comm-type-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.comm-type-option span {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.comm-type-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Tags picker */
.comm-tags-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comm-tag-option {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.comm-tag-option:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.comm-tag-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Form error */
.comm-form-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 0.88rem;
}

/* Spinner */
@keyframes comm-spin {
  to { transform: rotate(360deg); }
}

.comm-spinner {
  display: none;
}

.comm-spinner:not([hidden]) {
  display: inline-block;
  animation: comm-spin 0.7s linear infinite;
}

/* -----------------------------------------------------------------------------
   Post detail (inside modal)
----------------------------------------------------------------------------- */
.comm-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.comm-detail-content {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comm-detail-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.comm-replies-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text);
}

.comm-reply {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.comm-reply-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.comm-reply-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comm-reply-accepted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #065f46;
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
  align-self: flex-start;
}

/* Reply form */
.comm-reply-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.comm-reply-form-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* -----------------------------------------------------------------------------
   Footer
----------------------------------------------------------------------------- */
.comm-footer {
  text-align: center;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}

.comm-footer-tagline {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

/* -----------------------------------------------------------------------------
   Responsive
----------------------------------------------------------------------------- */
@media (max-width: 700px) {
  .comm-how-grid {
    grid-template-columns: 1fr;
  }

  .comm-posts-grid {
    grid-template-columns: 1fr;
  }

  .comm-posts-grid .comm-post-card:nth-child(n+3) {
    grid-column: span 1;
  }

  .comm-posts-grid:has(.comm-post-card:nth-child(3)) .comm-post-card:first-child,
  .comm-posts-grid:has(.comm-post-card:nth-child(3)) .comm-post-card:nth-child(2) {
    grid-column: span 1;
  }

  .comm-hero-title {
    font-size: 2.2rem;
  }
}
