/* ==========================================================================
   yechya-papers · Core Stylesheet
   Herdr-inspired Paper/Ink aesthetic, crisp typography & math readability
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Light Theme (Paper Warm White) */
  --bg-page: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f3f5;
  --bg-card: #ffffff;
  --bg-muted: #f1f3f5;
  --bg-highlight: #fdf2f8;
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;

  --text-main: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --text-link: #3b82f6;

  --accent: #4f46e5;
  --accent-light: #e0e7ff;
  --accent-text: #3730a3;

  --badge-must-read-bg: #fef2f2;
  --badge-must-read-text: #991b1b;
  --badge-must-read-border: #fecaca;

  --badge-radar-bg: #fffbeb;
  --badge-radar-text: #92400e;
  --badge-radar-border: #fde68a;

  --badge-trending-bg: #ecfdf5;
  --badge-trending-text: #065f46;
  --badge-trending-border: #a7f3d0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
  /* Dark Theme (Charcoal Ink) */
  --bg-page: #0d0e12;
  --bg-surface: #14161e;
  --bg-surface-hover: #1c1f2b;
  --bg-card: #14161e;
  --bg-muted: #1e2230;
  --bg-highlight: #23192e;
  --border-subtle: #242838;
  --border-strong: #373d52;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --text-link: #60a5fa;

  --accent: #818cf8;
  --accent-light: #1e1b4b;
  --accent-text: #c7d2fe;

  --badge-must-read-bg: #450a0a;
  --badge-must-read-text: #fca5a5;
  --badge-must-read-border: #7f1d1d;

  --badge-radar-bg: #451a03;
  --badge-radar-text: #fcd34d;
  --badge-radar-border: #78350f;

  --badge-trending-bg: #064e3b;
  --badge-trending-text: #6ee7b7;
  --badge-trending-border: #047857;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text-link);
}

/* ==========================================================================
   Header & Nav
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-name {
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-tag {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.25rem 0.1rem;
  border-bottom: 2px solid transparent;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  border-bottom-color: var(--accent);
}

.nav-link.external {
  opacity: 0.8;
}

.theme-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.theme-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

[data-theme="light"] .dark-icon { display: none; }
[data-theme="light"] .light-icon { display: block; }
[data-theme="dark"] .light-icon { display: none; }
[data-theme="dark"] .dark-icon { display: block; }

/* ==========================================================================
   Page Layout
   ========================================================================== */

.site-main {
  flex: 1;
}

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.hero-section {
  margin-bottom: 2.5rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 1.02rem;
  max-width: 720px;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.tag-chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* ==========================================================================
   Notes Grid View
   ========================================================================== */

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.note-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.note-venue {
  font-weight: 600;
  color: var(--accent);
}

.note-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}

.note-full-title {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.note-tldr {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-main);
  background: var(--bg-muted);
  padding: 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  flex: 1;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.tag-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
  font-size: 0.85rem;
}

.authors-brief {
  color: var(--text-dim);
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.read-link {
  font-weight: 600;
  color: var(--accent);
}

/* Empty Notes State */
.empty-notes-card {
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 3.5rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
}

.empty-notes-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-notes-card p {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 560px;
  line-height: 1.6;
}

.empty-notes-card code {
  background: var(--bg-muted);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent);
}

.browse-discover-btn {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

.browse-discover-btn:hover {
  color: #ffffff;
  opacity: 0.9;
}
/* ==========================================================================
   Article Detail View (Deep Reading)
   ========================================================================== */

.article-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 3rem;
  align-items: start;
}

.sidebar-sticky {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.back-link {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.toc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.15rem;
}

.toc-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 60vh;
  overflow-y: auto;
}

.toc-item {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding-left: 0.4rem;
  border-left: 2px solid transparent;
}

.toc-item:hover {
  color: var(--text-main);
  border-left-color: var(--accent);
}

.toc-item.level-3 {
  padding-left: 1.2rem;
  font-size: 0.8rem;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-btn {
  display: block;
  text-align: center;
  padding: 0.55rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.article-content {
  min-width: 0;
}

.article-header {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 2rem;
}

.article-badges {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.badge.venue {
  background: var(--accent-light);
  color: var(--accent-text);
}

.badge.date {
  background: var(--bg-muted);
  color: var(--text-dim);
}

.badge.category {
  background: var(--bg-muted);
  color: var(--text-muted);
}

.article-title {
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.article-meta-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.tldr-banner {
  background: var(--bg-muted);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1.15rem 1.25rem;
}

.tldr-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent);
  color: #ffffff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.tldr-banner p {
  font-size: 1.02rem;
  line-height: 1.6;
  font-weight: 500;
}

/* Article Body Typography */
.article-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-main);
}

.article-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.article-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.8rem;
  margin-bottom: 0.75rem;
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body ul, .article-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.article-body li {
  margin-bottom: 0.5rem;
}

.article-body blockquote {
  border-left: 4px solid var(--border-strong);
  padding: 0.75rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--bg-muted);
  border-radius: 0 6px 6px 0;
  color: var(--text-main);
  font-style: italic;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.article-body th, .article-body td {
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 0.9rem;
  text-align: left;
}

.article-body th {
  background: var(--bg-muted);
  font-weight: 600;
}

.article-body pre {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-muted);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.article-body pre code {
  background: none;
  padding: 0;
}

/* Math blocks styling */
.katex-display {
  margin: 1.5rem 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* ==========================================================================
   Discover Feed View
   ========================================================================== */

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feed-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.feed-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.feed-priority {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  border: 1px solid transparent;
}

.feed-priority.must-read {
  background: var(--badge-must-read-bg);
  color: var(--badge-must-read-text);
  border-color: var(--badge-must-read-border);
}

.feed-priority.radar {
  background: var(--badge-radar-bg);
  color: var(--badge-radar-text);
  border-color: var(--badge-radar-border);
}

.feed-category {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.feed-date {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.copy-prompt-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-prompt-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.feed-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.feed-authors {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.feed-affiliations {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 1.1rem;
}

.feed-summary-box {
  background: var(--bg-muted);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.92rem;
}

.feed-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
  font-size: 0.85rem;
}

.feed-links {
  display: flex;
  gap: 0.85rem;
  font-weight: 500;
}

.feed-links a {
  color: var(--text-link);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-page);
  padding: 2.5rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .sidebar-sticky {
    position: static;
  }

  .toc-card {
    display: none;
  }
}
