/* Notation glossary: the tap-to-explain popover and the #/notation page.
   Uses the app's existing tokens so it themes with everything else. */

/* The affordance on an expression. Deliberately quiet: a dotted underline that
   only shows on hover/focus, because every lesson is full of math and a loud
   marker on each one would be worse than no marker at all. */
.has-notation { cursor: help; border-bottom: 1px dotted transparent; transition: border-color .12s ease; }
.has-notation:hover,
.has-notation:focus-visible { border-bottom-color: var(--accent); }

@media (hover: none) {
  /* No hover on touch, so show a faint standing hint instead. */
  .has-notation { border-bottom-color: color-mix(in srgb, var(--accent) 35%, transparent); }
}

.notation-pop {
  position: absolute; z-index: 900; max-width: min(30rem, calc(100vw - 1.5rem));
  background: var(--paper, #12100c); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: .5rem;
  box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.35); padding: .75rem .85rem;
  font-size: .92rem; line-height: 1.45;
}
.notation-pop .np-head {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .5rem;
}
.notation-pop .np-row { display: flex; gap: .6rem; padding: .35rem 0; }
.notation-pop .np-row + .np-row { border-top: 1px solid var(--line); }
.notation-pop .np-sym { flex: 0 0 auto; min-width: 2.2rem; text-align: center; color: var(--accent); }
.notation-pop .np-body { display: block; }
.notation-pop .np-read { display: block; color: var(--ink-strong); font-size: .86rem; }
.notation-pop .np-gloss { display: block; color: var(--ink-soft); }
.notation-pop .np-more {
  display: inline-block; margin-top: .6rem; font-size: .82rem; color: var(--accent);
}

/* ---- #/notation page ---- */
/* Wide enough for a real grid. The old 46rem held one column of 144 rows and
   left most of a desktop screen empty beside it. */
.notation-page { max-width: 76rem; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.notation-page .np-intro, .notation-page .np-search { max-width: 46rem; }
.notation-page h1 { margin-bottom: .35rem; }
.notation-page .np-intro { color: var(--ink-soft); margin-bottom: 1rem; }
.notation-page .np-search {
  width: 100%; padding: .6rem .75rem; margin-bottom: 1.25rem;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: .4rem; font: inherit;
}
.notation-page .np-group {
  font-size: .78rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); margin: 1.6rem 0 .5rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--line);
}
/* An entry is a disclosure. Closed, it is one index card; open, it teaches.
   The closed state has to stay ONE line tall, or 144 of them is a wall again.

   They sit in a grid with real gaps rather than stacked flush, because a
   hairline between rows is not separation — it is a strip. An OPEN entry takes
   the whole width, so its worked example and widget get room while everything
   still shut stays a compact index. */
.notation-page .np-list {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  align-items: start;
}
.notation-page .np-entry {
  border: 1px solid var(--line); border-radius: .5rem;
  background: var(--bg-2, transparent);
  transition: border-color .14s ease;
}
.notation-page .np-entry:hover { border-color: var(--line-strong); }
.notation-page .np-entry[open] {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.notation-page .np-sum {
  display: flex; gap: .75rem; align-items: baseline; padding: .6rem .8rem;
  cursor: pointer; list-style: none;
}
.notation-page .np-sum::-webkit-details-marker { display: none; }
.notation-page .np-sum::marker { content: ""; }
.notation-page .np-sum:hover .np-sumtext b { color: var(--accent); }
.notation-page .np-esym { flex: 0 0 2.5rem; text-align: right; color: var(--accent); }
/* min-width:0 lets the gloss actually truncate instead of forcing the row wide */
.notation-page .np-sumtext { flex: 1 1 auto; min-width: 0; display: flex; gap: .5rem; align-items: baseline; }
.notation-page .np-sumtext b { color: var(--ink-strong); font-weight: 600; flex: 0 0 auto; }
.notation-page .np-sumgloss {
  color: var(--ink-soft); font-size: .9rem; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* a quiet caret so the row reads as openable */
.notation-page .np-sum::after {
  content: ""; flex: 0 0 auto; width: .45rem; height: .45rem; margin-left: .3rem;
  border-right: 1.5px solid var(--ink-faint); border-bottom: 1.5px solid var(--ink-faint);
  transform: rotate(45deg) translate(-.1rem, -.1rem); transition: transform .15s ease;
}
.notation-page .np-entry[open] .np-sum::after { transform: rotate(-135deg) translate(-.05rem, -.05rem); }
/* opened: the full gloss returns, since the summary only ever showed one line */
.notation-page .np-entry[open] .np-sumgloss { white-space: normal; overflow: visible; }
.notation-page .np-body { padding: 0 .8rem .8rem 4rem; max-width: 46rem; }

@media (max-width: 30rem) {
  .notation-page .np-list { grid-template-columns: 1fr; }
  .notation-page .np-sum { flex-wrap: wrap; gap: .15rem .6rem; }
  .notation-page .np-esym { flex: 0 0 auto; text-align: left; }
  .notation-page .np-sumtext { flex: 1 1 100%; }
  .notation-page .np-body { padding-left: .8rem; }
}

/* ---- taught entries: worked example, the trap, and a retrieval check ---- */
.np-also { display:block; font-size:.8rem; color:var(--ink-faint); margin:.1rem 0 .2rem; }
.np-lbl {
  display:block; font-size:.68rem; letter-spacing:.07em; text-transform:uppercase;
  color:var(--ink-faint); margin-bottom:.25rem;
}
.np-worked, .np-trap, .np-sensebox {
  margin-top:.55rem; padding:.5rem .6rem; border-radius:.35rem;
  border:1px solid var(--line); background:color-mix(in srgb, var(--ink) 4%, transparent);
}
.np-worked .np-reads { display:block; color:var(--ink-soft); font-size:.88rem; margin:.2rem 0; }
.np-worked .np-equals { display:block; color:var(--ink-strong); }
.np-trap { border-color:color-mix(in srgb, var(--accent) 45%, var(--line)); }
.np-trap b { color:var(--ink-strong); font-weight:600; }
.np-trap div { color:var(--ink-soft); font-size:.9rem; margin-top:.25rem; }
.np-sense { padding:.3rem 0; font-size:.9rem; }
.np-sense + .np-sense { border-top:1px solid var(--line); }
.np-sense b { color:var(--ink-strong); margin-left:.4rem; }
.np-sense i { color:var(--ink-faint); font-style:normal; font-size:.8rem; margin-left:.3rem; }
/* Must be .np-means, not a bare span: KaTeX emits dozens of nested spans per
   formula, and display:block on all of them stacked every symbol on its own
   line. Caught by looking at the rendered page, not by any test. */
.np-sense .np-means { display:block; color:var(--ink-soft); font-size:.86rem; margin-top:.15rem; }
.np-sense .katex { display:inline-block; }
.np-check { margin-top:.55rem; }
.np-check summary { cursor:pointer; color:var(--accent); font-size:.9rem; }
.np-check > div { margin-top:.35rem; color:var(--ink-soft); font-size:.9rem; }
.np-check > div b { color:var(--ink-strong); }
/* popover extras */
.notation-pop .np-eg { display:block; margin-top:.2rem; color:var(--ink-strong); font-size:.9rem; }
.notation-pop .np-senses { display:block; margin-top:.15rem; color:var(--ink-faint); font-size:.82rem; }
.notation-pop .np-senses i { font-style:normal; }
.np-widget { margin-top:.6rem; border:1px solid var(--line); border-radius:.35rem; padding:.4rem; }
.np-widget:empty { display:none; }
