/* Navigation, glossary and long-page controls */
@media (min-width: 1001px) {
  body { padding-top: 78px; }
  .nav {
    position: fixed;
    inset: 0 0 auto;
    width: 100%;
    justify-content: flex-start;
    gap: clamp(24px, 3vw, 54px);
    border-bottom-color: rgba(18, 32, 25, .12);
    box-shadow: 0 8px 28px rgba(18, 32, 25, .06);
  }
  .nav .brand { flex: 0 0 auto; }
  .primary-nav {
    flex: 1;
    justify-content: center;
    gap: clamp(14px, 1.5vw, 25px) !important;
  }
  .primary-nav > a,
  .nav-more > summary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: #425148;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }
  .nav-more { position: relative; }
  .nav-more > summary { gap: 7px; list-style: none; }
  .nav-more > summary::-webkit-details-marker { display: none; }
  .nav-more > summary i { font-size: 9px; transition: transform .18s var(--ease); }
  .nav-more[open] > summary i { transform: rotate(180deg); }
  .nav-more > div {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: 225px;
    padding: 8px;
    border: 1px solid rgba(18, 32, 25, .14);
    background: rgba(249, 247, 241, .98);
    box-shadow: 0 18px 45px rgba(18, 32, 25, .16);
  }
  .nav-more > div a {
    display: flex !important;
    min-height: 42px !important;
    align-items: center;
    padding: 0 11px;
    font-size: 12px !important;
    text-decoration: none;
  }
  .nav-more > div a:hover,
  .nav-more > div a:focus-visible { background: #e8ece5; color: #173c2d; }
  .nav .author-link { flex: 0 0 auto; }
}

.back-to-top {
  position: fixed;
  right: max(22px, var(--safe-right, 0px));
  bottom: max(22px, calc(var(--safe-bottom, 0px) + 14px));
  z-index: 28;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 17px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: #173c2d;
  color: #fff;
  box-shadow: 0 12px 34px rgba(14, 43, 32, .24);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .18s linear, transform .18s var(--ease), visibility .18s;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: #0e2b20; transform: translateY(-2px); }
.back-to-top:focus-visible { outline: 3px solid #d7b768; outline-offset: 3px; }

.term-hint {
  display: inline;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
  cursor: help;
}
.term-hint:focus-visible { outline: 2px solid #c7a35c; outline-offset: 2px; }
.glossary-tooltip {
  position: fixed;
  z-index: 80;
  width: min(340px, calc(100vw - 28px - var(--safe-left, 0px) - var(--safe-right, 0px)));
  padding: 15px 17px;
  border: 1px solid rgba(255,255,255,.16);
  background: #102d21;
  color: #f6f4ee;
  box-shadow: 0 18px 46px rgba(8, 25, 18, .28);
  font-size: 13px;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: opacity .12s linear, transform .12s var(--ease), visibility .12s;
}
.glossary-tooltip b { display: block; margin-bottom: 5px; color: #e1c575; font-size: 13px; }
.glossary-tooltip.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }

@media (max-width: 1000px) {
  .back-to-top { width: 48px; padding: 0; justify-content: center; }
  .back-to-top span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top, .glossary-tooltip, .nav-more > summary i { transition: none !important; }
}
