/* Сноски читалки: тултип на ПК, шторка на мобиле */

.md-fn {
  position: relative;
  display: inline;
  cursor: pointer;
}

.md-fn-phrase {
  padding: 0 0.14em;
  border-radius: 2px;
  border-bottom: 1px solid var(--accent);
  background: var(--accent-soft);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: inherit;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.md-fn:hover .md-fn-phrase,
.md-fn:focus-visible .md-fn-phrase,
.md-fn.is-open .md-fn-phrase {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.md-fn:focus {
  outline: none;
}

.md-fn:focus-visible .md-fn-phrase {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.md-fn.is-active .md-fn-phrase {
  background: var(--accent);
  border-bottom-color: var(--accent);
  color: var(--on-accent);
}

.md-fn-ref {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.md-fn-tip {
  position: fixed;
  z-index: 95;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text2);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}

.md-fn-tip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.md-fn-tip p { margin: 0 0 .55em; }
.md-fn-tip p:last-child { margin-bottom: 0; }

.md-fn-sheet {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.md-fn-sheet[hidden] {
  display: none !important;
}

.md-fn-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: auto;
}

.md-fn-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: min(70vh, 420px);
  margin: 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--border2);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  transform: translateY(110%);
  transition: transform .2s ease;
  pointer-events: auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.md-fn-sheet.is-open {
  pointer-events: auto;
}

.md-fn-sheet.is-open .md-fn-sheet-backdrop {
  opacity: 1;
}

.md-fn-sheet.is-open .md-fn-sheet-panel {
  transform: translateY(0);
}

.md-fn-sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.md-fn-sheet-close:hover,
.md-fn-sheet-close:focus-visible {
  color: var(--text);
  background: var(--bg-elevated2);
  outline: none;
}

.md-fn-sheet-heading {
  margin: 0 40px 12px 0;
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.25;
  color: var(--text);
}

.md-fn-sheet-body {
  margin: 0;
  padding-right: 8px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text2);
}

.md-fn-sheet-body p { margin: 0 0 .7em; }
.md-fn-sheet-body p:last-child { margin-bottom: 0; }

body.md-fn-sheet-open {
  overflow: hidden;
}

@media (max-width: 960px) {
  .md-fn-tip {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .md-fn-phrase,
  .md-fn-tip,
  .md-fn-sheet-backdrop,
  .md-fn-sheet-panel {
    transition: none;
  }
}
