/* ============================================
   The Scholar's Chronicle — Sidebar Edition
   ============================================ */

@import url('https://cdn.jsdelivr.net/npm/lxgwwenkai-webfont@1.7.0/style.css');

:root {
  /* Warm rice paper palette */
  --bg-page: #faf9f6;
  --bg-surface: #ffffff;
  --bg-elevated: #f5f5f4;
  --bg-highlight: #fef2f2;

  /* Ink tones */
  --ink-900: #1c1917;
  --ink-700: #44403c;
  --ink-500: #78716c;
  --ink-400: #a8a29e;
  --ink-300: #d6d3d1;
  --ink-200: #e7e5e4;
  --ink-100: #f5f5f4;

  /* Vermilion accent */
  --vermilion: #b91c1c;
  --vermilion-dark: #991b1b;
  --vermilion-soft: #fef2f2;
  --vermilion-muted: #fca5a5;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(28 25 23 / 0.05);
  --shadow: 0 4px 6px -1px rgb(28 25 23 / 0.07), 0 2px 4px -2px rgb(28 25 23 / 0.07);
  --shadow-md: 0 6px 10px -2px rgb(28 25 23 / 0.08), 0 3px 6px -3px rgb(28 25 23 / 0.08);
  --shadow-lg: 0 12px 24px -4px rgb(28 25 23 / 0.1), 0 4px 8px -4px rgb(28 25 23 / 0.1);

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Typography */
  --font-display: 'LXGW WenKai', 'PingFang SC', 'Microsoft YaHei', 'Noto Serif SC', serif;
  --font-body: 'LXGW WenKai', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;

  /* Sidebar */
  --sidebar-width: 280px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--ink-900);
  line-height: 1.7;
  font-size: 0.9375rem;
}

::selection {
  background-color: var(--vermilion-soft);
  color: var(--vermilion-dark);
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ink-300);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-400);
}

a {
  color: var(--vermilion);
  text-decoration: none;
  transition: color 0.2s var(--ease-out);
}
a:hover {
  color: var(--vermilion-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--ink-200);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-brand {
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ink-200);
  position: relative;
}
.sidebar-brand::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: var(--vermilion);
  border-radius: 1px;
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}
.site-subtitle {
  font-size: 0.75rem;
  color: var(--ink-500);
  letter-spacing: 0.04em;
}

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

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--ink-200);
  font-size: 0.72rem;
  color: var(--ink-400);
  text-align: center;
}
.sidebar-footer a {
  color: var(--ink-500);
}

/* Calendar (compact for sidebar) */
.calendar-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  padding: 0.75rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0 0.1rem;
}
.nav-group {
  display: flex;
  gap: 2px;
}
.nav-group button {
  background: var(--bg-surface);
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  padding: 2px 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--ink-500);
  line-height: 1.4;
  transition: all 0.15s var(--ease-out);
}
.nav-group button:hover {
  background: var(--vermilion-soft);
  border-color: var(--vermilion-muted);
  color: var(--vermilion);
}

.calendar-month-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-900);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.calendar-dow {
  font-size: 0.65rem;
  color: var(--ink-400);
  padding: 0.3rem 0;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.calendar-day {
  padding: 4px 0;
  font-size: 0.75rem;
  border-radius: 5px;
  cursor: default;
  color: var(--ink-300);
  transition: all 0.15s var(--ease-out);
}
.calendar-day.empty {
  cursor: default;
}
.calendar-day.available {
  color: var(--ink-900);
  font-weight: 500;
  cursor: pointer;
}
.calendar-day.available:hover {
  background: var(--vermilion-soft);
  color: var(--vermilion);
}
.calendar-day.in-range {
  background: #fee2e2;
  color: var(--vermilion-dark);
}
.calendar-day.selected {
  background: var(--vermilion);
  color: #fff;
  font-weight: 600;
}
.calendar-day.selected:hover {
  background: var(--vermilion-dark);
  color: #fff;
}

.calendar-date-display {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--ink-500);
  text-align: center;
  min-height: 1.2em;
}

/* Filters in sidebar */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-select,
.filter-input {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--bg-surface);
  color: var(--ink-900);
  font-family: inherit;
  width: 100%;
  transition: all 0.2s var(--ease-out);
  outline: none;
}
.filter-select:focus,
.filter-input:focus {
  border-color: var(--vermilion);
  box-shadow: 0 0 0 3px var(--vermilion-soft);
}
.filter-select:disabled {
  background: var(--bg-elevated);
  color: var(--ink-400);
  cursor: not-allowed;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 2rem 2.5rem 4rem;
  max-width: calc(var(--sidebar-width) + 960px);
}

.results-meta {
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: var(--ink-500);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ink-200);
}

/* Paper Cards */
.papers-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.paper-card {
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--ink-200);
  transition: all 0.35s var(--ease-out);
  opacity: 0;
  transform: translateY(12px);
  animation: card-enter 0.5s var(--ease-out) forwards;
}
.paper-card:hover,
.paper-card:has(.pill-wrap.open) {
  z-index: 2;
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.paper-card:nth-child(1) { animation-delay: 0.04s; }
.paper-card:nth-child(2) { animation-delay: 0.08s; }
.paper-card:nth-child(3) { animation-delay: 0.12s; }
.paper-card:nth-child(4) { animation-delay: 0.16s; }
.paper-card:nth-child(5) { animation-delay: 0.20s; }
.paper-card:nth-child(6) { animation-delay: 0.24s; }
.paper-card:nth-child(7) { animation-delay: 0.28s; }
.paper-card:nth-child(8) { animation-delay: 0.32s; }

@keyframes card-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}
.card-header.with-image {
  grid-template-columns: 1fr 200px;
}
.card-main {
  min-width: 0;
}

.paper-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-900);
  margin-bottom: 0.45rem;
  letter-spacing: -0.01em;
}
.paper-authors {
  font-size: 0.82rem;
  color: var(--ink-500);
  margin-bottom: 0.35rem;
  font-style: italic;
}
.paper-meta {
  font-size: 0.78rem;
  color: var(--ink-500);
  margin-bottom: 0.65rem;
}
.paper-meta a {
  color: var(--vermilion);
  font-weight: 500;
}
.paper-meta .meta-sep {
  color: var(--ink-300);
  margin: 0 0.35rem;
}

/* Badges */
.paper-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-size: 0.7rem;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: transform 0.15s var(--ease-out);
}
.badge:hover {
  transform: scale(1.04);
}
.badge-tag {
  background: var(--vermilion-soft);
  color: var(--vermilion);
  border: 1px solid #fecaca;
}
.badge-category {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.badge-institution {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Note highlights */
.note-highlights {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border-radius: 10px;
  border-left: 3px solid var(--vermilion);
}
.note-highlights p {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-700);
}
.note-highlights p:last-child {
  margin-bottom: 0;
}
.hl-label {
  font-weight: 600;
  color: var(--vermilion);
  margin-right: 0.4rem;
}
.hl-text {
  color: var(--ink-700);
}

/* Content pills */
.content-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pill-wrap {
  position: relative;
}
.pill {
  background: var(--bg-surface);
  border: 1px solid var(--ink-300);
  border-radius: 8px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 0.76rem;
  color: var(--ink-700);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-weight: 500;
}
.pill:hover,
.pill-wrap:hover .pill,
.pill-wrap.open .pill {
  background: var(--vermilion-soft);
  border-color: var(--vermilion-muted);
  color: var(--vermilion);
}

/* Popovers */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  width: min(480px, 70vw);
  max-height: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.pill-wrap:hover .popover,
.pill-wrap.open .popover {
  display: flex;
  animation: popover-enter 0.2s var(--ease-out);
}
@keyframes popover-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--ink-100);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--ink-900);
  flex-shrink: 0;
}
.popover-body {
  padding: 0.85rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin: 0;
  color: var(--ink-900);
  font-size: 0.82rem;
  line-height: 1.7;
}
.popover-body.summary {
  text-align: justify;
}
.popover-body.note {
  font-family: inherit;
  white-space: pre-wrap;
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 0.85rem;
}

/* Copy button */
.copy-btn {
  background: var(--bg-surface);
  border: 1px solid var(--ink-200);
  border-radius: 6px;
  padding: 2px 9px;
  font: inherit;
  font-size: 0.68rem;
  color: var(--ink-500);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s var(--ease-out);
  font-weight: 500;
}
.copy-btn:hover {
  background: var(--vermilion-soft);
  border-color: var(--vermilion-muted);
  color: var(--vermilion);
}
.copy-btn.copied {
  background: var(--vermilion-soft);
  border-color: var(--vermilion);
  color: var(--vermilion);
}

/* Image hover */
.card-image-col {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}
.image-hover-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.image-thumb {
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease-out);
}
.image-thumb:hover {
  box-shadow: var(--shadow-md);
}
.image-thumb img {
  display: block;
  max-width: 100%;
  max-height: 240px;
}
.image-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
}
.image-hover-wrap:hover .image-overlay {
  display: block;
  animation: popover-enter 0.25s var(--ease-out);
}
.image-overlay img {
  display: block;
  max-width: 560px;
  max-height: 560px;
  border-radius: 8px;
}
.image-overlay a {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  padding: 0.4rem 0 0.2rem;
  color: var(--vermilion);
  font-weight: 500;
}

/* Empty */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--ink-400);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ink-200);
  text-align: center;
  color: var(--ink-400);
  font-size: 0.8rem;
}

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

@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--ink-200);
    z-index: auto;
  }
  .sidebar-inner {
    padding: 1.25rem 1rem;
    gap: 1rem;
  }
  .sidebar-brand {
    padding-bottom: 0.5rem;
  }
  .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 1.5rem 1rem 3rem;
    max-width: 100%;
  }

  .card-header.with-image {
    grid-template-columns: 1fr;
  }
  .card-image-col {
    justify-content: center;
    margin-top: 1rem;
  }
  .paper-card {
    padding: 1.25rem;
    border-radius: 12px;
  }
  .paper-title {
    font-size: 1.05rem;
  }
  .popover {
    width: min(320px, 90vw);
  }
  .image-overlay {
    left: 50%;
    transform: translateX(-50%);
  }
  .image-overlay img {
    max-width: 92vw;
    max-height: 60vh;
  }
}
