/* BPL Card Catalog OCR Comparison — Tufte-inspired minimal styles */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  color: #333;
  background: #fff;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

/* Header */
header {
  border-bottom: 1px solid #ddd;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

header .brand {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

header .brand {
  text-decoration: none;
  color: inherit;
}

header .subtitle {
  font-size: 0.8rem;
  color: #999;
}

header .header-link {
  font-size: 0.8rem;
  color: #999;
  text-decoration: none;
  margin-left: auto;
}

header .header-link:hover {
  color: #333;
}

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

.tab {
  font-size: 0.85rem;
  font-weight: 500;
  color: #999;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #666;
}

.tab.active {
  color: #333;
  border-bottom-color: #333;
}

/* Page heading */
.page-intro {
  margin-bottom: 0.75rem;
}

.page-intro h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: #333;
}

.page-intro p {
  font-size: 0.85rem;
  color: #666;
  margin: 0;
  max-width: 720px;
  line-height: 1.5;
}

.page-intro .card-count {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #333;
}

/* Search form */
.search-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.search-form .field.query-field {
  flex: 1;
  min-width: 200px;
}

.search-form label {
  font-size: 0.75rem;
  color: #999;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.search-form input[type="text"] {
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  outline: none;
  transition: border-color 0.15s;
}

.search-form input[type="text"]:focus {
  border-color: #999;
}

.search-form select {
  font-size: 0.85rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
}

.search-form input[type="number"] {
  font-size: 0.85rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 4rem;
  text-align: center;
}

.search-form button {
  font-size: 0.85rem;
  padding: 0.45rem 1.2rem;
  border: 1px solid #333;
  border-radius: 4px;
  background: #333;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.search-form button:hover {
  background: #555;
}

/* Example queries */
.examples {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.examples .examples-label {
  font-size: 0.75rem;
  color: #999;
  margin-right: 0.25rem;
}

.examples a {
  font-size: 0.8rem;
  color: #666;
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  transition: border-color 0.15s, color 0.15s;
}

.examples a:hover {
  color: #333;
  border-color: #999;
}

/* Results header */
.results-header {
  padding: 0.5rem 0;
  border-bottom: 2px solid #333;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.results-header .query-display {
  font-size: 0.95rem;
  color: #666;
}

.results-header .query-text {
  color: #333;
  font-weight: 600;
}

.results-header .results-meta {
  font-size: 0.8rem;
  color: #999;
}

/* Two-column grid (Compare tab) */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

/* Single-column list (Search tab) */
.results-list {
}

/* Column headers */
.column-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #ddd;
  letter-spacing: 0.02em;
}

.column-header .model-name {
  font-weight: 400;
  color: #999;
}

.old-header { color: #8b6914; border-bottom-color: #d4b86a; }
.new-header { color: #2d6a4f; border-bottom-color: #74c69d; }

/* Result cards */
.result-card {
  margin-bottom: 1rem;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.result-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Search card: side-by-side image + text */
.search-card-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
}

.search-card .card-image {
  max-height: 300px;
}

.card-rank-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
  font-size: 0.75rem;
  color: #bbb;
}

.card-rank {
  font-weight: 600;
  color: #999;
}

.card-score {
  font-variant-numeric: tabular-nums;
}

.card-image-wrap {
  position: relative;
  background: #f5f5f5;
  overflow: hidden;
}

.card-image {
  width: 100%;
  display: block;
  object-fit: contain;
  background: #f5f5f5;
  max-height: 360px;
  transition: transform 0.3s ease;
}

.rotate-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-image-wrap:hover .rotate-btn {
  opacity: 1;
}

.card-body {
  padding: 0.75rem 1rem;
}

.card-meta {
  font-size: 0.75rem;
  color: #bbb;
  margin-bottom: 0.5rem;
}

.card-meta a {
  color: #999;
  text-decoration: none;
}

.card-meta a:hover {
  color: #333;
  text-decoration: underline;
}

.drawer-label {
  font-weight: 500;
  color: #999;
  text-decoration: none;
}

a.drawer-label:hover {
  color: #333;
  text-decoration: underline;
}

.drawer-subject {
  color: #bbb;
}

/* OCR text blocks */
.ocr-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #bbb;
  margin-bottom: 0.2rem;
}

.ocr-text {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow-y: auto;
  padding: 0.25rem 0;
  color: #444;
}

/* Collapsible comparison */
details {
  margin-top: 0.5rem;
}

details summary {
  font-size: 0.75rem;
  color: #bbb;
  cursor: pointer;
  user-select: none;
}

details summary:hover {
  color: #666;
}

details .ocr-text {
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: #f8faf8;
  border-radius: 3px;
}

/* No results */
.no-results {
  text-align: center;
  color: #999;
  padding: 3rem 0;
  font-size: 0.9rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state p {
  color: #999;
  margin: 0.25rem 0;
}

.empty-state .prompt {
  font-size: 1.1rem;
  color: #666;
}

/* HTMX loading indicator */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.loading-indicator {
  color: #999;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid #ddd;
  margin-top: 3rem;
  padding: 1.5rem 0;
  background: #fafafa;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-about,
.footer-note {
  flex: 1;
  min-width: 280px;
}

.footer-content p {
  font-size: 0.78rem;
  color: #999;
  line-height: 1.6;
  margin: 0 0 0.5rem;
}

.footer-content a {
  color: #888;
  text-decoration: none;
}

.footer-content a:hover {
  color: #333;
  text-decoration: underline;
}

.footer-note p {
  font-style: italic;
  color: #aaa;
}

/* Spotlight (random cards on landing) */
.spotlight { padding: 2rem 0; }
.spotlight-header {
  font-size: 0.8rem; color: #999; text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 1rem;
}
.spotlight-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem;
}
.spotlight-card {
  border: 1px solid #e8e8e8; border-radius: 4px; overflow: hidden;
}
.spotlight-image { width: 100%; display: block; max-height: 240px; object-fit: contain; background: #f5f5f5; }
.spotlight-meta { font-size: 0.72rem; color: #bbb; padding: 0.5rem 0.75rem 0.25rem; }
.spotlight-text {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem; color: #666; padding: 0.25rem 0.75rem 0.75rem;
  line-height: 1.5; max-height: 4.5rem; overflow: hidden;
}

/* Drawer table */
.drawer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.drawer-table th {
  text-align: left;
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #ddd;
}

.drawer-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.drawer-table tbody tr:hover {
  background: #f8f8f8;
}

.drawer-table a {
  color: #333;
  text-decoration: none;
}

.drawer-table a:hover {
  text-decoration: underline;
}

.dt-num { width: 5rem; font-variant-numeric: tabular-nums; }
.dt-count { width: 5rem; text-align: right; font-variant-numeric: tabular-nums; color: #999; }
.dt-count:first-child { text-align: right; }

/* Drawer navigation */
.drawer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.drawer-nav a {
  color: #666;
  text-decoration: none;
}

.drawer-nav a:hover {
  color: #333;
}

.drawer-nav-center {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.drawer-nav .drawer-nav-index {
  font-weight: 500;
}

.drawer-nav .drawer-nav-back {
  font-size: 0.8rem;
}

.drawer-nav .disabled {
  color: #ddd;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
}

.card-image, .spotlight-image {
  cursor: zoom-in;
}

/* Responsive */
@media (max-width: 768px) {
  .results-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .search-card-layout {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 1rem 2rem;
  }

  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form .field.query-field {
    min-width: auto;
  }

  .spotlight-grid { grid-template-columns: 1fr; }

  .footer-content {
    flex-direction: column;
    gap: 1rem;
  }
}
