/* ════════════════════════════════════════════════════════════════
   Bench Tester — CAN Analyzer manual modal
   ════════════════════════════════════════════════════════════════ */

/* Trigger button placed under the analyzer head copy. */
.bt-analyzer__head-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  width: 100%;
}
.bt-manual-trigger {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--bt-cond, "Barlow Condensed", "Rajdhani", sans-serif);
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  font-size: 14px;
  padding: 16px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #b30016 0%, #c40018 38%, #df102a 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
  box-shadow:
    0 16px 36px rgba(196, 0, 24, .34),
    0 0 0 1px rgba(196, 0, 24, .16),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  animation: btManualPulse 2.4s ease-in-out infinite;
}
.bt-manual-trigger::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .22) 45%, transparent 100%);
  transform: translateX(-135%);
  animation: btManualSweep 3.2s ease-in-out infinite;
  z-index: -1;
}
.bt-manual-trigger::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(223, 16, 42, .28) 0%, transparent 70%);
  opacity: .9;
  z-index: -2;
}
.bt-manual-trigger:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.08);
  box-shadow:
    0 22px 46px rgba(196, 0, 24, .46),
    0 0 0 1px rgba(223, 16, 42, .28),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}
.bt-manual-trigger:focus-visible {
  outline: 2px solid #c40018;
  outline-offset: 3px;
}
.bt-manual-trigger svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.bt-manual-trigger span {
  position: relative;
  z-index: 1;
}
@keyframes btManualPulse {
  0%, 100% {
    box-shadow:
      0 16px 36px rgba(196, 0, 24, .34),
      0 0 0 0 rgba(196, 0, 24, .2),
      inset 0 1px 0 rgba(255, 255, 255, .22);
  }
  50% {
    box-shadow:
      0 22px 46px rgba(196, 0, 24, .44),
      0 0 0 12px rgba(196, 0, 24, 0),
      inset 0 1px 0 rgba(255, 255, 255, .26);
  }
}
@keyframes btManualSweep {
  0%, 18% { transform: translateX(-135%); }
  38%, 100% { transform: translateX(135%); }
}
@media (prefers-reduced-motion: reduce) {
  .bt-manual-trigger,
  .bt-manual-trigger::before {
    animation: none;
  }
}

/* ════════════════════════════════════════════════════════════════
   Modal container
   ════════════════════════════════════════════════════════════════ */
.bt-manual {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9300;
  background: rgba(8, 9, 14, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px;
  align-items: center;
  justify-content: center;
}
.bt-manual.is-open {
  display: flex;
  animation: btManualFade .25s ease;
}
@keyframes btManualFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
body.bt-manual-open {
  overflow: hidden;
}

.bt-manual__wrap {
  width: min(100%, 1280px);
  height: min(100%, 880px);
  background: linear-gradient(155deg, #14151c 0%, #1a1c25 50%, #11131a 100%);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, .5),
    0 0 0 1px rgba(21, 101, 192, .25);
  animation: btManualRise .35s cubic-bezier(.22, .9, .26, 1);
  color: #d6d8df;
}
@keyframes btManualRise {
  from { transform: translateY(28px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Header ── */
.bt-manual__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 22px;
  background: linear-gradient(90deg, #1565C0 0%, #1976D2 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: #fff;
  flex-wrap: wrap;
}
.bt-manual__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}
.bt-manual__brand svg {
  flex-shrink: 0;
  color: rgba(255, 255, 255, .9);
}
.bt-manual__brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.bt-manual__brand-text strong {
  font-family: var(--bt-cond, "Barlow Condensed", "Rajdhani", sans-serif);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.05;
}
.bt-manual__brand-text span {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, .72);
  margin-top: 2px;
}

.bt-manual__tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bt-manual__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 0 12px 0 38px;
  height: 40px;
  width: clamp(220px, 32vw, 360px);
  color: rgba(255, 255, 255, .92);
  transition: background .25s ease, border-color .25s ease;
}
.bt-manual__search:focus-within {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .4);
}
.bt-manual__search > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, .65);
  pointer-events: none;
}
.bt-manual__search input {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
  min-width: 0;
}
.bt-manual__search input::placeholder { color: rgba(255, 255, 255, .55); }
.bt-manual__search-meta {
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 10px;
  color: rgba(255, 255, 255, .7);
  letter-spacing: 1px;
  white-space: nowrap;
}

.bt-manual__lang {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 8px;
  overflow: hidden;
}
.bt-manual__lang-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .7);
  font-family: var(--bt-cond, "Barlow Condensed", "Rajdhani", sans-serif);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.4px;
  padding: 0 14px;
  height: 40px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.bt-manual__lang-btn + .bt-manual__lang-btn {
  border-left: 1px solid rgba(255, 255, 255, .18);
}
.bt-manual__lang-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}
.bt-manual__lang-btn.is-active {
  background: #fff;
  color: #1565C0;
}

.bt-manual__close {
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .25s ease;
}
.bt-manual__close:hover {
  background: rgba(255, 255, 255, .9);
  color: #C8001C;
  transform: rotate(90deg);
}

/* ── Body ── */
.bt-manual__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 0;
}

.bt-manual__toc {
  background: rgba(0, 0, 0, .35);
  border-right: 1px solid rgba(255, 255, 255, .06);
  overflow-y: auto;
  padding: 18px 14px 22px;
}
.bt-manual__toc-loading {
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  color: rgba(255, 255, 255, .4);
  padding: 8px 4px;
  letter-spacing: 0.6px;
}
.bt-manual__toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bt-manual__toc-list li {
  margin: 0;
}
.bt-manual__toc-link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .68);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .2s ease;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.bt-manual__toc-link:hover {
  background: rgba(255, 255, 255, .05);
  color: #fff;
  border-left-color: rgba(21, 101, 192, .55);
}
.bt-manual__toc-link.is-active {
  background: rgba(21, 101, 192, .18);
  color: #fff;
  border-left-color: #3b82f6;
  font-weight: 600;
}
.bt-manual__toc-link[data-level="2"] {
  padding-left: 24px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .55);
}
.bt-manual__toc-link[data-level="3"] {
  padding-left: 36px;
  font-size: 12px;
  color: rgba(255, 255, 255, .45);
}

/* ── Content area ── */
.bt-manual__content {
  overflow-y: auto;
  padding: clamp(20px, 3vw, 36px) clamp(24px, 4vw, 56px);
  outline: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* Disable Safari long-press context menu */
  -webkit-touch-callout: none;
  scroll-behavior: smooth;
}
.bt-manual__content::-webkit-scrollbar { width: 10px; }
.bt-manual__content::-webkit-scrollbar-track { background: rgba(255, 255, 255, .03); }
.bt-manual__content::-webkit-scrollbar-thumb {
  background: rgba(21, 101, 192, .35);
  border-radius: 4px;
}
.bt-manual__content::-webkit-scrollbar-thumb:hover {
  background: rgba(21, 101, 192, .55);
}

.bt-manual__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  color: rgba(255, 255, 255, .5);
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 12px;
  letter-spacing: 1px;
}
.bt-manual__spinner {
  animation: btManualSpin 1.2s linear infinite;
  color: rgba(21, 101, 192, .85);
}
@keyframes btManualSpin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}

/* ── Rendered markdown ── */
.bt-manual__article h1,
.bt-manual__article h2,
.bt-manual__article h3,
.bt-manual__article h4 {
  font-family: var(--bt-cond, "Barlow Condensed", "Rajdhani", sans-serif);
  letter-spacing: -0.3px;
  color: #fff;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}
.bt-manual__article h1:first-child,
.bt-manual__article h2:first-child {
  margin-top: 0;
}
.bt-manual__article h1 {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 800;
  text-transform: uppercase;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.bt-manual__article h2 {
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 700;
  text-transform: uppercase;
  color: #93c5fd;
  margin-top: 2em;
}
.bt-manual__article h3 {
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 700;
  color: #fff;
  margin-top: 1.6em;
}
.bt-manual__article h4 {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, .9);
}
.bt-manual__article p {
  font-size: 14.5px;
  line-height: 1.7;
  color: rgba(232, 232, 240, .82);
  margin: 0 0 1em;
}
.bt-manual__article ul,
.bt-manual__article ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
  color: rgba(232, 232, 240, .82);
  font-size: 14.5px;
  line-height: 1.65;
}
.bt-manual__article li {
  margin-bottom: 4px;
}
.bt-manual__article li::marker {
  color: rgba(21, 101, 192, .8);
}
.bt-manual__article strong {
  color: #fff;
  font-weight: 600;
}
.bt-manual__article em {
  color: rgba(255, 255, 255, .9);
}
.bt-manual__article a {
  color: #93c5fd;
  text-decoration: none;
  border-bottom: 1px dashed rgba(147, 197, 253, .4);
}
.bt-manual__article a:hover {
  color: #fff;
  border-bottom-color: #fff;
}
.bt-manual__article hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin: 2em 0;
}
.bt-manual__article code {
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 13px;
  padding: 2px 6px;
  background: rgba(21, 101, 192, .18);
  color: #bfdbfe;
  border-radius: 4px;
  border: 1px solid rgba(21, 101, 192, .28);
}
.bt-manual__article pre {
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1.2em;
}
.bt-manual__article pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: #d1d5db;
  font-size: 12.5px;
  line-height: 1.55;
  display: block;
}
.bt-manual__article blockquote {
  margin: 0 0 1.2em;
  padding: 12px 18px;
  border-left: 3px solid #1565C0;
  background: rgba(21, 101, 192, .08);
  border-radius: 0 8px 8px 0;
  color: rgba(232, 232, 240, .82);
}

/* Search highlight */
.bt-manual__article mark.bt-manual__hit {
  background: rgba(255, 220, 90, .35);
  color: #fffbea;
  padding: 1px 3px;
  border-radius: 3px;
  border: 1px solid rgba(255, 220, 90, .6);
}
.bt-manual__article mark.bt-manual__hit.is-current {
  background: #fbbf24;
  color: #1a1a1a;
  border-color: #fbbf24;
}

/* Block any selection / copy / context menu / drag in the content */
.bt-manual__article,
.bt-manual__article * {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-user-drag: none !important;
}
.bt-manual__article img {
  pointer-events: none;
  -webkit-user-drag: none;
}

/* ── Footer ── */
.bt-manual__footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(0, 0, 0, .35);
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, .55);
  text-transform: uppercase;
  flex-wrap: wrap;
}
.bt-manual__footer kbd {
  font-family: var(--bt-mono, "JetBrains Mono", monospace);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 4px;
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .85);
  margin-right: 4px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .bt-manual { padding: 12px; }
  .bt-manual__header {
    padding: 14px 16px;
    gap: 12px;
  }
  .bt-manual__body {
    grid-template-columns: 1fr;
  }
  .bt-manual__toc {
    max-height: 180px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
  }
  .bt-manual__search {
    width: 100%;
    flex: 1 1 100%;
  }
  .bt-manual__brand-text strong { font-size: 16px; }
  .bt-manual__brand-text span { display: none; }
}
@media (max-width: 540px) {
  .bt-manual__lang-btn { padding: 0 10px; height: 36px; }
  .bt-manual__close { width: 36px; height: 36px; }
  .bt-manual__search { height: 36px; padding-left: 34px; }
  .bt-manual__footer { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .bt-manual.is-open,
  .bt-manual__wrap,
  .bt-manual__spinner {
    animation: none !important;
  }
}
