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

/* Typography & Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f4f5f7;
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus ring for keyboard navigation */
:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; font-weight: 600; }

/* Nav */
nav {
  background: #1a1a2e;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  height: 52px;
}

nav .brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

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

nav .nav-links a {
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
}

nav .nav-links a:hover { color: #fff; }
nav .nav-links a.active { color: #60a5fa; }

/* Layout */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Search Bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input[type="search"] {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
}

.search-bar input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.search-bar button {
  padding: 0.6rem 1.2rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.search-bar button:hover { background: #1d4ed8; }

/* Filters */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters.collapsible { display: none; }
.filters.collapsible.active { display: flex; }

.filters select,
.filters input[type="date"] {
  padding: 0.4rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #fff;
}

.filters select:focus,
.filters input[type="date"]:focus {
  outline: none;
  border-color: #2563eb;
}

.filters label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.card-title a { color: #1a1a2e; }
.card-title a:hover { color: #2563eb; text-decoration: none; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.8rem;
  color: #64748b;
}

.card-meta span { white-space: nowrap; }

.card-indicators {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.patented { background: #dcfce7; color: #166534; }
.status-badge.pending  { background: #fef9c3; color: #854d0e; }
.status-badge.abandoned { background: #fee2e2; color: #991b1b; }
.status-badge.default  { background: #e2e8f0; color: #475569; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  font-size: 0.85rem;
  color: #64748b;
}

.pagination button {
  padding: 0.35rem 0.75rem;
  background: #fff;
  color: #2563eb;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #2563eb;
}

.pagination button:disabled {
  color: #cbd5e1;
  cursor: default;
}

/* Loading Skeletons */
.skeleton-list { display: flex; flex-direction: column; gap: 0.75rem; }

.skeleton-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.sk-line {
  height: 0.75rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

.sk-title { width: 60%; margin-bottom: 0.6rem; height: 0.9rem; }
.sk-meta { width: 85%; }

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

/* Spinner (kept for keyword cloud / detail) */
.loading {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Error */
.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: #991b1b;
}

.error-box h2 { font-size: 1rem; margin-bottom: 0.5rem; }

.retry-btn {
  margin-top: 0.75rem;
  padding: 0.4rem 1rem;
  background: #991b1b;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.retry-btn:hover:not(:disabled) { background: #7f1d1d; }
.retry-btn:disabled { opacity: 0.5; cursor: default; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
  font-size: 0.95rem;
}

/* Cache latency hint */
.cache-hint {
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  padding: 0.5rem 0;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Results Header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}

/* Summary Strip */
.summary-strip {
  margin-bottom: 1rem;
  display: none;
}

.facet-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.facet-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-right: 0.25rem;
}

.facet-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  background: #f1f5f9;
  border-radius: 12px;
  font-size: 0.75rem;
}

.facet-label { color: #334155; }
.facet-count { color: #94a3b8; font-size: 0.7rem; }

/* Responsive */
@media (max-width: 1024px) {
  main { max-width: 100%; padding: 1.25rem; }
}

@media (max-width: 768px) {
  nav .nav-links { gap: 1rem; }
  nav .nav-links a { font-size: 0.8rem; }
  .data-table { font-size: 0.78rem; }
  .data-table th, .data-table td { padding: 0.35rem 0.5rem; }
  .tab { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
}

@media (max-width: 640px) {
  nav { padding: 0 1rem; gap: 1rem; }
  nav .nav-links { gap: 0.75rem; }
  main { padding: 1rem; }
  .search-bar { flex-direction: column; }
  .filters { flex-direction: column; align-items: stretch; }
  .card-meta { flex-direction: column; gap: 0.25rem; }
  .facet-group { gap: 0.25rem; }
  .data-table { display: block; overflow-x: auto; }
  .tab-bar { overflow-x: auto; }
}

/* Detail Page */
.back-link {
  font-size: 0.85rem;
  color: #64748b;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.detail-header {
  margin-bottom: 1.5rem;
}

.detail-header h1 {
  font-size: 1.35rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.detail-meta .app-num {
  font-weight: 600;
  color: #1a1a2e;
  font-size: 0.95rem;
}

.detail-dates {
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
  color: #64748b;
}

.detail-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.detail-section h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

/* Prosecution Highlights */
.highlights-metrics {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2563eb;
}

.metric-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.highlights-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  position: relative;
  padding-left: 1rem;
  border-left: 2px solid #e2e8f0;
}

.highlight-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0;
  width: 100%;
}

.highlight-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  margin-top: 0.3rem;
  margin-left: -1.35rem;
  flex-shrink: 0;
}

.highlight-step[data-label="allowance"] .highlight-dot,
.highlight-step[data-label="granted"] .highlight-dot {
  background: #16a34a;
}

.highlight-step[data-label="final_rejection"] .highlight-dot {
  background: #dc2626;
}

.highlight-step[data-label="non_final_rejection"] .highlight-dot {
  background: #f59e0b;
}

.highlight-step[data-label="rce_filed"] .highlight-dot,
.highlight-step[data-label="appeal_filed"] .highlight-dot {
  background: #7c3aed;
}

.highlight-info {
  display: flex;
  justify-content: space-between;
  flex: 1;
  gap: 0.5rem;
}

.highlight-label {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: capitalize;
}

.highlight-date {
  font-size: 0.8rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* People */
.people-grid {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.people-col h3 {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.people-list {
  list-style: none;
  font-size: 0.9rem;
}

.people-list li { padding: 0.15rem 0; }

.muted { color: #94a3b8; font-size: 0.8rem; }

/* Assignments */
.assignment-single {
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

.assignment-chain {
  border-left: 2px solid #e2e8f0;
  padding-left: 1rem;
}

.assignment-step {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.assignment-step + .assignment-step {
  border-top: 1px solid #f1f5f9;
}

.assignment-date {
  flex-shrink: 0;
  color: #64748b;
  font-size: 0.8rem;
  min-width: 90px;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  color: #64748b;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #e2e8f0;
}

.data-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

.data-table code {
  font-size: 0.8rem;
  background: #f1f5f9;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* Events Details */
.events-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #2563eb;
  margin-top: 0.75rem;
}

/* Charts */
.chart-container {
  width: 100%;
  height: 260px;
  margin-bottom: 0.75rem;
}

/* Responsive Detail */
@media (max-width: 768px) {
  .detail-header h1 { font-size: 1.15rem; }
  .detail-section { padding: 1rem; }
}

@media (max-width: 640px) {
  .people-grid { flex-direction: column; gap: 1rem; }
  .assignment-step { flex-direction: column; gap: 0.25rem; }
  .chart-container { height: 200px; }
  .detail-meta { flex-direction: column; gap: 0.25rem; }
  .detail-dates { flex-direction: column; gap: 0.25rem; }
}

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid #e2e8f0;
}

.tab {
  padding: 0.5rem 1.25rem;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: #1a1a2e; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; }

/* Type Badge */
.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #dbeafe;
  color: #1e40af;
}

/* Tag River */
.tag-river {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: baseline;
  justify-content: center;
  padding: 1.5rem 1rem;
}
.tag-river-tag {
  display: inline-block;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.15s;
  cursor: pointer;
}
.tag-river-tag:hover {
  opacity: 1 !important;
  transform: scale(1.08);
}

/* Landing Intro */
.landing-intro {
  text-align: center;
  padding: 1rem 0 0;
  color: #475569;
}

.landing-intro h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.25rem;
}

.landing-intro p {
  font-size: 0.9rem;
  color: #64748b;
}

/* About Page */
.about-page h1 { margin-bottom: 1.5rem; }
.about-page h2 { margin-top: 2rem; margin-bottom: 0.5rem; font-size: 1.25rem; }
.about-page p { margin-bottom: 0.75rem; line-height: 1.6; }
.about-page ul { margin-left: 1.5rem; margin-bottom: 1rem; }
.about-page li { margin-bottom: 0.5rem; line-height: 1.5; }
.about-page a { color: var(--link); }

/* Portfolio */
.portfolio-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.portfolio-search input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.95rem;
}

.portfolio-search input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.btn-primary {
  padding: 0.6rem 1.25rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover { background: #1d4ed8; }

.portfolio-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .portfolio-charts { grid-template-columns: 1fr; }
}
