/* Thematic directory and practitioner guides share the home page's editorial palette. */
body:has(:is(section[data-page="thematics"], article[data-central-thematic], main[data-thematic-detail]):not([hidden])) {
  --theme-ink: #103833;
  --theme-accent: #246957;
  --theme-body: #365a50;
  --theme-rule: #cbd9d3;
  --theme-tint: #f0f6f3;
  --paper: #fff;
  --ink: var(--theme-ink);
  --green: var(--theme-accent);
  --line: var(--theme-rule);
  --theme-gutter: clamp(1.125rem, 4vw, 3.75rem);
  --theme-inset: max(var(--theme-gutter), calc((100% - 77.5rem) / 2));
  background: #fff;
}

:is(section[data-page="thematics"], article[data-central-thematic], main[data-thematic-detail]) {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 clamp(2.5rem, 5vw, 5rem);
  color: var(--theme-ink);
  overflow-wrap: break-word;
}

section[data-page="thematics"] > :not(.thematic-hero),
article[data-central-thematic] > :not(.page-heading),
main[data-thematic-detail] > :not(.intro) {
  width: min(77.5rem, calc(100% - 2 * var(--theme-gutter)));
  margin-inline: auto;
}

section[data-page="thematics"] .thematic-hero,
article[data-central-thematic] .page-heading,
main[data-thematic-detail] .intro {
  padding: clamp(2.6rem, 5vw, 4.75rem) var(--theme-inset);
  color: #fff;
  background: linear-gradient(112deg, #102f2d, #153d37 65%, #1b4a40);
  border: 0;
}

:is(section[data-page="thematics"] .thematic-hero, article[data-central-thematic] .page-heading) .eyebrow {
  margin: 0 0 .9rem;
  color: #bde4cf;
  font: bold .813rem/1.45 Arial, Helvetica, sans-serif;
  letter-spacing: .105em;
}

:is(section[data-page="thematics"] .thematic-hero, article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) h1 {
  margin: 0 0 1rem;
  max-width: 28ch;
  color: #fff;
  font: 500 clamp(2.45rem, 5vw, 4.65rem)/1.05 Georgia, 'Times New Roman', serif;
  letter-spacing: -.045em;
  text-wrap: balance;
}

:is(section[data-page="thematics"] .thematic-hero, article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) p {
  max-width: 70ch;
  margin: .8rem 0 0;
  color: #deeee7;
  font-size: clamp(1.025rem, 1.3vw, 1.18rem);
  line-height: 1.6;
}

:is(article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) > a:first-child {
  display: inline-block;
  margin: 0 0 1.25rem;
}

:is(section[data-page="thematics"] .thematic-hero, article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) a {
  color: #fff;
  border-color: #8fb6a9;
  font: 700 .94rem/1.5 Arial, Helvetica, sans-serif;
  text-underline-offset: .19em;
}

:is(article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) a:not(.linkbtn) {
  text-decoration: underline;
  text-decoration-color: #9bc4b4;
}

section[data-page="thematics"] .thematic-tools {
  display: grid;
  grid-template-columns: minmax(12rem, 1.25fr) minmax(10rem, 1fr) auto minmax(8rem, auto);
  grid-template-areas: "search-label subject-label . ." "search subject reset count";
  align-items: center;
  gap: .4rem clamp(.8rem, 2vw, 1.65rem);
  padding-block: clamp(1.4rem, 2.5vw, 2.25rem);
  border-bottom: 1px solid var(--theme-rule);
}

section[data-page="thematics"] .thematic-tools label[for="thematic-search"] { grid-area: search-label; }
section[data-page="thematics"] .thematic-tools label[for="thematic-subject"] { grid-area: subject-label; }

section[data-page="thematics"] .thematic-tools label {
  color: var(--theme-ink);
  font-size: 1rem;
  font-weight: 700;
}

section[data-page="thematics"] .thematic-tools :is(input[type="search"], select, button) {
  box-sizing: border-box;
  max-width: 100%;
  min-height: 2.85rem;
  padding: .55rem .85rem;
  border: 1px solid #77918a;
  border-radius: .1875rem;
  background: #fff;
  color: var(--theme-ink);
  font: 1rem/1.5 Arial, Helvetica, sans-serif;
}

section[data-page="thematics"] .thematic-tools input[type="search"] {
  grid-area: search;
  width: 100%;
}

section[data-page="thematics"] .thematic-tools input::placeholder {
  color: #516c64;
  opacity: 1;
}

section[data-page="thematics"] #thematic-subject {
  grid-area: subject;
  width: 100%;
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m3 6 5 5 5-5' fill='none' stroke='%23246957' stroke-width='1.6'/%3E%3C/svg%3E");
  background-size: 1rem;
  background-repeat: no-repeat;
  background-position: right .65rem center;
}

section[data-page="thematics"] #thematic-reset {
  grid-area: reset;
  white-space: nowrap;
  font-weight: 700;
  color: var(--theme-accent);
  border-color: var(--theme-accent);
  cursor: pointer;
}

section[data-page="thematics"] #thematic-reset:hover { background: var(--theme-tint); }

section[data-page="thematics"] [hidden] { display: none !important; }

section[data-page="thematics"] #thematic-pending:not([hidden]) {
  margin-block: 1.5rem;
  padding: 1rem 1.25rem;
  border-left: .2rem solid var(--theme-accent);
  background: var(--theme-tint);
  color: var(--theme-body);
  font-size: 1rem;
  line-height: 1.6;
}

section[data-page="thematics"] #thematic-pending :first-child { margin-top: 0; }
section[data-page="thematics"] #thematic-pending :last-child { margin-bottom: 0; }
section[data-page="thematics"] #thematic-pending a {
  color: var(--theme-accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .17em;
}

section[data-page="thematics"] .thematic-result-count {
  grid-area: count;
  margin: 0 0 0 auto;
  color: var(--theme-body);
  font-size: .94rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

section[data-page="thematics"] .thematic-group,
section[data-page="thematics"] .thematic-method {
  padding-block: clamp(1.85rem, 3.25vw, 3.25rem);
}

section[data-page="thematics"] .thematic-group + .thematic-group {
  border-top: 1px solid var(--theme-rule);
}

section[data-page="thematics"] :is(.thematic-group, .thematic-method) h2,
article[data-central-thematic] .section > h2 {
  margin: 0 0 1.15rem;
  font: 500 clamp(1.75rem, 3.3vw, 2.65rem)/1.13 Georgia, 'Times New Roman', serif;
  letter-spacing: -.032em;
  color: var(--theme-ink);
  text-wrap: balance;
}

section[data-page="thematics"] .thematic-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 1rem;
}

section[data-page="thematics"] .thematic-cards > li {
  min-width: 0;
  position: relative;
  margin: 0;
  padding: clamp(1.1rem, 2.1vw, 1.6rem);
  background: var(--theme-tint);
  border: 1px solid var(--theme-rule);
  border-top: 3px solid var(--theme-accent);
}

section[data-page="thematics"] .thematic-cards h3 {
  margin: 0 0 .65rem;
  font: 500 clamp(1.29rem, 1.65vw, 1.58rem)/1.2 Georgia, 'Times New Roman', serif;
  letter-spacing: -.016em;
}

section[data-page="thematics"] .thematic-cards a {
  color: var(--theme-ink);
  text-decoration: underline;
  text-decoration-color: #87aca0;
  text-decoration-thickness: 1px;
  text-underline-offset: .16em;
}

section[data-page="thematics"] .thematic-cards h3 a:only-child::after {
  content: "";
  position: absolute;
  inset: 0;
}

section[data-page="thematics"] .thematic-cards > li:focus-within,
section[data-page="thematics"] .thematic-cards > li:hover {
  background: #e5f0ea;
  border-color: var(--theme-accent);
}

section[data-page="thematics"] :is(.thematic-cards, .thematic-method) p,
article[data-central-thematic] .section :is(p, li) {
  color: var(--theme-body);
  font-size: 1rem;
  line-height: 1.64;
}

section[data-page="thematics"] .thematic-cards p { margin: 0; }

section[data-page="thematics"] .thematic-method {
  padding-inline: clamp(1.2rem, 3vw, 2.5rem);
  border-left: .25rem solid var(--theme-accent);
  background: var(--theme-tint);
}

section[data-page="thematics"] .thematic-method :is(p, ol, ul) { max-width: 75ch; }
section[data-page="thematics"] .thematic-method :is(ol, ul) { padding-left: 1.25rem; }
section[data-page="thematics"] .thematic-method li + li { margin-top: .35rem; }
section[data-page="thematics"] .thematic-method > :last-child { margin-bottom: 0; }

article[data-central-thematic] > .section {
  padding-block: clamp(1.75rem, 3.2vw, 3rem);
}

article[data-central-thematic] .section + .section { border-top: 1px solid var(--theme-rule); }

article[data-central-thematic] .editorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: clamp(1.25rem, 3vw, 2.6rem);
}

article[data-central-thematic] .editorial-card {
  display: block;
  min-width: 0;
  padding: 1.05rem 0 0;
  border-top: 3px solid var(--theme-accent);
}

article[data-central-thematic] .editorial-card h2 {
  margin: 0 0 .75rem;
  font: 500 clamp(1.5rem, 2vw, 1.9rem)/1.2 Georgia, 'Times New Roman', serif;
  letter-spacing: -.025em;
}

article[data-central-thematic] .editorial-card p { margin: 0 0 .75rem; }
article[data-central-thematic] .section > :is(p, ul) { max-width: 78ch; }
article[data-central-thematic] .section > :not(:first-child) + h2 { margin-top: 2rem; }
article[data-central-thematic] .thematic-related li + li { margin-top: .45rem; }

:is(article[data-central-thematic] .section, section[data-page="thematics"] .thematic-method) a,
article[data-central-thematic] > .thematic-evidence-link a {
  color: var(--theme-accent);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .17em;
}

main[data-thematic-detail] .risk-contents,
main[data-thematic-detail] .subchecks {
  background: var(--theme-tint);
}

main[data-thematic-detail] :is(.risk-contents, .risk-guide, .risk-grid > div) {
  border-color: var(--theme-rule);
}

main[data-thematic-detail] .risk-contents { border-left-color: var(--theme-accent); }
main[data-thematic-detail] .risk-guide { scroll-margin-top: 6rem; }

:is(section[data-page="thematics"], article[data-central-thematic], main[data-thematic-detail]) :is(a, input, select, button):focus-visible {
  outline: 3px solid var(--theme-accent);
  outline-offset: 3px;
}

:is(section[data-page="thematics"] .thematic-hero, article[data-central-thematic] .page-heading, main[data-thematic-detail] .intro) a:focus-visible {
  outline-color: #c5e9d4;
}

@media (min-width: 42.01rem) and (max-width: 64rem) {
  section[data-page="thematics"] .thematic-tools {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-areas: "search-label subject-label" "search subject" "reset count";
  }

  section[data-page="thematics"] .thematic-result-count { margin-top: .35rem; }
  section[data-page="thematics"] #thematic-reset { justify-self: start; margin-top: .3rem; }
}

@media (max-width: 42rem) {
  section[data-page="thematics"] .thematic-tools {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "search-label" "search" "subject-label" "subject" "reset" "count";
  }

  section[data-page="thematics"] .thematic-tools label[for="thematic-subject"] { margin-top: .45rem; }
  section[data-page="thematics"] #thematic-reset { justify-self: start; margin-top: .35rem; }
  section[data-page="thematics"] .thematic-result-count { margin: .15rem 0 0; }
}
