/* RainbowSpace - Design system Heartstopper-inspired */
:root {
  --font-display: 'Quicksand', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-full: 999px;
  --shadow-soft: 0 8px 32px rgba(100, 80, 150, 0.12);
  --shadow-card: 0 4px 24px rgba(80, 60, 120, 0.1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; }

a { color: inherit; text-decoration: none; transition: color var(--transition); }
img { max-width: 100%; display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, #ff6b9d, #c44dff, #5eb3ff);
  color: #fff;
  box-shadow: 0 4px 20px rgba(196, 77, 255, 0.35);
}
.btn-ghost {
  background: transparent;
  border-color: currentColor;
  opacity: 0.85;
}
.btn-block { width: 100%; }
.btn-lg { padding: 0.9rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.btn-danger { background: #ff5a7a; color: #fff; border: none; }

/* Layout */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }
.app-main { flex: 1; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; width: 100%; }

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  background: var(--bg-nav);
}
.navbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.navbar-search-wrap {
  flex: 1; min-width: 200px; max-width: 420px;
  position: relative;
}
.navbar-search-bar {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.35rem 1rem;
}
.navbar-search-bar:focus-within {
  border-color: var(--accent-purple, #9b6bff);
  box-shadow: 0 0 0 2px rgba(155, 107, 255, 0.15);
}
.navbar-search-bar input {
  flex: 1; border: none; background: transparent;
  font-size: 0.95rem; outline: none; min-width: 0;
  font-family: inherit;
}
.navbar-search-icon { opacity: 0.55; }
.navbar-search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft, 0 8px 32px rgba(80, 60, 120, 0.2));
  max-height: 380px; overflow-y: auto;
  z-index: 200;
}
.navbar-search-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.navbar-search-item:last-child { border-bottom: none; }
.navbar-search-user {
  display: flex; align-items: center; gap: 0.65rem;
  text-decoration: none; color: inherit; flex: 1; min-width: 0;
}
.navbar-search-user strong { display: block; font-size: 0.95rem; }
.navbar-search-user span { font-size: 0.8rem; opacity: 0.65; }
.navbar-search-actions { flex-shrink: 0; }
.navbar-search-loading, .navbar-search-empty {
  padding: 1rem; text-align: center; font-size: 0.9rem; opacity: 0.7;
}
.navbar-brand {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
}
.brand-icon { font-size: 1.4rem; }
.nav-links { display: flex; align-items: center; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.nav-links a:hover { opacity: 0.8; }
.nav-avatar img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent-pink); }
.nav-toggle, .theme-toggle {
  display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer;
  padding: 0.4rem;
}
.theme-toggle { display: block; margin-left: 0.5rem; }

/* Cards */
.card, .post-card, .composer-card, .auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }

/* Avatar */
.avatar { border-radius: 50%; object-fit: cover; background: var(--bg-muted); }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-xl { width: 120px; height: 120px; border: 4px solid var(--bg-card); }

/* Feed */
.feed-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; }
.feed-sidebar { position: sticky; top: 80px; height: fit-content; }
.sidebar-card { background: var(--bg-card); border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.trend-list { list-style: none; }
.trend-list li { display: flex; justify-content: space-between; padding: 0.35rem 0; }
.trend-list a { color: var(--accent-purple); font-weight: 600; }
.sidebar-link { display: block; padding: 0.4rem 0; }

.composer-form textarea {
  width: 100%; border: none; background: var(--bg-muted);
  border-radius: var(--radius-md); padding: 1rem; resize: vertical;
  font-family: inherit; font-size: 1rem; color: var(--text);
}
.composer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; }
.file-label { cursor: pointer; font-size: 1.2rem; }
.file-label input { display: none; }

.post-header { margin-bottom: 0.75rem; }
.post-author { display: flex; gap: 0.75rem; align-items: center; }
.post-author time { display: block; font-size: 0.8rem; opacity: 0.7; }
.pronouns { font-size: 0.8rem; opacity: 0.75; margin-left: 0.35rem; }
.post-image { border-radius: var(--radius-md); margin-top: 0.75rem; max-height: 400px; width: 100%; object-fit: cover; }
.post-actions { display: flex; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.action-btn { background: none; border: none; cursor: pointer; font-size: 0.95rem; padding: 0.4rem 0.75rem; border-radius: var(--radius-full); transition: background var(--transition); color: var(--text); }
.action-btn:hover, .action-btn.is-active { background: var(--bg-muted); }
.inline-form { display: inline; }

/* Forms */
.form label { display: block; font-weight: 600; margin: 0.75rem 0 0.35rem; font-size: 0.9rem; }
.form input, .form textarea, .form select {
  width: 100%; padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 1rem;
  background: var(--bg-input); color: var(--text);
  transition: border-color var(--transition);
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent-purple); }

/* Auth */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: 1rem; text-align: center; }
.auth-links { text-align: center; margin-top: 1rem; font-size: 0.9rem; }
.auth-links a { color: var(--accent-purple); font-weight: 600; }

/* Profile */
.profile-header {
  text-align: center; padding: 3rem 1rem 2rem;
  background: linear-gradient(180deg, var(--gradient-hero), transparent);
  background-size: cover; background-position: center;
  border-radius: var(--radius-lg); margin-bottom: 1.5rem;
}
.profile-avatar { margin: 0 auto 1rem; }
.profile-meta { opacity: 0.8; font-size: 0.9rem; }
.profile-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.pronouns-badge {
  display: inline-block; background: var(--accent-pink-soft);
  padding: 0.2rem 0.75rem; border-radius: var(--radius-full);
  font-size: 0.85rem; margin-top: 0.5rem;
}

/* Flash */
.flash {
  max-width: 1200px; margin: 0.5rem auto; padding: 0.75rem 1rem;
  border-radius: var(--radius-sm); text-align: center; animation: slideDown 0.4s ease;
}
.flash-success { background: #d4f5e4; color: #1a6b42; }
.flash-error { background: #ffe0e8; color: #9b2346; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1rem; text-align: center;
  background: var(--bg-muted);
}
.footer-links { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; margin-top: 0.75rem; }

/* Misc */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.static-page { max-width: 720px; margin: 0 auto; }
.static-page h2 { margin-top: 1.5rem; }
.static-page .lead { font-size: 1.15rem; opacity: 0.9; }
.badge { display: inline-block; background: var(--accent-purple-soft); padding: 0.2rem 0.6rem; border-radius: var(--radius-full); font-size: 0.8rem; }
.meta { font-size: 0.85rem; opacity: 0.7; }
.empty-state { text-align: center; padding: 3rem; opacity: 0.7; }

/* Onboarding */
.onboarding-page { display: flex; justify-content: center; padding: 2rem 0; }
.onboarding-card { max-width: 480px; width: 100%; text-align: center; }
.onboarding-card h1 { margin-bottom: 0.5rem; }

/* Chat */
.chat-page { display: flex; flex-direction: column; height: calc(100vh - 180px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-bubble { max-width: 75%; padding: 0.75rem 1rem; border-radius: var(--radius-md); background: var(--bg-muted); }
.chat-bubble.is-mine { align-self: flex-end; background: linear-gradient(135deg, #ff9ec5, #c9a0ff); color: #fff; }
.chat-form { display: flex; gap: 0.5rem; padding: 1rem; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }

/* Support */
.support-hero { margin-bottom: 1.5rem; }
.support-resources { list-style: none; margin-top: 1rem; }
.support-resources li { padding: 0.5rem 0; }

/* Ami·e·s */
.nav-friends { position: relative; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem;
  background: var(--accent-pink, #ff6b9d); color: #fff;
  border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 700;
  margin-left: 0.25rem; vertical-align: middle;
}
.friends-section { margin-bottom: 1.5rem; }
.friends-section h2 { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.friends-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.friend-request-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}
.friend-request-item:last-child { border-bottom: none; }
.friend-request-user { display: flex; gap: 0.75rem; align-items: center; text-decoration: none; color: inherit; flex: 1; }
.friend-request-actions { display: flex; gap: 0.5rem; }
.friends-grid {
  list-style: none; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem;
}
.friend-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 1rem; border-radius: var(--radius-md); background: var(--bg-muted);
  text-decoration: none; color: inherit; text-align: center;
}
.badge-friend { background: #d4f5e4; color: #1a6b42; }
.profile-locked { text-align: center; padding: 2rem; }
.profile-locked p { margin-bottom: 0.75rem; }
.feed-empty-friends { text-align: center; padding: 2rem; margin-bottom: 1rem; }
.feed-empty-friends h3 { margin-bottom: 0.5rem; }
.notif-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.notif-body time { display: block; font-size: 0.8rem; opacity: 0.7; margin-top: 0.25rem; }

.friends-page-header { flex-wrap: wrap; gap: 0.75rem; }
.friends-header-links { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.friends-search-card { margin-bottom: 1.5rem; }
.friends-search-form { margin: 0; }
.friends-search-bar {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-muted); border-radius: var(--radius-full);
  padding: 0.35rem 0.35rem 0.35rem 1rem; border: 1px solid var(--border);
}
.friends-search-bar:focus-within { border-color: var(--accent-purple, #9b6bff); box-shadow: 0 0 0 2px rgba(155, 107, 255, 0.2); }
.friends-search-icon { opacity: 0.6; flex-shrink: 0; }
.friends-search-bar input {
  flex: 1; border: none; background: transparent; padding: 0.5rem 0;
  font-size: 1rem; outline: none; min-width: 0;
}
.friends-search-hint { font-size: 0.85rem; opacity: 0.7; margin: 0.75rem 0 0; }
.friend-search-item { align-items: flex-start; }
.friend-search-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.friend-search-info p { margin: 0.25rem 0 0; font-size: 0.9rem; opacity: 0.85; }
.friend-search-username { font-size: 0.85rem; opacity: 0.7; }
.friend-search-meta { font-size: 0.8rem; opacity: 0.75; }
.friend-search-actions { flex-shrink: 0; }
.nav-search { font-size: 1.1rem; }

[x-cloak] { display: none !important; }

/* Animations */
.animate-in { animation: fadeInUp 0.6s ease forwards; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .feed-layout { grid-template-columns: 1fr; }
  .feed-sidebar { display: none; }
  .navbar-search-wrap { order: 3; flex: 1 1 100%; max-width: none; }
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-nav); flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border); }
  .nav-links.is-open { display: flex; }
}
