/*
 * Wire UI stylesheet. Served once at /__wrnexus/ui.css. Every value is a theme
 * token (var(--wire-*)), so components restyle instantly when the theme changes.
 * Override any of these classes in your own CSS (it loads after ui.css).
 */

/* --- Layout --------------------------------------------------------------- */
.wire-container {
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding-inline: 1rem;
}
.wire-stack {
  display: flex;
  flex-direction: column;
}
.wire-hstack {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.wire-grid {
  display: grid;
}
.wire-spacer {
  flex: 1 1 auto;
}
.wire-divider {
  border: 0;
  border-top: 1px solid var(--wire-color-border);
  margin: 1rem 0;
}

/* gap scale (shared by stack / hstack / grid) */
.wire-gap-0 {
  gap: 0;
}
.wire-gap-1 {
  gap: 0.25rem;
}
.wire-gap-2 {
  gap: 0.5rem;
}
.wire-gap-3 {
  gap: 0.75rem;
}
.wire-gap-4 {
  gap: 1rem;
}
.wire-gap-5 {
  gap: 1.5rem;
}
.wire-gap-6 {
  gap: 2rem;
}
.wire-gap-8 {
  gap: 3rem;
}

.wire-items-start {
  align-items: flex-start;
}
.wire-items-center {
  align-items: center;
}
.wire-items-end {
  align-items: flex-end;
}
.wire-items-stretch {
  align-items: stretch;
}

.wire-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}
.wire-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.wire-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.wire-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.wire-cols-5 {
  grid-template-columns: repeat(5, 1fr);
}
.wire-cols-6 {
  grid-template-columns: repeat(6, 1fr);
}
@media (max-width: 640px) {
  .wire-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Button --------------------------------------------------------------- */
.wire-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--wire-radius-sm);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition:
    filter 0.15s ease,
    background 0.15s ease,
    transform 0.04s ease;
}
.wire-btn:active {
  transform: translateY(1px);
}
.wire-btn:focus-visible {
  outline: 2px solid var(--wire-color-primary);
  outline-offset: 2px;
}

.wire-btn--default {
  background: var(--wire-color-surface-2);
  color: var(--wire-color-text);
  border-color: var(--wire-color-border);
}
.wire-btn--primary {
  background: var(--wire-color-primary);
  color: var(--wire-color-primary-contrast);
}
.wire-btn--primary:hover {
  background: var(--wire-color-primary-hover);
}
.wire-btn--danger {
  background: var(--wire-color-danger);
  color: #fff;
}
.wire-btn--ghost {
  background: transparent;
  color: var(--wire-color-text);
  border-color: var(--wire-color-border);
}
.wire-btn--ghost:hover {
  background: var(--wire-color-surface-2);
}

.wire-btn--sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}
.wire-btn--md {
  padding: 0.55rem 0.9rem;
}
.wire-btn--lg {
  padding: 0.7rem 1.2rem;
  font-size: 1.05rem;
}

/* --- Inputs --------------------------------------------------------------- */
.wire-input {
  width: 100%;
  font: inherit;
  color: var(--wire-color-text);
  background: var(--wire-color-bg);
  border: 1px solid var(--wire-color-border);
  border-radius: var(--wire-radius-sm);
  padding: 0.5rem 0.7rem;
}
.wire-input::placeholder {
  color: var(--wire-color-muted);
}
.wire-input:focus-visible {
  outline: 2px solid var(--wire-color-primary);
  outline-offset: 1px;
  border-color: var(--wire-color-primary);
}
.wire-textarea {
  resize: vertical;
  min-height: 4.5rem;
}

/* Validation states (set by /__wrnexus/validate.js). */
.wire-invalid {
  border-color: var(--wire-color-danger) !important;
}
.wire-field-error {
  display: block;
  min-height: 1em;
  margin-top: 0.25rem;
  color: var(--wire-color-danger);
  font-size: 0.8rem;
}

.wire-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.wire-check__box {
  width: 1rem;
  height: 1rem;
  accent-color: var(--wire-color-primary);
}
.wire-check__box:focus-visible {
  outline: 2px solid var(--wire-color-primary);
  outline-offset: 2px;
}
.wire-check__label {
  color: var(--wire-color-text);
}

/* --- Badge ---------------------------------------------------------------- */
.wire-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}
.wire-badge--default {
  background: var(--wire-color-surface-2);
  color: var(--wire-color-text);
}
.wire-badge--primary {
  background: var(--wire-color-primary);
  color: var(--wire-color-primary-contrast);
}
.wire-badge--success {
  background: var(--wire-color-success);
  color: #05210f;
}
.wire-badge--danger {
  background: var(--wire-color-danger);
  color: #fff;
}
.wire-badge--warning {
  background: var(--wire-color-warning);
  color: #201400;
}

/* --- Alert ---------------------------------------------------------------- */
.wire-alert {
  border: 1px solid var(--wire-color-border);
  border-left-width: 4px;
  border-radius: var(--wire-radius-sm);
  padding: 0.75rem 1rem;
  background: var(--wire-color-surface);
  color: var(--wire-color-text);
}
.wire-alert__title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.wire-alert__title:empty {
  display: none;
}
.wire-alert__body {
  color: var(--wire-color-muted);
}
.wire-alert--info {
  border-left-color: var(--wire-color-primary);
}
.wire-alert--success {
  border-left-color: var(--wire-color-success);
}
.wire-alert--danger {
  border-left-color: var(--wire-color-danger);
}
.wire-alert--warning {
  border-left-color: var(--wire-color-warning);
}

/* --- Card ----------------------------------------------------------------- */
.wire-card {
  background: var(--wire-color-surface);
  border: 1px solid var(--wire-color-border);
  border-radius: var(--wire-radius);
  padding: 1.25rem;
  box-shadow: var(--wire-shadow-1);
}

/* --- Avatar --------------------------------------------------------------- */
.wire-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--wire-color-border);
}

/* --- Spinner -------------------------------------------------------------- */
.wire-spinner {
  display: inline-block;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--wire-color-border);
  border-top-color: var(--wire-color-primary);
  border-radius: 999px;
  animation: wire-spin 0.7s linear infinite;
}
@keyframes wire-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Disclosure ----------------------------------------------------------- */
.wire-disclosure {
  border: 1px solid var(--wire-color-border);
  border-radius: var(--wire-radius-sm);
  background: var(--wire-color-surface);
}
.wire-disclosure__summary {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
}
.wire-disclosure__summary:focus-visible {
  outline: 2px solid var(--wire-color-primary);
  outline-offset: -2px;
}
.wire-disclosure__body {
  padding: 0 0.9rem 0.75rem;
  color: var(--wire-color-muted);
}

/* --- Select --------------------------------------------------------------- */
.wire-select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--wire-color-muted) 50%),
    linear-gradient(135deg, var(--wire-color-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 1.05em,
    calc(100% - 13px) 1.05em;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

/* --- Switch --------------------------------------------------------------- */
.wire-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.wire-switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.wire-switch__track {
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--wire-color-border);
  transition: background 0.15s ease;
  flex: none;
}
.wire-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 4px);
  height: calc(1.25rem - 4px);
  border-radius: 999px;
  background: #fff;
  transition: transform 0.15s ease;
}
.wire-switch__input:checked + .wire-switch__track {
  background: var(--wire-color-primary);
}
.wire-switch__input:checked + .wire-switch__track .wire-switch__thumb {
  transform: translateX(1rem);
}
.wire-switch__input:focus-visible + .wire-switch__track {
  outline: 2px solid var(--wire-color-primary);
  outline-offset: 2px;
}
.wire-switch__label {
  color: var(--wire-color-text);
}

/* --- Progress ------------------------------------------------------------- */
.wire-progress {
  appearance: none;
  width: 100%;
  height: 0.5rem;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--wire-color-surface-2);
}
.wire-progress::-webkit-progress-bar {
  background: var(--wire-color-surface-2);
}
.wire-progress::-webkit-progress-value {
  background: var(--wire-color-primary);
  border-radius: 999px;
}
.wire-progress::-moz-progress-bar {
  background: var(--wire-color-primary);
}

/* --- Tag ------------------------------------------------------------------ */
.wire-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: var(--wire-radius-sm);
  border: 1px solid var(--wire-color-border);
  background: var(--wire-color-surface-2);
  color: var(--wire-color-text);
}
.wire-tag--primary {
  background: var(--wire-color-primary);
  color: var(--wire-color-primary-contrast);
  border-color: transparent;
}
.wire-tag--success {
  background: var(--wire-color-success);
  color: #05210f;
  border-color: transparent;
}
.wire-tag--danger {
  background: var(--wire-color-danger);
  color: #fff;
  border-color: transparent;
}
.wire-tag--warning {
  background: var(--wire-color-warning);
  color: #201400;
  border-color: transparent;
}

/* --- Skeleton ------------------------------------------------------------- */
.wire-skeleton {
  display: inline-block;
  border-radius: var(--wire-radius-sm);
  background: linear-gradient(
    90deg,
    var(--wire-color-surface-2) 25%,
    var(--wire-color-border) 37%,
    var(--wire-color-surface-2) 63%
  );
  background-size: 400% 100%;
  animation: wire-shimmer 1.4s ease infinite;
}
@keyframes wire-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* --- Tooltip -------------------------------------------------------------- */
.wire-tooltip {
  position: relative;
  display: inline-flex;
  cursor: help;
}
.wire-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--wire-color-text);
  color: var(--wire-color-bg);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--wire-radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 10;
}
.wire-tooltip:hover::after,
.wire-tooltip:focus-visible::after {
  opacity: 1;
}

/* --- Table ---------------------------------------------------------------- */
.wire-table-wrap {
  overflow-x: auto;
}
.wire-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.wire-table th,
.wire-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--wire-color-border);
}
.wire-table th {
  font-weight: 700;
  color: var(--wire-color-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.wire-table tbody tr:hover {
  background: var(--wire-color-surface-2);
}
