/* THC Search — results page, form, badges, course-search box, header toggle.
   Uses the child theme's palette tokens; the child theme may restyle any thc-search-* class. */

:root {
  --thc-s-canvas: var(--wp--preset--color--base, #f7f1e4);
  --thc-s-raised: var(--wp--preset--color--accent-5, #fcf8ef);
  --thc-s-muted: var(--wp--preset--color--accent-4, #ece4d9);
  --thc-s-border: var(--wp--preset--color--accent-6, #d9d0bc);
  --thc-s-text: var(--wp--preset--color--contrast, #332d25);
  --thc-s-leaf: var(--wp--preset--color--accent-1, #5e7d53);
  --thc-s-deep: var(--wp--preset--color--accent-3, #3f5c3b);
  --thc-s-sage: var(--wp--preset--color--accent-2, #a8b79a);
  --thc-s-stroke: var(--wp--preset--color--control-stroke, #8a7f66);
  --thc-s-radius: 12px;
}

/* ---------- layout ---------- */
.thc-search-page { color: var(--thc-s-text); }
.thc-search-section { padding-block: var(--wp--preset--spacing--xl, 2rem); }
.thc-search__inner {
  max-width: var(--wp--style--global--content-size, 720px);
  margin-inline: auto;
  padding-inline: var(--wp--style--root--padding-left, 1.25rem);
  box-sizing: content-box;
}
.thc-search-hero { padding-top: var(--wp--preset--spacing--2-xl, 3rem); padding-bottom: var(--wp--preset--spacing--lg, 1.5rem); }
.thc-search-hero h1 { margin: 0 0 var(--wp--preset--spacing--md, 1rem); overflow-wrap: anywhere; }
.thc-search-lead { margin: 0 0 var(--wp--preset--spacing--md, 1rem); font-size: var(--wp--preset--font-size--large, 1.25rem); }
.thc-search-scope { margin: var(--wp--preset--spacing--sm, .75rem) 0 0; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-search-scope a { margin-left: .35em; }
.thc-search-didyoumean p { margin: var(--wp--preset--spacing--sm, .75rem) 0 0; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-search-results { padding-top: 0; }

/* ---------- form ---------- */
.thc-search-form {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--thc-s-stroke);
  border-radius: 999px;
  background: var(--thc-s-raised);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.thc-search-form:focus-within { outline: 2px solid var(--thc-s-leaf); outline-offset: 2px; }
.thc-search-form input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: .7em 1.1em;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.thc-search-form input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
.thc-search-form__submit {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  border: 0;
  margin: 0;
  padding: 0 1.1em;
  background: var(--thc-s-leaf);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0;
}
.thc-search-form__submit:hover, .thc-search-form__submit:focus-visible { background: var(--thc-s-deep); color: #fff; }
.thc-search-form__submit .thc-search-icon { flex: none; }
.thc-search-form--hero { font-size: 1.05rem; }
.thc-search-form--compact .thc-search-form__submit span,
.thc-search-form--course .thc-search-form__submit span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thc-search-form--compact .thc-search-form__submit,
.thc-search-form--course .thc-search-form__submit { padding: 0 .8em; position: relative; }

/* ---------- results list ---------- */
.thc-search-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--wp--preset--spacing--md, 1rem); }
.thc-search-card {
  background: var(--thc-s-raised);
  border: 1px solid var(--thc-s-border);
  border-radius: var(--thc-s-radius);
  padding: var(--wp--preset--spacing--lg, 1.5rem);
}
.thc-search-card__kicker {
  margin: 0 0 .35em;
  font-size: var(--wp--preset--font-size--small, .875rem);
  letter-spacing: .02em;
  color: var(--thc-s-deep);
}
.thc-search-card__kicker::before { content: ""; }
.thc-search-card__title {
  margin: 0 0 .45em;
  font-size: var(--wp--preset--font-size--x-large, 1.5rem);
  line-height: 1.25;
}
.thc-search-card__title a { text-decoration: none; color: inherit; }
.thc-search-card__title a:hover, .thc-search-card__title a:focus-visible { text-decoration: underline; text-underline-offset: .15em; }
.thc-search-card__snippet { margin: 0 0 .75em; }
.thc-search-card__snippet mark { background: color-mix(in srgb, var(--thc-s-sage) 45%, transparent); color: inherit; padding: 0 .12em; border-radius: 3px; }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .thc-search-card__snippet mark { background: #e2e8d6; } }
.thc-search-card__foot { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5em 1em; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-search-card__action { text-decoration: none; font-weight: 600; color: var(--thc-s-deep); }
.thc-search-card__action:hover, .thc-search-card__action:focus-visible { text-decoration: underline; }

/* ---------- badges ---------- */
.thc-badge {
  display: inline-block;
  padding: .2em .7em;
  border-radius: 999px;
  border: 1px solid var(--thc-s-border);
  background: var(--thc-s-muted);
  color: var(--thc-s-text);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.thc-badge--in-course { background: var(--thc-s-leaf); border-color: var(--thc-s-leaf); color: #fff; }
.thc-badge--preview, .thc-badge--free { background: color-mix(in srgb, var(--thc-s-sage) 40%, var(--thc-s-raised)); border-color: var(--thc-s-sage); }
.thc-badge--locked { background: var(--thc-s-raised); border-color: var(--thc-s-stroke); }
.thc-badge--course { background: var(--thc-s-raised); }

/* ---------- pagination ---------- */
.thc-search-pagination { margin-top: var(--wp--preset--spacing--xl, 2rem); }
.thc-search-pagination ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4em; align-items: center; }
.thc-search-pagination .page-numbers {
  display: inline-block; padding: .35em .8em; border-radius: 999px; border: 1px solid var(--thc-s-border); text-decoration: none; color: inherit; background: var(--thc-s-raised);
}
.thc-search-pagination .page-numbers.current { background: var(--thc-s-leaf); border-color: var(--thc-s-leaf); color: #fff; }
.thc-search-pagination a.page-numbers:hover { border-color: var(--thc-s-stroke); }

/* ---------- empty state ---------- */
.thc-search-empty h2 { margin-top: 0; }
.thc-search-empty .thc-actions { display: flex; flex-wrap: wrap; gap: .75em; margin-top: var(--wp--preset--spacing--md, 1rem); }

/* ---------- "Search this course" in Tutor's lesson sidebar ---------- */
.thc-course-search { padding: 8px 16px 12px; border-bottom: 1px solid var(--thc-s-border); }
.thc-course-search .thc-search-form { font-size: .95rem; }
.thc-course-search .thc-search-form input[type="search"] { padding: .5em .9em; }
.tutor-course-single-content-wrapper .thc-course-search,
.tutor-course-details-widget .thc-course-search { padding: 0 0 12px; border: 0; }

/* ---------- header toggle (magnifier that expands) ---------- */
.thc-search-toggle { position: relative; display: inline-flex; align-items: center; }
.thc-search-toggle__button .thc-search-icon { width: 22px; height: 22px; }
.thc-search-toggle__button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer; flex: none;
}
.thc-search-toggle__button:hover, .thc-search-toggle__button:focus-visible { background: var(--thc-s-muted); }
.thc-search-toggle__button[aria-expanded="true"] { background: var(--thc-s-muted); }
.thc-search-toggle__panel {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 60;
  width: min(22rem, calc(100vw - 2rem));
  padding: .5rem; border-radius: var(--thc-s-radius);
  background: var(--thc-s-raised); border: 1px solid var(--thc-s-border);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.thc-search-toggle__panel[hidden] { display: none; }
@media (max-width: 600px) {
  .thc-search-toggle__panel { position: fixed; left: 1rem; right: 1rem; width: auto; margin: 0; }
}

/* ---------- small screens ---------- */
@media (max-width: 480px) {
  .thc-search-card { padding: var(--wp--preset--spacing--md, 1rem); }
  .thc-search-form__submit span { display: none; }
  .thc-search-form__submit { padding: 0 .9em; }
}

/* ---------- Research Desk ---------- */
.thc-rd { margin-block: var(--wp--preset--spacing--md, 1rem) 0; }
.thc-rd__form { font-size: 1.05rem; }
.thc-rd__hint, .thc-rd__note { font-size: var(--wp--preset--font-size--small, .875rem); color: var(--thc-s-deep); margin: .6em 0 0; }
.thc-rd__panels { display: grid; gap: var(--wp--preset--spacing--lg, 1.5rem); margin-top: var(--wp--preset--spacing--lg, 1.5rem); }
@media (min-width: 900px) { .thc-rd__panels { grid-template-columns: 1fr 1fr; } .thc-rd__panel--links { grid-column: 1 / -1; } .thc-rd__panel[data-rd-panel="site"] { grid-column: 1 / -1; } }
.thc-rd__panel { background: var(--thc-s-raised); border: 1px solid var(--thc-s-border); border-radius: var(--thc-s-radius); padding: var(--wp--preset--spacing--lg, 1.5rem); min-width: 0; }
.thc-rd__panel h3 { margin: 0 0 .75em; font-size: var(--wp--preset--font-size--large, 1.25rem); display: flex; flex-wrap: wrap; align-items: baseline; gap: .5em; }
.thc-rd__src { font-family: var(--wp--preset--font-family--fira-sans, sans-serif); font-weight: 400; font-size: var(--wp--preset--font-size--small, .875rem); color: var(--thc-s-deep); }
.thc-rd__body.is-loading { opacity: .6; }
.thc-rd__loading, .thc-rd__empty { margin: 0; color: var(--thc-s-text); }
.thc-rd__more { margin: .75em 0 0; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-rd__meta { margin: .15em 0 0; font-size: var(--wp--preset--font-size--small, .875rem); color: var(--thc-s-deep); }
.thc-rd__paper-title { margin: 0; }
.thc-rd__papers, .thc-rd__web, .thc-rd__species { list-style: none; margin: 0; padding: 0; display: grid; gap: .9em; }
.thc-rd__papers li, .thc-rd__web li { padding-bottom: .9em; border-bottom: 1px solid var(--thc-s-border); }
.thc-rd__papers li:last-child, .thc-rd__web li:last-child { border-bottom: 0; padding-bottom: 0; }
.thc-rd__host { font-size: var(--wp--preset--font-size--small, .875rem); color: var(--thc-s-deep); }
.thc-rd__taxon { display: grid; grid-template-columns: auto 1fr; gap: .9em; align-items: start; }
.thc-rd__photo { margin: 0; width: 72px; }
.thc-rd__photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; display: block; }
.thc-rd__photo figcaption { font-size: .68rem; color: var(--thc-s-deep); line-height: 1.25; margin-top: .25em; }
.thc-rd__taxon-name { margin: 0; }
.thc-rd__links-inline { margin: .25em 0 0; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-rd__minilink { text-decoration: none; font-weight: 600; color: var(--thc-s-deep); }
.thc-rd__minilink:hover { text-decoration: underline; }
.thc-rd__links { display: flex; flex-wrap: wrap; gap: .5em; }
.thc-rd__chip { display: inline-block; padding: .4em .9em; border-radius: 999px; border: 1px solid var(--thc-s-border); background: var(--thc-s-canvas); color: var(--thc-s-text); text-decoration: none; font-weight: 600; font-size: var(--wp--preset--font-size--small, .875rem); }
.thc-rd__chip:hover, .thc-rd__chip:focus-visible { border-color: var(--thc-s-leaf); color: var(--thc-s-deep); }
.thc-search-list--compact { gap: .75rem; }
.thc-search-list--compact .thc-search-card { padding: var(--wp--preset--spacing--md, 1rem); }
.thc-search-list--compact .thc-search-card__title { font-size: var(--wp--preset--font-size--large, 1.25rem); }
.thc-search-more { margin: var(--wp--preset--spacing--lg, 1.5rem) 0 0; padding-top: var(--wp--preset--spacing--md, 1rem); border-top: 1px solid var(--thc-s-border); }
.thc-search-more a { font-weight: 600; color: var(--thc-s-deep); text-decoration: none; }
.thc-search-more a:hover { text-decoration: underline; }

/* ---------- share button / desk bar ---------- */
.thc-rd__bar { display: flex; align-items: center; justify-content: space-between; gap: 1em; flex-wrap: wrap; margin-top: .6em; }
.thc-rd__bar .thc-rd__hint { margin: 0; }
.thc-share { display: inline-flex; align-items: center; gap: .45em; padding: .4em .9em; border-radius: 999px; border: 1px solid var(--thc-s-border); background: var(--thc-s-raised); color: var(--thc-s-deep); font: inherit; font-size: var(--wp--preset--font-size--small, .875rem); font-weight: 600; cursor: pointer; }
.thc-share:hover, .thc-share:focus-visible { border-color: var(--thc-s-leaf); background: var(--thc-s-muted); }
