@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans:wght@700&family=IBM+Plex+Sans+Condensed:wght@400;700&family=IBM+Plex+Serif:ital,wght@0,400;0,700;1,400&display=swap');

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}
body {
  font-family: "IBM Plex Serif", serif;
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  max-width: 1600px;
  margin: 0 auto;
  color: #111;
  background-color: hsl(220, 15%, 98%);
}

main {
  flex: 3;
  font-size: 14pt;
  padding: clamp(1rem, 4vw, 4rem) clamp(1rem, 2vw, 2rem);
  min-width: calc(320px - 4rem);
  max-width: calc(1200px - 4rem);
}

aside {
  flex: 1;
  padding: clamp(1rem, 4vw, 4rem) clamp(1rem, 2vw, 2rem);
  font-size: 12pt;
  line-height: 1.4;
  color: #444;
  min-width: calc(320px - 4rem);
  max-width: calc(500px - 4rem);
  position: sticky;
  top: 0;
  height: calc(100vh - 128px);
}

@media (width < 575px) {
  aside {
    height: fit-content;
    position: static;
  }
  body:not(.home) {
    aside {
      order: 2;
    }
    main {
      order: 1;
    }
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-weight: 700;
  font-style: normal;
  line-height: 1.2;
}
h1 {
  margin-block: 0 0.5em;
}
h2 {
  margin-block: 1.5em 0.5em;
}
h3, h4, h5, h6 {
  margin-block: 1em 0.5em;
}

.muted {
  color: #999;
  font-weight: 300;
}
p {
  margin-block: 0 1rem;
  text-wrap: pretty;
}
p.lead {
  font-size: 16pt;
  color: #555;
}

a {
  color: hsl(220, 40%, 40%);
  text-underline-offset: 2px;
  text-decoration-color: hsl(220, 40%, 70%);
  text-decoration-thickness: 1px;
}
a:hover {
  color: hsl(220, 40%, 55%);
  text-decoration-color: hsl(220, 40%, 55%);
}
aside a {
  text-decoration: none;
}

aside h2 {
  font-size: 24pt;
  margin-block: 0 0.5rem;
  line-height: 1;
}
.site-title {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 72pt;
  font-weight: 700;
  letter-spacing: 0.15ch;
  text-transform: uppercase;
  color: hsl(220, 10%, 70%);
}
.site-version {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11pt;
  font-weight: 400;
  color: #999;
  margin-top: 0.3rem;
}
.site-subtitle {
  font-size: 15pt;
  font-weight: 400;
  color: #666;
  line-height: 1.3;
  margin-top: 0.3rem;
}

aside nav {
  margin-block: 1rem;
}
aside nav .nav-main {
  font-size: 15pt;
  font-weight: 500;
  margin: 0 0 0.5rem 0;
}
aside nav.small {
  margin-top: 2rem;
  font-size: 10pt;
}
aside .blurb {
  margin-top: 1rem;
  font-size: 11pt;
  line-height: 1.5;
}

/* code styling */
code, .code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.98em;
}
a.code {
  text-decoration: none;
  font-weight: 700;
}
pre.pattern {
  background: hsl(220, 15%, 95%);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12pt;
  line-height: 1.4;
  position: relative;
}
.pattern-lang {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 9pt;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05ch;
}
.pattern-lang.cql {
  background: hsl(260, 40%, 92%);
  color: hsl(260, 40%, 40%);
}
.pattern-lang.semgrex {
  background: hsl(160, 40%, 90%);
  color: hsl(160, 40%, 35%);
}
.pattern-lang.regex {
  background: hsl(30, 50%, 92%);
  color: hsl(30, 50%, 35%);
}

/* category / feature list */
.count {
  font-weight: 400;
  color: #999;
  font-size: 0.8em;
}

.category-description {
  color: #555;
  font-size: 13pt;
}

table.feature-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13pt;
  margin-bottom: 1rem;
}
table.feature-list th {
  text-align: left;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11pt;
  color: #666;
  border-bottom: 2px solid hsl(220, 15%, 85%);
  padding: 0.3rem 0.5rem;
}
table.feature-list td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid hsl(220, 15%, 92%);
}
table.feature-list td.num {
  text-align: center;
  color: #888;
}
table.feature-list tr.group-header td {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-weight: 700;
  font-size: 11pt;
  color: #555;
  padding-top: 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid hsl(220, 15%, 85%);
}
table.feature-list tr:target {
  animation: highlight-fade 3s ease-out;
}
@keyframes highlight-fade {
  0%   { background-color: hsl(50, 100%, 85%); }
  100% { background-color: transparent; }
}

/* badges */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.badge {
  display: inline-block;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 10pt;
  font-weight: 700;
  padding: 0.2em 0.6em;
  border-radius: 3px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
a.badge {
  text-decoration: none;
}
a.badge:hover {
  filter: brightness(0.93);
}
.badge.biber {
  background: hsl(220, 50%, 92%);
  color: hsl(220, 50%, 35%);
}
.badge.xiao {
  background: hsl(35, 50%, 92%);
  color: hsl(35, 50%, 30%);
}
.badge.mfte {
  background: hsl(140, 40%, 92%);
  color: hsl(140, 50%, 28%);
}
.badge.bohmann {
  background: hsl(320, 40%, 92%);
  color: hsl(320, 45%, 35%);
}
.badge.norm {
  background: hsl(160, 30%, 92%);
  color: hsl(160, 40%, 30%);
  text-transform: none;
}
.badge.composite {
  background: hsl(280, 30%, 92%);
  color: hsl(280, 40%, 35%);
}
.badge.child {
  background: hsl(280, 20%, 94%);
  color: hsl(280, 30%, 45%);
  text-transform: none;
}
.badge.mapped {
  background: hsl(140, 30%, 90%);
  color: hsl(140, 40%, 30%);
}
.badge.added {
  background: hsl(220, 40%, 92%);
  color: hsl(220, 40%, 35%);
}
.badge.deferred {
  background: hsl(40, 40%, 92%);
  color: hsl(40, 50%, 35%);
}
.badge.excluded {
  background: hsl(0, 15%, 93%);
  color: hsl(0, 10%, 50%);
}
tr.excluded td {
  color: #aaa;
}
tr.deferred td {
  color: #999;
}

/* yaml link */
.yaml-link {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(220, 15%, 92%);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11pt;
}
.yaml-link a {
  color: #999;
  text-decoration: none;
}
.yaml-link a:hover {
  color: hsl(220, 40%, 40%);
}

/* pagination */
.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(220, 15%, 92%);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 10pt;
}
.pagination a {
  color: hsl(220, 40%, 50%);
  text-decoration: none;
}
.pagination a:hover {
  color: hsl(220, 40%, 30%);
}
.pagination .prev { text-align: left; }
.pagination .next { text-align: right; }
.pagination-label {
  font-size: 8pt;
  color: hsl(220, 15%, 55%);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  text-decoration: none;
}
.pagination-label:hover {
  color: hsl(220, 40%, 40%);
}
.biber-pagination {
  border-top: none;
  margin-top: 1.5rem;
  padding-top: 0;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid hsl(220, 15%, 92%);
  margin-bottom: 0;
}
.biber-pagination + .pagination {
  border-top: none;
  margin-top: 0;
  padding-top: 0.35rem;
}

/* search */
.search-box {
  position: relative;
  margin-bottom: 1rem;
}
#search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5em 0.7em;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 12pt;
  border: 1px solid hsl(220, 15%, 82%);
  border-radius: 5px;
  background: white;
  outline: none;
}
#search:focus {
  border-color: hsl(220, 40%, 55%);
  box-shadow: 0 0 0 2px hsla(220, 40%, 55%, 0.2);
}
#search::placeholder {
  color: #aaa;
}
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid hsl(220, 15%, 82%);
  border-top: none;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 4px 12px hsla(220, 20%, 20%, 0.12);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}
.search-item {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  padding: 0.45em 0.7em;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-bottom: 1px solid hsl(220, 15%, 95%);
}
.search-item:last-child {
  border-bottom: none;
}
.search-item:hover,
.search-item.selected {
  background: hsl(220, 40%, 96%);
}
.search-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10pt;
  font-weight: 600;
  color: hsl(220, 40%, 40%);
  flex-shrink: 0;
}
.search-name {
  font-size: 11pt;
  color: #333;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-cat {
  font-size: 9pt;
  color: #aaa;
  flex-shrink: 0;
}
.search-empty {
  padding: 0.7em;
  color: #999;
  font-size: 11pt;
  text-align: center;
}

/* table of contents */
nav.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 2rem;
  padding: 1rem;
  background: hsl(220, 15%, 97%);
  border-radius: 6px;
}
nav.toc a {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11pt;
  color: hsl(220, 40%, 40%);
  text-decoration: none;
  padding: 0.2em 0.6em;
  border-radius: 3px;
  background: white;
  border: 1px solid hsl(220, 15%, 88%);
}
nav.toc a:hover {
  background: hsl(220, 40%, 95%);
  border-color: hsl(220, 40%, 70%);
}
nav.toc .count {
  color: #999;
  font-size: 10pt;
}

/* pilcrow permalink */
a.pilcrow {
  text-decoration: none;
  color: hsl(220, 15%, 80%);
  font-weight: 400;
  margin-left: 0.3em;
}
a.pilcrow:hover {
  color: hsl(220, 40%, 50%);
}

/* back to top */
.back-to-top {
  text-align: right;
  margin-top: 0.5rem;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11pt;
}
.back-to-top a {
  color: #999;
  text-decoration: none;
}
.back-to-top a:hover {
  color: hsl(220, 40%, 40%);
}

/* definition lists */
dl {
  margin: 1rem 0;
}
dt {
  font-weight: 700;
  margin-top: 1.2rem;
  color: hsl(220, 30%, 30%);
}
dd {
  margin-left: 0;
  margin-top: 0.3rem;
  margin-bottom: 0.8rem;
  color: #444;
}

/* feature detail */
.breadcrumb {
  font-size: 12pt;
  color: #888;
  margin-bottom: 1rem;
}

/* Feature page two-column layout */
.feature-layout {
  display: flex;
  gap: 2rem;
}
.feature-main {
  flex: 1;
  min-width: 0;
}
.feature-toc {
  width: 140px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
  align-self: flex-start;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 10pt;
}
.feature-toc ul {
  border-left: 2px solid hsl(220, 15%, 90%);
  padding-left: 0.75rem;
}
.feature-toc .toc-header {
  font-size: 11pt;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.25s ease, margin-bottom 0.25s ease;
  margin-bottom: 0;
}
.feature-toc .toc-header.visible {
  max-height: 3rem;
  opacity: 1;
  margin-bottom: 0.5rem;
}
.feature-toc .toc-header .code {
  font-family: "IBM Plex Mono", monospace;
}
.feature-toc ul {
  list-style: none;
  margin: 0;
}
.feature-toc li {
  margin: 0;
  padding: 0.15rem 0 0.15rem calc(0.75rem - 2px);
  border-left: 2px solid transparent;
  margin-left: calc(-0.75rem - 2px);
  transition: border-color 0.2s, color 0.2s;
}
.feature-toc li.active {
  border-left-color: hsl(220, 40%, 40%);
}
.feature-toc li.active > a {
  color: hsl(220, 40%, 40%);
  font-weight: 600;
}
.feature-toc a {
  color: #888;
  text-decoration: none;
}
.feature-toc a:hover {
  color: hsl(220, 40%, 40%);
}
.feature-toc .toc-sub {
  padding-left: 0.75rem;
  padding-top: 0.05rem;
  padding-bottom: 0.05rem;
  font-size: 0.85em;
  line-height: 1.2;
}
@media (max-width: 800px) {
  .feature-toc {
    display: none;
  }
}

.meta {
  font-size: 12pt;
  color: #666;
}

.detection-rule {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid hsl(220, 15%, 88%);
  border-radius: 6px;
  background: hsl(220, 15%, 98%);
}
.detection-rule h3 {
  font-size: 14pt;
  margin-top: 0;
  margin-bottom: 0.3rem;
}
.rule-source {
  color: #999;
  font-weight: 400;
}
.named-part {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.named-part .part-name {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12pt;
  color: #888;
  min-width: 2.5em;
  padding-top: 0.65rem;
  flex-shrink: 0;
}
.named-part pre.pattern {
  flex: 1;
  margin: 0;
}
.detection-rule pre.pattern {
  background: hsl(220, 15%, 93%);
}
.rule-description {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11pt;
  color: #666;
}
.rule-meta .meta {
  margin-bottom: 0.3rem;
}
.meta.caveat {
  color: hsl(30, 60%, 40%);
}

/* collapsible word list */
details.word-list {
  margin: 0.75rem 0;
}
details.word-list summary {
  user-select: none;
  cursor: pointer;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 12pt;
  color: #666;
  padding: 0.4rem 0;
}
details.word-list summary:hover {
  color: hsl(220, 40%, 40%);
}
code.list-name {
  font-family: "IBM Plex Mono", monospace;
  background: none;
  padding: 0;
}
.words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.75rem 0;
}
.word {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10pt;
  background: hsl(220, 15%, 95%);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  color: #444;
}

/* examples */
.example {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  border-left: 4px solid;
}
.example.positive {
  background: hsl(140, 30%, 96%);
  border-left-color: hsl(140, 40%, 60%);
}
.example.negative {
  background: hsl(0, 20%, 97%);
  border-left-color: hsl(0, 30%, 70%);
}
.example-text {
  margin-bottom: 0.3rem;
}
.example-note {
  font-size: 12pt;
  color: #666;
  font-style: italic;
  margin-bottom: 0;
}
.example-source {
  font-size: 11pt;
  color: #888;
  margin-bottom: 0;
}
mark {
  background: hsl(50, 80%, 80%);
  padding: 0.1em 0.2em;
  border-radius: 2px;
}
mark.fp {
  background: hsl(0, 60%, 92%);
  padding: 0.1em 0.2em;
  border-radius: 2px;
  text-decoration: wavy underline hsl(0, 50%, 60%);
  text-underline-offset: 3px;
}

/* home page */
.home-grid {
  display: grid;
  gap: 2rem;
  margin-top: 1.5rem;
}
.home-card {
  border: 1px solid hsl(220, 15%, 88%);
  border-radius: 6px;
  padding: 1.2rem 1.5rem;
}
.home-card h2 {
  margin-top: 0;
}
.home-sources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.home-sources a {
  display: block;
  padding: 0.8rem 1rem;
  background: hsl(220, 15%, 97%);
  border-radius: 5px;
  text-decoration: none;
  color: inherit;
  line-height: 1;
}
.home-sources a:hover {
  background: hsl(220, 20%, 93%);
}
.home-sources strong {
  display: block;
  color: hsl(220, 50%, 35%);
  margin-bottom: 0;
  line-height: 1.2;
}
.home-sources span {
  font-size: 10pt;
  color: #666;
  line-height: 1.2;
}
