/* ──────────────────────────────────────────────────────────
   Analyseize Library — v2 polished editorial
   Brand palette by default (set via data-palette="brand" on <html>).
   ────────────────────────────────────────────────────────── */

/* Hide native input number spinners */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ─── 0 · Hero ────────────────────────────────────────────── */
.lib-hero {
  padding: 72px 0 64px;
  position: relative;
  overflow: hidden;
}
.lib-hero__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 80px;
  align-items: end;
}
.lib-hero__title {
  font-family: var(--font-display);
  font-size: clamp(48px, 6.4vw, 104px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.98;
  margin: 0;
  color: var(--ink-900);
}
.lib-hero__title em {
  font-style: italic;
  color: var(--forest-700);
}
.lib-hero__side {
  padding-bottom: 16px;
}
.lib-hero__side p {
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 24px;
  color: var(--ink-900);
  max-width: 460px;
}
.lib-hero__links {
  display: flex;
  gap: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.lib-hero__links a {
  font-size: 13px;
}

/* ─── 1 · Stats ribbon ───────────────────────────────────── */
.lib-stats {
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  padding: 44px 0;
  background: linear-gradient(180deg, var(--sand-100) 0%, var(--bg) 100%);
}
.lib-stats__row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}
.lib-stats__cell {
  padding: 0 28px;
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lib-stats__cell:first-child {
  padding-left: 0;
  border-left: 0;
}
.lib-stats__value {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.022em;
  color: var(--ink-900);
}
.lib-stats__suffix {
  color: var(--terracotta-600);
  font-size: 0.65em;
}
.lib-stats__label {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}

/* ─── 2 · Featured flagship ──────────────────────────────── */
.lib-featured {
  padding: 96px 0 80px;
}
.lib-featured__grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 64px;
  align-items: stretch;
}

.lib-featured__card {
  display: block;
  padding: 44px 48px;
  background: var(--ink-900);
  color: var(--ivory-50);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  text-decoration: none;
}
.lib-featured__tags {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.lib-featured__card h2 {
  font-family: var(--font-display);
  font-size: clamp(36px, 4vw, 56px);
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.06;
  margin: 0 0 24px;
  color: var(--ivory-50);
}
.lib-featured__card h2 em {
  font-style: italic;
  color: var(--ochre-500);
}
.lib-featured__abstract {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(247, 243, 236, 0.78);
  margin: 0 0 32px;
  max-width: 540px;
}
.lib-featured__meta {
  display: flex;
  gap: 28px;
  font-size: 12px;
  color: rgba(247, 243, 236, 0.6);
  margin-bottom: 28px;
  font-family: var(--font-mono);
  flex-wrap: wrap;
}
.lib-featured__meta .k {
  color: var(--ochre-500);
}
.lib-featured__ctas {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.lib-featured__ctas .btn--ghost {
  color: var(--ivory-50);
  border-color: rgba(247, 243, 236, 0.3);
}
.lib-featured__ctas .btn--ghost:hover {
  background: var(--ivory-50);
  color: var(--ink-900);
}
.lib-featured__year-mark {
  position: absolute;
  right: -10px;
  top: -30px;
  font-family: var(--font-display);
  font-size: 240px;
  font-weight: 500;
  color: rgba(247, 243, 236, 0.04);
  pointer-events: none;
  letter-spacing: -0.04em;
  line-height: 1;
}

.lib-finding {
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  padding: 28px;
  display: flex;
  flex-direction: column;
}
.lib-finding__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--terracotta-600);
  margin-bottom: 8px;
}
.lib-finding h3 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.014em;
  margin: 0 0 18px;
}
.lib-finding h3 em {
  font-style: italic;
  color: var(--terracotta-600);
}
.lib-finding__caption {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
.lib-finding__chart {
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.lib-finding__footer {
  padding-top: 16px;
  margin-top: 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

/* Bright tags for dark surfaces */
.dark-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.85;
  border: 1px solid var(--ivory-50);
  color: var(--ivory-50);
  background: transparent;
}
.dark-tag--filled {
  background: var(--ochre-500);
  color: var(--ink-900);
  border-color: var(--ochre-500);
  opacity: 1;
}

/* ─── 3 · Sector browser ─────────────────────────────────── */
.lib-sectors {
  padding: 96px 0;
  background: var(--sand-100);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.lib-sectors__head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 16px;
}
.lib-sectors__head h2 {
  font-family: var(--font-display);
  font-size: clamp(36px, 3.8vw, 52px);
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.06;
  margin: 0;
  max-width: 740px;
}
.lib-sectors__head h2 em {
  font-style: italic;
  color: var(--forest-700);
}

.lib-sectors__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule-strong);
}
.sector-tile {
  background: var(--bg);
  color: var(--ink-900);
  padding: 24px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
  border: 0;
  position: relative;
  text-align: start;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.sector-tile.is-active {
  background: var(--ink-900);
  color: var(--ivory-50);
}
.sector-tile__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sector-tile__index {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.6;
  letter-spacing: 0.1em;
}
.sector-tile__count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 2px;
}
.sector-tile.is-active .sector-tile__count {
  color: var(--ochre-500);
  border-color: var(--ochre-500);
}
.sector-tile h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.18;
  margin: 8px 0 0;
}
.sector-tile__bottom { margin-top: auto; }
.sector-tile__eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  opacity: 0.6;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sector-tile__underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0;
  transition: width 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.sector-tile:hover .sector-tile__underline,
.sector-tile.is-active .sector-tile__underline { width: 100%; }
.sector-tile.is-active .sector-tile__underline { background: var(--ochre-500) !important; }

/* ─── 4 · Sticky filter bar ──────────────────────────────── */
.lib-filters {
  position: sticky;
  top: 68px;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: 0 1px 0 rgba(17, 32, 28, 0.04);
}
.lib-filters__row {
  padding: 18px 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--bg);
}
.search-input input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-900);
}
.search-input button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.dropdown {
  position: relative;
}
.dropdown__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-900);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.dropdown.is-active .dropdown__btn {
  background: var(--ink-900);
  color: var(--ivory-50);
  border-color: var(--ink-900);
}
.dropdown__label {
  opacity: 0.6;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.dropdown__value {
  font-weight: 500;
  flex: 1;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown__caret { transition: transform 0.15s; }
.dropdown.is-open .dropdown__caret { transform: rotate(180deg); }
.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(17, 32, 28, 0.12);
  padding: 4px;
  z-index: 40;
  max-height: 320px;
  overflow: auto;
  display: none;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__item {
  display: block;
  width: 100%;
  text-align: start;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-900);
  font-size: 13px;
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown__item.is-selected {
  background: var(--sand-100);
}

.year-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--bg);
}
.year-slider__label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.year-slider input[type=range] {
  flex: 1;
  accent-color: var(--terracotta-600);
  min-width: 60px;
}
.year-slider__value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-900);
  min-width: 32px;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  overflow: hidden;
}
.view-toggle button {
  padding: 8px 10px;
  background: var(--bg);
  color: var(--ink-900);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.view-toggle button.is-active {
  background: var(--ink-900);
  color: var(--ivory-50);
}

.lib-filters__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 14px;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
}
.lib-filters__count {
  letter-spacing: 0.06em;
}
.lib-filters__count .hi {
  color: var(--terracotta-600);
  font-weight: 600;
}
.lib-filters__count .dim {
  color: var(--muted);
}
.lib-filters__clear {
  background: transparent;
  border: 1px solid var(--rule-strong);
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--terracotta-600);
  cursor: pointer;
  font-family: var(--font-mono);
}

/* ─── 5 · Year strip ─────────────────────────────────────── */
.year-strip {
  padding: 32px 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.year-strip__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.14em;
}
.year-strip__bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.year-strip__bar {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: start;
  font-family: inherit;
  color: var(--ink-900);
}
.year-strip__bar.is-dim { opacity: 0.35; }
.year-strip__bar-track {
  height: 40px;
  display: flex;
  align-items: flex-end;
}
.year-strip__bar-fill {
  width: 100%;
  background: var(--ink-900);
  transition: background 0.15s, height 0.25s;
}
.year-strip__bar.is-dim .year-strip__bar-fill { background: var(--sand-200); }
.year-strip__bar.is-active .year-strip__bar-fill { background: var(--terracotta-600); }
.year-strip__bar-label {
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
}
.year-strip__bar.is-active .year-strip__bar-label {
  border-top-color: var(--terracotta-600);
  border-top-width: 2px;
  font-weight: 600;
}
.year-strip__bar-count {
  font-size: 11px;
  color: var(--muted);
}

/* ─── 6 · Results — grid view ────────────────────────────── */
.lib-results {
  padding: 56px 0 96px;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.pub-card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--rule);
  overflow: hidden;
  position: relative;
  text-decoration: none;
  color: var(--ink-900);
  transition: transform 0.2s var(--ease-std), box-shadow 0.2s, border-color 0.2s;
}
.pub-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(17, 32, 28, 0.10), 0 2px 6px rgba(17, 32, 28, 0.04);
  border-color: var(--rule-strong);
}
.pub-card__band {
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--sand-100);
  color: var(--ink-900);
}
.pub-card.is-flagship .pub-card__band {
  background: var(--ink-900);
  color: var(--ivory-50);
}
.pub-card__type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--terracotta-600);
}
.pub-card.is-flagship .pub-card__type { color: var(--ochre-500); }
.pub-card__tier {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
  letter-spacing: 0.06em;
}
.pub-card__body {
  padding: 24px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.pub-card h3 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.008em;
  line-height: 1.22;
  margin: 0;
  color: var(--ink-900);
}
.pub-card__abstract {
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pub-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.pub-card__meta .date {
  color: var(--ink-900);
  font-weight: 500;
}
.pub-card__footer {
  padding: 12px 22px 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
}
.pub-card__stats {
  display: flex;
  gap: 16px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.pub-card__stats .k {
  color: var(--ink-900);
}
.pub-card__read {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-900);
  font-weight: 500;
  transition: color 0.15s, transform 0.2s;
}
.pub-card:hover .pub-card__read {
  color: var(--terracotta-600);
  transform: translateX(3px);
}
.pub-card__accent {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--terracotta-600);
  transition: width 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.pub-card:hover .pub-card__accent { width: 100%; }

/* Cover thumbnail banner — sits above the type/tier band */
.pub-card__cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--sand-100);
  border-bottom: 1px solid var(--rule);
}
.pub-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease-std);
}
.pub-card:hover .pub-card__cover img { transform: scale(1.035); }
/* Flagship cards get a darker overlay so the dark band reads against the image */
.pub-card.is-flagship .pub-card__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17, 32, 28, 0) 55%, rgba(17, 32, 28, 0.18) 100%);
  pointer-events: none;
}

/* ─── 6b · Results — list view ───────────────────────────── */
.results-list {
  display: grid;
  gap: 0;
}
.pub-row {
  display: grid;
  grid-template-columns: 64px 100px 120px 1fr 140px 80px 24px;
  gap: 20px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--rule);
  align-items: center;
  color: var(--ink-900);
  background: transparent;
  text-decoration: none;
  transition: background 0.15s;
}
.pub-row:first-child { border-top: 1px solid var(--rule-strong); }
.pub-row:hover { background: var(--sand-100); }
.pub-row__thumb {
  width: 64px;
  height: 64px;
  overflow: hidden;
  background: var(--sand-100);
  border: 1px solid var(--rule);
  display: block;
}
.pub-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pub-row__thumb--placeholder {
  background: var(--sand-100);
}
.pub-row__date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.pub-row__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--sand-100);
  color: var(--ink-900);
  border: 1px solid var(--rule);
  width: max-content;
}
.pub-row__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.pub-row__sub {
  font-size: 12px;
  color: var(--muted);
}
.pub-row__n,
.pub-row__access {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.pub-row__arrow {
  color: var(--terracotta-600);
  transition: transform 0.2s;
}
.pub-row:hover .pub-row__arrow { transform: translateX(4px); }

/* ─── 7 · Empty state ───────────────────────────────────── */
.lib-empty {
  padding: 120px 0;
}
.lib-empty__inner {
  text-align: center;
}
.lib-empty h2 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.018em;
  margin: 0 0 12px;
}
.lib-empty h2 em {
  font-style: italic;
  color: var(--terracotta-600);
}
.lib-empty p {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 24px;
}

/* ─── Responsive collapses ──────────────────────────────── */
@media (max-width: 1180px) {
  .lib-filters__row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
  }
  .lib-filters__row > :first-child { grid-column: 1 / -1; }
  .lib-featured__grid { grid-template-columns: 1fr; gap: 24px; }
  .lib-stats__row { grid-template-columns: repeat(3, 1fr); row-gap: 24px; }
  .lib-stats__cell { padding-left: 0; padding-right: 20px; }
  .lib-stats__cell:first-child { padding-right: 20px; }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .lib-sectors__grid { grid-template-columns: repeat(2, 1fr); }
  .lib-hero__grid { grid-template-columns: 1fr; gap: 32px; }
}
@media (max-width: 720px) {
  .lib-filters__row { grid-template-columns: 1fr 1fr; }
  .lib-stats__row { grid-template-columns: repeat(2, 1fr); }
  .results-grid { grid-template-columns: 1fr; }
  .lib-sectors__grid { grid-template-columns: 1fr; }
  .pub-row { grid-template-columns: 1fr; gap: 6px; padding: 16px 12px; }
  .pub-row__date,
  .pub-row__n,
  .pub-row__access { order: 2; }
  .pub-row__arrow { display: none; }
}
