/* Revision 18b: the glossary in the brand system (brand.css). */
.glossary-hero { position: relative; overflow: hidden; padding: clamp(48px, 7vw, 88px) 0 clamp(32px, 4vw, 48px); }
.glossary-hero-art { position: absolute; inset: 0 0 0 auto; width: 52%; background: url(assets/ink-landscape.webp) 60% 58% / cover no-repeat; opacity: .38; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%), linear-gradient(180deg, #000 60%, transparent); -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 45%), linear-gradient(180deg, #000 60%, transparent); mask-composite: intersect; }
.glossary-hero .wrap { position: relative; }
.glossary-hero .eyebrow [lang="zh"] { letter-spacing: .1em; }
.glossary-hero h1 { max-width: 11em; margin-top: 20px; }
.glossary-lead { max-width: 36em; margin-top: 20px; font-size: clamp(17px, 1.5vw, 19px); line-height: 1.6; color: var(--ink-2); }
.glossary-note { display: flex; gap: 10px; max-width: 40em; margin-top: 18px; font-size: 14px; line-height: 1.55; color: var(--ink-3); }
.glossary-note .i { margin-top: 2px; color: var(--gold-deep); }

/* Start here: the four ideas every reading uses */
.glossary-start { margin-bottom: 36px; }
.glossary-start h2 { margin-bottom: 16px; font-size: 24px; }
.start-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.start-card { display: grid; align-content: start; justify-items: start; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.start-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.start-chinese { display: grid; place-items: center; min-width: 48px; height: 48px; padding: 0 10px; border-radius: 12px; background: var(--red-tint); color: var(--red); font: 600 19px/1 var(--zh); white-space: nowrap; }
.start-body { display: grid; gap: 4px; }
.start-title { font: 500 18px/1.25 var(--serif); }
.start-text { font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }

/* Search and categories, kept in reach while reading */
.glossary-toolbar { position: sticky; top: 72px; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 0 calc(-1 * var(--gutter)) 8px; padding: 14px var(--gutter); background: rgba(247, 242, 232, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search-field { flex: 0 1 360px; min-width: 240px; }
.search-field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.search-control { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 14px; border: 1.5px solid var(--line-2); border-radius: 999px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.search-control:focus-within { border-color: var(--jade); box-shadow: 0 0 0 4px rgba(24, 63, 53, .12); }
.search-control .i { color: var(--ink-3); }
.search-control input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 16px; color: var(--ink); outline: none; }
.search-control input::-webkit-search-cancel-button { display: none; }
.search-control button { padding: 8px 12px; border: 0; border-radius: 999px; background: var(--paper); font-size: 13.5px; font-weight: 600; color: var(--red); }
.category-nav { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 400px; padding: 2px; scrollbar-width: none; }
.category-nav::-webkit-scrollbar { display: none; }
.category-nav a { display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.category-nav a:hover { border-color: var(--red); color: var(--red); }
.category-count { min-width: 22px; padding: 1px 6px; border-radius: 999px; background: var(--paper-2); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; color: var(--ink-3); }

/* Terms */
.glossary-results { padding-bottom: 72px; }
.glossary-count { min-height: 20px; margin: 18px 0 8px; font-size: 13.5px; color: var(--ink-3); }
.glossary-category { margin-top: 36px; scroll-margin-top: 150px; }
.glossary-category > h2 { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); font-size: 28px; }
.glossary-category { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.glossary-category > h2 { grid-column: 1 / -1; }
.term-card { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-content: start; gap: 0 18px; margin-bottom: 18px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); scroll-margin-top: 150px; overflow-wrap: anywhere; transition: box-shadow .2s, border-color .2s; }
.term-card:target, .term-card:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(198, 173, 121, .3); }
.term-heading { display: contents; }
.term-chinese { grid-column: 1; grid-row: 1 / span 2; display: grid; place-items: center; width: 64px; min-height: 64px; padding: 6px; border-radius: 14px; background: var(--red-tint); color: var(--red); font: 600 20px/1.2 var(--zh); text-align: center; }
#category-stems_branches .term-chinese, #category-calendar .term-chinese { background: #f3ead6; color: var(--gold-deep); }
#category-ten_gods .term-chinese { background: #e1ebe5; color: var(--jade); }
#category-elements_cycles .term-chinese { background: #e3e9f0; color: var(--water); }
.term-card h3 { grid-column: 2; align-self: end; font-size: 23px; }
.term-card h3 a { color: var(--ink); text-decoration: none; }
.term-card h3 a:hover { color: var(--red); }
.term-pinyin { grid-column: 2; align-self: start; margin-top: 2px; font: italic 400 15px/1.4 var(--serif); color: var(--ink-3); }
.term-card > :not(.term-heading, .term-pinyin) { grid-column: 1 / -1; }
.term-definition { margin-top: 16px; font-size: 16px; line-height: 1.65; }
.term-detail { margin-top: 10px; font-size: 14.5px; line-height: 1.65; color: var(--ink-2); }
.term-aliases, .term-related { margin-top: 14px; font-size: 13.5px; line-height: 1.7; color: var(--ink-3); }
/* The related links are chips; the separators between them are only for plain text and screen readers. */
.term-related { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0; }
.term-related .term-meta-label { font-size: 13.5px; }
.term-meta-label { font-weight: 600; color: var(--ink-2); }
.term-related a { display: inline-block; padding: 3px 11px; font-size: 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--jade); text-decoration: none; }
.term-related a:hover { border-color: var(--jade); }
.term-sources { margin-top: 14px; font-size: 13px; color: var(--ink-3); }
.term-sources summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; }
.term-sources summary::-webkit-details-marker { display: none; }
.term-sources summary::before { content: "+"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--paper-2); color: var(--red); font-size: 13px; }
.term-sources[open] summary::before { content: "−"; }
.term-sources ul { margin: 10px 0 0; padding-left: 18px; }
.term-sources li { margin-bottom: 6px; }
.term-sources a { color: var(--ink-2); text-underline-offset: 3px; }
.glossary-empty, .glossary-error { margin-top: 24px; padding: 24px; border: 1px dashed var(--line-2); border-radius: var(--radius); font-size: 15px; color: var(--ink-2); }

/* Closing call to action */
.glossary-cta { position: relative; overflow: hidden; background: var(--jade); color: #eee8db; }
.glossary-cta .wrap { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 28px; padding: 64px 0; }
.glossary-cta h2 { max-width: 16em; color: #fff; }
.glossary-cta p { max-width: 34em; margin-top: 12px; color: #b9c4bd; }

/* Revision 18e: one page per term (glossary/<slug>.html) */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--ink-3); }
.breadcrumb li + li::before { content: "/"; margin: 0 10px; color: var(--line-2); }
.breadcrumb a { color: var(--ink-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--red); }
.term-title { display: flex; align-items: center; gap: clamp(18px, 3vw, 28px); margin-top: 28px; }
.term-seal { display: grid; place-items: center; flex: none; min-width: clamp(84px, 10vw, 112px); height: clamp(84px, 10vw, 112px); margin: 0; padding: 0 14px; border-radius: 22px; background: var(--red-tint); color: var(--red); font: 600 clamp(30px, 3.6vw, 42px)/1 var(--zh); white-space: nowrap; }
.term-hero .term-title h1 { max-width: none; margin: 0; }
.term-hero-pinyin { margin-top: 8px; font: italic 400 clamp(17px, 1.6vw, 20px)/1.4 var(--serif); color: var(--ink-3); }
.term-hero-pinyin [lang="zh"] { font-style: normal; font-family: var(--zh); }
.term-hero .glossary-lead { max-width: 40em; margin-top: 24px; }
.term-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(24px, 4vw, 48px); align-items: start; padding-bottom: clamp(40px, 6vw, 64px); }
.term-article { padding: clamp(24px, 4vw, 44px); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
.term-article section + section { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--line); }
.term-article h2, .term-aside h2 { margin-bottom: 14px; font-size: 24px; }
.term-article p { font-size: 16.5px; line-height: 1.75; color: var(--ink-2); }
.term-article .term-aliases { margin-top: 14px; font-size: 14.5px; color: var(--ink-3); }
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.char-list li { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.char-hanzi { display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font: 600 30px/1 var(--zh); }
.char-body { display: grid; gap: 2px; }
.char-body b { font: italic 500 17px/1.3 var(--serif); color: var(--red); }
.char-body span { font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.term-article .char-literal { margin-top: 16px; padding: 14px 18px; border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; background: var(--paper); font-size: 15.5px; }
.char-literal [lang="zh"] { font-family: var(--zh); }
.term-source-list { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.7; color: var(--ink-3); }
.term-source-list li { margin-bottom: 6px; }
.term-source-list li::marker { color: var(--red); }
.term-source-list a { color: var(--ink-2); text-underline-offset: 3px; }
.term-article .glossary-note { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.term-article .glossary-note span { font-size: 14px; color: var(--ink-3); }
.term-aside { position: sticky; top: 96px; display: grid; gap: 12px; }
.term-aside h2 { margin-bottom: 4px; font-size: 20px; }
.related-terms { display: grid; gap: 10px; }
.related-terms .start-card { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 14px; padding: 14px 16px; }
.related-terms .start-chinese { min-width: 44px; height: 44px; font-size: 17px; }
.term-aside .text-link { justify-self: start; margin-top: 6px; }
.term-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-bottom: clamp(48px, 7vw, 80px); }
.pager-link { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; font: 500 18px/1.3 var(--serif); transition: border-color .15s, box-shadow .15s; }
.pager-link:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.pager-link.next { justify-content: flex-end; text-align: right; }
.pager-link small { display: block; margin-bottom: 4px; font: 600 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.pager-link [lang="zh"] { font-family: var(--zh); color: var(--red); }
.pager-link .i { flex: none; color: var(--red); }

@media (max-width: 1020px) {
  .start-grid { grid-template-columns: 1fr 1fr; }
  .term-layout { grid-template-columns: 1fr; }
  .term-aside { position: static; }
  .related-terms { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .glossary-hero-art { width: 100%; opacity: .16; }
  .glossary-category { grid-template-columns: 1fr; }
  .glossary-toolbar { top: 62px; }
  .search-field { flex-basis: 100%; }
}
@media (max-width: 560px) {
  .start-grid { grid-template-columns: 1fr; }
  .term-card { grid-template-columns: 52px minmax(0, 1fr); gap: 0 14px; padding: 20px; }
  .term-chinese { width: 52px; min-height: 52px; font-size: 17px; }
  .term-card h3 { font-size: 21px; }
  .glossary-cta .button { width: 100%; }
  .term-title { align-items: flex-start; }
  .related-terms, .term-pager { grid-template-columns: 1fr; }
  .term-article { padding: 22px 18px; border-radius: var(--radius); }
}
