/* =============================================================================
   Entelechy Book Catalog · stylesheet
   Aesthetic: refined editorial / library catalog
   ============================================================================= */

:root {
  /* Brand teal */
  --teal-900: #052E32;
  --teal-700: #085458;
  --teal-500: #08706A;
  --teal-100: #DEF1EC;

  /* Paper / surfaces */
  --paper:      #F8F4EC;
  --paper-dim:  #EFE9DA;
  --paper-edge: #DDD5C4;

  /* Ink */
  --ink:       #1A1F1E;
  --ink-soft:  #41494B;
  --ink-muted: #7A7F7E;

  /* Tag colors — earthy, not pastel */
  --rust-700: #9E3A1A;
  --rust-bg:  #FBE8DD;
  --rust-bd:  #E8B596;

  --gold-700: #6F5614;
  --gold-bg:  #F4EAD0;
  --gold-bd:  #D8C586;

  --forest-700: #1F4329;
  --forest-bg:  #DEEAE2;
  --forest-bd:  #9CB7A6;

  --border:        rgba(8, 84, 88, 0.12);
  --border-strong: rgba(8, 84, 88, 0.22);

  /* Type */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --max-w: 1400px;
  --gutter: clamp(16px, 3vw, 32px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% -10%, rgba(8, 112, 106, 0.4), transparent 60%),
    linear-gradient(135deg, var(--teal-700) 0%, var(--teal-500) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--gutter);
}

/* ============================================================ Masthead */
.masthead {
  padding: clamp(20px, 4vw, 56px) 4px clamp(24px, 4vw, 40px);
  color: rgba(255, 255, 255, 0.95);
}

.masthead-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  font-size: clamp(48px, 8vw, 88px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  color: rgba(255, 255, 255, 0.97);
}

.brand-sub {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: 'opsz' 14;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.005em;
  color: rgba(255, 255, 255, 0.62);
  margin-top: 8px;
}

.stats {
  display: flex;
  gap: 36px;
  align-items: baseline;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 36;
  line-height: 1;
  color: rgba(255, 255, 255, 0.96);
}

.stat-label {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
}

.stat-loading {
  font-style: italic;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.55);
}

/* ============================================================ Content surface */
.content {
  background: var(--paper);
  border-radius: 3px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 24px 60px rgba(5, 35, 38, 0.32),
    0 4px 12px rgba(5, 35, 38, 0.18);
  overflow: hidden;
  position: relative;
}

.content::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  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.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.55 0 0 0 0 0.45 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.6;
  mix-blend-mode: multiply;
}

/* ============================================================ Filter strip */
.filter-strip {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px;
  background: var(--paper-dim);
  border-bottom: 1px solid var(--border-strong);
  z-index: 2;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-row.preset-row {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group.flex-grow { flex: 1 1 240px; }

.filter-group.divider {
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.filter-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  white-space: nowrap;
}

.filter-value {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  min-width: 28px;
}

.search-input {
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(8, 112, 106, 0.14);
}

.search-input::placeholder {
  color: var(--ink-muted);
  font-style: italic;
}

/* Selects */
.filter-select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 26px 6px 10px;
  background: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237A7F7E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  min-width: 130px;
  max-width: 200px;
  transition: border-color 0.12s;
  appearance: none;
  -webkit-appearance: none;
}

.filter-select:focus {
  border-color: var(--teal-500);
}

.filter-select:hover {
  border-color: var(--ink-soft);
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 3px;
  background: var(--border-strong);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--teal-700);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Price inputs */
.price-prefix {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.price-input {
  font-family: var(--font-body);
  font-size: 13px;
  width: 56px;
  padding: 5px 6px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--ink);
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.price-input:focus {
  border-color: var(--teal-500);
}

/* Toggles */
.toggle-group { gap: 16px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 2px;
  background: var(--paper);
  position: relative;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}

.toggle input[type="checkbox"]:checked {
  background: var(--teal-700);
  border-color: var(--teal-700);
}

.toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 7px;
  border: solid var(--paper);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.btn-ghost {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.12s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--paper);
  border-color: var(--teal-500);
  color: var(--teal-700);
}

/* Preset buttons */
.preset-btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.015em;
  padding: 7px 16px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.preset-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(5, 35, 38, 0.12);
}

.preset-btn.donate:hover {
  background: var(--rust-bg);
  border-color: var(--rust-bd);
  color: var(--rust-700);
}

.preset-btn.sell:hover {
  background: var(--gold-bg);
  border-color: var(--gold-bd);
  color: var(--gold-700);
}

.preset-btn.keep:hover {
  background: var(--forest-bg);
  border-color: var(--forest-bd);
  color: var(--forest-700);
}

/* ============================================================ Catalog table */
.catalog {
  position: relative;
  background: var(--paper);
  overflow-x: auto;
  z-index: 2;
}

.catalog-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.catalog-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: left;
  padding: 14px 18px;
  color: var(--ink-muted);
  background: var(--paper-dim);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.catalog-table thead th.col-conf,
.catalog-table thead th.col-kindle,
.catalog-table thead th.col-oop,
.catalog-table thead th.col-tags,
.catalog-table thead th.col-price {
  text-align: center;
}

.catalog-table tbody tr { transition: background-color 0.1s; }
.catalog-table tbody tr:hover { background: rgba(8, 112, 106, 0.04); }
.catalog-table tbody tr.pending { opacity: 0.5; pointer-events: none; }

.catalog-table tbody td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.title-cell { max-width: 360px; }

.title-text {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: 'opsz' 14;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.3;
}

.title-illegible { font-style: italic; color: var(--ink-muted); font-weight: 400; }

.title-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 3px;
  font-style: italic;
  font-family: var(--font-body);
}

.author-cell {
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 180px;
  font-feature-settings: 'kern';
}

.conf-cell {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  text-align: center;
  font-weight: 500;
}

.conf-high { color: var(--forest-700); }
.conf-mid  { color: var(--gold-700); }
.conf-low  { color: var(--rust-700); }

.kindle-cell { text-align: center; font-size: 14px; line-height: 1; }
.kindle-strong { color: var(--teal-700); font-size: 14px; }
.kindle-soft   { color: var(--ink-muted); opacity: 0.6; font-size: 14px; }

.oop-cell { text-align: center; white-space: nowrap; }

.oop-badge {
  display: inline-block;
  padding: 2px 7px;
  background: var(--rust-bg);
  border: 1px solid var(--rust-bd);
  color: var(--rust-700);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
  font-feature-settings: 'kern';
}

.tag-cell { text-align: center; padding: 8px 6px; white-space: nowrap; }

/* ============================================================ Tag pills */
.tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  min-width: 60px;
  font-feature-settings: 'kern';
}

.tag-pill:hover {
  border-color: var(--ink-soft);
  color: var(--ink-soft);
  transform: translateY(-1px);
}

.tag-pill.active { font-weight: 600; }

.tag-pill.donate.active {
  background: var(--rust-bg);
  border-color: var(--rust-bd);
  color: var(--rust-700);
}

.tag-pill.sell.active {
  background: var(--gold-bg);
  border-color: var(--gold-bd);
  color: var(--gold-700);
}

.tag-pill.keep.active {
  background: var(--forest-bg);
  border-color: var(--forest-bd);
  color: var(--forest-700);
}

/* ============================================================ Enrichment cells */
.price-cell {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  white-space: nowrap;
  font-feature-settings: 'kern', 'tnum';
}

.price-empty { color: var(--ink-muted); opacity: 0.5; }

.subcat-cell, .synopsis-cell, .categories-cell {
  font-size: 12.5px;
  color: var(--ink-soft);
}

.subcat-cell {
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 14;
}

.subcat-cell .ellipsis { max-width: 140px; }
.synopsis-cell { color: var(--ink-soft); }
.synopsis-cell .ellipsis { max-width: 280px; }
.categories-cell { color: var(--ink-muted); font-size: 11.5px; }
.categories-cell .ellipsis { max-width: 180px; }

.ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placeholder {
  color: var(--ink-muted);
  opacity: 0.45;
  font-style: normal;
}

.notes-cell {
  font-size: 12.5px;
  color: var(--ink-muted);
  font-style: italic;
  max-width: 200px;
  font-family: var(--font-body);
}

.empty-state {
  text-align: center !important;
  padding: 80px 20px !important;
  font-style: italic;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 16px;
}

/* ============================================================ Footer */
.page-footer {
  padding: 24px 4px 8px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.footer-dot {
  margin: 0 12px;
  opacity: 0.5;
}

/* ============================================================ Responsive */
@media (max-width: 880px) {
  .masthead-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats { gap: 24px; }

  .filter-group.divider {
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px dashed var(--border);
    width: 100%;
  }

  .filter-select { max-width: none; flex: 1; min-width: 100px; }

  .toggle-group { flex-wrap: wrap; }
}
