/* Discrete components. Names use the .c- prefix to avoid colliding with
   any leftover Bootstrap classes during the migration. */

/* ---------- Buttons ---------- */

.c-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--fs-100);
  line-height: 1;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
}

.c-button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.c-button--ghost {
  background: transparent;
  color: var(--ink);
}

.c-button--ghost:hover {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.c-button--accent {
  background: var(--accent);
  border-color: var(--accent);
}

.c-button--accent:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

/* ---------- Tag chip ---------- */

.c-tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-75);
  font-family: var(--font-body);
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  letter-spacing: var(--ls-normal);
  transition: background var(--transition-fast),
              color var(--transition-fast);
}

.c-tag:hover {
  background: var(--accent);
  color: var(--bg);
}

.c-tag--ghost {
  background: transparent;
  color: var(--muted);
  border: var(--hairline);
}

.c-tag--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.c-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
}

.c-tag-list li {
  margin: 0;
}

/* ---------- Search input ---------- */

.c-search {
  position: relative;
  width: 100%;
  max-width: 540px;
}

.c-search__input {
  width: 100%;
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-8);
  font-family: var(--font-body);
  font-size: var(--fs-125);
  background: var(--bg);
  border: var(--hairline);
  border-radius: var(--radius-sm);
}

.c-search__input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

.c-search__icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  width: 1.125rem;
  height: 1.125rem;
}

/* ---------- Library card ---------- */

.c-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  transition: transform var(--transition-base);
}

.c-card:hover {
  color: var(--ink);
}

.c-card:hover .c-card__title {
  color: var(--accent);
}

.c-card__cover {
  aspect-ratio: 3 / 4;
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
  border: var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.c-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Type-driven fallback when there's no cover image */
.c-card__cover--type {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 25%, var(--rule));
}

/* Large display initial inside type-driven covers — visual weight without
   re-printing the title (which now lives below all card types). */
.c-card__cover-mark {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 500;
  line-height: 1;
  color: color-mix(in srgb, var(--accent) 30%, transparent);
  align-self: end;
}

.c-card__cover-author {
  font-family: var(--font-body);
  font-size: var(--fs-75);
  font-style: italic;
  color: var(--muted);
}

.c-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-150);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
  transition: color var(--transition-fast);
  /* Clamp to 3 lines so meta stays at predictable Y position across the row */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.c-card__meta {
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  /* Clamp meta to 2 lines so long institutional authors don't blow out the
     row height and break grid alignment downstream. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Provenance line (article header metadata) ---------- */

.c-provenance {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* Trailing separators rather than leading: when the line wraps, the orphan
   "·" stays at the END of the previous line (reads as a continuation marker)
   instead of orphaning at the start of the next line. */
.c-provenance > *:not(:last-child)::after {
  content: "·";
  margin-left: var(--space-3);
  color: var(--rule);
}

/* ---------- Pull quote ---------- */

.c-pullquote {
  margin: var(--space-7) 0;
  padding: var(--space-6) 0;
  border-block: var(--hairline);
  font-family: var(--font-display);
  font-size: var(--fs-200);
  font-style: italic;
  line-height: var(--lh-snug);
  color: var(--ink);
  text-wrap: balance;
}

.c-pullquote__attr {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--fs-75);
  font-style: normal;
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* ---------- Sources block (entry CTAs) ---------- */

.c-sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block: var(--space-6);
}

/* ---------- Breadcrumb ---------- */

.c-breadcrumb {
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-5);
}

.c-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.c-breadcrumb a:hover {
  color: var(--accent);
}

/* ---------- Article header (entry / blog post) ---------- */

.c-article-header {
  margin-bottom: var(--space-7);
  padding-bottom: var(--space-5);
  border-bottom: var(--hairline);
}

/* When a book entry has a cover, lay out cover + body side-by-side at
   tablet+; stack on mobile. */
.c-article-header--with-cover {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 40rem) {
  .c-article-header--with-cover {
    grid-template-columns: minmax(140px, 200px) 1fr;
    align-items: start;
  }
}

.c-article-header__cover {
  display: block;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
  max-width: 200px;
  transition: transform var(--transition-base);
}

.c-article-header__cover:hover {
  transform: translateY(-2px);
}

.c-article-header__cover img {
  width: 100%;
  height: auto;
  display: block;
}

.c-article-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  margin-bottom: var(--space-4);
  text-wrap: balance;
}

.c-article-header__dek {
  font-family: var(--font-body);
  font-size: var(--fs-150);
  color: var(--muted);
  margin-bottom: var(--space-4);
  max-width: var(--measure-prose);
  text-wrap: pretty;
}

/* ---------- Editor's note (Tim's commentary on a library entry) ---------- */

.c-editors-note {
  margin-block: var(--space-7);
  padding: var(--space-5);
  border-left: 2px solid var(--accent);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
}

.c-editors-note__label {
  display: block;
  font-size: var(--fs-75);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: var(--space-3);
}

/* ---------- Post list (blog landing) ---------- */

.c-post-list {
  list-style: none;
  padding: 0;
}

.c-post-list__item {
  padding-block: var(--space-6);
  border-bottom: var(--hairline);
}

.c-post-list__item:first-child {
  padding-top: 0;
}

.c-post-list__title {
  font-family: var(--font-display);
  font-size: var(--fs-300);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
}

.c-post-list__title a {
  color: var(--ink);
  text-decoration: none;
}

.c-post-list__title a:hover {
  color: var(--accent);
}

.c-post-list__dek {
  font-size: var(--fs-125);
  color: var(--muted);
  margin-top: var(--space-3);
  max-width: var(--measure-prose);
}

.c-post-list__meta {
  margin-top: var(--space-3);
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* ---------- Search results ---------- */

.search-meta {
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  margin-block: var(--space-5) var(--space-3);
}

.search-empty,
.search-loading {
  margin-top: var(--space-5);
  color: var(--muted);
  font-style: italic;
}

.search-loading::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  vertical-align: baseline;
  animation: search-loading-dots 1.4s steps(4, end) infinite;
}

@keyframes search-loading-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
  .search-loading::after {
    animation: none;
    content: "…";
  }
}

.search-results {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-result {
  padding-block: var(--space-5);
  border-bottom: var(--hairline);
}

.search-result:first-child { padding-top: 0; }

.search-result__title {
  font-family: var(--font-display);
  font-size: var(--fs-200);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  text-decoration: none;
  color: var(--ink);
  text-wrap: balance;
  display: inline-block;
}

.search-result__title:hover { color: var(--accent); }

.search-result__meta {
  margin-top: var(--space-2);
  font-size: var(--fs-75);
  color: var(--muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.search-result__snippet {
  margin-top: var(--space-3);
  color: var(--ink);
  max-width: var(--measure-prose);
}

.search-result__snippet mark {
  background: var(--accent-bg);
  color: var(--accent-ink);
  padding: 0 0.1em;
}

/* ---------- Hero (homepage) ---------- */

.c-hero {
  padding-block: var(--space-7) var(--space-8);
}

.c-hero__title {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
  /* Constrain at desktop sizes so the title doesn't span 1400px+ */
  max-width: 18ch;
}

.c-hero__tagline {
  font-family: var(--font-body);
  font-size: var(--fs-150);
  color: var(--muted);
  max-width: 36ch;
  margin-top: var(--space-4);
  text-wrap: pretty;
}

.c-hero__search {
  margin-top: var(--space-6);
  max-width: 640px;
}
