/* wbydc core components. Needs dist/tokens.css loaded first.
   Pages built with them must also pass guidelines/web-interface-guidelines.md (check_ui.py checks the mechanical rules). */

.wb-skip-link {
  position: absolute; left: var(--wb-space-4); top: var(--wb-space-4); z-index: 100;
  padding: var(--wb-space-2) var(--wb-space-4); border-radius: var(--wb-radius-control);
  background: var(--wb-accent); color: var(--wb-on-accent); font: 600 var(--wb-text-sm)/1.2 var(--wb-font-mono);
  transform: translateY(-200%);
}
.wb-skip-link:focus-visible { transform: none; outline: 2px solid var(--wb-fg); outline-offset: 2px; }

.wb-backdrop {
  position: relative;
  isolation: isolate;
  color: var(--wb-fg);
  font: var(--wb-text-md)/1.55 var(--wb-font-sans);
  background: var(--wb-backdrop-image), var(--wb-bg);
}
.wb-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--wb-grain);
  background-image: var(--wb-grain-image);
  background-size: var(--wb-grain-size);
}

.wb-card {
  border-radius: var(--wb-radius-card);
  padding: var(--wb-space-6);
  background: var(--wb-glass-sheen), var(--wb-glass);
  border: 1px solid var(--wb-glass-edge);
  box-shadow: var(--wb-elevation);
  -webkit-backdrop-filter: blur(var(--wb-glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--wb-glass-blur)) saturate(180%);
  overflow-wrap: break-word;
  min-width: 0;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .wb-card { background: var(--wb-input-bg); }
}
@media (prefers-reduced-transparency: reduce) {
  .wb-card { background: var(--wb-input-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.wb-h1, .wb-h2 { margin: 0; font-family: var(--wb-font-heading); font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; scroll-margin-top: var(--wb-space-6); }
.wb-h1 { font-size: var(--wb-text-2xl); line-height: 1.15; }
.wb-h2 { font-size: var(--wb-text-xl); line-height: 1.2; }
.wb-muted { color: var(--wb-muted); }
.wb-label { font: 500 var(--wb-text-xs)/1.2 var(--wb-font-mono); letter-spacing: 0.04em; color: var(--wb-muted); }

.wb-input {
  box-sizing: border-box;
  width: 100%;
  height: var(--wb-size-control);
  padding: 0 13px;
  font: var(--wb-text-md) var(--wb-font-sans);
  color: var(--wb-fg);
  background: var(--wb-input-bg);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-radius-control);
}
.wb-input { touch-action: manipulation; transition: border-color 0.15s, box-shadow 0.15s; }
.wb-input:hover { border-color: var(--wb-fg); }
/* The ring replaces the outline; text inputs match :focus-visible on click too, so the ring shows whenever typing is possible. */
.wb-input:focus-visible { outline: none; border-color: var(--wb-accent); box-shadow: 0 0 0 3px var(--wb-ring); } /* check-ui: ok, ring replaces outline */
.wb-input[aria-invalid="true"] { border-color: var(--wb-danger); }
.wb-input::placeholder { color: var(--wb-muted); }
.wb-field-error { margin: var(--wb-space-1) 0 0; padding: 2px var(--wb-space-2); border-radius: 6px; width: fit-content;
  font-size: var(--wb-text-sm); background: var(--wb-danger-bg); color: var(--wb-danger-fg); }

.wb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wb-space-2);
  height: var(--wb-size-control);
  padding: 0 var(--wb-space-5);
  font: 600 var(--wb-text-sm)/1 var(--wb-font-mono);
  letter-spacing: 0.02em;
  border-radius: var(--wb-radius-control);
  border: 0;
  cursor: pointer;
  background: var(--wb-accent);
  color: var(--wb-on-accent);
  box-shadow: 0 6px 18px -8px var(--wb-accent);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.wb-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--wb-accent) 86%, var(--wb-fg)); }
.wb-btn:active:not(:disabled) { transform: translateY(1px); }
.wb-btn[aria-busy="true"] { cursor: progress; }
.wb-btn[aria-busy="true"]::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: wb-spin 0.7s linear infinite;
}
@keyframes wb-spin { to { transform: rotate(360deg); } }
.wb-btn:focus-visible { outline: 2px solid var(--wb-fg); outline-offset: 2px; }
.wb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.wb-btn--secondary { background: transparent; color: var(--wb-fg); box-shadow: inset 0 0 0 1px var(--wb-border); }
.wb-btn--danger { background: var(--wb-danger); color: var(--wb-on-danger); box-shadow: none; }
.wb-btn--secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--wb-fg) 8%, transparent); box-shadow: inset 0 0 0 1px var(--wb-fg); }
.wb-btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--wb-danger) 86%, var(--wb-fg)); }
.wb-btn--sm { height: var(--wb-size-control-sm); padding: 0 var(--wb-space-4); }

.wb-link { color: var(--wb-link); text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--wb-link) 40%, transparent); }
.wb-link:hover { text-decoration-color: currentColor; }
.wb-link:focus-visible { outline: 2px solid var(--wb-link); outline-offset: 2px; border-radius: 2px; }
.wb-link { touch-action: manipulation; overflow-wrap: anywhere; }

.wb-alert { overflow-wrap: break-word; padding: 10px 12px; border-radius: var(--wb-radius-control); font-size: var(--wb-text-sm); background: var(--wb-info-bg); color: var(--wb-info-fg); }
.wb-alert--success { background: var(--wb-success-bg); color: var(--wb-success-fg); }
.wb-alert--warning { background: var(--wb-warning-bg); color: var(--wb-warning-fg); }
.wb-alert--danger { background: var(--wb-danger-bg); color: var(--wb-danger-fg); }

.wb-icon { width: 20px; height: 20px; stroke-width: 1.75; flex: none; }

.wb-num { font-variant-numeric: tabular-nums; }
.wb-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .wb-btn, .wb-input { transition: none; }
  .wb-btn:active:not(:disabled) { transform: none; }
  .wb-btn[aria-busy="true"]::after { animation: none; border-right-color: currentColor; opacity: 0.6; }
}
