/* ════════════════════════════════════════════════════════════
   Fun Over Here — Global Design System
   Mobile-first • Facebook-inspired • Importance-based contrast
   ════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Design Tokens) ────────────────── */
:root {
  /* Brand colours */
  --foh-primary: #667eea;
  --foh-primary-dark: #5a6fd6;
  --foh-secondary: #764ba2;
  --foh-accent: #f093fb;

  /* Semantic colours */
  --foh-success: #38a169;
  --foh-warning: #ed8936;
  --foh-danger: #e53e3e;
  --foh-info: #3182ce;

  /* Neutral palette */
  --foh-bg: #f0f2f5;
  --foh-surface: #ffffff;
  --foh-surface-raised: #ffffff;
  --foh-border: #dddfe2;
  --foh-border-light: #e4e6eb;
  --foh-text-primary: #1c1e21;
  --foh-text-secondary: #65676b;
  --foh-text-muted: #8a8d91;

  /* Spacing scale */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 28px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows (Facebook-like subtle elevation) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ── Dark mode ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --foh-bg: #18191a;
    --foh-surface: #242526;
    --foh-surface-raised: #3a3b3c;
    --foh-border: #3e4042;
    --foh-border-light: #3e4042;
    --foh-text-primary: #e4e6eb;
    --foh-text-secondary: #b0b3b8;
    --foh-text-muted: #8a8d91;
  }
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  line-height: 1.34;
  color: var(--foh-text-primary);
  background: var(--foh-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--foh-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ════════════════════════════════════════════════════════════
   BUTTON SYSTEM — Importance-based contrast
   ════════════════════════════════════════════════════════════ */

/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  min-height: 44px; /* Touch target */
  padding: 0 16px;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── PRIMARY: Highest importance — solid bold fill ────────── */
.btn-primary {
  background: var(--foh-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--foh-primary-dark); box-shadow: var(--shadow-md); }

/* ── SECONDARY: Medium importance — lighter fill ──────────── */
.btn-secondary {
  background: rgba(102, 126, 234, 0.12);
  color: var(--foh-primary);
}
.btn-secondary:hover { background: rgba(102, 126, 234, 0.2); }

/* ── TERTIARY: Low importance — ghost/text only ───────────── */
.btn-tertiary {
  background: transparent;
  color: var(--foh-text-secondary);
}
.btn-tertiary:hover { background: var(--foh-border-light); }

/* ── DANGER: Destructive — red high contrast ──────────────── */
.btn-danger {
  background: var(--foh-danger);
  color: #fff;
}
.btn-danger:hover { background: #c53030; }

/* ── SUCCESS: Positive action — green ─────────────────────── */
.btn-success {
  background: var(--foh-success);
  color: #fff;
}
.btn-success:hover { background: #2f855a; }

/* ── Facebook connect ─────────────────────────────────────── */
.btn-facebook {
  background: #1877F2;
  color: #fff;
}
.btn-facebook:hover { background: #166fe5; }

/* ── Sizes ────────────────────────────────────────────────── */
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--text-sm); }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: var(--text-lg); }
.btn-block { display: flex; width: 100%; }
.btn-round { border-radius: var(--radius-full); }
.btn-icon { width: 44px; padding: 0; border-radius: var(--radius-full); }
.btn-icon.btn-sm { width: 36px; min-height: 36px; }

/* ════════════════════════════════════════════════════════════
   CARD SYSTEM — Facebook-style content cards
   ════════════════════════════════════════════════════════════ */

.card {
  background: var(--foh-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-md);
  overflow: hidden;
}

.card-header {
  padding: var(--sp-md);
  border-bottom: 1px solid var(--foh-border-light);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.card-body { padding: var(--sp-md); }
.card-footer {
  padding: var(--sp-sm) var(--sp-md);
  border-top: 1px solid var(--foh-border-light);
  display: flex;
  gap: var(--sp-sm);
}

/* ════════════════════════════════════════════════════════════
   CONTAINER / LAYOUT
   ════════════════════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--sp-md);
}

.container-wide {
  max-width: 960px;
}

/* ════════════════════════════════════════════════════════════
   AVATAR
   ════════════════════════════════════════════════════════════ */

.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--foh-border-light);
  flex-shrink: 0;
}

.avatar-xs { width: 28px; height: 28px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 80px; height: 80px; }
.avatar-xl { width: 128px; height: 128px; }

.avatar-ring {
  border: 3px solid var(--foh-primary);
  padding: 2px;
}

/* ════════════════════════════════════════════════════════════
   BADGES / TAGS
   ════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary { background: rgba(102, 126, 234, 0.12); color: var(--foh-primary); }
.badge-success { background: rgba(56, 161, 105, 0.12); color: var(--foh-success); }
.badge-danger { background: rgba(229, 62, 62, 0.12); color: var(--foh-danger); }
.badge-warning { background: rgba(237, 137, 54, 0.12); color: var(--foh-warning); }
.badge-muted { background: var(--foh-border-light); color: var(--foh-text-muted); }

.badge-verified {
  background: var(--foh-primary);
  color: #fff;
  font-size: var(--text-sm);
  padding: 2px 10px;
}

/* ════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════════════════════ */

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px; /* Prevent iOS zoom */
  font-family: var(--font-body);
  border: 1px solid var(--foh-border);
  border-radius: var(--radius-md);
  background: var(--foh-surface);
  color: var(--foh-text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--foh-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-input::placeholder { color: var(--foh-text-muted); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--foh-text-secondary);
  margin-bottom: 6px;
}

.form-group { margin-bottom: var(--sp-md); }
.form-hint { font-size: var(--text-xs); color: var(--foh-text-muted); margin-top: 4px; }

/* ════════════════════════════════════════════════════════════
   TABS (for profile sections)
   ════════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--foh-border-light);
  background: var(--foh-surface);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 14px 16px;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--foh-text-secondary);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
  min-width: max-content;
}

.tab:hover { background: var(--foh-border-light); }
.tab.active {
  color: var(--foh-primary);
  border-bottom-color: var(--foh-primary);
}

/* ════════════════════════════════════════════════════════════
   ALERT / TOAST
   ════════════════════════════════════════════════════════════ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: none;
  margin-bottom: var(--sp-md);
}
.alert.show { display: flex; align-items: center; gap: 8px; }
.alert-error { background: rgba(229, 62, 62, 0.08); color: var(--foh-danger); border: 1px solid rgba(229, 62, 62, 0.2); }
.alert-success { background: rgba(56, 161, 105, 0.08); color: var(--foh-success); border: 1px solid rgba(56, 161, 105, 0.2); }
.alert-info { background: rgba(49, 130, 206, 0.08); color: var(--foh-info); border: 1px solid rgba(49, 130, 206, 0.2); }
.alert-warning { background: rgba(237, 137, 54, 0.08); color: var(--foh-warning); border: 1px solid rgba(237, 137, 54, 0.2); }

/* ════════════════════════════════════════════════════════════
   JAIL BANNER
   ════════════════════════════════════════════════════════════ */

.jail-banner {
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  color: #fff;
  padding: var(--sp-md);
  text-align: center;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 100;
}

.jail-banner a { color: #fbd38d; }

/* ════════════════════════════════════════════════════════════
   SKELETON LOADING
   ════════════════════════════════════════════════════════════ */

.skeleton {
  background: linear-gradient(90deg, var(--foh-border-light) 25%, #f5f5f5 50%, var(--foh-border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ════════════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-muted { color: var(--foh-text-muted); }
.text-secondary { color: var(--foh-text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-bold { font-weight: 700; }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mb-sm { margin-bottom: var(--sp-sm); }
.mb-md { margin-bottom: var(--sp-md); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Safe area for notch devices ──────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ── Prevent pull-to-refresh interference on mobile ──────── */
body {
  overscroll-behavior-y: contain;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
