/* ----------------------------------------------------------------------
   Egyptian Inscriptions DB — v2 design system
   See docs/site_redesign_2026-05-25.md
   ---------------------------------------------------------------------- */

:root {
  /* Color tokens */
  --paper:       #f7f2e7;
  --paper-2:     #efe7d3;
  --paper-3:     #e6dcc1;
  --ink:         #1e1a14;
  --ink-2:       #2b2519;
  --ink-muted:   #5b5042;
  --ink-faint:   #8a7e6c;
  --ochre:       #9c6b2a;
  --ochre-soft:  #d9b482;
  --ochre-deep:  #6e4a1c;
  --lapis:       #2a5c8c;
  --lapis-soft:  #7da3c4;
  --rule:        #d6caa6;
  --rule-soft:   #e8dfc4;
  --shadow:      0 1px 2px rgba(31,26,20,0.07);
  --shadow-2:    0 2px 8px rgba(31,26,20,0.08);

  /* Spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;  --s8: 64px;

  /* Type sizes */
  --t-mega: 56px; --t-h1: 38px; --t-h2: 26px; --t-h3: 20px;
  --t-body: 16px; --t-small: 14px; --t-tiny: 12px;
}

/* Base typography — Google Fonts loaded via <link> in base.html, NOT @import
   (browser blocks rendering on @import; <link rel="preconnect"> is faster) */

html, body {
  margin: 0; padding: 0;
  font-family: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  font-size: var(--t-body); line-height: 1.55;
  color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500; color: var(--ink);
  line-height: 1.2; margin: 0 0 var(--s3);
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }
h4 { font-size: var(--t-body); font-weight: 600; letter-spacing: 0.01em; }

p { margin: 0 0 var(--s4); }
a { color: var(--ochre-deep); text-decoration: underline; text-decoration-thickness: 1px;
    text-underline-offset: 2px; }
a:hover { color: var(--ochre); }
code, pre { font-family: 'JetBrains Mono', Menlo, Consolas, monospace; font-size: 0.9em; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 var(--s5); }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 var(--s5); }

/* Header */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: var(--s4); padding-bottom: var(--s4);
}
.site-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600; font-size: 20px; color: var(--ink);
  text-decoration: none; letter-spacing: 0.01em;
}
.site-logo .sub {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400; font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.12em; margin-left: var(--s2);
}
.site-nav { display: flex; gap: var(--s5); align-items: center; }
.site-nav a {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--t-small); color: var(--ink-muted);
  text-decoration: none; padding: var(--s1) 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--ochre); }
.site-nav a.active { color: var(--ink); border-bottom-color: var(--ochre); }

/* Search box in header */
.site-search { display: flex; align-items: center; }
.site-search input {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--t-small); color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 18px; padding: 6px 14px;
  width: 220px;
}
.site-search input:focus { outline: none; border-color: var(--ochre); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule); margin-top: var(--s8);
  padding: var(--s6) 0; color: var(--ink-faint);
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-tiny);
}
.site-footer .container {
  display: flex; justify-content: space-between; gap: var(--s5); flex-wrap: wrap;
}
.site-footer a { color: var(--ink-muted); }

/* Hero */
.hero {
  padding: var(--s8) 0 var(--s7);
  border-bottom: 1px solid var(--rule-soft);
}
.hero h1 {
  font-size: var(--t-mega); line-height: 1.05; margin-bottom: var(--s4);
  max-width: 760px;
}
.hero .lead {
  font-size: 19px; line-height: 1.55; color: var(--ink-muted);
  max-width: 660px; margin-bottom: var(--s5);
}
.hero .stat-strip {
  display: flex; gap: var(--s6); flex-wrap: wrap; margin-top: var(--s5);
  padding-top: var(--s4); border-top: 1px solid var(--rule-soft);
}
.hero .stat { display: flex; flex-direction: column; gap: 2px; }
.hero .stat .n {
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600;
  font-size: 28px; color: var(--ochre-deep); line-height: 1;
}
.hero .stat .lbl {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--t-tiny); color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* Section headers (used on Home + index pages) */
.section { padding: var(--s7) 0; border-bottom: 1px solid var(--rule-soft); }
.section:last-child { border-bottom: none; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--s5);
}
.section-head h2 { margin: 0; }
.section-head a {
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small);
  color: var(--ink-muted); text-decoration: none;
  border-bottom: 1px dotted var(--ink-muted);
}
.section-head a:hover { color: var(--ochre); border-color: var(--ochre); }

.kicker {
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-tiny);
  color: var(--ochre-deep); text-transform: uppercase; letter-spacing: 0.14em;
  font-weight: 600; margin-bottom: var(--s2);
}

/* Card grid (used for featured objects, themes) */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s5); }
@media (max-width: 880px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Object card (compact) */
.card-obj {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 6px; overflow: hidden; transition: box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.card-obj:hover { box-shadow: var(--shadow-2); border-color: var(--ochre-soft); }
.card-obj a { color: inherit; text-decoration: none; }
.card-obj .thumb {
  aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-obj .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-obj .thumb.placeholder {
  color: var(--ink-faint); font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--t-tiny); letter-spacing: 0.06em; text-transform: uppercase;
}
.card-obj .body { padding: var(--s4); flex: 1; display: flex; flex-direction: column; }
.card-obj .source-pill {
  display: inline-block; font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 600; padding: 2px 8px; border-radius: 3px;
  background: var(--paper-2); color: var(--ink-muted);
  border: 1px solid var(--rule); align-self: flex-start; margin-bottom: var(--s2);
}
.card-obj .card-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500; font-size: 19px; line-height: 1.25;
  color: var(--ink); margin: 0 0 var(--s2);
}
.card-obj .card-meta {
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-tiny);
  color: var(--ink-faint); line-height: 1.5;
}

/* Theme card */
.card-theme {
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 6px; padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s2);
  transition: background 0.15s;
}
.card-theme:hover { background: var(--paper-3); }
.card-theme a { color: inherit; text-decoration: none; display: block; }
.card-theme .kicker { margin-bottom: var(--s3); }
.card-theme h3 {
  font-size: 22px; margin: 0 0 var(--s2);
}
.card-theme p {
  color: var(--ink-muted); font-size: var(--t-small);
  line-height: 1.55; margin: 0;
}

/* Sources strip */
.source-strip {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small);
  color: var(--ink-muted);
}
.source-strip .source-tag {
  padding: 4px 12px; background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 14px;
  color: var(--ink-muted); text-decoration: none;
}
.source-strip .source-tag:hover { color: var(--ink); border-color: var(--ochre); }
.source-strip .source-tag .count {
  color: var(--ink-faint); margin-left: 6px; font-size: 12px;
}

/* Object detail page */
.object-page { padding: var(--s7) 0; }
.object-page .breadcrumb {
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-tiny);
  color: var(--ink-faint); letter-spacing: 0.04em; margin-bottom: var(--s3);
}
.object-page .breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.object-page .breadcrumb a:hover { color: var(--ochre); }
.object-page h1 { margin-bottom: var(--s3); }
.object-page .obj-layout {
  display: grid; grid-template-columns: 320px 1fr;
  gap: var(--s7); margin-top: var(--s5);
}
@media (max-width: 760px) {
  .object-page .obj-layout { grid-template-columns: 1fr; }
}
.object-page .obj-image {
  aspect-ratio: 1 / 1; background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
}
.object-page .obj-image img { width: 100%; height: 100%; object-fit: cover; }
.object-page .obj-meta {
  display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4);
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small);
  margin-bottom: var(--s5);
}
.object-page .obj-meta dt {
  color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 11px; padding-top: 2px;
}
.object-page .obj-meta dd { margin: 0; color: var(--ink-2); }

/* Inscription blocks on detail page */
.block { margin-bottom: var(--s6); }
.block h3 {
  font-family: 'Inter', system-ui, sans-serif; font-weight: 600;
  font-size: var(--t-small); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ochre-deep);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s4);
}
.inscription { margin-bottom: var(--s5); padding-bottom: var(--s4);
  border-bottom: 1px dashed var(--rule-soft); }
.inscription:last-child { border-bottom: none; }
.inscription .ins-num {
  font-family: 'Inter', system-ui, sans-serif; font-size: 11px;
  color: var(--ochre); text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: var(--s2);
}
.inscription .modality { margin-bottom: var(--s3); }
.inscription .modality h4 {
  font-family: 'Inter', system-ui, sans-serif; font-size: 11px;
  color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: var(--s2); font-weight: 600;
}
.inscription .modality .body {
  background: var(--paper-2); border-left: 3px solid var(--ochre-soft);
  padding: var(--s3) var(--s4); border-radius: 0 3px 3px 0;
  font-size: 15px; line-height: 1.6; color: var(--ink-2);
}
.inscription .modality .body code { font-size: 13.5px; color: var(--ink-2); }
.translation { margin: var(--s2) 0; padding: var(--s2) 0;
  border-bottom: 1px dotted var(--rule-soft); }
.translation:last-child { border-bottom: none; }
.translation .trans-meta {
  font-family: 'Inter', system-ui, sans-serif; font-size: 11px;
  color: var(--ink-faint); display: flex; align-items: center; gap: var(--s2);
  margin-bottom: 4px;
}
.translation .trans-text { font-size: 15px; line-height: 1.55; color: var(--ink-2); }

/* Badges */
.badge {
  display: inline-block; padding: 1px 7px; font-size: 10px; font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif; letter-spacing: 0.08em;
  border-radius: 3px; text-transform: uppercase;
}
.badge-ai { background: rgba(42,92,140,0.1); color: var(--lapis);
  border: 1px solid rgba(42,92,140,0.3); }
.badge-scholarly { background: rgba(156,107,42,0.1); color: var(--ochre-deep);
  border: 1px solid rgba(156,107,42,0.3); }

/* AI analysis panel */
.ai-block {
  background: linear-gradient(180deg, rgba(42,92,140,0.04), rgba(42,92,140,0.01));
  border: 1px solid rgba(42,92,140,0.18); border-radius: 6px;
  padding: var(--s4) var(--s5); margin-bottom: var(--s6);
}
.ai-block h3 {
  color: var(--lapis); border-bottom-color: rgba(42,92,140,0.18);
}
.ai-block .ai-desc {
  font-family: 'Source Serif 4', Georgia, serif; font-style: italic;
  font-size: 15px; line-height: 1.55; color: var(--ink-2);
  margin-bottom: var(--s3);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s2); }
.chip {
  font-family: 'Inter', system-ui, sans-serif; font-size: 11px;
  padding: 2px 10px; background: rgba(42,92,140,0.08);
  border: 1px solid rgba(42,92,140,0.18); border-radius: 12px;
  color: var(--lapis); letter-spacing: 0.04em; text-transform: capitalize;
}
.tag-row {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline;
  font-family: 'Inter', system-ui, sans-serif; font-size: 12px;
  margin: var(--s2) 0;
}
.tag-row .tag-label {
  font-size: 10px; color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: 0.08em; min-width: 78px;
}
.tag {
  padding: 2px 8px; background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 3px;
  font-size: 12px; color: var(--ink-2);
}

/* Cross-references */
.xrefs ul { list-style: none; margin: 0; padding: 0;
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small); }
.xrefs li { padding: 5px 0; border-bottom: 1px dotted var(--rule-soft);
  color: var(--ink-muted); }
.xrefs li:last-child { border-bottom: none; }
.xrefs .xref-type { font-size: 11px; color: var(--ink-faint); margin-right: var(--s3); }
.xrefs .xref-val { color: var(--ink-2); }

/* Browse table */
.browse-controls {
  display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  padding: var(--s4) 0; border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s5);
}
.browse-controls input, .browse-controls select {
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small);
  padding: 6px 12px; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px; color: var(--ink);
}
.browse-controls input:focus, .browse-controls select:focus {
  outline: none; border-color: var(--ochre);
}
.browse-table { width: 100%; border-collapse: collapse;
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small); }
.browse-table th {
  text-align: left; padding: var(--s2) var(--s3);
  color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 11px; font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
.browse-table td {
  padding: var(--s3); border-bottom: 1px solid var(--rule-soft);
  color: var(--ink-2);
}
.browse-table tbody tr { cursor: pointer; transition: background 0.1s; }
.browse-table tbody tr:hover { background: var(--paper-2); }
.browse-table a { color: var(--ink); text-decoration: none; font-weight: 500; }
.browse-table a:hover { color: var(--ochre); }

/* Pagination */
.pager {
  display: flex; justify-content: center; gap: var(--s2); align-items: center;
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--t-small);
  margin-top: var(--s5);
}
.pager a, .pager span {
  padding: 4px 10px; border: 1px solid var(--rule);
  border-radius: 3px; color: var(--ink-muted); text-decoration: none;
  background: var(--paper);
}
.pager a:hover { border-color: var(--ochre); color: var(--ink); }
.pager .current { background: var(--ochre); color: var(--paper); border-color: var(--ochre); }
.pager .disabled { color: var(--ink-faint); pointer-events: none; opacity: 0.5; }

/* ----------------------------------------------------------------------
   Mobile responsive
   ---------------------------------------------------------------------- */

@media (max-width: 760px) {
  :root {
    --t-mega: 36px; --t-h1: 28px; --t-h2: 22px; --t-h3: 18px;
  }
  .container, .container-narrow { padding: 0 var(--s4); }

  /* Header: stack nav + hide search */
  .site-header .container {
    flex-wrap: wrap; gap: var(--s2);
    padding-top: var(--s3); padding-bottom: var(--s3);
  }
  .site-logo { font-size: 17px; }
  .site-logo .sub { display: none; }
  .site-nav {
    width: 100%; order: 3; gap: var(--s3);
    padding-top: var(--s2); border-top: 1px solid var(--rule-soft);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .site-nav a { font-size: 12px; white-space: nowrap; }
  .site-search { display: none; }

  /* Hero */
  .hero { padding: var(--s6) 0 var(--s5); }
  .hero h1 { font-size: var(--t-mega); }
  .hero .lead { font-size: 16px; }
  .hero .stat-strip {
    gap: var(--s4) var(--s5); padding-top: var(--s3);
  }
  .hero .stat .n { font-size: 22px; }

  /* Section spacing */
  .section { padding: var(--s5) 0; }

  /* Browse: collapse facets above results, swap grid for stack */
  .browse-table { font-size: 13px; }
  .browse-table thead th:nth-child(3),
  .browse-table tbody td:nth-child(3),
  .browse-table thead th:nth-child(5),
  .browse-table tbody td:nth-child(5) { display: none; }
  .browse-table td { padding: var(--s2); }

  /* Sidebar layouts: stack on mobile */
  .object-page .obj-layout { grid-template-columns: 1fr; gap: var(--s5); }
  .object-page .obj-image { aspect-ratio: 4 / 3; }

  /* Browse facets sidebar — make it horizontally scrollable on mobile */
  .browse-controls { padding: var(--s3) 0; }
}

@media (max-width: 540px) {
  .hero h1 { font-size: 28px; }
  .hero .lead { font-size: 14.5px; }
  .stat-strip { gap: var(--s3); }
  .hero .stat .n { font-size: 19px; }
  .hero .stat .lbl { font-size: 10px; }
  .grid-3, .grid-4 { gap: var(--s4); }
  .object-page .obj-meta { grid-template-columns: 1fr; gap: var(--s1) var(--s2); }
  .object-page .obj-meta dt { padding-top: var(--s2); }
}
