/* ============================================================
   Design Explainer — Tooltip overlay for UI documentation
   Toggle via the ◈ button in the design navigator bar.
   When active, hovering any annotated element or link/button
   shows user stories, UX rationale, and navigation context.
   ============================================================ */

/* ── TOGGLE BUTTON IN NAV BAR ─────────────────────── */
#design-nav-bar .dn-explainer-toggle {
  background: #1a1a1a;
  color: #888;
  border: 1px solid #333;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s;
}
#design-nav-bar .dn-explainer-toggle:hover {
  background: #222;
  color: #fff;
  border-color: #555;
}
#design-nav-bar .dn-explainer-toggle.active {
  background: oklch(68% 0 0);
  color: #0E0E0E;
  border-color: oklch(68% 0 0);
  font-weight: 600;
}
#design-nav-bar .dn-explainer-toggle .ex-icon {
  font-size: 13px;
  line-height: 1;
}

/* ── ACTIVE STATE: ELEMENT HIGHLIGHTS ─────────────── */
body.explainer-on [data-ex-annotated] {
  outline: 2px dashed oklch(68% 0.12 60) !important;
  outline-offset: 3px;
  cursor: help !important;
  transition: outline-color 0.2s;
}
body.explainer-on [data-ex-annotated]:hover {
  outline-color: oklch(78% 0.15 60) !important;
}
body.explainer-on a[href]:not([data-ex-annotated]),
body.explainer-on button:not([data-ex-annotated]) {
  outline: 1px dotted rgba(241,241,241,0.25) !important;
  outline-offset: 2px;
  cursor: help !important;
}
body.explainer-on a[href]:not([data-ex-annotated]):hover,
body.explainer-on button:not([data-ex-annotated]):hover {
  outline-color: rgba(241,241,241,0.5) !important;
}

/* ── ANNOTATION BADGE ─────────────────────────────── */
body.explainer-on [data-ex-annotated] {
  position: relative;
}
body.explainer-on [data-ex-persona]::after {
  content: attr(data-ex-persona);
  position: absolute;
  top: -10px;
  right: -6px;
  background: oklch(68% 0.12 60);
  color: #0E0E0E;
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  z-index: 100;
  pointer-events: none;
  line-height: 1.2;
  white-space: nowrap;
}

/* ── TOOLTIP ──────────────────────────────────────── */
#ex-tooltip {
  position: fixed;
  z-index: 10001;
  background: #111;
  border: 1px solid #333;
  max-width: 440px;
  min-width: 300px;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: none;
  display: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

/* Tooltip header */
#ex-tooltip .ex-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #0a0a0a;
  border-bottom: 1px solid #222;
}
#ex-tooltip .ex-tag {
  display: inline-block;
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  line-height: 1;
}
#ex-tooltip .ex-tag-element {
  background: oklch(68% 0.12 60);
  color: #0E0E0E;
}
#ex-tooltip .ex-tag-nav {
  background: #2a5a3a;
  color: #7deb9a;
}
#ex-tooltip .ex-tag-persona {
  background: #1a1a3a;
  color: #8888ee;
}
#ex-tooltip .ex-el-name {
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Tooltip sections */
#ex-tooltip .ex-section {
  padding: 10px 14px;
  border-bottom: 1px solid #1a1a1a;
}
#ex-tooltip .ex-section:last-child {
  border-bottom: none;
}
#ex-tooltip .ex-label {
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
#ex-tooltip .ex-label-icon {
  font-size: 11px;
}
#ex-tooltip .ex-text {
  font-size: 12.5px;
  line-height: 1.55;
  color: #ccc;
}
#ex-tooltip .ex-text em {
  color: oklch(68% 0.12 60);
  font-style: italic;
}
#ex-tooltip .ex-text strong {
  color: #fff;
  font-weight: 600;
}

/* Story section */
#ex-tooltip .ex-story .ex-label { color: oklch(68% 0.12 60); }
#ex-tooltip .ex-story .ex-text { color: #ddd; }

/* UX section */
#ex-tooltip .ex-ux .ex-label { color: #6b8aff; }
#ex-tooltip .ex-ux .ex-text { color: #aab; }

/* Nav section */
#ex-tooltip .ex-nav .ex-label { color: #5cb85c; }
#ex-tooltip .ex-nav .ex-target {
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: #7deb9a;
  background: rgba(93,184,92,0.08);
  padding: 4px 8px;
  display: inline-block;
  margin-bottom: 4px;
}
#ex-tooltip .ex-nav .ex-why {
  font-size: 12px;
  color: #8a8;
  line-height: 1.5;
}

/* Arrow */
#ex-tooltip::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: #111;
  border-right: 1px solid #333;
  border-bottom: 1px solid #333;
  transform: rotate(45deg);
}
#ex-tooltip.arrow-top::after {
  top: -6px;
  left: 20px;
  transform: rotate(-135deg);
}
#ex-tooltip.arrow-bottom::after {
  bottom: -6px;
  left: 20px;
  transform: rotate(45deg);
}

/* ── LEGEND PANEL ─────────────────────────────────── */
#ex-legend {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 10000;
  background: #111;
  border: 1px solid #333;
  padding: 12px 16px;
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: #888;
  display: none;
  line-height: 1.8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
body.explainer-on #ex-legend {
  display: block;
}
#ex-legend .ex-legend-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 6px;
}
#ex-legend .ex-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#ex-legend .ex-swatch-annotated {
  width: 20px;
  height: 2px;
  border: 1px dashed oklch(68% 0.12 60);
}
#ex-legend .ex-swatch-link {
  width: 20px;
  height: 2px;
  border: 1px dotted rgba(241,241,241,0.4);
}

/* ── STAT COUNTER ─────────────────────────────────── */
#ex-counter {
  font-family: 'Inter', ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: #555;
  margin-left: 4px;
}
.dn-explainer-toggle.active #ex-counter {
  color: #0E0E0E;
  opacity: 0.6;
}

/* ── PRINT: HIDE EVERYTHING ───────────────────────── */
@media print {
  #ex-tooltip,
  #ex-legend,
  body.explainer-on [data-ex-annotated]::before {
    display: none !important;
  }
  body.explainer-on [data-ex-annotated] {
    outline: none !important;
  }
}
