/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0c1222;
  --bg-soft: #151e32;
  --card: #1a2438;
  --border: #2a3650;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --accent: #38bdf8;
  --need: #f59e0b;
  --offer: #22c55e;
  --resolved: #64748b;
  --radius: 12px;
  --danger: #ef4444;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ===== Top bar ===== */
.topbar {
  background: #0a0f1a;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
}
.back-link { color: var(--text-muted); font-weight: 500; }
.back-link:hover { color: var(--primary); text-decoration: none; }
.topbar-label { color: var(--text-muted); opacity: 0.8; }

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 18, 34, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { font-size: 1.5rem; }
.logo strong {
  display: block;
  font-family: 'Oswald', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tagline { font-size: 0.72rem; color: var(--text-muted); }
.nav { display: flex; align-items: center; gap: 1.25rem; }
.nav a { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.nav a:hover { color: var(--text); text-decoration: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.15rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #0c1222; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-soft); border-color: var(--text-muted); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* ===== Hero ===== */
.hero {
  padding: 4rem 0 3.5rem;
  text-align: center;
  background: linear-gradient(165deg, #1a2438 0%, var(--bg) 70%);
}
.hero-eyebrow {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.hero h1 {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 1.1rem;
}
.hero-text {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.65;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Categories ===== */
.categories { padding: 3rem 0 2.5rem; }
.categories h2, .how h2, .needs h2, .post-section h2 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.55rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: 0.02em;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
}
.category-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s;
}
.category-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.cat-icon { font-size: 1.9rem; margin-bottom: 0.65rem; }
.category-card h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.category-card p { font-size: 0.875rem; color: var(--text-muted); }

/* ===== How it works ===== */
.how { padding: 3rem 0; background: var(--bg-soft); }
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.5rem;
}
.step { text-align: center; padding: 0.75rem; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--primary);
  color: #0c1222;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.7rem;
}
.step h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.step p { font-size: 0.9rem; color: var(--text-muted); }

/* ===== The Board ===== */
.needs { padding: 3.5rem 0; }
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.section-header h2 { margin-bottom: 0; text-align: left; }
.filter-btns { display: flex; gap: 0.4rem; }
.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #0c1222;
  font-weight: 600;
}

.loading, .empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
}
.error-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.posts-list { display: flex; flex-direction: column; gap: 1.1rem; }

/* Post card */
.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  transition: border-color 0.15s;
}
.post-card.resolved { opacity: 0.65; }
.post-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-bottom: 0.55rem;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-need { background: rgba(245, 158, 11, 0.18); color: var(--need); }
.badge-offer { background: rgba(34, 197, 94, 0.18); color: var(--offer); }
.badge-cat { background: rgba(56, 189, 248, 0.12); color: var(--accent); }
.badge-resolved { background: rgba(100, 116, 139, 0.25); color: var(--resolved); }
.post-meta { font-size: 0.8rem; color: var(--text-muted); }
.post-desc { font-size: 1.02rem; line-height: 1.55; margin-bottom: 0.5rem; }
.post-contact { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.post-contact strong { color: var(--text); }

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Replies */
.replies {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.reply {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
}
.reply-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.reply-message { line-height: 1.5; }

.reply-form {
  margin-top: 0.75rem;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}
.reply-form.open { display: flex; }
.reply-form input,
.reply-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.reply-form textarea { resize: vertical; min-height: 70px; }
.reply-form input:focus,
.reply-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.reply-form-actions { display: flex; gap: 0.5rem; }

/* ===== Post form section ===== */
.post-section { padding: 3.5rem 0 4rem; background: var(--bg-soft); }
.form-intro {
  text-align: center;
  color: var(--text-muted);
  max-width: 500px;
  margin: -0.6rem auto 1.75rem;
  font-size: 0.95rem;
}
.post-form {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.optional { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 100px; }
.post-form .btn { margin-top: 0.4rem; align-self: flex-start; }
.form-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* ===== Footer ===== */
.footer {
  padding: 2.25rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.footer .small { font-size: 0.82rem; margin-top: 0.4rem; }
.footer a { color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .nav a:not(.btn) { display: none; }
  .topbar-label { display: none; }
  .hero { padding: 3rem 0 2.5rem; }
  .form-row { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Secret box (after posting) ===== */
.secret-box {
  max-width: 540px;
  margin: 2rem auto 0;
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  text-align: center;
}
.secret-box h3 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 0.5rem;
}
.secret-code {
  font-family: monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  margin: 1rem 0;
  color: var(--primary);
}
.secret-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}
.modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-content h3 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 0.4rem;
}
.modal-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.modal-content label {
  margin-bottom: 1rem;
}
.manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.btn-danger {
  background: transparent;
  color: #f87171;
  border: 1.5px solid #7f1d1d;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}
#edit-form-wrap {
  margin-top: 0.5rem;
}
#edit-form-wrap hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
#edit-form-wrap h4 {
  margin-bottom: 0.75rem;
}
#edit-form-wrap label {
  margin-bottom: 0.85rem;
}
