/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f0e8;
    --bg-card: #fff;
    --text: #2c2418;
    --text-muted: #6b5d4d;
    --accent: #8b4513;
    --accent-light: #d4a574;
    --border: #d4c5a9;
    --shadow: rgba(44, 36, 24, 0.1);
    --header-bg: #2c2418;
    --header-text: #f5f0e8;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font-serif); background: var(--bg); color: var(--text); line-height: 1.7; }

/* ===== Header ===== */
header { background: var(--header-bg); color: var(--header-text); padding: 3rem 2rem 2rem; text-align: center; }
.header-content { max-width: 800px; margin: 0 auto; }
header h1 { font-size: 2.2rem; font-weight: 400; letter-spacing: 0.02em; margin-bottom: 0.5rem; }
header h1 em { font-style: italic; }
.subtitle { font-size: 1rem; color: var(--accent-light); margin-bottom: 0.5rem; font-family: var(--font-sans); }
.attribution { font-size: 0.85rem; color: #9a8c7a; font-family: var(--font-sans); }

/* ===== Nav ===== */
.site-nav { margin-top: 1.2rem; display: flex; justify-content: center; gap: 0.25rem; flex-wrap: wrap; }
.site-nav a { color: #9a8c7a; text-decoration: none; font-family: var(--font-sans); font-size: 0.85rem; padding: 0.35rem 0.8rem; border-radius: 3px; transition: all 0.2s; }
.site-nav a:hover { color: var(--accent-light); background: rgba(255,255,255,0.05); }
.site-nav a.active { color: var(--header-text); background: rgba(255,255,255,0.1); }

/* ===== Stats ===== */
.stats { display: flex; justify-content: center; gap: 2rem; padding: 2rem; max-width: 700px; margin: 0 auto 2rem; }
.stat-card { text-align: center; padding: 1.5rem 2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; flex: 1; }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { display: block; font-size: 0.85rem; color: var(--text-muted); font-family: var(--font-sans); margin-top: 0.25rem; }

/* ===== Gallery ===== */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; padding: 1rem 2rem 3rem; max-width: 1400px; margin: 0 auto; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--shadow); }
.card-body { padding: 1rem 1.2rem; }
.card-sig { font-size: 1.1rem; font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; }
.card-label { font-size: 0.85rem; color: var(--text); margin-bottom: 0.4rem; }
.card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; max-height: 3em; overflow: hidden; }
.card-placeholder { width: 100%; aspect-ratio: 4/3; background: linear-gradient(135deg, #e8e0d0 0%, #d4c5a9 100%); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: var(--accent); font-weight: 700; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 2px; font-size: 0.7rem; font-weight: 600; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; }
.badge-primary { background: #c0392b; color: white; }
.badge-direct { background: #2980b9; color: white; }
.badge-contextual { background: #7f8c8d; color: white; }
.badge-stage { background: var(--accent); color: white; }
.review-badge { display: inline-block; padding: 0.1rem 0.4rem; background: #e8dcc8; color: #6b5420; border-radius: 2px; font-size: 0.65rem; font-weight: 600; font-family: var(--font-sans); text-transform: uppercase; margin-left: 0.3rem; }
.confidence-high { background: #dce8d4; color: #3d5a2d; }
.confidence-medium { background: #e8dcc8; color: #6b5420; }
.confidence-low { background: #e8d4d0; color: #6b3028; }

/* ===== Lightbox ===== */
.lightbox { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.96); z-index: 1000; overflow-y: auto; }
.lightbox.active { display: flex; align-items: flex-start; justify-content: center; }
.lightbox-close { position: fixed; top: 1rem; right: 1.5rem; font-size: 2rem; color: #ccc; background: none; border: none; cursor: pointer; z-index: 1001; }
.lightbox-close:hover { color: white; }
.lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); font-size: 3rem; color: #ccc; background: none; border: none; cursor: pointer; z-index: 1001; padding: 1rem; }
.lightbox-nav:hover { color: white; }
.lightbox-prev { left: 0.5rem; }
.lightbox-next { right: 0.5rem; }
.lightbox-content { display: flex; flex-direction: column; max-width: 900px; width: 100%; margin: 2rem auto; padding: 0 3rem; }
.lightbox-details { color: #e8e0d0; padding: 1.5rem; background: rgba(255,255,255,0.05); border-radius: 4px; }
.lightbox-details h3 { font-size: 1.4rem; color: var(--accent-light); margin-bottom: 0.5rem; }
.lightbox-motto { font-style: italic; font-size: 1.1rem; color: #e8d5c0; margin-bottom: 1rem; padding: 0.75rem; border-left: 3px solid var(--accent-light); }
.lightbox-desc { font-size: 0.9rem; color: #b0a090; line-height: 1.6; }

/* ===== Emblem Detail (Comparative View) ===== */
.emblem-detail { max-width: 1200px; margin: 2rem auto; padding: 0 2rem; }
.emblem-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; font-family: var(--font-sans); font-size: 0.9rem; }
.emblem-nav a { color: var(--accent); text-decoration: none; }
.emblem-nav a:hover { text-decoration: underline; }
.comparative-view { display: grid; grid-template-columns: 3fr 2fr; gap: 2rem; }
.source-panel, .scholarship-panel { min-width: 0; }
.source-panel h2, .scholarship-panel h2 { font-size: 1.3rem; color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.motto-block { background: var(--bg-card); border-left: 3px solid var(--accent); padding: 1rem 1.5rem; margin-bottom: 1.5rem; font-style: italic; font-size: 1.1rem; }
.epigram-block { background: var(--bg-card); padding: 1rem 1.5rem; margin-bottom: 1.5rem; border: 1px solid var(--border); font-size: 0.95rem; line-height: 1.8; }
.discourse-block { margin-bottom: 1.5rem; font-size: 0.95rem; }
.ref-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 1rem; margin-bottom: 1rem; }
.ref-card h4 { font-size: 0.9rem; color: var(--accent); font-family: var(--font-sans); margin-bottom: 0.5rem; }
.ref-card p { font-size: 0.88rem; line-height: 1.6; }
.source-link { display: inline-block; margin: 0.2rem 0.3rem 0.2rem 0; padding: 0.15rem 0.5rem; background: #e8dcc8; color: var(--accent); border-radius: 2px; font-size: 0.75rem; font-family: var(--font-sans); text-decoration: none; }
.source-link:hover { background: var(--accent); color: white; }
.placeholder-img { width: 100%; aspect-ratio: 4/3; background: linear-gradient(135deg, #e8e0d0 0%, #d4c5a9 100%); display: flex; align-items: center; justify-content: center; font-size: 4rem; color: var(--accent); font-weight: 700; border-radius: 4px; margin-bottom: 1.5rem; }
.emblem-plate { width: 100%; max-width: 600px; height: auto; border-radius: 4px; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

/* ===== Emblem Analysis Block ===== */
.emblem-analysis { margin-top: 2rem; padding-top: 1.5rem; border-top: 2px solid var(--border); }
.emblem-analysis h3 { font-size: 1.05rem; color: var(--accent); margin: 1.5rem 0 0.5rem; font-family: var(--font-sans); }
.emblem-analysis h3:first-of-type { margin-top: 0.5rem; }
.emblem-analysis p { font-size: 0.92rem; line-height: 1.7; margin-bottom: 0.75rem; }
.emblem-analysis dl { margin: 0.5rem 0 1rem; }
.emblem-analysis dt { font-weight: 600; font-size: 0.85rem; color: var(--accent); font-family: var(--font-sans); margin-top: 0.75rem; }
.emblem-analysis dd { font-size: 0.9rem; line-height: 1.6; margin-left: 0; padding-left: 1rem; border-left: 2px solid var(--border); }
.ai-banner { background: #fdf8e8; border: 1px solid #e8d8a0; border-radius: 4px; padding: 0.6rem 1rem; font-size: 0.78rem; color: #6b5420; font-family: var(--font-sans); margin-bottom: 1rem; }

/* ===== Source Authority Cards ===== */
.source-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 1.25rem; margin-bottom: 1.25rem; }
.source-card h4 { font-size: 1rem; color: var(--accent); font-family: var(--font-sans); margin-bottom: 0.5rem; }
.source-card .source-desc { font-size: 0.9rem; line-height: 1.65; margin-bottom: 0.75rem; }
.source-card .emblem-links { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }

/* ===== Timeline Cards ===== */
.timeline-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 1.25rem; margin-bottom: 1rem; }
.timeline-card h4 { font-size: 0.95rem; color: var(--accent); font-family: var(--font-sans); margin-bottom: 0.4rem; }
.timeline-card .event-desc { font-size: 0.9rem; line-height: 1.65; color: var(--text); }
.timeline-year { font-size: 1.5rem; font-weight: 700; color: var(--accent); margin-top: 2rem; margin-bottom: 0.5rem; position: sticky; top: 0; background: var(--bg); padding: 0.3rem 0; z-index: 10; }

/* ===== Dictionary Cards ===== */
.dict-card-wrap { position: relative; margin-bottom: 0.75rem; }
.dict-card-wrap .dict-card { margin-bottom: 0; }
.dict-card-cat { position: absolute; top: 0.85rem; right: 1rem; text-decoration: none; transition: opacity 0.15s; }
.dict-card-cat:hover { opacity: 0.85; }
.dict-related { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.dict-related-card { display: block; padding: 0.5rem 0.75rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 3px; text-decoration: none; color: var(--text); font-size: 0.85rem; transition: all 0.15s; min-width: 0; flex: 1 1 calc(33.33% - 0.4rem); max-width: calc(33.33% - 0.4rem); }
.dict-related-card:hover { border-color: var(--accent); background: var(--bg); }
.dict-related-card .dict-related-label { color: var(--accent); font-weight: 600; }
.dict-related-card .dict-related-latin { font-style: italic; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.1rem; }
@media (max-width: 768px) { .dict-related-card { flex-basis: 100%; max-width: 100%; } }
.related-emblems { margin-top: 2rem; padding-top: 1.5rem; border-top: 2px solid var(--border); }
.related-emblems h3 { font-size: 1.05rem; color: var(--accent); margin-bottom: 0.75rem; font-family: var(--font-sans); }
.related-emblems .related-section { margin-bottom: 1rem; }
.related-emblems .related-section-label { font-family: var(--font-sans); font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem; }
.related-emblems .related-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.related-emblems .related-emblem-card { display: inline-block; padding: 0.4rem 0.7rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 3px; text-decoration: none; color: var(--text); font-size: 0.82rem; transition: all 0.15s; }
.related-emblems .related-emblem-card:hover { border-color: var(--accent); background: var(--bg); }
.related-emblems .related-emblem-card strong { color: var(--accent); }
.search-result { display: flex; align-items: stretch; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 0; margin-bottom: 0.6rem; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s; overflow: hidden; }
.search-result:hover { border-color: var(--accent); transform: translateY(-1px); }
.search-result-kind { width: 100px; min-width: 100px; padding: 0.7rem 0.5rem; color: white; font-family: var(--font-sans); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; justify-content: center; text-align: center; }
.search-result-body { flex: 1; padding: 0.7rem 1rem; min-width: 0; }
.search-result-title { font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; font-size: 1rem; }
.search-result-snippet { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.search-result mark { background: #fbe8a0; color: var(--text); padding: 0 2px; border-radius: 2px; }
@media (max-width: 600px) { .search-result-kind { width: 70px; min-width: 70px; font-size: 0.6rem; } }

/* ===== Visual Browser ===== */
#vis-tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; padding: 0.6rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; }
.vis-tag-chip { font-family: var(--font-sans); font-size: 0.78rem; padding: 0.25rem 0.55rem; border: 1px solid; background: transparent; border-radius: 3px; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 0.3rem; }
.vis-tag-chip:hover { background: var(--bg); }
.vis-tag-chip.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }
.vis-tag-count { display: inline-block; font-size: 0.7rem; opacity: 0.7; padding: 0 0.3rem; border-radius: 8px; background: rgba(0,0,0,0.06); }
.vis-tag-chip.active .vis-tag-count { background: rgba(255,255,255,0.25); opacity: 1; }
.vis-tag-dict-link { color: inherit; opacity: 0.6; text-decoration: none; padding: 0 0.2rem; font-size: 0.85rem; }
.vis-tag-dict-link:hover { opacity: 1; }
.vis-img-tags { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-top: 0.4rem; }
.vis-img-tag { font-family: var(--font-sans); font-size: 0.62rem; padding: 0.1rem 0.35rem; color: white; border-radius: 2px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.03em; }
.vis-img-tag:hover { opacity: 0.85; }

/* ===== Dictionary "Depicted in" cross-corpus panel ===== */
.depicts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.depicts-card { display: block; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.depicts-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow); border-color: var(--accent); }
.depicts-card img { width: 100%; aspect-ratio: 1/1.2; object-fit: cover; display: block; background: var(--bg); }
.depicts-placeholder { width: 100%; aspect-ratio: 1/1.2; background: linear-gradient(135deg, #e8e0d0 0%, #d4c5a9 100%); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--accent); font-weight: 700; font-family: var(--font-sans); }
.depicts-meta { padding: 0.5rem 0.6rem; }
.depicts-meta .depicts-work { font-size: 0.78rem; color: var(--accent); font-weight: 600; line-height: 1.3; }
.depicts-meta .depicts-folio { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-sans); margin-top: 0.15rem; }
.gallery-tile:hover { transform: translateY(-3px); box-shadow: 0 6px 18px var(--shadow); border-color: var(--accent); }
.gallery-tile h3 { transition: color 0.15s; }
.gallery-tile:hover h3 { color: var(--accent-light, var(--accent)); }
.dict-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 1rem 1.25rem; margin-bottom: 0.75rem; text-decoration: none; color: inherit; display: block; transition: transform 0.15s, box-shadow 0.15s; }
.dict-card:hover { transform: translateY(-1px); box-shadow: 0 3px 12px var(--shadow); }
.dict-card .dict-label { font-size: 1rem; font-weight: 600; color: var(--accent); }
.dict-card .dict-latin { font-style: italic; font-size: 0.88rem; color: var(--text-muted); margin-top: 0.15rem; }
.dict-card .dict-def { font-size: 0.85rem; color: var(--text); margin-top: 0.4rem; line-height: 1.5; }
.term-latin { font-style: italic; font-size: 1.15rem; color: var(--text-muted); margin-bottom: 1.25rem; }

/* ===== Filter Bar (gallery + dictionary) ===== */
.filter-bar { max-width: 1100px; margin: 0 auto 1rem; padding: 1rem 2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; }
.filter-bar .filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.filter-bar .filter-row:last-of-type { margin-bottom: 0; }
.filter-label { font-family: var(--font-sans); font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 0.4rem; min-width: 3.5rem; }
.filter-chip { font-family: var(--font-sans); font-size: 0.78rem; padding: 0.3rem 0.7rem; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 3px; cursor: pointer; transition: all 0.15s; }
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.filter-chip.active.filter-chip-stage { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5); }
.filter-chip-count { display: inline-block; background: rgba(0,0,0,0.12); padding: 0.05rem 0.35rem; margin-left: 0.3rem; border-radius: 8px; font-size: 0.68rem; }
.filter-chip.active .filter-chip-count { background: rgba(255,255,255,0.25); }
.filter-search { width: 100%; padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 3px; font-family: var(--font-sans); font-size: 0.9rem; background: var(--bg); color: var(--text); margin-bottom: 0.6rem; }
.filter-search:focus { outline: none; border-color: var(--accent); }
.filter-status { font-family: var(--font-sans); font-size: 0.82rem; color: var(--text-muted); margin-top: 0.4rem; }
.filter-status strong { color: var(--accent); }
.filter-clear { color: var(--accent); text-decoration: underline; margin-left: 0.4rem; }
.filter-empty { display: none; }

/* ===== Cross-Links ===== */
.emblem-link-badge { display: inline-block; padding: 0.15rem 0.45rem; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; font-size: 0.72rem; font-weight: 600; font-family: var(--font-sans); color: var(--accent); text-decoration: none; transition: all 0.15s; }
.emblem-link-badge:hover { background: var(--accent); color: white; border-color: var(--accent); }
.cross-link { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent-light); }
.cross-link:hover { border-bottom-style: solid; }

/* ===== Content Pages ===== */
.page-content { max-width: 900px; margin: 2rem auto; padding: 0 2rem; }
.page-content h2 { color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; margin: 2rem 0 1rem; }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--accent); text-decoration: none; font-family: var(--font-sans); font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; }

/* ===== Footer ===== */
footer { background: var(--header-bg); color: var(--header-text); padding: 2rem; margin-top: 2rem; text-align: center; }
footer p { font-size: 0.85rem; color: #9a8c7a; }
footer a { color: var(--accent-light); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    header h1 { font-size: 1.5rem; }
    .stats { flex-direction: column; gap: 1rem; }
    .gallery { grid-template-columns: 1fr; padding: 1rem; }
    .comparative-view { grid-template-columns: 1fr; }
    .lightbox-content { padding: 0 1rem; }
    .lightbox-nav { font-size: 2rem; }
    .site-nav { gap: 0.1rem; }
    .site-nav a { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
}
