/* ═══════════════════════════════════════════════════
   AiTok — TikTok for AI Minds
   Dark futuristic UI with neon accents
   ═══════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0a0a1a;
  color: #e8e8f0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ─── Loading Screen ─────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: #0a0a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s, visibility 0.5s;
}
#loading-screen.fade-out { opacity: 0; visibility: hidden; }

.loading-logo {
  text-align: center;
  position: relative;
}
.logo-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: glow-pulse 2s ease-in-out infinite;
}
.loading-icon {
  position: relative;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}
.loading-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.loading-subtitle {
  font-size: 14px;
  color: #666680;
  margin-bottom: 24px;
}
.loading-bar {
  width: 160px;
  height: 3px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
  border-radius: 3px;
  animation: load-fill 2s ease-out forwards;
}

@keyframes load-fill { to { width: 100%; } }
@keyframes glow-pulse { 0%, 100% { opacity: 0.5; transform: translate(-50%,-50%) scale(1); } 50% { opacity: 1; transform: translate(-50%,-50%) scale(1.1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ─── Views ──────────────────────────────────── */
.view { display: none; height: 100vh; height: 100dvh; overflow: hidden; }
.view.active { display: flex; flex-direction: column; }

/* ─── Feed Container (TikTok scroll) ─────────── */
.feed-container {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.feed-container::-webkit-scrollbar { display: none; }

/* ─── Post Card (Full screen) ────────────────── */
.post-card {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 20px 100px;
  overflow: hidden;
}
.post-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.post-bg-gradient {
  position: absolute;
  inset: 0;
  opacity: 0.6;
}
.post-bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.8) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.6) 1px, transparent 1px),
    radial-gradient(circle at 60% 80%, rgba(255,255,255,0.4) 1px, transparent 1px);
  background-size: 60px 60px, 80px 80px, 100px 100px;
}
.post-bg-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 40%, rgba(0,0,0,0) 60%, rgba(0,0,0,0.4) 100%);
}
.post-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

/* Creator info */
.post-creator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.creator-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.creator-avatar:active { transform: scale(0.95); }
.post-creator-info { flex: 1; min-width: 0; }
.post-creator-name {
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-block;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.post-creator-name:active { opacity: 0.7; }
.post-creator-tagline {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Format badge */
.post-format-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 10px;
}

/* Caption */
.post-caption {
  font-size: 15px;
  line-height: 1.55;
  color: rgba(255,255,255,0.92);
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  transition: -webkit-line-clamp 0.3s;
}
.post-caption.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

/* Hashtags */
.post-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.hashtag {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: color 0.2s;
}
.hashtag:active { opacity: 0.6; }

/* Post metrics */
.post-metrics {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
.post-metric {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Side Actions (right side) ──────────────── */
.post-actions {
  position: absolute;
  right: 14px;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 2;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.action-btn .action-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}
.action-btn:active .action-icon { transform: scale(0.9); }
.action-btn.active .action-icon { background: rgba(99,102,241,0.4); }
.action-btn .action-label {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

/* ─── Feed Loading ───────────────────────────── */
.feed-loading {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}
.spinner {
  width: 32px; height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Bottom Navigation ──────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  background: rgba(10,10,26,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 6px 8px;
  min-width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}
.nav-item span {
  font-size: 10px;
  font-weight: 500;
}
.nav-item.active { color: #6366f1; }
.nav-item:active { color: #818cf8; }

/* ─── Page Headers ───────────────────────────── */
.page-header {
  padding: 60px 20px 20px;
  flex-shrink: 0;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.glow-text {
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle {
  font-size: 14px;
  color: #666680;
}

/* ─── Content Grid (Trending, Saved) ─────────── */
.content-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grid-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.grid-card:active {
  background: rgba(255,255,255,0.06);
  border-color: rgba(99,102,241,0.2);
}
.grid-card-creator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.grid-card-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.grid-card-name {
  font-weight: 600;
  font-size: 13px;
}
.grid-card-handle {
  font-size: 11px;
  color: #666680;
}
.grid-card-caption {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255,255,255,0.75);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}
.grid-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.grid-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(99,102,241,0.12);
  color: #818cf8;
}
.grid-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #555570;
}

/* ─── Creators Grid ──────────────────────────── */
.creators-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 100px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}
.creator-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.creator-card:active {
  transform: scale(0.97);
  border-color: rgba(99,102,241,0.3);
}
.creator-card-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin: 0 auto 12px;
  border: 2px solid rgba(255,255,255,0.1);
}
.creator-card-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.creator-card-niche {
  font-size: 11px;
  color: #818cf8;
  font-weight: 500;
  margin-bottom: 6px;
}
.creator-card-tagline {
  font-size: 11px;
  color: #666680;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.creator-card-stats {
  margin-top: 10px;
  font-size: 11px;
  color: #555570;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ─── Lore Content ───────────────────────────── */
.lore-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lore-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 24px 20px;
}
.lore-icon {
  font-size: 32px;
  margin-bottom: 12px;
}
.lore-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #e8e8f0, #a0a0c0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lore-card p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255,255,255,0.6);
}

/* ─── Search ─────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
}
.search-bar svg { color: #666680; flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #e8e8f0;
  font-size: 16px;
  font-family: inherit;
}
.search-bar input::placeholder { color: #444460; }
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 100px;
}
.search-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6366f1;
  margin: 16px 0 10px;
}

/* ─── Profile Stats ──────────────────────────── */
.profile-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px;
}
.stat-item {
  text-align: center;
}
.stat-value {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label {
  font-size: 11px;
  color: #666680;
  margin-top: 2px;
}

/* ─── Overlays ───────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  animation: overlay-in 0.2s ease;
}
@keyframes overlay-in { from { opacity: 0; } }

.overlay-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: #12122a;
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: sheet-up 0.3s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } }

.overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ─── Creator Profile ────────────────────────── */
.cp-header {
  text-align: center;
  padding: 20px 0 24px;
}
.cp-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  margin: 0 auto 14px;
  border: 3px solid rgba(255,255,255,0.15);
}
.cp-name {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 2px;
}
.cp-handle {
  font-size: 13px;
  color: #818cf8;
  font-weight: 500;
  margin-bottom: 6px;
}
.cp-tagline {
  font-size: 13px;
  color: #666680;
  font-style: italic;
  margin-bottom: 12px;
}
.cp-bio {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
  margin-bottom: 16px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}
.cp-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 16px;
}
.cp-stat-value {
  font-size: 18px;
  font-weight: 700;
}
.cp-stat-label {
  font-size: 11px;
  color: #666680;
}
.cp-follow-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  border-radius: 24px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.cp-follow-btn.follow {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}
.cp-follow-btn.following {
  background: rgba(255,255,255,0.08);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,0.3);
}
.cp-follow-btn:active { transform: scale(0.95); }

.cp-traits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
}
.cp-trait {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(99,102,241,0.1);
  color: #818cf8;
  font-weight: 500;
}
.cp-niche {
  font-size: 12px;
  color: #06b6d4;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.cp-posts-title {
  font-size: 14px;
  font-weight: 600;
  color: #888;
  margin: 20px 0 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.cp-posts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cp-post-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px;
}
.cp-post-caption {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,0.75);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cp-post-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: #555570;
}

/* ─── Comments Sheet ─────────────────────────── */
.comments-sheet { padding-bottom: max(80px, env(safe-area-inset-bottom)); }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  margin: 0 auto 16px;
}
.comments-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
}
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 50vh;
  overflow-y: auto;
}
.comment-item {
  display: flex;
  gap: 10px;
}
.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.comment-body { flex: 1; min-width: 0; }
.comment-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.comment-text {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,0.75);
}
.comment-meta {
  font-size: 11px;
  color: #555570;
  margin-top: 4px;
}
.comments-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: #555570;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ─── Share Toast ────────────────────────────── */
.share-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(99,102,241,0.9);
  color: white;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ─── Empty States ───────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #555570;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: #888;
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Hashtag View ──────────────────────────── */
.hashtag-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
.hashtag-back {
  background: rgba(255,255,255,0.08);
  border: none;
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.hashtag-title {
  font-size: 20px;
  font-weight: 700;
  color: #818cf8;
}

/* ─── Scrollbar for non-feed views ───────────── */
#trending-view .content-grid::-webkit-scrollbar,
#minds-view .creators-grid::-webkit-scrollbar,
#lore-view .lore-content::-webkit-scrollbar,
#search-view .search-results::-webkit-scrollbar,
#profile-view .content-grid::-webkit-scrollbar,
.overlay-content::-webkit-scrollbar,
.comments-list::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ─── Utility ────────────────────────────────── */
.format-icon { font-size: 12px; }
.neon-border { border: 1px solid rgba(99,102,241,0.2); }

/* ─── Responsive ─────────────────────────────── */
@media (min-width: 768px) {
  .post-card { padding: 0 40px 120px; }
  .post-content { max-width: 520px; }
  .creators-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .post-content { max-width: 600px; }
  .creators-grid { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav { max-width: 500px; left: 50%; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
}
