/**
 * WAVULT DRILLDOWN DRAWER SYSTEM v1.0.0
 * Apple-native drilldown drawer with enterprise tokens.
 * wavult-drilldown.css
 *
 * @build 2026-05-04
 */

/* ═══════════════════════════════════════════════════════════════
   OVERLAY & BACKDROP
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}
.wv-drawer-overlay.wv-drawer-active {
  pointer-events: auto;
  opacity: 1;
}

/* Backdrop */
.wv-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 14, 26, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════════════════
   DRAWER PANEL
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: #FFFFFF;
  border-left: 1px solid #E8E3DC;
  box-shadow: -8px 0 48px rgba(0, 14, 26, 0.18), -2px 0 8px rgba(0, 14, 26, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9001;
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(0.25, 1.0, 0.5, 1.0);
  will-change: transform;
}

.wv-drawer.wv-drawer-open {
  transform: translateX(0);
}

/* Stacked drawer pushes parent 24px left */
.wv-drawer.wv-drawer-stacked {
  transform: translateX(-24px);
  box-shadow: -8px 0 48px rgba(0, 14, 26, 0.08), -2px 0 4px rgba(0, 14, 26, 0.04);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wv-drawer {
    transition: transform 200ms linear;
  }
  .wv-drawer-overlay {
    transition: opacity 100ms linear;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DRAWER HEADER (Vibrancy)
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 13px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid #E8E3DC;
  min-height: 56px;
  user-select: none;
}

.wv-drawer-back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: #001E50;
  border-radius: 6px;
  padding: 0;
  flex-shrink: 0;
  transition: background 120ms ease;
}
.wv-drawer-back:hover { background: rgba(0, 30, 80, 0.08); }
.wv-drawer-back svg { width: 16px; height: 16px; }

.wv-drawer.wv-drawer-child .wv-drawer-back {
  display: flex;
}

.wv-drawer-titles {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.wv-drawer-eyebrow {
  font-family: 'JetBrains Mono', 'Menlo', 'Courier New', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #C8763A;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wv-drawer-title {
  font-family: 'Saira Condensed', 'Inter Tight', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #001E50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

/* Header actions */
.wv-drawer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.wv-drawer-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: #5E6880;
  border-radius: 6px;
  padding: 0;
  transition: background 120ms ease, color 120ms ease;
}
.wv-drawer-action-btn:hover {
  background: rgba(0, 30, 80, 0.08);
  color: #001E50;
}
.wv-drawer-action-btn svg { width: 15px; height: 15px; }

.wv-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: #5E6880;
  border-radius: 6px;
  padding: 0;
  margin-left: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.wv-drawer-close:hover {
  background: rgba(188, 27, 27, 0.08);
  color: #BC1B1B;
}
.wv-drawer-close svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════════════
   DRAWER BODY
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.wv-drawer-body::-webkit-scrollbar { width: 4px; }
.wv-drawer-body::-webkit-scrollbar-track { background: transparent; }
.wv-drawer-body::-webkit-scrollbar-thumb {
  background: #D5CFC4;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 16px;
  color: #5E6880;
}

.wv-drawer-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #E8E3DC;
  border-top-color: #001E50;
  border-radius: 50%;
  animation: wv-spin 700ms linear infinite;
}

@keyframes wv-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   SECTION DIVIDERS (§ XX.00 style)
   ═══════════════════════════════════════════════════════════════ */
.wv-section {
  margin-bottom: 28px;
}

.wv-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #E8E3DC;
}

.wv-section-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  color: #C8763A;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.wv-section-title {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3A4358;
}

/* ═══════════════════════════════════════════════════════════════
   KV GRID (Key-Value pairs)
   ═══════════════════════════════════════════════════════════════ */
.wv-kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wv-kv-item {
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  padding: 10px 12px;
}

.wv-kv-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8C94A4;
  margin-bottom: 3px;
}

.wv-kv-value {
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #001E50;
  word-break: break-word;
}

.wv-kv-value.pos { color: #007A33; }
.wv-kv-value.neg { color: #BC1B1B; }
.wv-kv-value.warn { color: #B8860B; }
.wv-kv-value.amber { color: #C8763A; }

/* ═══════════════════════════════════════════════════════════════
   METRIC CLUSTER
   ═══════════════════════════════════════════════════════════════ */
.wv-metric-cluster {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.wv-metric-cell {
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  padding: 12px;
  text-align: center;
}

.wv-metric-cell-value {
  font-family: 'Saira Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #001E50;
  line-height: 1.1;
}

.wv-metric-cell-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8C94A4;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   TIMELINE
   ═══════════════════════════════════════════════════════════════ */
.wv-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wv-timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F4F1EC;
  cursor: pointer;
  transition: background 120ms ease;
  border-radius: 2px;
  padding-left: 8px;
}

.wv-timeline-item:hover {
  background: rgba(0, 30, 80, 0.04);
}

.wv-timeline-item:last-child {
  border-bottom: none;
}

.wv-timeline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #C8763A;
  flex-shrink: 0;
  margin-top: 5px;
}

.wv-timeline-dot.pos { background: #007A33; }
.wv-timeline-dot.neg { background: #BC1B1B; }
.wv-timeline-dot.warn { background: #B8860B; }

.wv-timeline-content {
  flex: 1;
  min-width: 0;
}

.wv-timeline-text {
  font-size: 12px;
  color: #1C2432;
  line-height: 1.4;
}

.wv-timeline-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #8C94A4;
  margin-top: 2px;
  letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════
   MATRIX (coverage / status grid)
   ═══════════════════════════════════════════════════════════════ */
.wv-matrix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.wv-matrix-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
}

.wv-matrix-label {
  font-size: 11px;
  color: #3A4358;
  flex: 1;
}

.wv-matrix-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 2px;
  text-transform: uppercase;
}

.wv-matrix-badge.pos { background: rgba(0,122,51,0.1); color: #007A33; }
.wv-matrix-badge.neg { background: rgba(188,27,27,0.1); color: #BC1B1B; }
.wv-matrix-badge.warn { background: rgba(184,134,11,0.1); color: #B8860B; }
.wv-matrix-badge.info { background: rgba(0,30,80,0.1); color: #001E50; }

/* ═══════════════════════════════════════════════════════════════
   LINKS LIST
   ═══════════════════════════════════════════════════════════════ */
.wv-links-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wv-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  text-decoration: none;
  color: inherit;
}

.wv-link-item:hover {
  border-color: #001E50;
  background: #F0F4F9;
}

.wv-link-item-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 30, 80, 0.08);
  border-radius: 2px;
  flex-shrink: 0;
  color: #001E50;
  font-size: 12px;
}

.wv-link-item-text {
  flex: 1;
  min-width: 0;
}

.wv-link-item-label {
  font-size: 12px;
  font-weight: 600;
  color: #001E50;
}

.wv-link-item-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #8C94A4;
  letter-spacing: 0.04em;
}

.wv-link-item-arrow {
  color: #C5CBD3;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   RELATED CHIPS
   ═══════════════════════════════════════════════════════════════ */
.wv-related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wv-related-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  font-size: 11px;
  color: #3A4358;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.wv-related-chip:hover {
  border-color: #001E50;
  background: #F0F4F9;
  color: #001E50;
}

.wv-related-chip-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #C8763A;
}

/* ═══════════════════════════════════════════════════════════════
   DRAWER FOOTER (Sticky)
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  border-top: 1px solid #E8E3DC;
  min-height: 56px;
}

.wv-drawer-footer-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  background: #001E50;
  color: #FFFFFF;
  border: none;
  border-radius: 2px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 120ms ease;
}
.wv-drawer-footer-primary:hover { background: #002D6E; }

.wv-drawer-footer-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: #FAF9F6;
  color: #3A4358;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.wv-drawer-footer-secondary:hover { border-color: #001E50; background: #F0F4F9; color: #001E50; }

/* ═══════════════════════════════════════════════════════════════
   DANGER ACTION
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-footer-danger {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: rgba(188,27,27,0.08);
  color: #BC1B1B;
  border: 1px solid rgba(188,27,27,0.2);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease;
}
.wv-drawer-footer-danger:hover { background: rgba(188,27,27,0.14); }

/* ═══════════════════════════════════════════════════════════════
   ACTION BUTTONS LIST (inside body)
   ═══════════════════════════════════════════════════════════════ */
.wv-action-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wv-action-btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #FAF9F6;
  border: 1px solid #E8E3DC;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  text-align: left;
}
.wv-action-btn-row:hover { border-color: #001E50; background: #F0F4F9; }
.wv-action-btn-row.danger:hover { border-color: #BC1B1B; background: rgba(188,27,27,0.04); }

.wv-action-btn-row-label {
  font-size: 12px;
  font-weight: 600;
  color: #001E50;
  flex: 1;
}
.wv-action-btn-row.danger .wv-action-btn-row-label { color: #BC1B1B; }

/* ═══════════════════════════════════════════════════════════════
   CHART BARS (inline sparkline/bar for drilldown)
   ═══════════════════════════════════════════════════════════════ */
.wv-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 48px;
}

.wv-bar-chart-bar {
  flex: 1;
  background: #001E50;
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: opacity 120ms ease;
}
.wv-bar-chart-bar:hover { opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════ */
.wv-progress-bar {
  height: 4px;
  background: #E8E3DC;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.wv-progress-bar-fill {
  height: 100%;
  background: #001E50;
  border-radius: 2px;
  transition: width 600ms cubic-bezier(0.25, 1.0, 0.5, 1.0);
}
.wv-progress-bar-fill.pos { background: #007A33; }
.wv-progress-bar-fill.neg { background: #BC1B1B; }
.wv-progress-bar-fill.amber { background: #C8763A; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE (fullscreen)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 520px) {
  .wv-drawer {
    width: 100vw;
    border-left: none;
    border-radius: 0;
  }
  .wv-kv-grid { grid-template-columns: 1fr; }
  .wv-metric-cluster { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════
   DRILLDOWN CURSOR — any element with [data-drilldown]
   ═══════════════════════════════════════════════════════════════ */
[data-drilldown] {
  cursor: pointer;
  position: relative;
}

[data-drilldown]:hover::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(200, 118, 58, 0.4);
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   ERROR STATE
   ═══════════════════════════════════════════════════════════════ */
.wv-drawer-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  color: #5E6880;
  text-align: center;
}

.wv-drawer-error-icon {
  font-size: 28px;
  color: #BC1B1B;
}

.wv-drawer-error-msg {
  font-size: 13px;
  color: #3A4358;
  line-height: 1.5;
}

.wv-drawer-error-retry {
  margin-top: 8px;
  padding: 8px 16px;
  background: #001E50;
  color: #FFFFFF;
  border: none;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
