/* ============================================================================
   ASCENT LEXICON — styles for the searchable vocabulary component
   ----------------------------------------------------------------------------
   Mount point:  <div data-course-lexicon></div>
   Renderer:     /assets/js/course-lexicon.js
   Data:         /assets/data/course-lexicon.json

   Colour rules: every colour is an existing studio token (with a fallback
   for hosts that scope their own palette, like Note Studio). Course chips
   reuse the per-course accent tokens that studio-tokens.css already
   contrast-verifies in both the dark theme and the .light-band daylight scope.
   Course is never the only signal — the chip text names the course.
   ========================================================================== */

.cl { display: block; min-width: 0; container-type: inline-size; }

/* ---- controls ---------------------------------------------------------- */
.cl-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  align-items: end;
  margin: 0 0 0.6rem;
}
@media (min-width: 640px) {
  .cl-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-field--search { grid-column: 1 / -1; }
  .cl-clear { justify-self: start; }
}
@media (min-width: 1100px) {
  .cl-controls { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
  .cl-field--search { grid-column: span 2; }
  .cl-clear { justify-self: stretch; }
}
.cl-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.cl-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted, #5A6584);
}
.cl-input, .cl-select {
  width: 100%; min-height: 44px;
  font: inherit; font-size: 1rem; color: var(--ink, #141B36);
  background: var(--surface, #fff);
  border: 1px solid var(--line-strong, rgba(20,27,54,.22));
  border-radius: 10px; padding: 0.55rem 0.8rem;
  -webkit-appearance: none; appearance: none;
}
.cl-select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 2rem;
}
.cl-input:focus-visible, .cl-select:focus-visible, .cl-clear:focus-visible, .cl-more-btn:focus-visible,
.cl-insert:focus-visible, .cl-source-link:focus-visible, .cl-more summary:focus-visible {
  outline: 3px solid var(--accent, #4F49D0); outline-offset: 2px;
}
.cl-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.cl-clear, .cl-more-btn, .cl-insert {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 0.5rem 1rem; border-radius: 10px;
  color: var(--accent, #4F49D0);
  background: var(--accent-tint, rgba(79,73,208,.10));
  border: 1px solid var(--line-strong, rgba(20,27,54,.22));
}
.cl-clear:hover, .cl-more-btn:hover, .cl-insert:hover { filter: brightness(0.96); }
.cl-more-btn { display: block; margin: 1rem auto 0; }
.cl-more-btn[hidden] { display: none; }

/* ---- status ------------------------------------------------------------ */
.cl-status, .cl-loading, .cl-error {
  font-size: 0.9rem; color: var(--ink-2, #3A4463); margin: 0 0 0.8rem; line-height: 1.5;
}
.cl-error { color: var(--ink, #141B36); }
.cl-error a, .cl-source-link { color: var(--accent, #4F49D0); text-decoration: underline; text-underline-offset: 2px; }

/* ---- results ----------------------------------------------------------- */
.cl-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.cl-term {
  background: var(--surface, #fff);
  border: 1px solid var(--line, rgba(20,27,54,.10));
  border-radius: 14px; padding: 1rem 1.1rem;
  box-shadow: var(--arch-shadow-md, 0 2px 6px rgba(20,27,54,.05));
  min-width: 0; overflow-wrap: anywhere;
}
.cl-term.is-light { border-style: dashed; }
.cl-term.is-linked { outline: 3px solid var(--accent, #4F49D0); outline-offset: 2px; scroll-margin-top: 90px; }
.cl-term-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.8rem; margin-bottom: 0.4rem; }
.cl-term-name {
  margin: 0; font-family: var(--font-display, Georgia, serif); font-weight: 700;
  font-size: 1.2rem; line-height: 1.2; color: var(--ink, #141B36);
}
.cl-def { margin: 0; color: var(--ink-2, #3A4463); font-size: 0.98rem; line-height: 1.6; }
.cl-def .katex, .cl-study .katex { font-size: 1.02em; }
.cl-def .katex-display { margin: 0.4rem 0; overflow-x: auto; overflow-y: hidden; }
.cl-def--review {
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--warn, #B7791F);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--warn, #B7791F) 8%, transparent);
  font-style: italic;
}
.cl-confusion {
  margin-top: 0.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong, rgba(20,27,54,.22));
  border-radius: 8px;
  background: var(--accent-tint, rgba(79,73,208,.10));
  color: var(--ink-2, #3A4463);
  font-size: 0.84rem;
  line-height: 1.5;
}
.cl-confusion-link { color: var(--accent, #4F49D0); text-decoration: underline; text-underline-offset: 2px; }
.cl-confusion-link:focus-visible { outline: 3px solid var(--accent, #4F49D0); outline-offset: 2px; }

/* chips */
.cl-chips { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.cl-chip {
  --cl-hue: var(--accent, #4F49D0);
  --cl-tint: var(--accent-tint, rgba(79,73,208,.10));
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.64rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  color: var(--cl-hue); background: var(--cl-tint);
  border: 1px solid var(--line, rgba(20,27,54,.10)); border-radius: 6px; padding: 0.18rem 0.5rem;
}
.cl-chip.is-active { border-color: var(--cl-hue); }
.cl-chip--light { background: transparent; border-style: dashed; text-transform: none; letter-spacing: 0; }
.cl-chip--alg1   { --cl-hue: var(--c-alg1, var(--accent)); --cl-tint: var(--c-alg1-tint, var(--accent-tint)); }
.cl-chip--geo    { --cl-hue: var(--c-geo, var(--accent));  --cl-tint: var(--c-geo-tint, var(--accent-tint)); }
.cl-chip--alg2   { --cl-hue: var(--c-alg2, var(--accent)); --cl-tint: var(--c-alg2-tint, var(--accent-tint)); }
.cl-chip--precalc{ --cl-hue: var(--c-precalc, var(--accent)); --cl-tint: var(--c-precalc-tint, var(--accent-tint)); }
.cl-chip--calc   { --cl-hue: var(--c-calc, var(--accent)); --cl-tint: var(--c-calc-tint, var(--accent-tint)); }
.cl-chip--phys   { --cl-hue: var(--c-phys, var(--accent)); --cl-tint: var(--c-phys-tint, var(--accent-tint)); }
.cl-chip--apphys { --cl-hue: var(--c-apphys, var(--accent)); --cl-tint: var(--c-apphys-tint, var(--accent-tint)); }
.cl-chip--ess    { --cl-hue: var(--c-ess, var(--accent));  --cl-tint: var(--c-ess-tint, var(--accent-tint)); }
.cl-chip--sci    { --cl-hue: var(--c-sci, var(--accent));  --cl-tint: var(--c-sci-tint, var(--accent-tint)); }

/* word study */
.cl-more { margin-top: 0.6rem; border-top: 1px dashed var(--line, rgba(20,27,54,.10)); padding-top: 0.5rem; }
.cl-more summary {
  cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--accent, #4F49D0);
  list-style: none; display: inline-flex; align-items: center; gap: 0.4rem; min-height: 32px;
}
.cl-more summary::-webkit-details-marker { display: none; }
.cl-more summary::before { content: '▸'; font-size: 0.8em; transition: transform .15s; }
.cl-more[open] summary::before { transform: rotate(90deg); }
.cl-study { display: grid; grid-template-columns: clamp(6rem, 24%, 11rem) minmax(0, 1fr); gap: 0.35rem 0.9rem; margin: 0.5rem 0 0; font-size: 0.9rem; line-height: 1.55; }
.cl-study dt { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted, #5A6584); padding-top: 0.2rem; }
.cl-study dd { margin: 0; color: var(--ink-2, #3A4463); }
@media (max-width: 480px) { .cl-study { grid-template-columns: 1fr; gap: 0.1rem 0; } .cl-study dd { margin-bottom: 0.4rem; } }

/* provenance + actions */
.cl-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; margin-top: 0.7rem; }
.cl-source { font-size: 0.8rem; color: var(--muted, #5A6584); line-height: 1.5; }
.cl-source-label { font-weight: 600; }
.cl-lesson-ref { white-space: normal; }
.cl-insert { min-height: 38px; padding: 0.35rem 0.8rem; font-size: 0.82rem; }

/* ---- compact (side pane) ---------------------------------------------- */
.cl--compact .cl-controls { grid-template-columns: 1fr; gap: 0.5rem; }
.cl--compact .cl-clear { justify-self: start; min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.82rem; }
.cl--compact .cl-input, .cl--compact .cl-select { min-height: 40px; font-size: 0.92rem; }
.cl--compact .cl-term { padding: 0.7rem 0.8rem; border-radius: 10px; box-shadow: none; }
.cl--compact .cl-term-name { font-size: 1.02rem; }
.cl--compact .cl-def { font-size: 0.9rem; }
.cl--compact .cl-status { font-size: 0.82rem; }
.cl--compact .cl-results { gap: 0.55rem; }
@container (min-width: 520px) {
  .cl--compact .cl-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl--compact .cl-field--search { grid-column: 1 / -1; }
}

/* ---- print ------------------------------------------------------------- */
@media print {
  .cl-controls, .cl-more-btn, .cl-insert { display: none !important; }
  .cl-term { break-inside: avoid; box-shadow: none; }
  .cl-more { display: block; } .cl-more summary { display: none; }
  .cl-more > .cl-study { display: grid; }
}

/* ---- Note Studio pane chrome (the pane itself is .ns-material-pane) ------ */
.ns-lexicon-status { font-size: 0.82rem; color: var(--ink-2, #55607a); margin: 0.4rem 0 0.6rem; }
.ns-lexicon-foot { font-size: 0.82rem; color: var(--ink-2, #55607a); margin-top: 0.6rem; }
.ns-lexicon-foot a { color: var(--accent, #4F49D0); text-decoration: underline; text-underline-offset: 2px; }
