/* Custom styles for The Witchglass Covenant */

:root {
  font-size: 16px;
  --max-width: 76rem;
  --sidebar-width: 22rem;
}

[data-md-color-primary="orange"] {
  --md-primary-fg-color: hsl(22, 100%, 61%);
  --md-primary-fg-color--light: var(--md-primary-fg-color);
  --md-primary-fg-color--dark: var(--md-primary-fg-color);
}

[data-md-color-primary="orange"]:not([data-md-color-scheme="slate"]) {
  --md-typeset-a-color: var(--md-primary-fg-color);
}

@media screen and (max-width: 76.2344em) {
  [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary {
    box-shadow: var(--md-shadow-z3);
    transform: translateX(var(--sidebar-width));
  }
}

@media screen and (max-width: 76.2344em) {
  [dir="ltr"] .md-sidebar--primary {
    left: calc(var(--sidebar-width) * -1);
  }
}

/*
 * In the mobile drawer, Material renders the active page's nav item as a
 * `for="__toc"` toggle with a caret icon, which visually collides with the
 * nav link text. Hide that icon and disable the toggle so the drawer entry
 * reads as a plain link. This only affects the in-drawer item; the page's
 * actual table of contents (the secondary sidebar) is untouched.
 */
.md-nav--primary .md-nav__link--active[for="__toc"] {
  pointer-events: none;
}

.md-nav--primary .md-nav__link--active[for="__toc"] .md-nav__icon {
  display: none;
}

.md-grid {
  max-width: var(--max-width);
}

.md-sidebar--primary {
  width: var(--sidebar-width);
}

@supports selector(::-webkit-scrollbar) {
  [dir="ltr"] .md-sidebar__inner {
    padding-right: calc(100% - (var(--sidebar-width) - 1rem));
  }
}

/* Improve readability with better line height and spacing */
.md-content {
  line-height: 1.8;
}

.md-typeset p {
  margin: 1rem 0;
}

/* Make chapter headings more prominent */
.md-typeset h1 {
  font-weight: 700;
  font-size: 1.45rem;
  margin-top: 0;
  color: var(--md-primary-fg-color);
}
.md-typeset h2 {
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--md-primary-fg-color);
}

/* Improve quote styling if you have dialogue */
.md-typeset blockquote {
  border-left: 4px solid var(--md-primary-fg-color);
  padding-left: 1rem;
  font-style: italic;
}

.md-header__title {
  font-size: 1.25rem;
}

.md-tabs__link {
  font-size: 1rem;
  line-height: 1em;
}

.md-tabs__item--active {
  font-weight: 700;
}

/* Add some breathing room to the content */
.md-main__inner {
  margin-top: 1rem;
}

.md-nav {
  font-size: 0.8rem;
}

.md-nav__item--section {
  margin-bottom: 2rem;
}

.md-nav__item--section > .md-nav__link[for] {
  border-bottom: 1px solid var(--md-typeset-color);
}

/* Style the navigation items for better readability */
.md-nav__item--nested > .md-nav__link {
  font-weight: 600;
}

/* Adjust font size for comfortable reading */
.md-typeset {
  font-size: 1rem;
}

.md-footer-meta__inner {
  justify-content: center;
}

/* Word count display styling */
.word-count-display {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  opacity: 0.9;
  bottom: 2rem;
  right: 4rem;
  background: var(--md-default-bg-color);
  border-radius: 8px;
  padding: 1rem;
  text-align: right;
  font-size: 0.875rem;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.word-count-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.word-count-label {
  font-weight: 600;
  opacity: 0.7;
}

.word-count-value {
  font-weight: 700;
  font-family: "Roboto Mono", monospace;
  color: var(--md-primary-fg-color);
}

/* Responsive: hide on very small screens */
@media screen and (max-width: 600px) {
  .word-count-display {
    bottom: 0.5rem;
    right: 0.5rem;
    padding: 0.75rem;
    font-size: 0.75rem;
  }
}

/* Glossary styling */
dt.glossary-term {
  color: var(--md-primary-fg-color);
  font-weight: 600;
  font-size: 1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.15rem;
  margin-left: 1.5rem;
}

.glossary-entries {
  margin: 1.5rem 0;
}

.glossary-entry dd {
  margin-left: 0;
  margin-bottom: 0;
  padding-left: 0;
  line-height: 1.7;
}

.glossary-section-heading {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

/* Glossary tag filters */
.glossary-filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.glossary-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.glossary-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  min-width: 5rem;
}

.glossary-tag-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 1rem;
  background: transparent;
  color: var(--md-default-fg-color--light);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.glossary-tag-btn:hover {
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

.glossary-tag-btn.active {
  background: var(--md-primary-fg-color);
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color, #fff);
}

/* Glossary entry layout */
.glossary-entry {
  margin-bottom: 0.25rem;
}

.glossary-entry-tags {
  display: inline-flex;
  gap: 0.35rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.glossary-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.7;
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}

.glossary-pill--cantereian {
  background: oklch(0.92 0.05 140);
  color: oklch(0.35 0.1 140);
}
.glossary-pill--sarmalan {
  background: oklch(0.92 0.05 250);
  color: oklch(0.35 0.1 250);
}
.glossary-pill--dzharian {
  background: oklch(0.92 0.05 30);
  color: oklch(0.35 0.1 30);
}
.glossary-pill--anashi {
  background: oklch(0.92 0.05 300);
  color: oklch(0.35 0.1 300);
}
.glossary-pill--places {
  background: oklch(0.92 0.04 200);
  color: oklch(0.35 0.08 200);
}
.glossary-pill--people {
  background: oklch(0.92 0.04 60);
  color: oklch(0.35 0.08 60);
}
.glossary-pill--things {
  background: oklch(0.92 0.04 100);
  color: oklch(0.35 0.08 100);
}

[data-md-color-scheme="slate"] .glossary-pill--cantereian {
  background: oklch(0.3 0.05 140);
  color: oklch(0.8 0.1 140);
}
[data-md-color-scheme="slate"] .glossary-pill--sarmalan {
  background: oklch(0.3 0.05 250);
  color: oklch(0.8 0.1 250);
}
[data-md-color-scheme="slate"] .glossary-pill--dzharian {
  background: oklch(0.3 0.05 30);
  color: oklch(0.8 0.1 30);
}
[data-md-color-scheme="slate"] .glossary-pill--anashi {
  background: oklch(0.3 0.05 300);
  color: oklch(0.8 0.1 300);
}
[data-md-color-scheme="slate"] .glossary-pill--places {
  background: oklch(0.3 0.04 200);
  color: oklch(0.8 0.08 200);
}
[data-md-color-scheme="slate"] .glossary-pill--people {
  background: oklch(0.3 0.04 60);
  color: oklch(0.8 0.08 60);
}
[data-md-color-scheme="slate"] .glossary-pill--things {
  background: oklch(0.3 0.04 100);
  color: oklch(0.8 0.08 100);
}

/* Home page two-column layout */
.home-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: start;
}

.home-cover img {
  max-height: 80dvh;
  width: auto;
  display: block;
}

@media screen and (max-width: 800px) {
  .home-layout {
    grid-template-columns: 1fr;
  }

  .home-cover img {
    margin: 0 auto;
  }
}

.md-typeset .cover-image {
  max-height: 80dvh;
}

/*
 * The "Admin" nav entry (docs/.pages) is hidden unless admin-nav.js has
 * confirmed via /api/whoami that the reader is in ADMIN_EMAILS, in which
 * case it stamps .wc-is-admin on <html>. Cosmetic only — the /admin routes
 * themselves return 403 to non-admins server-side.
 */
li:has(> a[href="/admin"]) {
  display: none;
}

html.wc-is-admin li:has(> a[href="/admin"]) {
  display: revert;
}
