/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #0d0d0d;
  --paper:      #f5f2eb;
  --cream:      #ede9df;
  --accent:     #c8401b;
  --accent2:    #2b5f8e;
  --muted:      #7a7468;
  --border:     #d6d0c4;
  --card-bg:    #ffffff;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 12px 48px rgba(0,0,0,0.16);
  --radius:     4px;
  --font-head:  'Playfair Display', Georgia, serif;
  --font-body:  'DM Sans', sans-serif;
  --font-mono:  'DM Mono', monospace;
}

html { font-size: 16px; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── ONBOARDING ────────────────────────────────────────────── */
#onboarding {
  min-height: 100vh;
  display: none;
  position: relative;
  overflow: hidden;
}
#onboarding.active { display: flex; align-items: center; justify-content: center; }

.onboard-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 50%, #e8dfc8 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 30%, #d4e5f0 0%, transparent 60%),
    var(--paper);
  z-index: 0;
}
.onboard-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23a09880' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.onboard-inner {
  position: relative;
  z-index: 1;
  max-width: 620px;
  width: 100%;
  padding: 48px 32px;
  text-align: center;
}

.onboard-logo {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.4em;
  color: var(--accent);
  margin-bottom: 32px;
}

.onboard-title {
  font-family: var(--font-head);
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 16px;
}
.onboard-title em {
  font-style: italic;
  color: var(--accent);
}

.onboard-sub {
  font-size: 1.05rem;
  color: var(--muted);
  margin-bottom: 40px;
  font-weight: 300;
}

/* Topic Grid */
.topic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 40px;
}

.topic-chip {
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--card-bg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topic-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.topic-chip.liked {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.topic-chip.disliked {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
  opacity: 0.5;
}
.topic-chip .chip-icon { font-size: 1rem; }

/* Onboard actions */
.onboard-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.user-id-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
  max-width: 360px;
}
.user-id-row label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}
.user-id-row input {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
  flex: 1;
}

.btn-primary {
  padding: 14px 36px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 100px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) {
  background: #a83416;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(200,64,27,0.3);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── FEED HEADER ───────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,242,235,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
}

.header-left { display: flex; align-items: baseline; gap: 14px; }
.logo {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.tagline {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  font-weight: 300;
}
.header-right { display: flex; align-items: center; gap: 10px; }

.user-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 12px;
  color: var(--muted);
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--cream);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  color: var(--ink);
}
.btn-icon:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ── LAYOUT ────────────────────────────────────────────────── */
.feed-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  max-width: 1140px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.sidebar-divider { border-top: 1px solid var(--border); margin: 20px 0; }

.topic-pills { display: flex; flex-direction: column; gap: 6px; }
.topic-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  background: var(--cream);
  border: 1px solid var(--border);
}
.topic-pill .pill-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.topic-pill.disliked .pill-dot { background: var(--muted); }

.stats-block { display: flex; flex-direction: column; gap: 8px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}
.stat-label { color: var(--muted); }
.stat-val { font-family: var(--font-mono); font-weight: 500; font-size: 0.85rem; }

.event-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.event-entry {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--muted);
  padding: 3px 0;
  border-bottom: 1px solid var(--cream);
  animation: slideIn 0.3s ease;
}
.event-entry .ev-type { color: var(--accent2); font-weight: 500; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── FEED MAIN ─────────────────────────────────────────────── */
.feed-main { padding: 32px 36px; }
.feed-toolbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
}
.feed-heading {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ink);
}
.post-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Feed grid */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ── NEWS CARD ─────────────────────────────────────────────── */
.news-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  animation: cardIn 0.4s ease both;
  position: relative;
}
.news-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Rank badge */
.card-rank {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 26px;
  height: 26px;
  background: var(--ink);
  color: white;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.news-card:nth-child(1) .card-rank { background: var(--accent); }

.card-topic-bar {
  height: 3px;
  background: var(--accent);
}

.card-body { padding: 18px 18px 14px; flex: 1; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.card-topic-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.card-time {
  font-size: 0.7rem;
  color: var(--muted);
}
.card-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border); }

.card-title {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 8px;
}
.card-excerpt {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Score bar */
.card-score-row {
  padding: 0 18px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-bar-track {
  flex: 1;
  height: 3px;
  background: var(--cream);
  border-radius: 100px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 100px;
  transition: width 0.6s ease;
}
.score-val {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Card actions */
.card-actions {
  border-top: 1px solid var(--cream);
  padding: 10px 18px;
  display: flex;
  gap: 4px;
}
.action-btn {
  flex: 1;
  padding: 6px 4px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--muted);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-body);
}
.action-btn:hover { background: var(--cream); color: var(--ink); }
.action-btn.active-like { color: var(--accent); background: #fef0ec; }
.action-btn.active-skip { color: var(--muted); opacity: 0.5; }

/* ── LOADING / EMPTY ───────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--muted);
}

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,13,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--card-bg);
  border-radius: 8px;
  max-width: 680px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 40px;
  position: relative;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--cream);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--accent); color: white; border-color: var(--accent); }

.modal-topic { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.modal-title { font-family: var(--font-head); font-size: 1.8rem; font-weight: 700; line-height: 1.25; margin-bottom: 16px; }
.modal-body { font-size: 0.95rem; line-height: 1.75; color: #3a3630; }
.modal-score-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.modal-score-title { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.bd-topic { width: 90px; color: var(--ink); font-weight: 500; text-transform: capitalize; }
.bd-bar { flex: 1; height: 4px; background: var(--cream); border-radius: 100px; overflow: hidden; }
.bd-fill { height: 100%; background: var(--accent2); border-radius: 100px; }
.bd-val { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); width: 36px; text-align: right; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .feed-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .feed-main { padding: 20px 16px; }
  .feed-grid { grid-template-columns: 1fr; }
  .site-header { padding: 0 16px; }
  .tagline { display: none; }
}
