/* ═══════════════════════════════════════════════════════════════
   TLDR ARTICLES — Premium Dark-Mode CSS
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* Core palette */
  --bg:        #09090b;
  --bg-2:      #111114;
  --bg-3:      #18181c;
  --bg-4:      #1f1f26;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.12);

  /* Text */
  --text:      #f4f4f5;
  --text-2:    #a1a1aa;
  --text-3:    #71717a;

  /* Accent */
  --accent:      #a78bfa;
  --accent-dim:  rgba(167,139,250,0.15);
  --accent-glow: rgba(167,139,250,0.3);

  /* Category colours */
  --tech:    #38bdf8;
  --ai:      #a78bfa;
  --design:  #fb7185;

  --tech-dim:   rgba(56,189,248,0.12);
  --ai-dim:     rgba(167,139,250,0.12);
  --design-dim: rgba(251,113,133,0.12);

  /* Misc */
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);

  /* Heights */
  --topbar-h: 56px;
  --search-h: 52px;
  --strip-h:  48px;
  --stats-h:  32px;
  --nav-h:    62px;

  --header-total: calc(var(--topbar-h) + var(--search-h) + var(--strip-h) + var(--stats-h));

  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

/* ── Top Bar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 720px;
  margin: 0 auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  font-size: 18px;
  color: var(--accent);
  line-height: 1;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-accent {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover, .icon-btn:active {
  color: var(--text);
  background: var(--bg-4);
}

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

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

.filter-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: none;
}

.filter-dot.visible { display: block; }

/* ── Search ───────────────────────────────────────────────────── */
.search-wrapper {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  z-index: 99;
  height: var(--search-h);
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: none;
  max-width: 100%;
}

.search-wrapper.visible { display: block; }

.search-inner {
  position: relative;
  max-width: 688px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0 36px 0 36px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--text-3); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* remove native X in webkit */
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: var(--bg-4);
  border: none;
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
}

.search-clear.visible { display: flex; }

/* ── Filter Panel ─────────────────────────────────────────────── */
.filter-panel {
  position: fixed;
  top: calc(var(--topbar-h));
  left: 0; right: 0;
  z-index: 98;
  background: rgba(17,17,20,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1), padding 0.3s;
}

.filter-panel.open {
  max-height: 300px;
  padding: 12px 0 4px;
}

.filter-panel-inner {
  padding: 0 16px 8px;
  max-width: 720px;
  margin: 0 auto;
}

.filter-section {
  margin-bottom: 12px;
}

.filter-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.pill:hover { border-color: var(--accent); color: var(--text); }

.pill-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-tech { background: var(--tech); }
.dot-ai   { background: var(--ai); }
.dot-design { background: var(--design); }

.clear-filters-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
}

.clear-filters-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--bg-3); }

/* ── Category Strip ───────────────────────────────────────────── */
.category-strip {
  position: fixed;
  left: 0; right: 0;
  z-index: 97;
  top: var(--topbar-h);
  height: var(--strip-h);
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: top 0.3s cubic-bezier(0.4,0,0.2,1);
}

.category-strip-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 100%;
  overflow-x: auto;
  max-width: 720px;
  margin: 0 auto;
}

.category-strip-inner::-webkit-scrollbar { display: none; }

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cat-btn:hover { color: var(--text); background: var(--bg-3); }

.cat-btn-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.cat-btn[data-cat="tech"].cat-btn-active {
  background: var(--tech-dim);
  border-color: var(--tech);
  color: var(--tech);
}

.cat-btn[data-cat="ai"].cat-btn-active {
  background: var(--ai-dim);
  border-color: var(--ai);
  color: var(--ai);
}

.cat-btn[data-cat="design"].cat-btn-active {
  background: var(--design-dim);
  border-color: var(--design);
  color: var(--design);
}

.cat-icon { font-size: 13px; }

/* ── Stats Bar ────────────────────────────────────────────────── */
.stats-bar {
  position: fixed;
  left: 0; right: 0;
  z-index: 96;
  top: calc(var(--topbar-h) + var(--strip-h));
  height: var(--stats-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: rgba(9,9,11,0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 11px;
  color: var(--text-3);
  transition: top 0.3s cubic-bezier(0.4,0,0.2,1);
  max-width: 100%;
}

.stats-count { font-weight: 500; color: var(--text-2); }
.stats-sep   { opacity: 0.4; }

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  padding-top: calc(var(--topbar-h) + var(--strip-h) + var(--stats-h) + 8px);
  padding-bottom: calc(var(--nav-h) + 16px);
  max-width: 720px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
  min-height: 100dvh;
}

/* ── Skeleton ─────────────────────────────────────────────────── */
.skeleton-list { display: flex; flex-direction: column; gap: 12px; }

.skeleton-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow: hidden;
}

.sk-tag, .sk-title, .sk-meta, .sk-body {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 10px;
}

.sk-tag    { width: 60px; height: 20px; border-radius: 99px; }
.sk-title  { height: 20px; width: 85%; }
.sk-title.sk-title-sm { width: 55%; }
.sk-meta   { height: 12px; width: 140px; }
.sk-body   { height: 14px; width: 100%; }
.sk-body.sk-body-sm { width: 70%; }

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

/* ── Article List ─────────────────────────────────────────────── */
.article-list { display: flex; flex-direction: column; gap: 10px; }

/* ── Article Card ─────────────────────────────────────────────── */
.article-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: default;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  position: relative;
  overflow: hidden;
  will-change: transform;
}

.article-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.015) 0%, transparent 60%);
  pointer-events: none;
}

.article-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}

.article-card.is-read {
  opacity: 0.45;
}

.article-card.is-read:hover { opacity: 0.7; }

/* Category accent line */
.article-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--tech);
  opacity: 0;
  transition: opacity 0.2s;
}

.article-card.cat-tech::after   { background: var(--tech);   opacity: 1; }
.article-card.cat-ai::after     { background: var(--ai);     opacity: 1; }
.article-card.cat-design::after { background: var(--design); opacity: 1; }

/* Card header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cat-tag-tech   { background: var(--tech-dim);   color: var(--tech); }
.cat-tag-ai     { background: var(--ai-dim);     color: var(--ai); }
.cat-tag-design { background: var(--design-dim); color: var(--design); }

.read-time {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-str {
  font-size: 11px;
  color: var(--text-3);
}

/* Card actions */
.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-3);
  transition: all 0.15s;
}

.card-btn:hover { color: var(--text); background: var(--bg-4); }

.card-btn.fav-active {
  color: #fbbf24;
}

.card-btn.fav-active svg { fill: #fbbf24; }

.card-btn.read-active { color: #4ade80; }
.card-btn.read-active svg { stroke: #4ade80; }

/* Star animation */
.card-btn.star-pop {
  animation: star-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes star-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Card title */
.card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.card-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

.card-title a:hover { color: var(--accent); }

/* Card body */
.card-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-body.expanded { -webkit-line-clamp: unset; }

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.card-source {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

.card-source-icon {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--bg-4);
  flex-shrink: 0;
}

.source-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.expand-btn {
  font-size: 11px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  transition: background 0.15s;
  flex-shrink: 0;
}

.expand-btn:hover { background: var(--accent-dim); }

/* Read-out animation */
.article-card.slide-out {
  animation: slide-out 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slide-out {
  0%   { transform: translateX(0); opacity: 1; max-height: 400px; margin-bottom: 10px; }
  60%  { transform: translateX(60px); opacity: 0; }
  100% { transform: translateX(60px); opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; border-width: 0; }
}

/* Slide-in for new cards */
.article-card.slide-in {
  animation: slide-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slide-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1);        opacity: 1; }
}

/* highlight search */
.highlight {
  background: rgba(167,139,250,0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Empty & Error States ─────────────────────────────────────── */
.empty-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}

.empty-icon, .error-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-title, .error-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-desc, .error-desc {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
}

.empty-action {
  padding: 10px 20px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.empty-action:hover { background: var(--accent); color: var(--bg); }

/* ── Bottom Nav ───────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(9,9,11,0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  padding: 8px 0;
}

.nav-item:hover { color: var(--text-2); }

.nav-active {
  color: var(--accent) !important;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:active .nav-icon { transform: scale(0.9); }
.nav-active .nav-icon { transform: scale(1.08); }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.nav-badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 8px);
  background: var(--accent);
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
  height: 14px;
  display: none;
}

.nav-badge.show { display: block; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
  pointer-events: auto;
}

.toast.out {
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(-8px); opacity: 0; }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (min-width: 480px) {
  .card-title { font-size: 16px; }
  .card-body  { font-size: 14px; }
}

@media (min-width: 720px) {
  .main-content { padding-left: 24px; padding-right: 24px; }
  .topbar-inner, .filter-panel-inner, .category-strip-inner { padding-left: 24px; padding-right: 24px; }
  .stats-bar { padding: 0 24px; }
  .search-wrapper { padding: 8px 24px; }
}

/* ── Favourites active state in main content ──────────────────── */
body.view-favorites .article-card:not(.is-fav) {
  display: none;
}

/* show-read-favourites toggle */
body.view-favorites:not(.show-read-favs) .article-card.is-read.is-fav {
  display: none;
}

body.view-favorites .show-read-favs-bar {
  display: flex;
}

.show-read-favs-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  margin-bottom: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
}

.show-read-favs-bar button {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  border-radius: 99px;
  color: var(--text-2);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.show-read-favs-bar button:hover { background: var(--bg-4); color: var(--text); }
.show-read-favs-bar button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
