/* WEFT component library — Constitution §5. Uses tokens only. */

/* —— Button —— */
.weft-btn,
.btn-primary,
.btn-ghost {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: filter var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.weft-btn:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.weft-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.weft-btn--primary,
.btn-primary {
  border: none;
  background: var(--accent);
  color: var(--selected-ink);
  width: 100%;
  font-size: var(--text-base);
  min-height: calc(var(--touch-min) + 4px);
  padding: var(--space-3) var(--space-6);
}

.weft-btn--primary:hover,
.btn-primary:hover { filter: brightness(1.08); }

.weft-btn--secondary {
  border: 1px solid var(--line-ui);
  background: var(--surface);
  color: var(--text);
}

/* In-game "Next" primary action (auto width, accent) */
.btn-next {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: linear-gradient(135deg,
    var(--accent),
    color-mix(in oklch, var(--accent) 70%, var(--word-4)));
  color: var(--selected-ink);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: filter var(--duration-fast) var(--ease-out);
}
.btn-next:hover { filter: brightness(1.1); }
.btn-next:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* .btn-next is already inline-flex with a gap, so the icon needs sizing only. */
.btn-icon { font-size: 1.15em; line-height: 1; }

.weft-btn--ghost,
.btn-ghost {
  border: 1px solid var(--line-ui);
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

.weft-btn--ghost:hover,
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

.weft-btn--destructive {
  border: 1px solid color-mix(in oklch, var(--danger) 40%, var(--line-ui));
  background: transparent;
  color: var(--danger);
}

/* —— Icon button —— */
.weft-icon-btn,
.gear-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.weft-icon-btn:hover,
.gear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* —— Select —— */
.weft-select,
.setup-field select {
  width: 100%;
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-3);
  min-height: var(--touch-min);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

/* —— Chip —— */
.weft-chip,
.chip-streak {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--chip-streak);
  color: var(--chip-streak-ink);
}

.weft-chip[hidden],
.chip-streak[hidden] { display: none !important; }

/* —— Card —— */
.weft-card,
.setup-card,
.modal,
.solve-panel,
.word-rail {
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-md);
}

.setup-card,
.solve-panel {
  padding: var(--space-6);
}

/* —— Progress —— */
.weft-progress,
.progress-bar {
  height: 8px;
  background: var(--line-ui);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.weft-progress__fill,
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width var(--duration-normal) var(--ease-out);
}

/* —— Badge —— */
.weft-badge {
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  color: var(--accent);
}

/* —— Sheet (mobile learning panel — styled in Phase 2) —— */
.weft-sheet {
  background: var(--surface-raised);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-raised);
}

/* —— Learning panel skeleton —— */
.learning-panel {
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-height: 120px;
}

.learning-panel--idle .learning-panel-hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

/* —— App footer (SETUP / SOLVED only) —— */
.app-footer {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: var(--footer-h);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--line-ui);
  margin-top: auto;
}

[data-ui-state="solved"] .app-footer {
  display: flex;
}
