.surface-hero::after {
  --surface-hero-watermark: "Bibliographie";
}

/* ============ FILTER / SEARCH TOOLBAR ============ */
.toolbar {
  background: var(--background-color-muted);
  border-bottom: 1px solid var(--surface-primary-foreground-strong);
  padding: 1.2rem 4rem;
  position: sticky;
  top: var(--header-h);
  z-index: 100;
}
.toolbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Search input */
.bib-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.bib-search-wrap svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-color-subtle);
  pointer-events: none;
}
.bib-search {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.4rem;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  border: 1px solid var(--surface-primary-foreground-strong);
  border-radius: 2px;
  background: var(--background-color);
  color: var(--text-color);
  outline: none;
  transition: border-color 0.2s;
}
.bib-search::placeholder {
  color: var(--text-color-subtle);
}
.bib-search:focus {
  border-color: var(--secondary-color);
}

/* Filter dropdowns */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.filter-select {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--text-color-muted);
  border: 1px solid var(--surface-primary-foreground-strong);
  border-radius: 2px;
  background: var(--background-color);
  padding: 0.5rem 2rem 0.5rem 0.7rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235C5246' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
.filter-select:focus {
  border-color: var(--secondary-color);
}

/* View toggle */
.view-toggle {
  display: flex;
  margin-left: auto;
  border: 1px solid var(--surface-primary-foreground-strong);
  border-radius: 2px;
  overflow: hidden;
}
.view-btn {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 0.85rem;
  background: var(--background-color);
  color: var(--text-color-muted);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.view-btn + .view-btn {
  border-left: 1px solid var(--surface-primary-foreground-strong);
}
.view-btn.active {
  background: var(--surface-primary-background);
  color: var(--background-color);
}
.view-btn svg {
  width: 13px;
  height: 13px;
}

/* Active filters */
.active-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.active-filter {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--surface-primary-background);
  background: rgba(26, 42, 66, 0.08);
  border: 1px solid rgba(26, 42, 66, 0.15);
  padding: 0.25rem 0.6rem;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.active-filter button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-color);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}
.filter-clear {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  color: var(--primary-color);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  letter-spacing: 0.04em;
}

/* ============ LETTER BAR (A-Z by author view) ============ */
.letter-bar {
  background: var(--surface-primary-background);
  padding: 0.6rem 4rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
  justify-content: center;
  border-bottom: 1px solid rgba(201, 150, 12, 0.2);
  position: sticky;
  top: calc(var(--header-h) + 52px);
  z-index: 99;
}
.letter-link {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(245, 240, 232, 0.45);
  text-decoration: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  border-radius: 2px;
}
.letter-link:hover,
.letter-link.active {
  color: var(--secondary-color);
  background: rgba(201, 150, 12, 0.1);
}
.letter-link.empty {
  opacity: 0.25;
  pointer-events: none;
}
.letter-count {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  color: rgba(245, 240, 232, 0.3);
  margin-left: auto;
  padding-left: 1rem;
  letter-spacing: 0.04em;
}

/* ============ CONTENT AREA ============ */
.bib-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 4rem 4rem;
}

/* Letter section */
.letter-section {
  padding-top: 2.5rem;
}
.letter-heading {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.85rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--secondary-color);
}
.letter-char {
  font-family: "Playfair Display", serif;
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--secondary-color);
  line-height: 1;
}
.letter-meta {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  color: var(--text-color-subtle);
  letter-spacing: 0.06em;
}

/* ============ BIBLIOGRAPHY ENTRY ROW ============ */
.bib-entry {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid rgba(200, 184, 154, 0.4);
  align-items: start;
  transition: background 0.2s;
}
.bib-entry:hover {
  background: rgba(201, 150, 12, 0.03);
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Cover thumbnail */
.bib-cover {
  width: 72px;
  height: 100px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--surface-primary-foreground-strong);
  grid-row: 1 / 3;
  flex-shrink: 0;
}
.bib-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(15%) contrast(1.05);
}
.bib-cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface-primary-background);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(201, 150, 12, 0.35);
}

/* Main info */
.bib-main {
  min-width: 0;
}
.bib-title-line {
  font-family: "EB Garamond", serif;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text-color);
}
.bib-title-line a {
  text-decoration: none;
  color: inherit;
}
.bib-title-line a:hover {
  color: var(--primary-color);
}
.bib-title-line em {
  font-style: italic;
  font-weight: 500;
}
.bib-author {
  font-weight: 600;
}
.bib-pub {
  color: var(--text-color-muted);
  font-size: 0.95rem;
}
.bib-meta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}
.bib-type-badge {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 2px;
  display: inline-block;
}
.bib-type-livre {
  background: rgba(26, 42, 66, 0.1);
  color: var(--surface-primary-background);
}
.bib-type-article {
  background: rgba(184, 40, 28, 0.08);
  color: var(--primary-color);
}
.bib-type-guide,
.bib-type-web {
  background: var(--badge-bg-personnage);
  color: var(--bib-type-guide-text);
}
.bib-type-pamphlet,
.bib-type-archives {
  background: var(--badge-bg-theme);
  color: var(--badge-text-theme);
}
.bib-type-catalogue,
.bib-type-audiovisuel {
  background: var(--badge-bg-adresse);
  color: var(--badge-text-adresse);
}
.bib-type-revue,
.bib-type-encyclopedie {
  background: var(--bib-type-revue-bg);
  color: var(--bib-type-revue-text);
}

.bib-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.bib-tag {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--text-color-muted);
  background: var(--bib-tag-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  text-decoration: none;
  transition: all 0.2s;
}
.bib-tag:hover {
  background: var(--bib-tag-hover-bg);
  color: var(--secondary-color);
}
.bib-tag-period {
  background: var(--bib-tag-period-bg);
  color: var(--badge-text-lieu);
}
.bib-tag-period:hover {
  background: var(--bib-tag-period-hover-bg);
}

/* Right column: citations + links */
.bib-aside {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  padding-top: 0.15rem;
}
.bib-cite-count {
  font-family: "Playfair Display", serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--secondary-color);
  line-height: 1;
}
.bib-cite-label {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-color-subtle);
  display: block;
  margin-top: 0.1rem;
}
.bib-online-links {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bib-online-link {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--surface-primary-background-muted);
  text-decoration: none;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(44, 74, 110, 0.2);
  border-radius: 2px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.bib-online-link:hover {
  border-color: var(--surface-primary-background-muted);
  background: rgba(44, 74, 110, 0.06);
}
.bib-online-link svg {
  width: 10px;
  height: 10px;
}

/* ============ SUBJECT/THEME VIEW ============ */
.subject-view {
  display: none;
}
.subject-view.active {
  display: block;
}
.alpha-view.active {
  display: block;
}
.alpha-view {
  display: none;
}

.subject-group {
  padding-top: 2.5rem;
}
.subject-heading {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-color);
}
.subject-name {
  font-family: "Playfair Display", serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.2;
}
.subject-count {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  color: var(--text-color-subtle);
  letter-spacing: 0.06em;
}
.subject-desc {
  font-family: "EB Garamond", serif;
  font-size: 0.95rem;
  color: var(--text-color-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
  max-width: 680px;
}

/* ============ CITATIONS VIEW (ranked by citation count) ============ */
.citations-view {
  display: none;
}
.citations-view.active {
  display: block;
}

.citations-intro {
  padding-top: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--secondary-color);
  margin-bottom: 0.5rem;
}
.citations-intro-title {
  font-family: "Playfair Display", serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.citations-intro-desc {
  font-family: "EB Garamond", serif;
  font-size: 0.95rem;
  color: var(--text-color-muted);
  line-height: 1.7;
  max-width: 680px;
}

/* Ranked entry — override grid to include rank column */
.citations-view .bib-entry {
  grid-template-columns: 52px 72px 1fr auto;
}
.citations-view .bib-entry .bib-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0.3rem;
}
.bib-rank {
  display: none;
} /* Hidden in other views */
.bib-rank-num {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-color-subtle);
  line-height: 1;
}
.bib-rank-citations {
  font-family: "Playfair Display", serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--secondary-color);
  line-height: 1;
  margin-top: 0.15rem;
}
.bib-rank-label {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-color-subtle);
  margin-top: 0.1rem;
}

/* In citations view, hide the aside citation count (it's now in the rank column) */
.citations-view .bib-aside .bib-cite-count,
.citations-view .bib-aside .bib-cite-label {
  display: none;
}
/* But keep online links visible */
.citations-view .bib-aside {
  justify-content: flex-start;
  padding-top: 0.5rem;
}

/* Top 3 get gold accent */
.citations-view .bib-entry.rank-top .bib-rank-num {
  color: var(--secondary-color);
}
.citations-view .bib-entry.rank-top {
  background: rgba(201, 150, 12, 0.03);
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .toolbar {
    padding: 1rem 1.2rem;
  }
  .toolbar-inner {
    gap: 0.6rem;
  }
  .bib-search-wrap {
    min-width: 100%;
    max-width: 100%;
    order: -1;
  }
  .filter-group {
    width: 100%;
  }
  .filter-select {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
  }
  .view-toggle {
    margin-left: 0;
  }

  .letter-bar {
    padding: 0.5rem 1rem;
    gap: 0.1rem;
    top: calc(var(--header-h) + 68px);
  }
  .letter-link {
    width: 24px;
    height: 26px;
    font-size: 0.85rem;
  }
  .letter-count {
    display: none;
  }

  .bib-content {
    padding: 0 1.2rem 3rem;
  }
  .letter-char {
    font-size: 2.5rem;
  }

  .bib-entry {
    grid-template-columns: 56px 1fr;
    gap: 0 1rem;
  }
  .citations-view .bib-entry {
    grid-template-columns: 44px 56px 1fr;
  }
  .citations-view .bib-entry .bib-rank {
    display: flex;
  }
  .bib-rank-citations {
    font-size: 1.4rem;
  }
  .bib-cover {
    width: 56px;
    height: 78px;
  }
  .bib-aside {
    grid-column: 2;
    text-align: left;
    align-items: flex-start;
    flex-direction: row;
    gap: 1rem;
    margin-top: 0.5rem;
  }
  .bib-cite-count {
    font-size: 1.1rem;
  }

}

@media (max-width: 540px) {
  .bib-entry {
    grid-template-columns: 1fr;
  }
  .bib-cover {
    grid-row: auto;
    width: 100%;
    height: 60px;
    display: none;
  }
  .bib-entry.has-cover .bib-cover {
    display: block;
    width: 56px;
    height: 78px;
    float: left;
    margin-right: 0.85rem;
    margin-bottom: 0.25rem;
  }
  .bib-aside {
    grid-column: 1;
  }
  .bib-title-line {
    font-size: 0.95rem;
  }
  .bib-meta-row {
    margin-top: 0.4rem;
  }

  /* Citations view on mobile: rank + main info, no cover column */
  .citations-view .bib-entry {
    grid-template-columns: 44px 1fr;
  }
  .citations-view .bib-entry .bib-rank {
    display: flex;
  }
  .citations-view .bib-cover {
    display: none;
  }
  .citations-view .bib-entry.has-cover .bib-cover {
    display: none;
  }
  .citations-view .bib-aside {
    grid-column: auto;
  }
  .bib-rank-citations {
    font-size: 1.2rem;
  }
}
