/* RedNote Curator — Mobile Web App Styles */
/* Mobile-first, card-based feed design */

:root {
  --red: #ff2442;
  --red-light: #ffe5e9;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #888888;
  --border: #e5e5e5;
  --green: #22c55e;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
}

/* --- Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
}

.header-score {
  font-size: 12px;
  color: var(--text-secondary);
}

.back-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--red);
  cursor: pointer;
  padding: 4px 8px;
}

/* --- Feed Container --- */
.feed-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: 80px; /* space for bottom nav */
}

/* --- States --- */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.state-message.hidden { display: none; }

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Card --- */
.note-card {
  background: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: relative;
}

/* Reviewed card: collapse after like/dislike */
.note-card.reviewed {
  pointer-events: none;
}

.card-reviewed-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: rgba(34, 197, 94, 0.85);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  z-index: 2;
  pointer-events: none;
}

.note-card.swiping-left {
  transform: translateX(-120%) rotate(-10deg);
  opacity: 0;
}

.note-card.swiping-right {
  transform: translateX(120%) rotate(10deg);
  opacity: 0;
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #f0f0f0;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, #ff2442, #ff6b81);
  color: white;
}

.card-score-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.card-score-badge.high { background: rgba(34, 197, 94, 0.7); }
.card-score-badge.medium { background: rgba(245, 158, 11, 0.7); }
.card-score-badge.low { background: rgba(239, 68, 68, 0.7); }

.card-explore-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(139, 92, 246, 0.7);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  backdrop-filter: blur(8px);
}

.card-body {
  padding: 12px 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.card-author {
  font-weight: 500;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.card-tag {
  font-size: 11px;
  background: var(--red-light);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.card-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* --- Card Inline Actions --- */
.card-actions {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 12px 14px;
  gap: 4px;
  border-top: 1px solid var(--border);
}

.card-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.card-action-btn:active {
  transform: scale(0.93);
}

.dislike-action { color: #ef4444; }
.dislike-action:active { background: #fee2e2; }

.like-action { color: var(--green); }
.like-action:active { background: #dcfce7; }

.link-action { color: #6366f1; }
.link-action:active { background: #e0e7ff; }

/* --- Bottom Nav --- */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
  padding-bottom: var(--safe-bottom);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  max-width: 500px;
  margin: 0 auto;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 8px 24px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
  color: var(--red);
}

.nav-icon {
  font-size: 22px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* --- Preferences Page --- */
.page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 20;
  overflow-y: auto;
  max-width: 500px;
  margin: 0 auto;
}

.page.hidden { display: none; }

.prefs-content {
  padding: 16px;
  padding-bottom: 80px;
}

.pref-group {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.pref-group-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--red);
}

.pref-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}

.pref-row:last-child { border-bottom: none; }

.pref-emoji {
  font-size: 18px;
  width: 28px;
  text-align: center;
}

.pref-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pref-bar-bg {
  width: 60px;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.pref-bar-fill {
  height: 100%;
  border-radius: 2px;
}

.pref-bar-fill.pos { background: var(--green); }
.pref-bar-fill.neg { background: #ef4444; }

.pref-weight-val {
  width: 42px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--red);
  color: #fff;
  width: 100%;
  max-width: 280px;
}

.btn-secondary {
  background: #f0f0f0;
  color: var(--text);
}

/* --- Login Form --- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}

.login-form {
  width: 100%;
  max-width: 320px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.login-form h2 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--red);
}

.error-msg {
  color: #ef4444;
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 100;
  animation: fadeInOut 2s ease forwards;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Detail Modal --- */
.detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-width: 500px;
  margin: 0 auto;
}

.detail-modal.hidden { display: none; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-image-wrapper {
  width: 100%;
  background: #f0f0f0;
}

.detail-image-wrapper img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 50vh;
}

.detail-image-placeholder-large {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: linear-gradient(135deg, #ff2442, #ff6b81);
  color: white;
}

.detail-body {
  padding: 16px;
}

.detail-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.5;
}

.detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.detail-tags .card-tag {
  font-size: 12px;
}

.detail-desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.detail-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

/* --- Image Gallery --- */
.image-gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #000;
}

.image-gallery::-webkit-scrollbar { display: none; }

.gallery-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-slide img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 50vh;
}

.gallery-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: linear-gradient(135deg, #ff2442, #ff6b81);
  color: white;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  background: rgba(0,0,0,0.5);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
}

.gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
}

.gallery-dot.active {
  background: #fff;
}

/* --- Video Player in Detail --- */
.detail-image-wrapper video {
  width: 100%;
  max-height: 50vh;
  background: #000;
  display: block;
}

/* --- Dark mode hint --- */
@media (prefers-color-scheme: dark) {
  /* Light mode only for now; dark mode can be added later */
}
