/* ===== Variables ===== */
:root {
  --bg:           #0a0a0f;
  --fg:           #e2e8f0;
  --fg-muted:     rgba(226, 232, 240, 0.55);
  --primary:      #3b82f6;
  --primary-lt:   #60a5fa;
  --surface:      #1e293b;
  --surface-h:    #334155;
  --border:       #2563eb33;
  --border-h:     #3b82f6;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(59, 130, 246, 0.08);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-lt); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--surface);
  border-radius: 4px;
  font-family: monospace;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

/* ===== Layout ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ===== Header / Nav ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.9);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
}

.site-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-lt);
  white-space: nowrap;
}

.site-logo:hover { text-decoration: none; }

.header-spacer { flex: 1; }

.header-repo-link {
  font-size: 0.8rem;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  transition: border-color 0.2s, color 0.2s;
}

.header-repo-link:hover {
  color: var(--primary-lt);
  border-color: var(--primary);
  text-decoration: none;
}

/* ===== Hero ===== */
.hero {
  padding: 3.5rem 0 2rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--primary-lt);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero p {
  margin-top: 0.9rem;
  max-width: 600px;
  color: var(--fg-muted);
  font-size: 1.05rem;
}

/* ===== Search Form ===== */
.search-form {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
  max-width: 480px;
}

.search-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--fg-muted); }
.search-input:focus { border-color: var(--primary); }

.search-btn {
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  transition: background 0.2s;
}

.search-btn:hover { background: var(--primary-lt); }

.search-clear {
  font-size: 0.82rem;
  color: var(--fg-muted);
  align-self: center;
  margin-left: 0.25rem;
}

/* ===== Section Header ===== */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.count-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
  font-size: 0.75rem;
  padding: 0.1rem 0.6rem;
}

/* ===== PDF Grid ===== */
.pdf-section {
  padding-bottom: 4rem;
}

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

/* ===== PDF Card ===== */
.pdf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.pdf-card:hover {
  background: var(--surface-h);
  border-color: var(--border-h);
  box-shadow: var(--shadow);
}

.card-category {
  align-self: flex-start;
  background: rgba(59, 130, 246, 0.18);
  border-radius: 999px;
  color: var(--primary-lt);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.65rem;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
}

.card-desc {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  flex: 1;
}

.card-meta {
  color: var(--fg-muted);
  font-size: 0.75rem;
  margin-top: 0.6rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.card-tag {
  background: var(--bg);
  border-radius: 4px;
  color: var(--fg-muted);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-lt);
  color: #fff;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary-lt);
  text-decoration: none;
}

/* ===== Empty / Error States ===== */
.state-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--fg-muted);
}

.state-box h3 { color: var(--fg); margin-bottom: 0.5rem; }

.state-error {
  border-color: #ef444460;
  background: rgba(239, 68, 68, 0.06);
  color: #fca5a5;
}

/* ===== Viewer Page ===== */
.viewer-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.viewer-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  flex-shrink: 0;
}

.viewer-bar-title {
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-embed {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
  background: #fff;
}

.viewer-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--fg-muted);
  text-align: center;
  padding: 2rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-h); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero { padding: 2rem 0 1.5rem; }
  .search-form { max-width: 100%; }
  .pdf-grid { grid-template-columns: 1fr; }
}
