/* =============================================================================
   Free Flow Moments — Public Stylesheet
   Mobile-first, scoped to .ffm-* classes. Uses CSS custom properties.
   ============================================================================= */

:root {
  --ffm-primary:        #4f46e5;
  --ffm-primary-dark:   #4338ca;
  --ffm-accent:         #f59e0b;
  --ffm-text:           #111827;
  --ffm-text-muted:     #6b7280;
  --ffm-bg:             #f9fafb;
  --ffm-card-bg:        #ffffff;
  --ffm-border:         #e5e7eb;
  --ffm-radius:         12px;
  --ffm-radius-sm:      6px;
  --ffm-shadow:         0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --ffm-shadow-md:      0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --ffm-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ffm-transition:     .15s ease;
}

/* ─── Reset / Scope ─────────────────────────────────────────────────────────── */
.ffm-app-root,
.ffm-app-root * {
  box-sizing: border-box;
}

.ffm-app-root {
  font-family: var(--ffm-font);
  color: var(--ffm-text);
  background: var(--ffm-bg);
  min-height: 40vh;
}

/* ─── Loading / Notice ──────────────────────────────────────────────────────── */
.ffm-notice {
  padding: 1rem;
  text-align: center;
  color: var(--ffm-text-muted);
}

.ffm-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.ffm-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ffm-border);
  border-top-color: var(--ffm-primary);
  border-radius: 50%;
  animation: ffm-spin .7s linear infinite;
}

@keyframes ffm-spin { to { transform: rotate(360deg); } }

/* ─── Feed / Post Cards ─────────────────────────────────────────────────────── */
.ffm-feed {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem 0;
}

.ffm-post-card {
  background: var(--ffm-card-bg);
  border-radius: var(--ffm-radius);
  box-shadow: var(--ffm-shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.ffm-post-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
}

.ffm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ffm-border);
  flex-shrink: 0;
}

.ffm-author-name {
  font-weight: 600;
  font-size: .9rem;
}

.ffm-post-time {
  font-size: .75rem;
  color: var(--ffm-text-muted);
  margin-left: auto;
}

/* Media */
.ffm-media-wrap {
  position: relative;
  background: #000;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.ffm-media-wrap img,
.ffm-media-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Carousel indicators */
.ffm-carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.ffm-carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
}

.ffm-carousel-dot.active {
  background: #fff;
}

/* Actions bar */
.ffm-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
}

.ffm-btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: .35rem;
  border-radius: var(--ffm-radius-sm);
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--ffm-text-muted);
  transition: color var(--ffm-transition), background var(--ffm-transition);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.ffm-btn-icon:hover { color: var(--ffm-primary); background: #f0eeff; }
.ffm-btn-icon.active { color: var(--ffm-primary); }
.ffm-btn-icon svg { width: 20px; height: 20px; }

.ffm-save-btn { margin-left: auto; }

/* Caption */
.ffm-caption {
  padding: .25rem 1rem .5rem;
  font-size: .9rem;
  line-height: 1.5;
}

.ffm-caption strong { font-weight: 600; }

/* Reaction counts */
.ffm-counts {
  padding: 0 1rem .25rem;
  font-size: .8rem;
  color: var(--ffm-text-muted);
}

/* Comments preview */
.ffm-comment-preview {
  padding: .25rem 1rem .75rem;
  font-size: .85rem;
}

/* ─── Profile Grid ───────────────────────────────────────────────────────────── */
.ffm-profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
  background: var(--ffm-card-bg);
  border-radius: var(--ffm-radius);
  box-shadow: var(--ffm-shadow);
  margin-bottom: 1rem;
}

.ffm-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ffm-border);
}

.ffm-profile-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 .25rem;
}

.ffm-profile-bio {
  font-size: .85rem;
  color: var(--ffm-text-muted);
  margin: 0 0 .5rem;
}

.ffm-profile-stats {
  display: flex;
  gap: 1.5rem;
  font-size: .8rem;
}

.ffm-profile-stat strong { font-weight: 700; font-size: 1rem; }

.ffm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.ffm-grid-item {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--ffm-border);
  cursor: pointer;
}

.ffm-grid-item img,
.ffm-grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity var(--ffm-transition);
}

.ffm-grid-item:hover img,
.ffm-grid-item:hover video { opacity: .85; }

/* ─── Upload Form ────────────────────────────────────────────────────────────── */
.ffm-upload-form {
  max-width: 540px;
  margin: 0 auto;
  background: var(--ffm-card-bg);
  border-radius: var(--ffm-radius);
  box-shadow: var(--ffm-shadow);
  padding: 1.5rem;
}

.ffm-upload-form h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.ffm-drop-zone {
  border: 2px dashed var(--ffm-border);
  border-radius: var(--ffm-radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ffm-transition), background var(--ffm-transition);
  color: var(--ffm-text-muted);
  font-size: .9rem;
}

.ffm-drop-zone:hover,
.ffm-drop-zone.dragover { border-color: var(--ffm-primary); background: #f0eeff; }

.ffm-drop-zone input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ffm-progress {
  height: 4px;
  background: var(--ffm-border);
  border-radius: 2px;
  overflow: hidden;
  margin: .75rem 0;
}

.ffm-progress-bar {
  height: 100%;
  background: var(--ffm-primary);
  width: 0;
  transition: width .3s ease;
}

.ffm-field {
  margin-bottom: 1rem;
}

.ffm-field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .35rem;
}

.ffm-field textarea,
.ffm-field select,
.ffm-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--ffm-border);
  border-radius: var(--ffm-radius-sm);
  padding: .55rem .75rem;
  font-size: .9rem;
  font-family: var(--ffm-font);
  background: var(--ffm-bg);
  color: var(--ffm-text);
  transition: border-color var(--ffm-transition);
}

.ffm-field textarea:focus,
.ffm-field select:focus,
.ffm-field input:focus {
  outline: none;
  border-color: var(--ffm-primary);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.ffm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .6rem 1.25rem;
  border-radius: var(--ffm-radius-sm);
  font-size: .9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--ffm-transition), opacity var(--ffm-transition);
  min-height: 44px;
}

.ffm-btn-primary { background: var(--ffm-primary); color: #fff; }
.ffm-btn-primary:hover { background: var(--ffm-primary-dark); }
.ffm-btn-secondary { background: var(--ffm-border); color: var(--ffm-text); }
.ffm-btn-secondary:hover { background: #d1d5db; }
.ffm-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ─── Ministry surfaces ──────────────────────────────────────────────────────── */
.ffm-ministry-header {
  text-align: center;
  padding: 1.5rem 1rem .75rem;
}

.ffm-ministry-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ffm-primary);
  margin: 0 0 .25rem;
}

.ffm-ministry-header p {
  color: var(--ffm-text-muted);
  font-size: .9rem;
  margin: 0;
}

/* ─── Notification badge ─────────────────────────────────────────────────────── */
.ffm-notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  line-height: 1;
}

/* ─── Reaction pills ─────────────────────────────────────────────────────────── */
.ffm-reaction-picker {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  padding: .5rem 1rem;
}

.ffm-reaction-btn {
  background: var(--ffm-bg);
  border: 1px solid var(--ffm-border);
  border-radius: 999px;
  padding: .3rem .75rem;
  font-size: .85rem;
  cursor: pointer;
  transition: border-color var(--ffm-transition), background var(--ffm-transition);
  min-height: 36px;
}

.ffm-reaction-btn:hover { border-color: var(--ffm-primary); background: #f0eeff; }
.ffm-reaction-btn.active { border-color: var(--ffm-primary); background: #e0e7ff; font-weight: 700; }

/* ─── Load more / end state ─────────────────────────────────────────────────── */
.ffm-load-more {
  text-align: center;
  padding: 1.5rem;
}

.ffm-end-of-feed {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ffm-text-muted);
  font-size: .85rem;
}

/* ─── Lightbox ───────────────────────────────────────────────────────────────── */
.ffm-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ffm-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.ffm-lightbox-media {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ffm-profile-header { flex-direction: column; text-align: center; }
  .ffm-profile-stats  { justify-content: center; }
}
