/* ── Geniza Explorer — Museum-grade RTL Hebrew stylesheet ─────────────────── */

/* ── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
  /* Palette — light papyrus */
  --bg:           #faf8f3;
  --bg-2:         #f2ede4;
  --bg-card:      #ffffff;
  --bg-card-h:    #fdf9f5;
  --bg-input:     #ffffff;
  --text:         #1e1b17;
  --text-2:       #5c5044;
  /* --text-3 was #9c887c (3.2:1 on --bg) and --gold was used for links at
     4.2:1 — both below the 4.5:1 WCAG AA floor for body text. Darkened just
     enough to pass while keeping the warm papyrus cast. --gold itself is
     unchanged: it is a fill colour for badges, bars and rules, where the 3:1
     non-text threshold applies. */
  --text-3:       #806d60;
  --text-faint:   #9c887c;   /* decorative only — never for text */
  --gold:         #b5621e;
  --gold-light:   #d4883a;
  --gold-dark:    #7a3e0e;
  --link:         #a05418;   /* 5.2:1 on --bg, 5.6:1 on white */
  --link-hover:   #7a3e0e;   /* hover darkens, so contrast only improves */
  --border:       #e6ddd2;
  --border-2:     #d4c6b8;
  --divider:      rgba(181,98,30,.15);

  /* Type badges (light bg) */
  --badge-letter: #ede9f9;
  --badge-legal:  #e8f5ee;
  --badge-lit:    #fde8e8;
  --badge-rel:    #eef5e8;
  --badge-para:   #e8eef5;
  --badge-other:  #f0ede8;

  /* Fonts */
  --font-serif: 'Frank Ruhl Libre', 'David Libre', serif;
  --font-ui:    'Heebo', 'Arial', sans-serif;

  /* Spacing */
  --radius:    6px;
  --radius-lg: 12px;
  --shadow:    0 2px 10px rgba(30,20,10,.08);
  --shadow-lg: 0 8px 32px rgba(30,20,10,.13);
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

img { display: block; max-width: 100%; }

/* ── Site Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(180deg, #f8f3e8 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--divider);
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(201,168,76,.08) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner { position: relative; max-width: 700px; margin: 0 auto; }

.header-ornament {
  font-size: 1.5rem;
  color: var(--gold);
  opacity: .6;
  margin-bottom: .75rem;
  letter-spacing: .5em;
  display: block;
}

.site-title {
  font-family: var(--font-ui);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.1;
  margin-bottom: .5rem;
}

.site-subtitle {
  font-size: clamp(.95rem, 2.5vw, 1.15rem);
  color: var(--text-2);
  font-weight: 300;
  margin-bottom: .75rem;
  max-width: 560px;
  margin-inline: auto;
}

.site-source {
  font-size: .85rem;
  color: var(--text-3);
}
.site-source a { color: var(--text-3); }
.site-source a:hover { color: var(--gold); }

/* ── Intro text ──────────────────────────────────────────────────────────────── */
.site-intro {
  font-size: clamp(.88rem, 2vw, 1rem);
  color: var(--text-3);
  font-weight: 300;
  max-width: 600px;
  margin: 1rem auto 0;
  line-height: 1.75;
}

/* ── Browse section ──────────────────────────────────────────────────────────── */
.browse-section {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.browse-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: center;
}

.browse-group {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}


.browse-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.browse-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.chip {
  padding: .35rem .85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.chip:hover {
  background: var(--bg-card-h);
  border-color: var(--gold-dark);
  color: var(--gold-light);
}
.chip--active {
  background: var(--gold-dark);
  border-color: var(--gold);
  color: #fff;
  font-weight: 600;
}
/* Surprise cube */
.surprise-wrap {
  display: flex;
  justify-content: center;
}

.surprise-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  padding: 1.6rem 2.8rem;
  background: linear-gradient(160deg, var(--bg-card) 0%, #f0e8f8 60%, #e8f0fb 100%);
  border: 2px solid #8a4cb0;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font-ui);
  text-align: center;
  transition: transform .22s, box-shadow .22s, border-color .22s, background .22s;
  box-shadow: 0 4px 20px rgba(100,50,180,.15), 0 1px 4px rgba(100,50,180,.08);
  min-width: 260px;
  max-width: 400px;
}

.surprise-btn:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 12px 36px rgba(100,50,180,.25), 0 3px 10px rgba(100,50,180,.12);
  border-color: #b060e0;
  background: linear-gradient(160deg, #fff 0%, #f4e8ff 60%, #e4f0ff 100%);
}

.surprise-btn:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 5px 16px rgba(100,50,180,.18);
}

.surprise-dice {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  transition: transform .45s cubic-bezier(.34,1.56,.64,1);
}

.surprise-btn:hover .surprise-dice {
  transform: rotate(20deg) scale(1.14);
}

.surprise-title {
  display: block;
  font-size: 1.55rem;
  font-weight: 700;
  color: #6a20b0;
  font-family: var(--font-ui);
  line-height: 1.2;
  letter-spacing: .02em;
}

.surprise-sub {
  display: block;
  font-size: .8rem;
  color: var(--text-3);
  margin-top: -.1rem;
  font-style: italic;
}

@media (max-width: 600px) {
  .surprise-btn {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 1.3rem 1.5rem;
  }
  .surprise-dice { width: 86px; height: 86px; }
  .surprise-title { font-size: 1.35rem; }
}

/* Desktop: float the cube as a transparent corner accent above the hero */
@media (min-width: 900px) {
  .surprise-wrap {
    position: absolute;
    top: 1.25rem;
    left: 1.5rem;
    z-index: 5;
    margin: 0;
  }
  .surprise-wrap .surprise-btn,
  .surprise-wrap .surprise-btn:hover,
  .surprise-wrap .surprise-btn:active {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding: .35rem .6rem;
    min-width: 0;
    max-width: none;
    gap: .25rem;
  }
  .surprise-wrap .surprise-btn:hover {
    transform: translateY(-3px) scale(1.04);
  }
  .surprise-wrap .surprise-dice { width: 78px; height: 78px; }
  .surprise-wrap .surprise-title { font-size: 1rem; }
  .surprise-wrap .surprise-sub { font-size: .72rem; }
}

/* Reset button */
.btn-reset {
  padding: .45rem .85rem;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: .8rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-reset:hover { color: var(--text); border-color: var(--text-3); }

.btn-reset-inline {
  margin-top: 1rem;
  padding: .55rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-reset-inline:hover { background: var(--bg-card-h); }

/* Card geo line */
.card-geo {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.card-lib {
  font-size: .75rem;
  color: var(--text-3);
}

/* ── Search Bar ──────────────────────────────────────────────────────────────── */
.search-bar-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,248,243,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .85rem 0;
}

.search-bar-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  top: 50%;
  right: .85rem;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
  color: var(--text-3);
}

.search-input {
  width: 100%;
  padding: .6rem 2.4rem .6rem .85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .95rem;
  direction: rtl;
  transition: border-color .2s, box-shadow .2s;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
  outline: none;
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}

.search-clear {
  position: absolute;
  top: 50%;
  left: .6rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: .8rem;
  padding: .2rem;
  line-height: 1;
}
.search-clear:hover { color: var(--text); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.filter-select {
  padding: .55rem .75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: .85rem;
  direction: rtl;
  cursor: pointer;
  transition: border-color .2s;
  appearance: none;
  -webkit-appearance: none;
  padding-left: 1.8rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6050'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: .6rem center;
}
.filter-select:focus {
  outline: none;
  border-color: var(--gold-dark);
}

/* ── Main Content ────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.results-bar {
  font-size: .85rem;
  color: var(--text-3);
  margin-bottom: 1.25rem;
  min-height: 1.4em;
}
.results-bar strong { color: var(--text-2); }

/* ── Cards Grid ──────────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: var(--gold);
  opacity: 0;
  transition: opacity .2s;
}

.card:hover {
  background: var(--bg-card-h);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card:hover::after { opacity: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.card-shelfmark {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.card-icons {
  display: flex;
  gap: .25rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

.card-icon {
  font-size: .75rem;
  opacity: .55;
  line-height: 1;
}

.card-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px) 0 0;
  margin: -1.35rem -1.25rem 0;
  width: calc(100% + 2.5rem);
  display: block;
  background: var(--bg-2);
  transition: opacity .3s;
}
.card--has-thumb { padding-top: 0; }
.card--has-thumb .card-top { margin-top: 1rem; }

.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 500;
  padding: .2rem .55rem;
  border-radius: 99px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.badge-type-letter    { background: var(--badge-letter); color: #5b4b9e; }
.badge-type-legal     { background: var(--badge-legal);  color: #2a7a52; }
.badge-type-lit       { background: var(--badge-lit);    color: #8b3030; }
.badge-type-rel       { background: var(--badge-rel);    color: #4a7a20; }
.badge-type-para      { background: var(--badge-para);   color: #2a507a; }
.badge-type-other     { background: var(--badge-other);  color: #7a6a5a; }

.badge-lang {
  background: var(--border);
  color: var(--text-3);
  border: 1px solid var(--border-2);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

.card-date {
  font-size: .8rem;
  color: var(--text-3);
}

.card-origin {
  font-size: .8rem;
  color: var(--text-3);
}
.card-origin::before { content: '📍 '; font-size: .7rem; }

.card-description {
  font-size: .85rem;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.card-description {
  font-size: .82rem;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.card-desc-label {
  font-size: .72rem;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: .03em;
}

/* Fragment page description label */
.desc-lang-note {
  display: block;
  font-size: .72rem;
  color: var(--gold-dark);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: .4rem;
}

.card-footer {
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-3);
}

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .4rem;
  padding-top: 2rem;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 .6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.page-btn:hover { background: var(--bg-card-h); border-color: var(--border-2); color: var(--text); }
.page-btn.active {
  background: var(--gold-dark);
  border-color: var(--gold);
  color: #fff;
  font-weight: 700;
}
.page-btn:disabled { opacity: .3; cursor: default; }

/* ── States ──────────────────────────────────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-3);
}
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-3);
}
.empty-icon { font-size: 3rem; margin-bottom: .75rem; }

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border-2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Fragment page ───────────────────────────────────────────────────────────── */
.fragment-body { background: var(--bg-2); }

.top-nav {
  padding: .9rem 1.5rem;
  background: rgba(250,248,243,.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .9rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-home {
  color: var(--gold);
  white-space: nowrap;
}

.nav-breadcrumb {
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fragment-article {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

.fragment-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--divider);
}

.fragment-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}

.fragment-shelfmark {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: .4rem;
}

.fragment-library {
  font-size: .9rem;
  color: var(--text-3);
}

/* ── Two-column layout ───────────────────────────────────────────────────────── */
.fragment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 2.5rem;
  align-items: start;
}

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

/* ── Image column ────────────────────────────────────────────────────────────── */
.image-frame {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 3rem 1.5rem;
  color: var(--text-3);
  font-size: .9rem;
  min-height: 220px;
}

.placeholder-glyph {
  font-size: 3rem;
  opacity: .4;
}

.fragment-img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
  transition: transform .3s;
}
.fragment-img:hover { transform: scale(1.01); }

.image-caption {
  padding: .65rem 1rem;
  font-size: .78rem;
  color: var(--text-3);
  background: var(--bg-2);
  text-align: center;
  border-top: 1px solid var(--border);
}

.image-links {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
}

.image-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: .85rem;
  transition: border-color .15s, color .15s;
}
.image-link:hover {
  border-color: var(--gold-dark);
  color: var(--gold-light);
  text-decoration: none;
}
.image-link-icon { font-size: 1rem; }

/* ── Meta column ─────────────────────────────────────────────────────────────── */
.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  align-items: baseline;
  margin-bottom: 1.5rem;
}

.meta-list dt {
  font-size: .78rem;
  color: var(--text-3);
  white-space: nowrap;
  padding-top: .35rem;
  font-weight: 500;
  letter-spacing: .02em;
}

.meta-list dd {
  font-size: .92rem;
  color: var(--text-2);
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.meta-list dd:last-child { border-bottom: none; }

.section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--gold-dark);
  margin-bottom: .6rem;
}

.description-block {
  margin-bottom: 1.5rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-right: 3px solid var(--gold-dark);
}

.description-text {
  font-size: .92rem;
  color: var(--text-2);
  line-height: 1.7;
}

.tags-block { margin-bottom: 1.5rem; }

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tag-pill {
  display: inline-block;
  padding: .25rem .65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  font-size: .78rem;
  color: var(--text-3);
  transition: color .15s, border-color .15s;
}
.tag-pill:hover { color: var(--gold-light); border-color: var(--gold-dark); }

.actions-block { margin-top: 1.5rem; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.4rem;
  background: transparent;
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: .9rem;
  font-weight: 500;
  transition: background .2s, color .2s, border-color .2s;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--gold-dark);
  color: #fff;
  text-decoration: none;
}

/* ── Fragment navigation ─────────────────────────────────────────────────────── */
.fragment-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.frag-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: .85rem;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
}
.frag-nav-btn:hover {
  background: var(--bg-card-h);
  border-color: var(--gold-dark);
  color: var(--gold-light);
  text-decoration: none;
}

.frag-nav-label {
  font-size: .78rem;
  color: var(--text-3);
  text-align: center;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: .82rem;
  color: var(--text-3);
  line-height: 1.8;
}
.site-footer a { color: var(--link); text-decoration: underline; }
.site-footer a:hover { color: var(--link-hover); }
.footer-build { margin-top: .3rem; }
.footer-note {
  max-width: 46rem;
  margin: .5rem auto 0;
  font-size: .78rem;
  color: var(--text-3);
}

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .search-bar-inner { flex-direction: column; align-items: stretch; gap: .5rem; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
  .filter-select { min-width: 0; }
  .btn-reset { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .site-header { padding: 2.5rem 1rem 2rem; }
  .search-bar-wrapper { padding: .6rem 0; }
  .search-bar-inner { padding: 0 1rem; }
  .search-input { font-size: .9rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .fragment-article { padding: 1.25rem 1rem 3rem; }
  .meta-list { grid-template-columns: 1fr; }
  .meta-list dt { padding-bottom: 0; padding-top: .6rem; }
  .meta-list dd { border-bottom: 1px solid var(--border); }
  .fragment-nav { flex-direction: column; align-items: stretch; }
  .frag-nav-btn { justify-content: center; }
}

/* ── Selection ───────────────────────────────────────────────────────────────── */
::selection {
  background: rgba(181,98,30,.2);
  color: var(--text);
}

/* ── About link in header ────────────────────────────────────────────────────── */
.about-link {
  display: inline-block;
  margin-top: .75rem;
  font-family: var(--font-ui);
  font-size: .82rem;
  color: var(--gold-light);
  text-decoration: none;
  opacity: .8;
  transition: opacity .2s;
}
.about-link:hover { opacity: 1; }

/* ── KPI section (2-card version) ────────────────────────────────────────────── */
.dashboard-kpi {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
}
.dash-kpi-row--two {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-areas: "docs dyk dyk img";
  gap: .75rem;
}

.dash-kpi-row--two > :first-child { grid-area: docs; }
#kpi-dyk                          { grid-area: dyk; }
#kpi-img                          { grid-area: img; }

.kpi-card--dyk {
  align-items: flex-start;
  text-align: right;
  text-decoration: none;
  color: inherit;
  justify-content: flex-start;
}
.kpi-card--dyk:hover { color: inherit; }
.kpi-dyk-label { font-size: .73rem; color: var(--text-3); font-weight: 500; }
.kpi-dyk-text  { font-size: .875rem; line-height: 1.6; color: var(--text); flex: 1; }
.kpi-dyk-shelfmark { font-size: .72rem; color: var(--text-3); margin-top: auto; }

/* ── Dashboard (stats below cards) ──────────────────────────────────────────── */
.dashboard {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem;
}

.dash-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* KPI row (legacy - unused) */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .2rem;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.kpi-card:hover { box-shadow: var(--shadow-lg); }

.kpi-icon { font-size: 1.4rem; line-height: 1; opacity: .75; }

.kpi-num {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
}

.kpi-label { font-size: .73rem; color: var(--text-3); font-weight: 500; }

/* Panels grid */
.dash-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.dash-panel--wide { grid-column: 1 / -1; }

.dash-panel--century { grid-column: 1 / -1; }

.dash-panel-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: .7rem;
}

.dash-panel-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-3);
  margin-bottom: .7rem;
}
.dash-panel-hd .dash-panel-title { margin-bottom: 0; }

.dash-panel-hint { font-size: .7rem; color: var(--text-3); font-style: italic; }

.dash-loading { color: var(--text-3); font-size: .85rem; }

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .4rem;
  align-items: baseline;
  line-height: 2;
}

.tag-pill-cloud {
  cursor: pointer;
  color: var(--text-2);
  font-weight: 500;
  padding: .1rem .35rem;
  border-radius: var(--radius);
  background: none;
  border: none;
  font-family: var(--font-ui);
  transition: background .12s, color .12s;
  line-height: 1.3;
}
.tag-pill-cloud:hover { background: var(--gold-dark); color: #fff; }

/* Distribution bars */
.dist-list { display: flex; flex-direction: column; gap: .5rem; }

.dist-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 3.5rem;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
}

.dist-row--clickable {
  cursor: pointer;
  padding: .15rem .35rem;
  margin: 0 -.35rem;
  border-radius: 6px;
  transition: background .15s;
}
.dist-row--clickable:hover { background: var(--bg-card-h); }
.dist-row--clickable:hover .dist-label { color: var(--gold-light); }
.dist-row--active {
  background: var(--bg-card-h);
}
.dist-row--active .dist-label { color: var(--gold-light); font-weight: 700; }
.dist-row--active .dist-bar { background: linear-gradient(90deg, var(--gold-light), var(--gold)); }

.dist-label {
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-bar-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
  border-radius: 3px;
  transition: width .5s ease;
}

.dist-count { color: var(--text-3); font-size: .72rem; white-space: nowrap; }

/* Century chart */
.century-chart {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  height: 90px;
}

.century-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  height: 100%;
  justify-content: flex-end;
}

.century-col--clickable { cursor: pointer; }
.century-col--clickable:hover .century-bar {
  background: linear-gradient(180deg, var(--gold), var(--gold-light));
  filter: brightness(1.05);
}
.century-col--clickable:hover .century-label { color: var(--gold-light); }
.century-col--active .century-bar {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 0 0 2px var(--gold-light);
}
.century-col--active .century-label { color: var(--gold-light); font-weight: 700; }

.century-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: background .15s, box-shadow .15s, filter .15s;
}

.century-label { font-size: .68rem; color: var(--text-3); text-align: center; }
.century-count { font-size: .62rem; color: var(--text-3); }

@media (max-width: 700px) {
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-panels  { grid-template-columns: 1fr; }
  .dash-panel--wide, .dash-panel--century { grid-column: 1; }
}

@media (max-width: 600px) {
  .dash-kpi-row--two {
    padding: 0 1rem;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "docs img" "dyk dyk";
  }
}

/* ── Location map panel ───────────────────────────────────────────────────────── */
.dash-panel--map { padding-bottom: .75rem; }

#geniza-map {
  height: 340px;
  border-radius: var(--radius);
  margin-top: .7rem;
  background: var(--bg-2);
  z-index: 0;
}

/* Leaflet attribution override */
.leaflet-container .leaflet-control-attribution {
  font-size: .6rem;
  background: rgba(250,248,243,.7);
}

/* Map location pins */
.gmap-pin {
  width: 90px;
  height: 34px;
  background: var(--text);
  color: var(--bg);
  border: 1.5px solid var(--gold-dark);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  transition: background .15s, border-color .15s;
  position: relative;
}

.gmap-pin::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--gold-dark);
}

.gmap-pin:hover,
.gmap-pin--active {
  background: var(--gold-dark);
  border-color: var(--gold-light);
}

.gmap-pin:hover::after,
.gmap-pin--active::after {
  border-top-color: var(--gold-light);
}

.gmap-pin-name {
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 84px;
  display: block;
  text-align: center;
  direction: rtl;
  font-family: var(--font-ui);
  line-height: 1;
}

.gmap-pin-count {
  font-size: .6rem;
  opacity: .65;
  font-family: var(--font-ui);
  line-height: 1;
}

/* ── Spice bar ───────────────────────────────────────────────────────────────── */
.dash-panel--spices { padding-bottom: 1.1rem; }

.spice-banner-wrap {
  width: 100%;
  height: 80px;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: .9rem;
  background: var(--bg-2);
}

.spice-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  display: block;
}

.spice-buttons {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: .5rem;
}

.spice-btn {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .45rem .8rem;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  font-family: var(--font-ui);
}

.spice-btn:hover {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #fff;
}

.spice-btn-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.spice-btn-latin {
  font-size: .6rem;
  color: var(--text-3);
  font-style: italic;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.spice-btn:hover .spice-btn-name,
.spice-btn:hover .spice-btn-latin,
.spice-btn:hover .spice-btn-count { color: #fff; }

.spice-btn-count {
  font-size: .68rem;
  color: var(--text-3);
}

@media (max-width: 700px) {
  .spice-buttons { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .spice-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ── Accessibility ───────────────────────────────────────────────────────────── */

/* Keyboard focus. .search-input and .filter-select set `outline: none` and
   replace it with a border colour change, which is invisible to anyone who
   cannot perceive that hue; everything else relied on the UA default outline,
   which the papyrus palette washes out. One consistent, high-contrast ring for
   every interactive element, shown only for keyboard use. */
:focus-visible {
  outline: 3px solid var(--gold-dark);
  outline-offset: 2px;
  border-radius: 3px;
}
.search-input:focus-visible,
.filter-select:focus-visible {
  outline: 3px solid var(--gold-dark);
  outline-offset: 1px;
}

/* Skip link — first tab stop, so keyboard and screen-reader users can jump
   past the header, the search bar and the filter row. */
.skip-link {
  position: absolute;
  right: 1rem;
  top: -100px;
  z-index: 100;
  padding: .7rem 1.2rem;
  background: var(--gold-dark);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 500;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  transition: top .15s ease-out;
}
.skip-link:focus {
  top: 0;
  color: #fff;
  text-decoration: underline;
}

/* Respect the OS "reduce motion" setting: html has `scroll-behavior: smooth`,
   several buttons scroll the page programmatically, and the loading spinner
   animates continuously. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Honour a forced-colours / high-contrast mode. */
@media (forced-colors: active) {
  .badge, .chip, .tag-pill, .page-btn { border: 1px solid currentColor; }
  :focus-visible { outline: 3px solid Highlight; }
}

.noscript-note {
  margin-bottom: 1.5rem;
  padding: 1rem 1.2rem;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text-2);
}

/* ── Static document directory (/d/) ─────────────────────────────────────────── */
.doc-index {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.doc-index-title {
  font-family: var(--font-ui);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  color: var(--gold-dark);
  margin-bottom: .5rem;
}
.doc-index-sub {
  color: var(--text-2);
  font-size: .95rem;
  margin-bottom: 2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.doc-index-list {
  margin: 0 1.4rem 2rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.doc-index-list li {
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--divider);
  line-height: 1.5;
}
.doc-index-list a {
  font-weight: 500;
  font-size: .95rem;
}
.doc-index-meta {
  display: block;
  font-size: .8rem;
  color: var(--text-3);
}
.doc-index .pagination a.page-btn {
  text-decoration: none;
}
