/* ============================================================
 * components-terms.css
 *
 * Part of the brandolini year-site stylesheet, split out from
 * the original monolithic components.css on 2026-05-04 V2.0
 * when the file crossed the 600-line hard threshold.
 *
 * Loaded by the <page-head> directive — see ~/brandolini-build/inject.py.
 * Adding new rules: add them here if they fit the existing section,
 * or split off a new components-<thing>.css file if a coherent new
 * concern emerges.
 * ============================================================ */

/* --- terms: tooltip (default) --- */
/* Screen-reader-accessible tooltip pattern: the tooltip text lives in a real
   DOM element (.term-tip) pointed to by aria-describedby. Visually hidden by
   default via the sr-only technique; CSS un-hides it on hover / focus so
   sighted users see the standard tooltip affordance. */

.term {
  border-bottom: 1px dashed var(--accent-deep);
  cursor: help;
  position: relative;
  color: var(--ink);
  font-weight: 600;
  outline: none;
}
.term:hover, .term:focus, .term:focus-visible {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-bottom-style: solid;
}

/* Default state: visually hidden, still in the accessibility tree for
   screen readers via aria-describedby. */
.term-tip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;

  /* Visual styling (activates when un-hidden below). */
  background: var(--ink);
  color: var(--bg);
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 6px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(43, 37, 24, 0.22);
  z-index: 10;
  transition: opacity 0.18s ease;
}

/* Shown state: positioned tooltip above the term, pointer-unreachable so it
   doesn't interfere with hover targeting. */
.term:hover .term-tip,
.term:focus .term-tip,
.term:focus-visible .term-tip,
.term:focus-within .term-tip {
  position: absolute;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 280px;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Arrow below tooltip */
.term:hover::after,
.term:focus::after,
.term:focus-visible::after,
.term:focus-within::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
  z-index: 10;
  pointer-events: none;
}

@media (max-width: 600px) {
  .term:hover .term-tip,
  .term:focus .term-tip,
  .term:focus-visible .term-tip,
  .term:focus-within .term-tip {
    max-width: 240px;
    font-size: 13px;
  }
}



/* --- terms: inline short expansion --- */

.term-short {
  display: inline;
  padding: 2px 8px;
  margin: 0 2px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}



/* --- terms: block long expansion --- */

.term-long {
  margin: 20px 0;
  padding: 20px 24px;
  background: var(--bg-tint);
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.term-long p { margin-bottom: 12px; }
.term-long p:last-child { margin-bottom: 0; }
.term-long::before {
  content: attr(data-term);
  display: block;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 12px;
}



/* --- embedded reading --- */

.reading {
  margin: 24px 0;
  padding: 32px 36px;
  background: var(--bg-tint);
  border-radius: 8px;
  border: 1px solid var(--rule);
}
.reading-header h2 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 72, "SOFT" 40;
  font-weight: 420;
  font-size: 26px;
  margin-bottom: 6px;
  padding-bottom: 0;
  border-bottom: none;
  color: var(--ink);
}
.reading-header::after {
  content: 'reading';
  display: block;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin-bottom: 20px;
}
.reading h2 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-weight: 420;
  font-size: 22px;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--ink);
}
.reading > .reading-header + h2,
.reading > .reading-header ~ h2:first-of-type {
  margin-top: 4px;
}
.reading p { margin-bottom: 14px; line-height: 1.7; }
.reading p:last-child { margin-bottom: 0; }



/* --- embedded diagram --- */

.diagram {
  margin: 24px 0;
  padding: 28px 24px 20px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
}
.diagram svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  color: var(--ink-dim);
}
.diagram figcaption {
  margin-top: 16px;
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 24, "SOFT" 60;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-quiet);
}



/* --- links in prose --- */

main a:not(.mark) {
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
main a:not(.mark):hover {
  color: var(--accent);
  text-decoration-color: var(--accent-deep);
}

/* ============================================================
   --- WIDA language-level toggle: tooltip variant show/hide ---

   When the library has multiple WIDA variants for a term (e.g.
   tooltip :: sheltered AND tooltip :: entering), the builder emits
   both as siblings inside .term-multi. Only ONE should ever be
   visible at a time; the inactive one is hidden via display:none.

   These rules live HERE in components-terms.css (not site.css)
   because they need to override the .term:hover/focus .term-tip
   un-hide rules above. Tied specificity (both 0,3,1) means cascade
   order decides — same-file later-defined rules win. !important is
   added belt-and-suspenders so the hide stays even if a future
   refactor moves these rules elsewhere.

   The visible-DOM variants are siblings inside .term-multi:
     <span class="term term-multi">word
       <span class="term-tip" data-wida-variant="L3">L3 text...</span>
       <span class="term-tip" data-wida-variant="L1">L1 text...</span>
     </span>

   In default L3 mode, hide L1.
   In L1 mode (:root[data-wida="L1"]), show L1 and hide L3.
   ============================================================ */

.term-multi .term-tip[data-wida-variant="L1"],
.term-multi .term-short-variant[data-wida-variant="L1"],
.term-multi .term-long-variant[data-wida-variant="L1"] {
  display: none !important;
}

:root[data-wida="L1"] .term-multi .term-tip[data-wida-variant="L1"],
:root[data-wida="L1"] .term-multi .term-short-variant[data-wida-variant="L1"],
:root[data-wida="L1"] .term-multi .term-long-variant[data-wida-variant="L1"] {
  display: revert !important;
}

:root[data-wida="L1"] .term-multi .term-tip[data-wida-variant="L3"],
:root[data-wida="L1"] .term-multi .term-short-variant[data-wida-variant="L3"],
:root[data-wida="L1"] .term-multi .term-long-variant[data-wida-variant="L3"] {
  display: none !important;
}
