/*
  Created by Claude Code — Claude Sonnet 5 (claude-sonnet-5),
  planned with Claude Opus 5.5.

  Design direction: "terminal index card" — a dark, data-dense catalog
  readout. Near-black ground, acid-lime + hot-magenta accents, a wide
  geometric display face for the wordmark and big numbers, monospace
  for everything else so the page reads like a live console over the
  book collection.

  Adapted 2026-09-24 for the live API's actual shape (id/title/author
  only): removed genre/status/rating/year/notes styling, added the
  author stat list and the A-Z letter index.
*/

:root {
  --bg: #0a0b0d;
  --bg-panel: #131519;
  --bg-panel-raised: #191c21;
  --line: #2a2e35;
  --line-bright: #3c424c;
  --ink: #eef0ea;
  --ink-dim: #9aa0aa;
  --ink-faint: #656b75;
  --lime: #ccff33;
  --lime-dim: #8fb824;
  --magenta: #ff3d81;
  --cyan: #4de3d1;

  --font-display: "Unbounded", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 3px;
  --focus-ring: 0 0 0 3px rgba(204, 255, 51, 0.35), 0 0 0 1px var(--lime);
}

@media (prefers-color-scheme: light) {
  /* The design is intentionally dark-only; keep it consistent regardless
     of OS theme so the "console" aesthetic doesn't get inverted. */
  :root {
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.5;
  position: relative;
}

/* Subtle grain overlay for atmosphere, purely decorative */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: var(--cyan);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}

/* ---------------------------------------------------------------- header */

.site-header {
  position: relative;
  z-index: 2;
  padding: 3.5rem 1.5rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 60% 100% at 50% 0%, rgba(204, 255, 51, 0.08), transparent 70%);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 0 40px rgba(204, 255, 51, 0.25);
}

.wordmark .bracket {
  color: var(--lime);
}

.tagline {
  margin: 0.75rem 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------- main/layout */

main {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* --------------------------------------------------------------- stats bar */

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.stats-placeholder {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-faint);
}

.stat {
  padding: 1rem 1.1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat:last-child {
  border-right: none;
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--lime);
  line-height: 1.1;
}

.stat-value.is-small {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  font-family: var(--font-mono);
}

.stat-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--ink);
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.stat-list span.count {
  color: var(--ink-faint);
}

/* ------------------------------------------------------------------ toolbar */

.toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field input,
.field select {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  width: 100%;
  appearance: none;
}

.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
    linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.field input::placeholder {
  color: var(--ink-faint);
}

.field input:hover,
.field select:hover {
  border-color: var(--line-bright);
}

.field input:disabled,
.field select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ------------------------------------------------------------- letter index */

.letter-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1.25rem;
}

.letter-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-dim);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 1.7rem;
  height: 1.7rem;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.letter-btn:hover {
  border-color: var(--lime);
  color: var(--lime);
}

.letter-btn:disabled {
  color: var(--ink-faint);
  opacity: 0.35;
  cursor: not-allowed;
}

/* -------------------------------------------------------------- result row */

.result-count {
  margin: 0 0 1.25rem;
  color: var(--ink-faint);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

/* ---------------------------------------------------------------- states */

.state-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 3rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.state-panel.is-error {
  border-color: rgba(255, 61, 129, 0.4);
}

.state-icon {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--ink-faint);
  margin-bottom: 0.75rem;
}

.state-panel.is-error .state-icon {
  color: var(--magenta);
}

.state-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.state-detail {
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 0 0 1.25rem;
}

.retry-btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--lime);
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.retry-btn:hover {
  background: #d9ff66;
  transform: translateY(-1px);
}

.retry-btn:active {
  transform: translateY(0);
}

/* spinner used in the loading state */
.spinner {
  display: inline-block;
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid var(--line-bright);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

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

/* empty state (no matches) */
.state-panel.is-empty .state-icon {
  color: var(--ink-faint);
}

/* -------------------------------------------------------------- book list */
/* One line per record (changed by Claude Opus 5.5): title left, author
   right, both truncated with an ellipsis so every row stays one line. */

.book-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  overflow: hidden;
}

.book-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  scroll-margin-top: 1rem;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.book-row:last-child {
  border-bottom: none;
}

.book-row:hover {
  background: var(--bg-panel-raised);
  border-left-color: var(--lime);
}

.book-title,
.book-author {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-title {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
}

.book-author {
  color: var(--ink-dim);
  font-size: 0.82rem;
  text-align: right;
}

.book-row:hover .book-author {
  color: var(--magenta);
}

/* --------------------------------------------------------------- footer */

.site-footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.site-footer code {
  color: var(--ink-dim);
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 820px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .field-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .site-header {
    padding: 2.5rem 1rem 1.5rem;
  }
  main {
    padding: 1.5rem 1rem 3rem;
  }
  .toolbar {
    grid-template-columns: 1fr;
  }
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .book-row {
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
  }
  .letter-btn {
    width: 1.55rem;
    height: 1.55rem;
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-row,
  .retry-btn,
  .spinner {
    animation: none;
    transition: none;
  }
}
