/**
 * VPM — UX foundations (clarity, consistency, accessibility, feedback)
 * Keep It Simple · Clear hierarchy · Obvious navigation · Immediate feedback
 */

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

/* ——— Readable contrast (WCAG 4.5:1 body guidance) ——— */
html[data-theme='light'] {
  --vpm-text-muted: #475569;
}

/* ——— Global focus (keyboard navigation) ——— */
.vpm a:focus-visible,
.vpm button:focus-visible,
.vpm summary:focus-visible,
.vpm [role='tab']:focus-visible,
.vpm [tabindex]:not([tabindex='-1']):focus-visible {
  outline: 2px solid var(--vpm-primary);
  outline-offset: 2px;
}

.vpm .vpm-input:focus-visible,
.vpm .vpm-select:focus-visible,
.vpm textarea.vpm-input:focus-visible {
  outline: none;
  border-color: var(--vpm-primary);
  box-shadow: 0 0 0 3px var(--vpm-cta-muted);
}

/* ——— Touch targets (min 44px on mobile) ——— */
@media (max-width: 767px) {
  .vpm-icon-btn,
  .vpm-dash-header__menu,
  .vpm-mobile-header__menu,
  .vpm-mobile-header__theme,
  .vpm-mobile-header__icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .vpm-btn--sm {
    min-height: 44px;
  }

  .vpm-menu-drawer__link {
    min-height: 44px;
  }
}

/* ——— Clickable affordance ——— */
.vpm details.vpm-wallet-row > summary,
.vpm .vpm-dash-sidebar__link,
.vpm .vpm-card--interactive,
.vpm a.vpm-btn,
.vpm .vpm-avatar--link,
.vpm .vpm-menu-drawer__link,
.vpm .vpm-mobile-nav__link,
.vpm .vpm-app-bottom-nav__link,
.vpm .vpm-mobile-header__icon-btn,
.vpm .vpm-mobile-header__brand {
  cursor: pointer;
}

.vpm .vpm-card--trader:not(:has(form)) {
  cursor: default;
}

/* ——— Disabled / loading feedback ——— */
.vpm-btn:disabled,
.vpm-btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.vpm-btn--loading {
  position: relative;
  color: transparent !important;
}

.vpm-btn--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: vpm-spin 0.65s linear infinite;
  color: var(--vpm-text-inverse);
}

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

@media (prefers-reduced-motion: reduce) {
  .vpm-btn--loading::after {
    animation: none;
    border-right-color: currentColor;
  }
}

/* ——— Form clarity ——— */
.vpm-field__label,
.vpm-label {
  display: block;
  font-size: var(--vpm-text-sm);
  font-weight: var(--vpm-weight-medium);
  color: var(--vpm-text);
  line-height: 1.4;
}

.vpm-label {
  margin-bottom: 6px;
}

.vpm-field__label .vpm-required,
.vpm-label .vpm-required {
  color: var(--vpm-danger);
  margin-left: 2px;
}

.vpm-field__hint,
.vpm-field-hint {
  display: block;
  margin-top: 6px;
  font-size: var(--vpm-text-xs);
  color: var(--vpm-text-muted);
  line-height: 1.45;
}

.vpm-input--error,
.vpm-input:invalid:not(:placeholder-shown):not(:focus) {
  border-color: var(--vpm-danger);
}

.vpm-field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  font-size: var(--vpm-text-xs);
  color: var(--vpm-danger);
  line-height: 1.4;
}

.vpm-field-error::before {
  content: '';
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

textarea.vpm-input {
  min-height: 96px;
  padding: 10px 12px;
  height: auto;
  resize: vertical;
  line-height: 1.5;
}

/* ——— Alerts & feedback (immediate, visible) ——— */
.vpm-flash-stack {
  display: grid;
  gap: var(--vpm-space-1);
  margin-bottom: var(--vpm-space-2);
}

.vpm-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--vpm-radius-md);
  font-size: var(--vpm-text-sm);
  line-height: 1.5;
  border: 1px solid transparent;
}

.vpm-alert__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.vpm-alert__body {
  flex: 1;
  min-width: 0;
}

.vpm-alert__body ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.vpm-alert--success {
  background: var(--vpm-success-bg);
  color: var(--vpm-success);
  border-color: rgba(38, 166, 154, 0.35);
}

.vpm-alert--error {
  background: var(--vpm-danger-bg);
  color: var(--vpm-danger);
  border-color: rgba(239, 83, 80, 0.35);
}

.vpm-alert--info {
  background: var(--vpm-info-bg);
  color: var(--vpm-info);
  border-color: rgba(91, 156, 246, 0.35);
}

/* ——— Navigation context (where am I?) ——— */
.vpm-context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--vpm-space-2);
  font-size: var(--vpm-text-xs);
  color: var(--vpm-text-muted);
}

.vpm-context-bar__badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: var(--vpm-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  border: 1px solid var(--vpm-border);
  background: var(--vpm-surface-elevated);
  color: var(--vpm-text);
}

.vpm-context-bar__badge--admin {
  border-color: rgba(239, 83, 80, 0.35);
  background: rgba(239, 83, 80, 0.1);
  color: var(--vpm-danger);
}

.vpm-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.vpm-breadcrumb a {
  color: var(--vpm-text-muted);
  text-decoration: none;
  transition: color var(--vpm-duration) var(--vpm-ease-out);
}

.vpm-breadcrumb a:hover {
  color: var(--vpm-primary);
}

.vpm-breadcrumb [aria-current='page'] {
  color: var(--vpm-text);
  font-weight: var(--vpm-weight-medium);
}

.vpm-breadcrumb__sep {
  color: var(--vpm-text-muted);
  opacity: 0.6;
  user-select: none;
}

/* ——— Visual hierarchy (page shells) ——— */
.vpm-page-shell__title {
  font-size: var(--vpm-text-xl);
  font-weight: var(--vpm-weight-semibold);
  letter-spacing: -0.02em;
  color: var(--vpm-text);
  line-height: 1.25;
}

.vpm-page-shell__sub {
  margin-top: 6px;
  max-width: 62ch;
  font-size: var(--vpm-text-sm);
  color: var(--vpm-text-muted);
  line-height: 1.55;
}

.vpm-panel__title {
  font-size: var(--vpm-text-base);
  font-weight: var(--vpm-weight-semibold);
  color: var(--vpm-text);
}

/* ——— Empty states (reduce cognitive load) ——— */
.vpm-empty-state {
  padding: var(--vpm-space-4) var(--vpm-space-2);
  text-align: center;
  color: var(--vpm-text-muted);
  font-size: var(--vpm-text-sm);
  line-height: 1.55;
}

.vpm-empty-state__title {
  margin: 0 0 6px;
  font-size: var(--vpm-text-base);
  font-weight: var(--vpm-weight-medium);
  color: var(--vpm-text);
}

/* ——— Expandable rows ——— */
.vpm-wallet-row > summary {
  border-radius: var(--vpm-radius-sm);
  transition: background var(--vpm-duration) var(--vpm-ease-out);
}

.vpm-wallet-row > summary:hover {
  background: var(--vpm-surface-elevated);
}

.vpm-wallet-row[open] > summary {
  margin-bottom: 4px;
}

.vpm-wallet-row > summary::after {
  content: 'Edit';
  margin-left: auto;
  font-size: var(--vpm-text-xs);
  color: var(--vpm-primary);
  font-weight: var(--vpm-weight-medium);
}

/* ——— Tables: scan-friendly ——— */
.vpm-table th {
  font-size: var(--vpm-text-xs);
  font-weight: var(--vpm-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vpm-text-muted);
}

/* ——— Confirm destructive actions ——— */
.vpm-btn--destructive:focus-visible {
  outline-color: var(--vpm-danger);
}

/* ——— 11: Primary vs secondary actions ——— */
.vpm-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: var(--vpm-space-2);
}

.vpm-form-actions .vpm-btn--primary {
  order: 1;
  min-width: min(100%, 160px);
}

.vpm-form-actions .vpm-btn--ghost,
.vpm-form-actions .vpm-btn--secondary {
  order: 2;
}

.vpm-panel__head .vpm-btn--primary {
  flex-shrink: 0;
}

.vpm-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.vpm-actions-bar .vpm-btn--primary {
  box-shadow: 0 2px 8px rgba(41, 98, 255, 0.25);
}

/* ——— 12–16: Mobile-first spacing & scan-friendly sections ——— */
.vpm-section {
  margin-bottom: var(--vpm-space-4);
}

.vpm-section__head {
  margin-bottom: var(--vpm-space-2);
}

.vpm-section__title {
  margin: 0;
  font-size: var(--vpm-text-base);
  font-weight: var(--vpm-weight-semibold);
  color: var(--vpm-text);
  line-height: 1.35;
}

.vpm-section__lead {
  margin: 6px 0 0;
  max-width: 65ch;
  font-size: var(--vpm-text-sm);
  color: var(--vpm-text-muted);
  line-height: 1.55;
}

.vpm-scan-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--vpm-text-muted);
  font-size: var(--vpm-text-sm);
  line-height: 1.6;
}

.vpm-scan-list li + li {
  margin-top: 4px;
}

.vpm-panel + .vpm-panel {
  margin-top: var(--vpm-space-3);
}

.vpm-collapsible > summary {
  cursor: pointer;
  font-weight: var(--vpm-weight-semibold);
  list-style: none;
  padding: 4px 0;
}

.vpm-collapsible > summary::-webkit-details-marker {
  display: none;
}

.vpm-collapsible > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform var(--vpm-duration) var(--vpm-ease-out);
}

.vpm-collapsible[open] > summary::before {
  transform: rotate(90deg);
}

/* ——— 14: Mobile-first dashboard ——— */
@media (max-width: 767px) {
  .vpm-dash-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .vpm-dash-header__actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .vpm-balance-pill__label {
    display: none;
  }

  .vpm-dashboard__content {
    padding: var(--vpm-space-2);
  }

  .vpm-context-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .vpm-wallet-form__grid {
    grid-template-columns: 1fr !important;
  }

  .vpm-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .vpm-form-actions .vpm-btn {
    width: 100%;
  }

  .vpm-deposit-steps {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .vpm-deposit-steps__line {
    display: none;
  }
}

/* ——— 17: Goal-oriented task banner ——— */
.vpm-goal-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--vpm-space-2);
  padding: var(--vpm-space-2) var(--vpm-space-3);
  margin-bottom: var(--vpm-space-3);
  background: var(--vpm-surface);
  border: 1px solid var(--vpm-border);
  border-radius: var(--vpm-radius-lg);
  border-left: 3px solid var(--vpm-primary);
}

.vpm-goal-banner__title {
  margin: 0;
  font-size: var(--vpm-text-base);
  font-weight: var(--vpm-weight-semibold);
}

.vpm-goal-banner__text {
  margin: 4px 0 0;
  font-size: var(--vpm-text-sm);
  color: var(--vpm-text-muted);
  max-width: 50ch;
  line-height: 1.5;
}

.vpm-goal-banner__action {
  flex-shrink: 0;
}

/* ——— 10: Inline constraint feedback ——— */
.vpm-input-hint--live {
  margin-top: 6px;
  font-size: var(--vpm-text-xs);
  color: var(--vpm-text-muted);
}

.vpm-input-hint--live[data-state='invalid'] {
  color: var(--vpm-danger);
}

.vpm-input-hint--live[data-state='valid'] {
  color: var(--vpm-success);
}

/* ——— 18: Recoverable / reversible affordances ——— */
.vpm-link-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--vpm-text-sm);
  color: var(--vpm-text-muted);
  text-decoration: none;
  margin-bottom: var(--vpm-space-2);
  transition: color var(--vpm-duration) var(--vpm-ease-out);
}

.vpm-link-back:hover {
  color: var(--vpm-primary);
}

/* ——— 15: Performance — content visibility for long lists ——— */
.vpm-table-wrap {
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

.vpm-dash-sidebar__nav {
  content-visibility: auto;
}
