/* Articles module — shared styles */

:root {
  --bg-primary: #F5F0E8;
  --bg-card: #FFFFFF;
  --bg-hover: #EDE5D8;
  --accent: #C17F3E;
  --accent-light: #a96a2f;
  --accent-dim: rgba(193,127,62,0.1);
  --text-primary: #1A1612;
  --text-secondary: #6B5E4F;
  --text-muted: #9B8E7E;
  --border: #D9CFC0;
  --border-light: #E8DFD2;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-body: 'Inter', -apple-system, sans-serif;
  --nav-h: 60px;
  --content-max: 1100px;
  --idiom: #b06a1f;
  --phrasal: #2f6db0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body); background: var(--bg-primary); color: var(--text-primary);
  line-height: 1.55; min-height: 100vh; overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; padding: 0; }

/* Main (global header is sticky — no top padding needed) */
.main { padding-top: 24px; padding-bottom: 80px; }
.main, .hd, .chips, .feed, .loader, .empty, .error,
.article-wrap { max-width: var(--content-max); margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; }

.hd { margin-bottom: 20px; }
.hd h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.hd p { color: var(--text-secondary); margin-top: 6px; max-width: 640px; }

/* Chips */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; margin-bottom: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 100px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; transition: all 0.15s;
}
.chip:hover { color: var(--text-primary); border-color: var(--accent-light); }
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* Feed */
.feed { display: grid; gap: 14px; }
.card {
  display: flex; gap: 14px; padding: 12px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.card:hover { border-color: var(--accent-light); }
.card:active { transform: scale(0.997); }
.card-thumb {
  width: 160px; height: 100px; flex-shrink: 0;
  background: var(--bg-hover); border-radius: var(--radius-sm); overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.card-section {
  display: inline-block; padding: 2px 8px; background: var(--accent-dim);
  color: var(--accent-light); border-radius: 100px; font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.card-headline {
  font-size: 1.05rem; font-weight: 600; line-height: 1.3; color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-standfirst {
  font-size: 0.88rem; color: var(--text-secondary); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Loader / states */
.loader { display: flex; justify-content: center; padding: 32px 0; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty, .error { text-align: center; color: var(--text-secondary); padding: 32px 0; }
.error { color: #b00020; }

/* === Source picker === */
.source-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 8px;
}
.source-card {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  font-family: var(--font-body); color: var(--text-primary);
}
.source-card:hover { border-color: var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.source-card:active { transform: scale(0.997); }
.source-card-head { display: flex; align-items: center; justify-content: space-between; }
.source-card-cefr {
  display: inline-block; padding: 3px 9px;
  background: var(--accent-dim); color: var(--accent-light);
  border-radius: 100px; font-weight: 700; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.source-card-title {
  font-size: 1.25rem; font-weight: 700; line-height: 1.25;
}
.source-card-desc {
  color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5;
}
.source-card-cta {
  margin-top: auto; padding-top: 6px;
  color: var(--accent); font-weight: 600; font-size: 0.95rem;
}
.source-card-cta span { transition: transform 0.15s; display: inline-block; }
.source-card:hover .source-card-cta span { transform: translateX(3px); }
.source-card--bbc .source-card-cefr { background: rgba(47,109,176,0.10); color: #2f6db0; }
.source-card--guardian .source-card-cefr { background: rgba(176,106,31,0.10); color: var(--accent-light); }

/* === Source badge + change-source button (in catalog & article header) === */
.source-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.source-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-primary);
}
.source-badge > span { color: inherit; }
.source-badge .src-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.source-badge.src-bbc .src-dot { background: #2f6db0; }
.source-badge.src-guardian .src-dot { background: var(--accent); }
.source-change-btn {
  font-size: 0.85rem; color: var(--text-secondary);
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.source-change-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* === CEFR chip on catalog cards === */
.card-cefr {
  display: inline-block; padding: 2px 7px;
  background: rgba(47,109,176,0.10); color: #2f6db0;
  border-radius: 100px; font-weight: 700; font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.card-cefr.cefr-guardian { background: rgba(176,106,31,0.10); color: var(--accent-light); }
.card-cefr.cefr-bbc { background: rgba(47,109,176,0.10); color: #2f6db0; }

/* Mobile — Perplexity-style stacked card */
@media (max-width: 640px) {
  .main, .hd, .feed, .loader, .empty, .error,
  .article-wrap { padding-left: 16px; padding-right: 16px; }
  .hd h1 { font-size: 1.5rem; }

  /* Sticky chips under the global header */
  .chips {
    position: sticky;
    top: 64px;
    z-index: 50;
    background: var(--bg-primary);
    margin: 0; max-width: none;
    padding: 8px 16px 12px;
    /* Subtle separator that appears on scroll. */
    box-shadow: 0 6px 8px -8px rgba(0,0,0,0.18);
  }

  .feed { gap: 18px; }
  .card {
    flex-direction: column;
    padding: 0;
    border: none;
    background: transparent;
    gap: 10px;
  }
  .card:hover { border: none; }
  .card-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
  }
  .card-body { gap: 6px; padding: 0 2px; }
  .card-meta { font-size: 0.78rem; }
  .card-headline {
    font-size: 1.1rem; line-height: 1.3; font-weight: 700;
    -webkit-line-clamp: 3;
  }
  .card-standfirst {
    display: -webkit-box;
    font-size: 0.92rem; line-height: 1.45;
    -webkit-line-clamp: 3;
  }
}
