/* ══════════════════════════════════════════════
   JOHN T. BAILEY DIGITAL LIBRARY — styles.css
   ══════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
  --ink:          #1a1714;
  --ink-mid:      #3d3830;
  --ink-soft:     #7a726a;
  --ink-faint:    #c4bdb5;
  --paper:        #f7f4ef;
  --paper-warm:   #ede8e0;
  --paper-card:   #faf8f4;
  --gold:         #b8924a;
  --gold-light:   #d4aa6a;
  --gold-dim:     #8a6e38;
  --rule:         rgba(26,23,20,0.12);
  --shadow:       rgba(26,23,20,0.07);
  --controls-bg:  rgba(247,244,239,0.94);
  --toggle-bg:    #e8e3da;
  --toggle-knob:  #fff;
  --radius:       4px;
  --max-w:        1200px;
}

[data-theme="dark"] {
  --ink:          #e8e2d9;
  --ink-mid:      #c8c0b4;
  --ink-soft:     #7a7268;
  --ink-faint:    #4a4540;
  --paper:        #141210;
  --paper-warm:   #1c1916;
  --paper-card:   #1a1714;
  --gold:         #c49a52;
  --gold-light:   #d4aa6a;
  --gold-dim:     #c49a52;
  --rule:         rgba(232,226,217,0.10);
  --shadow:       rgba(0,0,0,0.30);
  --controls-bg:  rgba(20,18,16,0.94);
  --toggle-bg:    #3a3530;
  --toggle-knob:  #c49a52;
}

/* ── RESET & BASE ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    color 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Outfit', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* subtle grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.6;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
}

a { text-decoration: none; color: inherit; }

/* ══════════════════════════════════════════
   SITE HEADER
══════════════════════════════════════════ */
.site-header {
  position: relative;
  padding: 5rem 4rem 4rem;
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 2rem;
}

.catalog-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

h1 {
  font-size: clamp(3rem, 6vw, 5.5rem);
  font-weight: 300;
  line-height: 0.95;
  letter-spacing: -0.01em;
}

h1 em {
  font-style: italic;
  color: var(--gold-dim);
}

.header-meta { text-align: right; }

.stat-block { display: flex; gap: 2.5rem; justify-content: flex-end; }

.stat-item { text-align: right; }

.stat-num {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.6rem;
  font-weight: 300;
  color: var(--ink);
  line-height: 1;
  display: block;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
  margin-top: 0.2rem;
}

/* ══════════════════════════════════════════
   STICKY CONTROLS
══════════════════════════════════════════ */
.controls {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--controls-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  padding: 0.85rem 4rem;
}

.controls-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-card);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
}

input[type="search"]:focus       { border-color: var(--gold); }
input[type="search"]::placeholder { color: var(--ink-faint); }

/* Category pills + Series toggle, grouped together */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.cat-filters {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.cat-pill {
  font-family: 'Outfit', sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 0.25em 0.85em;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pill:hover { border-color: var(--gold); color: var(--gold); }
.cat-pill.active { background: var(--gold); border-color: var(--gold); color: var(--paper); }

/* Divider between category pills and series toggle */
.filter-group::after {
  content: '';
  width: 1px;
  height: 1.1rem;
  background: var(--rule);
  flex-shrink: 0;
}

/* Sort select */
.sort-wrap select {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink-soft);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 1.8rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a726a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}

.sort-wrap select:focus { border-color: var(--gold); }

/* Results count */
.results-count {
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  white-space: nowrap;
  margin-left: auto;
}

.results-count span { color: var(--gold); font-weight: 500; }

/* ── SERIES TOGGLE BUTTON (same visual language as .cat-pill) ── */
.series-toggle {
  font-family: 'Outfit', sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--ink-mid);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 0.25em 0.85em;
  white-space: nowrap;
  flex-shrink: 0;
}

.series-toggle:hover {
  border-color: var(--gold);
  color: var(--gold-dim);
}

.series-toggle.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

.series-toggle .series-label {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  user-select: none;
}

.series-toggle .series-toggle-icon {
  display: flex;
  align-items: center;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.series-toggle .series-toggle-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

/* ── THEME TOGGLE ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle .toggle-label {
  font-size: 0.67rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  user-select: none;
}

.toggle-pill {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--toggle-bg);
  border-radius: 10px;
  flex-shrink: 0;
}

.toggle-pill::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform 0.25s ease, background 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .toggle-pill::after { transform: translateX(16px); }

.theme-toggle .toggle-icon {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--ink-soft);
  user-select: none;
}

/* ══════════════════════════════════════════
   SERIES PANEL (collapsible)
══════════════════════════════════════════ */
.series-panel {
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.3s ease,
              opacity 0.25s ease;
  opacity: 0;
  position: relative;
}

.series-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.3s ease 0.15s;
}

.series-panel.open {
  max-height: 340px;
  opacity: 1;
  padding: 1.25rem 4rem 1.5rem;
}

.series-panel.open::before {
  opacity: 1;
}

.series-panel-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.series-panel-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Series pills */
.series-pill {
  font-family: 'Outfit', sans-serif;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-mid);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.28em 0.65em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.series-pill:hover {
  border-color: var(--gold);
  color: var(--gold-dim);
}

.series-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--paper);
}

.series-pill-count {
  font-size: 0.6rem;
  font-weight: 600;
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
  padding: 0.05em 0.35em;
  line-height: 1.4;
  letter-spacing: 0;
}

.series-pill.active .series-pill-count {
  background: rgba(255,255,255,0.25);
}

/* ══════════════════════════════════════════
   MAIN CATALOG AREA
══════════════════════════════════════════ */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 4rem 6rem;
}

/* ── Category Block ── */
.category-block         { margin-bottom: 4rem; }
.category-block.hidden  { display: none; }

.category-heading {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.category-heading::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.8rem;
  background: var(--gold);
  border-radius: 2px;
  flex-shrink: 0;
}

.category-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.category-name {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1;
}

.category-tally {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-left: auto;
  white-space: nowrap;
}

/* ── Series Section ── */
.series-section {
  margin-bottom: 2.5rem;
  animation: fadeUp 0.4s ease both;
}

.series-section.hidden { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.series-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.series-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.series-count {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(184,146,74,0.10);
  padding: 0.15em 0.6em;
  border-radius: 2px;
  border: 1px solid rgba(184,146,74,0.25);
  white-space: nowrap;
}

/* ── Title Rows ── */
.titles-list { list-style: none; }

.title-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(26,23,20,0.06);
}

.title-item:last-child  { border-bottom: none; }
.title-item.hidden      { display: none; }

.title-item:hover { background: rgba(184,146,74,0.03); }

.title-link {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--ink-mid);
  line-height: 1.5;
  padding: 0.1rem 0.4rem;
  margin-left: -0.4rem;
  border-radius: 2px;
}

.title-link:hover { color: var(--gold-dim); }

.title-link::after {
  content: ' ↗';
  font-size: 0.7em;
  opacity: 0;
  color: var(--gold);
}

.title-item:hover .title-link::after { opacity: 1; }

.asin-code {
  font-family: 'Outfit', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  white-space: nowrap;
}

.title-item:hover .asin-code { color: var(--ink-soft); }

/* ══════════════════════════════════════════
   NO RESULTS
══════════════════════════════════════════ */
.no-results          { display: none; text-align: center; padding: 5rem 2rem; }
.no-results.visible  { display: block; }

.no-results-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 300;
  font-style: italic;
  margin-bottom: 0.5rem;
  color: var(--ink-faint);
}

.no-results-sub {
  font-size: 0.82rem;
  color: var(--ink-faint);
}

/* ══════════════════════════════════════════
   FOOTER
══════════════════════════════════════════ */
footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 4rem;
  text-align: center;
}

footer::before {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 0 auto 1.5rem;
}

.footer-text {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.footer-link {
  color: var(--gold-dim);
  font-weight: 400;
}

.footer-link:hover { color: var(--gold); }

/* ══════════════════════════════════════════
   LOADING STATE
══════════════════════════════════════════ */
.loading-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--ink-soft);
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .site-header, .controls, main, footer {
    padding-left: 2rem;
    padding-right: 2rem;
  }
  .series-panel.open { padding-left: 2rem; padding-right: 2rem; }
}

@media (max-width: 680px) {
  .site-header { padding-top: 3rem; padding-left: 1.5rem; padding-right: 1.5rem; }
  .controls, main, footer { padding-left: 1.5rem; padding-right: 1.5rem; }
  .series-panel.open { padding-left: 1.5rem; padding-right: 1.5rem; max-height: 420px; }
  .header-inner { grid-template-columns: 1fr; }
  .header-meta { text-align: left; }
  .stat-block { justify-content: flex-start; }
  main { padding-top: 2rem; }
  .search-wrap { max-width: 100%; }
  .controls-inner { gap: 0.65rem; }
}
