/* Wardn shared components, built on tokens.css. Shared by the website and the dashboard, so anything
   that only one of them needs lives in that surface's own stylesheet (site/assets/ui/site.css, app.css). */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--text-md)/1.5 var(--font); letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, kbd { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: rgba(124, 92, 255, 0.4); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--s-4); top: -60px; z-index: 100; background: var(--surface-3); color: var(--text); padding: var(--s-2) var(--s-4); border-radius: var(--r-sm); }
.skip-link:focus { top: var(--s-4); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.mono { font-family: var(--mono); }
.hstack { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.vstack { display: flex; flex-direction: column; gap: var(--s-3); }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); }
.m-0 { margin: 0; } .my-1 { margin-block: var(--s-1); } .ml-auto { margin-left: auto; } .ml-1 { margin-left: var(--s-1); }

/* ---------- Icons (SVG sprite: icons.svg) ---------- */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }
.icon-tile {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-hi); box-shadow: inset 0 0 0 1px rgba(160, 139, 255, 0.18);
}
.icon-tile.green { background: var(--green-soft); color: var(--green); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.2); }
.icon-tile.amber { background: var(--amber-soft); color: var(--amber); box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.2); }
.icon-tile.red { background: var(--red-soft); color: var(--red); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.2); }
.icon-tile.blue { background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.2); }
.icon-tile.lg { width: 52px; height: 52px; border-radius: var(--r-lg); }
.icon-tile.lg .icon { width: 24px; height: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4); border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 550; font-size: var(--text-md); line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), filter var(--dur), transform var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.btn-primary {
  color: var(--on-accent); background: linear-gradient(180deg, #8d71ff, var(--accent) 60%, #6f4ff5);
  border-color: rgba(255, 255, 255, 0.08); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), var(--glow);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-secondary { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); box-shadow: var(--inset-hi); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { color: var(--text-2); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn-link { color: var(--accent-hi); background: none; padding: 0; height: auto; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: #fff; background: #dc4a4a; border-color: rgba(255, 255, 255, 0.08); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn.danger { color: var(--red); }
.btn-sm, .btn-small { height: 30px; padding: 0 var(--s-3); font-size: var(--text-sm); border-radius: var(--r-xs); }
.btn-lg, .btn-large { height: 46px; padding: 0 var(--s-6); font-size: var(--text-lg); border-radius: var(--r-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; vertical-align: 2px;
  background: var(--accent-soft); color: var(--accent-hi);
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.gray { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.badge.orange, .badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.kbd, kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font: 500 11px/1 var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-strong); }

/* ---------- Form controls ---------- */
.input, .select {
  height: 36px; padding: 0 var(--s-3); min-width: 220px; max-width: 100%;
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:hover, .select:hover { border-color: rgba(255, 255, 255, 0.2); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.input:disabled, .select:disabled { opacity: 0.45; }
.input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%239a9aab' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
textarea.input { height: auto; min-height: 96px; padding: 10px var(--s-3); resize: vertical; width: 100%; line-height: 1.45; }
.input.num { min-width: 110px; width: 110px; }
.field-error { color: var(--red); font-size: var(--text-xs); }

.switch {
  position: relative; width: 40px; height: 24px; flex: none; padding: 0; border: 0; border-radius: var(--r-pill);
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:disabled { opacity: 0.4; cursor: default; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.segmented button { border: 0; background: none; color: var(--muted); height: 30px; padding: 0 var(--s-3); border-radius: var(--r-sm); cursor: pointer; font-size: var(--text-sm); font-weight: 550; transition: background-color var(--dur), color var(--dur); }
.segmented button:hover { color: var(--text); }
.segmented button.on, .segmented button[aria-selected="true"] { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm), var(--inset-hi); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-6); box-shadow: var(--inset-hi); }
.card.interactive { transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), background-color var(--dur); }
.card.interactive:hover { border-color: var(--line-accent); background: var(--surface-2); transform: translateY(-1px); }
.callout {
  display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text-2); font-size: var(--text-sm);
}
.callout > .icon { color: var(--muted); }
.callout .btn { margin-left: auto; flex: none; }
.callout.premium { background: linear-gradient(120deg, rgba(124, 92, 255, 0.16), rgba(124, 92, 255, 0.04)); border-color: rgba(160, 139, 255, 0.28); }
.callout.premium > .icon { color: var(--accent-hi); }
.callout.warn { background: var(--amber-soft); border-color: rgba(251, 191, 36, 0.28); }
.callout.warn > .icon { color: var(--amber); }
.callout.danger { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.3); }
.callout.danger > .icon { color: var(--red); }

.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { text-align: left; padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:last-child td { border-bottom: 0; }

.empty { display: grid; justify-items: center; gap: var(--s-2); text-align: center; color: var(--muted); padding: var(--s-12) var(--s-6); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty .icon-tile { margin-bottom: var(--s-2); }
.empty b { color: var(--text); font-size: var(--text-lg); }
.empty .btn { margin-top: var(--s-3); }

.skeleton { height: 120px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton.line { height: 14px; border-radius: var(--r-xs); }

/* ---------- Overlays ---------- */
.toasts { position: fixed; bottom: var(--s-5); right: var(--s-5); display: grid; gap: var(--s-2); z-index: 60; }
.toast {
  display: flex; align-items: center; gap: var(--s-2); max-width: 380px; padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); animation: toast-in var(--dur-slow) var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.toast.error::before { background: var(--red); }

.savebar {
  position: fixed; left: 50%; bottom: var(--s-5); z-index: 40; transform: translate(-50%, 160%);
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  background: rgba(26, 26, 35, 0.92); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow-lg); white-space: nowrap;
  transition: transform var(--dur-slow) var(--ease);
}
.savebar.show { transform: translate(-50%, 0); }
.savebar .count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-hi); font-size: var(--text-xs); font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: start center; padding: 12vh var(--s-4) var(--s-4); background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: var(--s-6); animation: pop-in var(--dur-slow) var(--ease); }
.modal h2 { margin: 0 0 var(--s-2); font-size: var(--text-xl); letter-spacing: var(--tracking-tight); }
.modal p { margin: 0; color: var(--muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-6); }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* Motion only (no fading), so nothing is left see-through if animations stall */
@keyframes pop-in { from { transform: translateY(8px) scale(0.98); } to { transform: none; } }
@keyframes toast-in { from { transform: translateY(10px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
