/* Base design system for the Baldwin City Historical Archive.
   Palette built around what both org logos already share (warm orange,
   dark warm brown/grey text) plus BCPL's teal as a secondary accent --
   the logos themselves are never recolored, this just picks colors that
   sit well alongside them. See issue #30.

   Section backgrounds and borders were originally a warm cream/tan tint
   of the orange -- felt too one-note ("peachy"). Retinted as a light
   teal-gray instead, derived from --color-accent, so the teal actually
   reads as a second color in the palette rather than just link text. */

:root {
  --color-primary: #d9720c;
  --color-primary-dark: #a85708;
  --color-primary-darker: #8f4a07;
  --color-accent: #1b7a8c;
  --color-text: #3a3229;
  --color-text-muted: #6b6258;
  --color-bg: #ffffff;
  --color-bg-alt: #ddebee;
  --color-border: #b9d6d9;
  --color-border-dark: #8dbdc6;

  --font-heading: Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --container-width: 1400px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  color: var(--color-text);
  line-height: 1.2;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */

.site-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 3px solid var(--color-primary);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  color: var(--color-text);
}

.site-search {
  /* Grows to fill the space between brand and nav, so it visually sits
     in the middle of the header rather than needing absolute
     positioning -- capped so it doesn't stretch absurdly wide. */
  flex: 1 1 240px;
  max-width: 480px;
  margin: 0 auto;
}

.site-search input {
  width: 100%;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--color-text);
}

.site-search input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.site-header__brand:hover {
  text-decoration: none;
}

.site-header__logo {
  height: 56px;
  width: auto;
}

.site-header__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: bold;
}

.site-nav a {
  margin-left: 1.25rem;
  color: var(--color-text);
  font-weight: 600;
}

.site-nav a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

/* Main content area */

main {
  min-height: 60vh;
  /* Fully fluid (no cap) briefly, but on a wide monitor auto-fill grid
     columns (.card-grid) just stretch to fill the space -- cards ended
     up enormous. A cap is needed either way; this one's wider than the
     original 1100px so wide screens still see more content per row. */
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* Footer */

.site-footer {
  margin-top: 3rem;
  padding: 2rem 1.5rem;
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.site-footer p {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.site-footer__logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.site-footer__logos img {
  height: 70px;
  width: auto;
}

@media (max-width: 600px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav a {
    margin-left: 0;
    margin-right: 1rem;
  }
}

/* Homepage */

.intro {
  margin-bottom: 1.5rem;
}

.intro p {
  color: var(--color-text-muted);
  max-width: 65ch;
}

.featured-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .featured-grid {
    grid-template-columns: 1fr;
  }
}

/* Featured Collection and Featured Item are where a visitor's attention
   should go first -- image on the left, text on the right, taller than
   a plain thumbnail -- versus Recently Added below, deliberately
   shrunk so it reads as secondary. */
.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.25rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
}

.hero__media {
  flex: 0 0 260px;
}

.hero__content {
  flex: 1 1 260px;
}

.hero__media img {
  /* max-width/height only (no fixed width/height, no object-fit) --
     the image always keeps its real aspect ratio and is never cropped
     or stretched, just scaled down to fit within the box. */
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 4px;
}

.hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  color: var(--color-primary);
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.hero__content h2 {
  margin: 0 0 0.75rem;
}

.hero__content h2 a {
  color: var(--color-text);
}

.hero__description {
  /* Reserves the same vertical space whether or not there's real text --
     the Featured Item card doesn't always have a description, and
     without this its "View item" button floats higher than Featured
     Collection's "View collection" button next to it. */
  min-height: 1.6em;
}

.hero__content h2 a:hover {
  text-decoration: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.card {
  display: block;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--color-border-dark);
  text-decoration: none;
}

/* Browse page's live facet filtering (#57) toggles this rather than
   removing elements -- keeps the server-rendered grouping/counts intact,
   just hides what doesn't currently match. */
.is-hidden {
  display: none;
}

.card__thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.card__title {
  font-size: 1rem;
  margin: 0.75rem 0.75rem 0.25rem;
}

.card__meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0.75rem 0.75rem;
}

.placeholder-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem;
  border: 1px dashed var(--color-border);
}

.placeholder-thumb--hero {
  width: 260px;
  height: 240px;
  max-width: 100%;
  border-radius: 4px;
}

/* Recently added items is secondary to Featured Collection/Item above --
   shrunk deliberately so it reads as supporting content, not competing
   for attention. Scoped to .recent-items so the browse page's own
   .card-grid (same markup/classes, via the shared item-card partial)
   stays at normal size. */
.recent-items {
  margin-top: 2rem;
}

.recent-items h2 {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.recent-items .card-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.recent-items .card__thumb,
.recent-items .placeholder-thumb {
  height: 110px;
  font-size: 0.75rem;
}

.recent-items .card__title {
  font-size: 0.85rem;
  margin: 0.5rem 0.5rem 0.2rem;
}

.recent-items .card__meta {
  font-size: 0.75rem;
  margin: 0 0.5rem 0.5rem;
}

/* --color-primary against white text is under 3.5:1 -- not enough contrast
   for real text (WCAG AA needs 4.5:1). --color-primary-dark clears 5:1. */
/* border/font/cursor resets matter here since .button is applied to real
   <button> elements in the admin forms, not just <a> links -- without
   them the browser's own default button chrome (border, shadow, system
   font) shows through underneath. */
.button {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--color-primary-dark);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  background: var(--color-primary-darker);
  text-decoration: none;
}

/* Item page */

.item__layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}

.item__media img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.placeholder-thumb--item {
  height: 320px;
  border-radius: 8px;
}

.item__description {
  font-size: 1.05rem;
  margin: 0 0 1.5rem;
}

.item__meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin: 0 0 1.5rem;
}

.item__meta dt {
  font-weight: 600;
  color: var(--color-text-muted);
}

.item__meta dd {
  margin: 0;
}

.item__meta-empty {
  color: var(--color-text-muted);
}

.item__subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--color-text);
}

@media (max-width: 700px) {
  .item__layout {
    grid-template-columns: 1fr;
  }
}

/* Browse page */

.item-count {
  color: var(--color-text-muted);
  margin-top: -0.5rem;
}

.collection-group {
  margin-bottom: 3rem;
}

.collection-group__header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-primary);
}

.collection-group__header h2 {
  margin: 0 0 0.25rem;
}

.collection-group__header .item-count {
  margin: 0;
}

.collection-group__cover {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Search page */

.search-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-top: 1.5rem;
}

.search-facets {
  flex: 0 0 220px;
}

.search-facets h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}

.search-facets h3:first-of-type {
  margin-top: 0;
}

/* Subjects filter (subject-filter.js) -- deliberately minimal: just an
   input, empty by default. Suggestions/applied chips only appear once
   there's something to show, never a standing list of every value. */
.subject-filter__input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
}

.subject-filter__suggestions {
  margin-top: 0.5rem;
}

.subject-filter__suggestion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: none;
  background: none;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
}

.subject-filter__suggestion:hover {
  background: var(--color-bg-alt);
}

.subject-filter__count {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* The Date facet (hierarchicalMenu) is a stock InstantSearch widget --
   its count comes styled as a blue-tinted pill badge from the CDN theme
   (algolia-min.css), which doesn't match this site's palette at all.
   Overridden to the same plain, muted-text style already used for the
   subject filter's own counts above, so both read consistently.

   Scoped to .search-facets (not just the bare class) so this wins on
   specificity regardless of load order -- the theme's own stylesheet
   is linked from inside the page body (search.html/list.html), after
   this site's own style.css in <head>, so an equal-specificity rule
   here would otherwise lose the cascade to the theme's.

   flex/space-between on .ais-HierarchicalMenu-link didn't actually
   line the count up with the subject filter's, even confirmed applied
   via computed styles -- the real DOM has an extra unstyled <div>
   between <li> and <a> (confirmed via a live DOM dump) that flex
   through an unknown chain of ancestors wasn't reliably resolving.
   Absolute-positioning the count against the <li> itself sidesteps
   that entirely -- <li> is the one element in this chain confirmed to
   span the sidebar's full width.

   `right` is 0.5rem, not 0 -- confirmed via getBoundingClientRect() in
   a real browser that .subject-filter__suggestion's own right padding
   (0.4rem 0.5rem) puts its count 8px left of the sidebar's true edge,
   so right:0 here overshot past where the subject counts actually
   sit. Not a guess this time; measured the exact 8px gap directly. */
.search-facets .ais-HierarchicalMenu-item {
  position: relative !important;
  display: block !important;
  width: 100% !important;
}

.search-facets .ais-HierarchicalMenu-count {
  position: absolute !important;
  right: 0.5rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  padding: 0;
  background: none;
  border-radius: 0;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.subject-filter__empty {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.subject-filter__applied {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tag--removable {
  border: none;
  cursor: pointer;
  background: var(--color-primary-dark);
  color: #ffffff;
  font: inherit;
}

.search-results {
  flex: 1;
  min-width: 0;
}

.hit {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.hit:hover {
  text-decoration: none;
  background: var(--color-bg-alt);
}

.hit__thumb {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.hit__body h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.hit__body p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

@media (max-width: 700px) {
  .search-layout {
    flex-direction: column;
  }

  .search-facets {
    flex: none;
    width: 100%;
  }
}
