*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background: #faf6ee; color: #3b2f1e; line-height: 1.7;
  display: flex; min-height: 100vh;
}

/* ========== SIDEBAR ========== */
aside.sidebar {
  width: 280px; min-width: 280px; background: #2e2318; color: #d4c4a8;
  padding: 1.2rem 0 2rem; position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto; font-size: 0.85rem; line-height: 1.4; z-index: 200;
  transition: transform 0.3s ease;
}
aside.sidebar::-webkit-scrollbar { width: 6px; }
aside.sidebar::-webkit-scrollbar-thumb { background: #5a4a38; border-radius: 3px; }
aside.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-header {
  padding: 1rem 1.2rem 1.2rem; border-bottom: 1px solid #4a3a28;
  margin-bottom: 0.6rem; text-align: center;
}
.sidebar-header img { width: 80px; height: auto; margin-bottom: 0.5rem; opacity: 0.85; }
.sidebar-header h1 { font-size: 1.2rem; color: #f0e6d2; font-weight: normal; letter-spacing: 0.05em; }
.sidebar-header h1 a { color: #f0e6d2; text-decoration: none; }
.sidebar-header .tagline { font-size: 0.72rem; color: #8b7355; font-style: italic; margin-top: 0.15rem; }

/* Search */
.sidebar-search {
  padding: 0.5rem 1rem 0.7rem; border-bottom: 1px solid #3a2e20;
}
.sidebar-search input {
  width: 100%; padding: 0.4rem 0.7rem; border: 1px solid #4a3a28;
  border-radius: 4px; background: #faf6ee; color: #111;
  font-size: 0.95rem; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.sidebar-search input::placeholder { color: #8b7a65; }
.sidebar-search input:focus { border-color: #c9a96e; }
.search-results {
  display: none; max-height: 300px; overflow-y: auto;
  background: #352a1f; border-bottom: 1px solid #4a3a28;
}
.search-results.visible { display: block; }
.search-result {
  display: block; padding: 0.4rem 1rem; color: #d4c4a8;
  text-decoration: none; font-size: 0.78rem; border-bottom: 1px solid #3a2e20;
}
.search-result:hover { background: #4a3728; color: #f0e6d2; }
.search-result .sr-chapter { font-size: 0.68rem; color: #8b7355; }

/* Navigation */
.nav-chapter { margin-bottom: 0.1rem; }
.nav-chapter-label {
  display: flex; align-items: center; padding: 0.4rem 1rem;
  font-size: 1.25rem; color: #e0d4c0;
  transition: color 0.15s, background 0.15s;
  gap: 0.3rem;
}
.nav-chapter-label:hover { color: #f0e6d2; background: rgba(255,255,255,0.04); }
.nav-chapter-label a { color: inherit; text-decoration: none; }
.nav-chapter-label a:hover { color: #f0e6d2; }
.nav-active-chapter > .nav-chapter-label {
  color: #f0e6d2; font-weight: 600; background: #3d2e20;
  border-left: 3px solid #c9a96e; padding-left: calc(1rem - 3px);
}
.chevron {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5em; height: 1.5em; font-size: 0.65em; color: #c0b098;
  transition: transform 0.25s ease, color 0.15s;
  flex-shrink: 0; cursor: pointer; border-radius: 3px;
}
.chevron:hover { color: #c9a96e; background: rgba(255,255,255,0.06); }
.nav-active-chapter > .nav-chapter-label .chevron { transform: rotate(90deg); color: #c9a96e; }

.nav-groups {
  overflow: hidden; max-height: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-active-chapter > .nav-groups { max-height: 8000px; }

.nav-group { margin-bottom: 0.15rem; }
.nav-group-label {
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.3rem 1rem 0.3rem 1.4rem; font-size: 1.0rem;
  color: #e8d8c0; letter-spacing: 0.02em;
  font-weight: normal; transition: color 0.15s, background 0.15s;
}
.nav-group-label a { color: inherit; text-decoration: none; }
.nav-group-label a:hover { color: #f0e6d2; }
.nav-group-label:hover { color: #f0e6d2; background: rgba(255,255,255,0.04); }
.nav-group-active > .nav-group-label { color: #f0e6d2; background: #3d2e20; }
.nav-group-active > .nav-group-label .chevron { transform: rotate(90deg); color: #c9a96e; }

.nav-pages {
  list-style: none; overflow: hidden; max-height: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-group-active > .nav-pages { max-height: 8000px; }
.nav-pages li { margin: 0; }
.nav-pages a {
  display: block; padding: 0.22rem 1rem 0.22rem 2.2rem;
  color: #e0d6c4; text-decoration: none; font-size: 0.9rem;
  border-left: 2px solid transparent; transition: all 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-pages a::before { content: '\25E6'; margin-right: 0.45em; font-size: 0.7em; opacity: 0.55; }
.nav-pages a.active::before { content: '\25C6'; opacity: 0.85; color: #c9a96e; }
.nav-pages a:hover { color: #f0e6d2; background: rgba(255,255,255,0.05); }
.nav-pages a.active {
  color: #f5e6c8; background: #4a3728;
  border-left-color: #c9a96e; font-weight: 600;
}

/* ========== MOBILE MENU ========== */
.menu-toggle {
  display: none; position: fixed; top: 0.7rem; left: 0.7rem; z-index: 300;
  width: 40px; height: 40px; border: none; border-radius: 6px;
  background: #2e2318; color: #d4c4a8; cursor: pointer;
  font-size: 1.3rem; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: background 0.2s;
}
.menu-toggle:hover { background: #3d2e20; }
.menu-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 150; opacity: 0; transition: opacity 0.3s;
}

/* ========== MAIN ========== */
main {
  margin-left: 280px; flex: 1; min-width: 0;
  display: flex; flex-direction: column; min-height: 100vh;
}
.top-bar {
  background: linear-gradient(135deg, #4a3728 0%, #6b4f3a 50%, #4a3728 100%);
  color: #f0e6d2; padding: 1.5rem 2.5rem; border-bottom: 3px solid #8b7355;
  position: relative;
}
.top-bar h1 { font-size: 1.6rem; font-weight: normal; }
.top-bar .subtitle { font-size: 0.85rem; opacity: 0.7; font-style: italic; margin-top: 0.2rem; }

.content-area { padding: 2rem 2.5rem 3rem; flex: 1; }

/* ========== BREADCRUMBS ========== */
.breadcrumbs { font-size: 0.78rem; color: #8b7355; margin-bottom: 1.2rem; }
.bc-sep { margin: 0 0.35rem; color: #c9b896; }
.bc-item { color: #8b7355; text-decoration: none; transition: color 0.15s; }
a.bc-item:hover { color: #4a3220; }
.bc-current { color: #4a3220; font-weight: 600; }

/* Joomla breadcrumb module — now overridden by mod_breadcrumbs/default.php
   These fallback rules kept for safety */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; }
.breadcrumbs li { display: flex; align-items: center; }
.breadcrumbs li + li::before { content: '\203A'; margin: 0 0.35rem; color: #c9b896; }
.breadcrumbs a { color: #8b7355; text-decoration: none; transition: color 0.15s; }
.breadcrumbs a:hover { color: #4a3220; }
.breadcrumbs .active { color: #4a3220; font-weight: 600; }

/* ========== PAGE CONTENT ========== */
.page-title {
  font-size: 1.6rem; color: #3b2210; margin-bottom: 0.3rem;
  font-weight: normal; line-height: 1.3;
}
.group-summary {
  font-size: 1.05rem; line-height: 1.7; color: #4a3728;
  margin-bottom: 2rem; white-space: pre-line;
}
.page-meta {
  font-size: 0.75rem; color: #a09080; margin-bottom: 1.5rem;
  padding-bottom: 0.8rem; border-bottom: 1px solid #eee4d4;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.page-meta a { color: #a09080; text-decoration: none; }
.page-meta a:hover { color: #4a3220; }
.type-badge {
  display: inline-block; font-size: 0.68rem; padding: 0.12rem 0.5rem;
  border-radius: 3px; background: #f3ead8; color: #6b4f3a;
  letter-spacing: 0.03em; text-transform: capitalize;
}

.page-content { text-align: left; }
.page-content p { margin-bottom: 1rem; }
.page-content h1, .page-content h2 {
  font-size: 1.2rem; margin-top: 1.8rem; margin-bottom: 0.5rem;
  color: #4a3220; font-weight: normal;
}
.page-content h3 { font-size: 1.05rem; margin-top: 1.3rem; margin-bottom: 0.4rem; color: #5a4230; }
.page-content a { color: #7b4b2a; text-decoration: none; border-bottom: 1px solid #d4c4a8; transition: all 0.15s; }
.page-content a:hover { color: #3b2210; border-bottom-color: #3b2210; }
.page-content img {
  max-width: 100%; height: auto; margin: 0.8rem 0; border-radius: 4px;
  cursor: pointer; transition: box-shadow 0.2s;
}
.page-content img:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.12); }

/* PDF grid + thumbnail cards */
.pdf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem; margin: 1rem 0;
}
.pdf-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px solid #d4c4a8; border-radius: 6px; padding: 0.5rem;
  background: #faf6ee; transition: box-shadow 0.2s, border-color 0.2s;
  text-decoration: none !important; border-bottom: none !important;
}
.pdf-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.12); border-color: #7b4b2a; }
.pdf-thumb {
  width: 100%; height: auto; border-radius: 3px; margin: 0 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15); cursor: pointer;
}
.pdf-label {
  display: block; font-size: 0.75rem; color: #5a4a38; margin-top: 0.4rem;
  line-height: 1.3; word-break: break-word;
}

.page-content blockquote {
  border-left: 3px solid #c9b896; margin: 1rem 0; padding: 0.6rem 1.2rem;
  background: #f8f3ea; font-style: italic; color: #5a4a38;
}
.page-content ul, .page-content ol { margin: 0.5rem 0 1rem 1.5rem; }
.page-content li { margin-bottom: 0.3rem; }
.page-content table { border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; width: 100%; }
.page-content th, .page-content td { border: 1px solid #d4c4a8; padding: 0.4rem 0.7rem; text-align: left; }
.page-content th { background: #f3ead8; font-weight: 600; }

/* Kommentar / blandet: optimized for reading */
.type-kommentar .page-content, .type-blandet .page-content {
  font-size: 1.05rem; line-height: 1.85;
}
.type-kommentar .page-content p:first-of-type::first-letter,
.type-blandet .page-content p:first-of-type::first-letter {
  font-size: 2.4rem; float: left; line-height: 1; margin-right: 0.08rem;
  margin-top: 0.05rem; color: #6b4f3a;
}
.type-kommentar .page-content h2, .type-blandet .page-content h2 {
  font-size: 1.25rem; margin-top: 2.2rem; margin-bottom: 0.8rem;
  border-bottom: 1px solid #e8dcc6; padding-bottom: 0.3rem;
}
.type-kommentar .page-content p, .type-blandet .page-content p {
  margin-bottom: 1.2rem;
}

/* Transskription */
.type-transskription .page-title::before { content: "\2E3A "; color: #b89e78; }
.type-transskription .page-content { font-size: 0.95rem; line-height: 1.65; }

/* ========== CARDS ========== */
.group-header { margin-top: 2.2rem; margin-bottom: 1rem; }
.group-header:first-child { margin-top: 0; }
.group-title {
  font-size: 1.1rem; color: #6b4f3a; text-transform: uppercase;
  letter-spacing: 0.08em; border-bottom: 2px solid #d4c4a8;
  padding-bottom: 0.4rem; font-weight: normal;
}
.page-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 1.5rem; }
.page-card {
  background: #fff; border: 1px solid #e8dcc6; border-radius: 6px;
  padding: 1rem 1.2rem; text-decoration: none; color: #3b2f1e;
  transition: all 0.2s; display: block;
}
.page-card:hover {
  border-color: #c9a96e; box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.page-card h3 { font-size: 0.95rem; color: #4a3220; font-weight: normal; margin-bottom: 0.3rem; line-height: 1.3; }
.page-card .card-preview { font-size: 0.8rem; color: #8b7355; line-height: 1.45; }

/* Chapter intro + chapter cards (home page) */
.chapter-intro { }
.chapter-intro > p { margin-bottom: 1.2rem; font-size: 1.05rem; }
.intro-lead { font-size: 1.15rem !important; color: #3b2210; line-height: 1.8; }
.intro-lead::first-letter {
  font-size: 2.8rem; float: left; line-height: 1; margin-right: 0.1rem;
  margin-top: 0.05rem; color: #6b4f3a;
}

.chapter-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 1.5rem; }
.chapter-card {
  background: #fff; border: 1px solid #e8dcc6; border-radius: 6px;
  padding: 1.2rem 1.4rem; text-decoration: none; color: #3b2f1e;
  transition: all 0.2s; display: block;
}
.chapter-card:hover {
  border-color: #c9a96e; box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.chapter-card h2 { font-size: 1.1rem; color: #4a3220; font-weight: normal; margin-bottom: 0.25rem; }
.chapter-card .card-meta { font-size: 0.8rem; color: #8b7355; }

/* ========== PREV/NEXT ========== */
.page-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid #e8dcc6;
}
.page-nav a {
  color: #7b4b2a; text-decoration: none; font-size: 0.88rem;
  padding: 0.6rem 1rem; border: 1px solid #e0d4c0; border-radius: 6px;
  transition: all 0.2s; max-width: 48%; line-height: 1.3;
}
.page-nav a:hover { background: #f5efe5; border-color: #c9a96e; }
.page-nav .nav-label { font-size: 0.68rem; color: #8b7355; display: block; margin-bottom: 0.15rem; text-transform: uppercase; letter-spacing: 0.05em; }
.page-nav .nav-next { margin-left: auto; text-align: right; }

/* ========== LIGHTBOX ========== */
.lightbox {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.88);
  z-index: 1000; cursor: pointer; justify-content: center; align-items: center;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 92%; max-height: 92%; border-radius: 4px; box-shadow: 0 4px 30px rgba(0,0,0,0.5); }
.lightbox-close {
  position: fixed; top: 1rem; right: 1.5rem; color: #fff; font-size: 2rem;
  cursor: pointer; opacity: 0.7; transition: opacity 0.2s; z-index: 1001;
  background: none; border: none; font-family: inherit;
}
.lightbox-close:hover { opacity: 1; }

/* ========== FOOTER ========== */
footer {
  text-align: center; padding: 2rem; font-size: 0.8rem; color: #8b7355;
  border-top: 1px solid #d4c4a8; margin-top: auto;
}
footer a { color: #8b7355; text-decoration: none; }

/* ========== ARTICLE COUNT BADGE ========== */
.article-count {
  display: inline-block; font-size: 0.68rem; color: #8b7355;
  background: #f3ead8; padding: 0.1rem 0.45rem; border-radius: 3px;
  margin-left: 0.3rem; font-weight: normal;
}

/* ========== BACK TO TOP ========== */
.back-to-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem; width: 40px; height: 40px;
  border-radius: 50%; background: #4a3728; color: #f0e6d2; border: none;
  font-size: 1.2rem; cursor: pointer; opacity: 0; transition: opacity 0.3s, background 0.2s;
  z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
}
.back-to-top.visible { opacity: 1; }
.back-to-top:hover { background: #6b4f3a; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .page-cards, .chapter-cards { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  aside.sidebar { transform: translateX(-100%); }
  aside.sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .menu-overlay.visible { display: block; opacity: 1; }
  main { margin-left: 0; }
  .top-bar { padding: 1.2rem 1rem 1.2rem 3.5rem; }
  .top-bar h1 { font-size: 1.3rem; }
  .content-area { padding: 1.5rem 1rem 2rem; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: 100%; }
}
@media (max-width: 500px) {
  .content-area { padding: 1rem 0.8rem 2rem; }
}

/* ========== JOOMLA OVERRIDES ========== */
/* Hide default Joomla chrome */
.com-content-category .page-header,
.com-content-article .article-info,
.com-content-article .article-footer,
.com-content-featured .page-header,
.com-content-featured .article-info,
.com-content-featured .article-footer,
.com-content-featured h2,
.pagination, .counter, .com-content-category__filter,
.cat-children, .com-content-category .items-leading + .items-row,
.pager, .pagenav { display: none !important; }

/* Hide Joomla frontend editing chrome for modules (Edit Module, position labels, tooltips) */
.jmodedit, .jmenuedit,
a.btn.btn-link.jmodedit,
div[role="tooltip"],
.mod-preview, .mod-preview-info,
[class*="mod-preview"] { display: none !important; }

/* Breadcrumbs bar */
.breadcrumbs-bar {
  display: flex; align-items: center;
  margin-bottom: 1.2rem;
}
.breadcrumbs-bar .breadcrumbs { margin-bottom: 0; }

/* Admin toolbar — top-right of article, only visible to logged-in editors */
.admin-toolbar {
  float: right; display: flex; gap: 0.4rem; margin-left: 1rem; margin-bottom: 0.5rem;
}
.admin-btn {
  font-size: 0.72rem; color: #8b7355; text-decoration: none;
  padding: 0.15rem 0.55rem; border: 1px solid #d4c4a8; border-radius: 3px;
  background: #faf6ee; transition: all 0.2s; white-space: nowrap;
}
.admin-btn:hover {
  color: #4a3220; border-color: #c9a96e; background: #f5efe5;
}

/* Map Joomla article body to our page-content styling */
.com-content-article .com-content-article__body { text-align: left; }
.com-content-article .com-content-article__body p { margin-bottom: 1rem; }
.com-content-article .com-content-article__body img {
  max-width: 100%; height: auto; margin: 0.8rem 0; border-radius: 4px;
  cursor: pointer; transition: box-shadow 0.2s;
}

/* Joomla system messages */
.alert { border-radius: 6px; padding: 0.8rem 1.2rem; margin-bottom: 1rem; font-size: 0.9rem; }
