/* JB Digi-Lib — editorial library theme */
:root {
  --primary: #1f4d3f;          /* deep library green */
  --primary-dark: #163a2f;
  --accent: #c8963e;           /* brass */
  --text: #1c1b18;
  --muted: #6b665c;
  --bg: #f7f3ec;               /* warm paper */
  --surface: #ffffff;
  --line: #e6dfd2;
  --chip: #efe8dc;
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, .06), 0 2px 8px rgba(28, 27, 24, .04);
  --shadow-lg: 0 18px 40px -16px rgba(31, 77, 63, .35);
  --radius: 14px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', system-ui, sans-serif;
}

[data-theme="dark"] {
  --text: #ece7dd;
  --muted: #a39d90;
  --bg: #121513;
  --surface: #1b1f1c;
  --line: #2b302c;
  --chip: #232825;
  --primary: #4f9c80;
  --primary-dark: #3e8169;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .4s, color .4s;
}

/* ============ HEADER ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #f7f3ec;
  font-size: 18px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}

.logo-text { display: flex; flex-direction: column; line-height: 1.1; }

.logo-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}

.logo-tagline {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 3px;
}

.search-container {
  position: relative;
  flex: 1;
  max-width: 460px;
}

.search-box {
  width: 100%;
  padding: 12px 18px 12px 46px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}

.search-box::placeholder { color: var(--muted); }

.search-box:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

/* ============ HERO ============ */
.hero {
  background:
    radial-gradient(800px 300px at 85% 0%, rgba(200, 150, 62, .18), transparent 60%),
    linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #f7f3ec;
}

.hero-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 64px 24px 72px;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.05;
  letter-spacing: -.02em;
  max-width: 14ch;
}

.hero h1 em { font-style: italic; color: #e9c98a; }

.hero p {
  margin-top: 18px;
  max-width: 46ch;
  font-size: 17px;
  opacity: .85;
}

/* ============ MAIN ============ */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: 18px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.chip {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--chip);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}

.chip:hover { border-color: var(--primary); transform: translateY(-1px); }

.chip.active {
  background: var(--primary);
  color: #f7f3ec;
  border-color: var(--primary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 28px 22px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
  display: block;
  background: var(--chip);
  transition: transform .5s;
}

.card:hover img { transform: scale(1.03); }

.card-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  background: var(--surface);
}

.title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-top: 8px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
  transition: background .2s, color .2s, border-color .2s;
}

.card-content .btn:first-of-type { margin-top: auto; }

.read {
  background: var(--primary);
  color: #f7f3ec;
  border: 1px solid var(--primary);
}
.read:hover { background: var(--primary-dark); }

.download {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}
.download:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }

.empty, .loading, #empty p {
  text-align: center;
  margin-top: 60px;
  color: var(--muted);
  font-size: 16px;
  grid-column: 1 / -1;
}

.spinner {
  display: inline-block;
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ FOOTER ============ */
.footer {
  background: var(--primary-dark);
  color: rgba(247, 243, 236, .82);
  padding: 48px 24px 28px;
  margin-top: 56px;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.2fr;
  gap: 40px;
  align-items: start;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #163a2f;
  font-size: 20px;
  flex-shrink: 0;
}

.footer-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.footer-tagline {
  font-size: 13px;
  color: rgba(247, 243, 236, .6);
}

.footer-heading {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.footer-list {
  list-style: none;
  display: grid;
  gap: 10px;
  font-size: 15px;
}

.footer-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-list i {
  width: 18px;
  text-align: center;
  color: var(--accent);
  font-size: 15px;
}

.footer-list a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}

.footer-list a:hover {
  color: #fff;
  border-color: var(--accent);
}

.footer-account {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #fff;
}

.footer-copy {
  max-width: 1080px;
  margin: 36px auto 0;
  padding-top: 18px;
  border-top: 1px solid rgba(247, 243, 236, .14);
  text-align: center;
  font-size: 13px;
  color: rgba(247, 243, 236, .55);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 16px;
  }
  .search-container { max-width: 100%; }
  .hero-inner { padding: 44px 16px 52px; }
  .container { padding: 28px 16px 48px; }
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 14px;
  }
  .card-content { padding: 12px; }
  .title { font-size: 15px; }
  .footer { padding: 36px 16px 24px; }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 26px;
  }
  .footer { margin-top: 36px; }
}
