/* LiNK components, "Comet" system. Colours come only from --lk-* tokens
   (tests/test_lk_components.py rejects raw colour literals). Phase 0: loaded by /dev/ui only. */

body.lk-root { margin: 0; }
.lk-root {
  /* base type: 16px, Thai-safe leading (tone marks clip below ~1.35 on headings) */
  background: var(--lk-bg);
  color: var(--lk-ink);
  font-family: var(--lk-font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.lk-root :is(h1, h2, h3, h4) {
  font-family: var(--lk-font-head);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}
.lk-root:lang(th), .lk-root :lang(th) { letter-spacing: normal; text-transform: none; }
.lk-root a:not([class]) { color: var(--lk-link); text-decoration: underline; text-underline-offset: 0.2em; }
.lk-wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.lk-sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:where(.lk-root) :focus-visible { outline: 2px solid var(--lk-focus); outline-offset: 2px; }

.lk-icon { width: 1.25em; height: 1.25em; vertical-align: -0.25em; fill: currentColor; }
.lk-comet-mark { width: 120px; height: 12px; }

/* colour swatches for /dev/ui (classes, not inline var(), so the template scanners stay happy) */
.lk-swatch {
  display: inline-flex; padding: 0.25rem 0.75rem; border: 1px solid var(--lk-input-line);
  border-radius: var(--lk-radius); font-size: 0.875rem; font-weight: 600;
}
.lk-swatch--bg { background: var(--lk-bg); color: var(--lk-ink); }
.lk-swatch--surface { background: var(--lk-surface); color: var(--lk-ink); }
.lk-swatch--tint { background: var(--lk-tint); color: var(--lk-ink); }
.lk-swatch--ink { background: var(--lk-ink); color: var(--lk-bg); }
.lk-swatch--muted { background: var(--lk-muted); color: var(--lk-bg); }
.lk-swatch--link { background: var(--lk-link); color: var(--lk-bg); }
.lk-swatch--btn-fill { background: var(--lk-btn-fill); color: var(--lk-btn-ink); }
.lk-swatch--danger-fill { background: var(--lk-danger-fill); color: var(--lk-danger-ink); }
.lk-swatch--focus { background: var(--lk-focus); color: var(--lk-bg); }

/* buttons */
.lk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0 1.1rem; border: 1px solid transparent;
  border-radius: var(--lk-radius); font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; text-wrap: balance;
}
.lk-btn--primary { background: var(--lk-btn-fill); color: var(--lk-btn-ink); }
.lk-btn--secondary { background: transparent; color: var(--lk-ink); border-color: var(--lk-input-line); }
.lk-btn--danger { background: var(--lk-danger-fill); color: var(--lk-danger-ink); }
/* outline danger: a link to a confirm page (R3 PR 3). The solid .lk-btn--danger is kept for the
   button that does the action, so solid red always means "this click does it" */
.lk-btn--danger-quiet { background: var(--lk-surface); color: var(--lk-danger); border-color: var(--lk-danger); }
.lk-btn:disabled, .lk-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* fields */
.lk-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.35rem; margin-bottom: 1rem; }
.lk-field label { font-weight: 600; }
.lk-field__req { color: var(--lk-muted); font-weight: 400; }
.lk-field input, .lk-field select, .lk-field textarea {
  min-height: 44px; padding: 0.45rem 0.7rem; background: var(--lk-surface); color: var(--lk-ink);
  border: 1px solid var(--lk-input-line); border-radius: var(--lk-radius); font: inherit;
}
.lk-field input[aria-invalid="true"] { border-color: var(--lk-danger); border-width: 2px; }
.lk-field__help { margin: 0; color: var(--lk-muted); font-size: 0.9375rem; }
.lk-field__error { margin: 0; color: var(--lk-danger); font-size: 0.9375rem; font-weight: 600; }

/* status chips: always carry text, colour only reinforces it */
.lk-chip {
  display: inline-flex; align-items: center; padding: 0.05rem 0.65rem;
  border: 1px solid currentColor; border-radius: var(--lk-radius);
  background: var(--lk-surface); color: var(--lk-ink);
  font-size: 0.875rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.lk-id { font-family: var(--lk-font-mono); white-space: nowrap; }
.lk-chip--ok { color: var(--lk-ok); }
.lk-chip--warn { color: var(--lk-warn); }
.lk-chip--danger { color: var(--lk-danger); }
.lk-chip--info { color: var(--lk-link); }
.lk-chip--neutral { color: var(--lk-muted); }
.lk-chip { gap: 0.35rem; }
.lk-chip .lk-icon { width: 1em; height: 1em; flex: none; }
.lk-chip--dashed { border-style: dashed; }

/* progress: native <progress> (role + value for free) with the comet gradient as the fill.
   The pastel fill is low contrast against the track by design: the meaning is carried by the
   bordered track and the text beside it, so do not "fix" the fill colour. */
.lk-progress { display: flex; align-items: center; gap: 0.75rem; }
.lk-progress__bar {
  appearance: none; -webkit-appearance: none; flex: 1; height: 8px;
  border: 1px solid var(--lk-input-line); border-radius: var(--lk-radius);
  background: var(--lk-line); overflow: hidden;
}
.lk-progress__bar::-webkit-progress-bar { background: var(--lk-line); }
.lk-progress__bar::-webkit-progress-value {
  background: linear-gradient(90deg, var(--lk-peach), var(--lk-orchid), var(--lk-lavender), var(--lk-cyan));
}
.lk-progress__bar::-moz-progress-bar {
  background: linear-gradient(90deg, var(--lk-peach), var(--lk-orchid), var(--lk-lavender), var(--lk-cyan));
}
.lk-progress__bar:indeterminate {
  background: linear-gradient(90deg, var(--lk-line) 0%, var(--lk-lavender) 50%, var(--lk-line) 100%);
  background-size: 200% 100%;
}
.lk-progress__text { min-width: 3.5rem; font-variant-numeric: tabular-nums; }

/* empty / error states */
.lk-state {
  padding: 1.5rem; border: 1px dashed var(--lk-input-line); border-radius: var(--lk-radius);
  background: var(--lk-surface);
}
.lk-state--error { border-style: solid; border-color: var(--lk-danger); }
.lk-state h2 { margin: 0 0 0.5rem; font-size: 1.125rem; }
.lk-state p { margin: 0 0 1rem; color: var(--lk-muted); }
.lk-state code { font-family: var(--lk-font-mono); }

/* empty states with a drawing (the drawing is decorative, the words carry the meaning) */
.lk-state--art { text-align: center; }
/* 240x160 drawings (R3, Codex): width follows the column on phones, the viewBox keeps the ratio */
.lk-state__art { display: block; width: min(240px, 100%); height: auto; margin: 0 auto 12px; color: var(--lk-muted); }

/* tables */
.lk-table-wrap { overflow-x: auto; }
.lk-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.lk-table th {
  background: var(--lk-surface); text-align: left; font-weight: 600;
  padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--lk-input-line);
}
.lk-table td { height: 36px; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--lk-line); }
.lk-table tr[aria-selected="true"] td { background: var(--lk-tint); }
.lk-table tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--lk-link); }
.lk-num { font-family: var(--lk-font-mono); font-variant-numeric: tabular-nums; text-align: right; }

.lk-page-header { margin: 0 0 1.5rem; }
.lk-page-header h1 { margin: 0; }
.lk-page-header p { margin: 0.25rem 0 0; color: var(--lk-muted); }

/* alerts: an icon and words always, colour only reinforces. the macro sets role="alert|status" */
.lk-alert {
  display: flex; gap: 0.6rem; align-items: flex-start; margin: 0 0 1rem; padding: 0.75rem 0.9rem;
  background: var(--lk-surface); color: var(--lk-ink);
  border: 1px solid var(--lk-input-line); border-left-width: 4px; border-radius: var(--lk-radius);
}
.lk-alert .lk-icon { flex: none; margin-top: 0.15em; }
.lk-alert__body { min-width: 0; overflow-wrap: anywhere; }
.lk-alert__title { display: block; font-weight: 600; }
.lk-alert--info { border-left-color: var(--lk-link); }
.lk-alert--info .lk-icon, .lk-alert--info .lk-alert__title { color: var(--lk-link); }
.lk-alert--success { border-left-color: var(--lk-ok); }
.lk-alert--success .lk-icon, .lk-alert--success .lk-alert__title { color: var(--lk-ok); }
.lk-alert--warning { border-left-color: var(--lk-warn); }
.lk-alert--warning .lk-icon, .lk-alert--warning .lk-alert__title { color: var(--lk-warn); }
.lk-alert--danger { border-left-color: var(--lk-danger); }
.lk-alert--danger .lk-icon, .lk-alert--danger .lk-alert__title { color: var(--lk-danger); }

/* one checkbox with its label (remember this device) */
.lk-check { display: flex; gap: 0.5rem; align-items: center; margin: 0 0 1rem; cursor: pointer; min-height: 44px; }
.lk-check input { width: 1.25rem; height: 1.25rem; flex: none; }

@media (pointer: coarse) {
  .lk-btn, .lk-field input, .lk-field select, .lk-field textarea,
  .lk-table td a, .lk-table td button { min-height: 44px; }
  .lk-table td a, .lk-table td button { display: inline-flex; align-items: center; }
  .lk-table td { height: 44px; }
}

/* profile picture: a rounded square (the radius token), never a circle */
.lk-avatar { display: inline-block; flex: none; object-fit: cover; border-radius: var(--lk-radius); background: var(--lk-tint); }
.lk-avatar--32 { width: 32px; height: 32px; }
.lk-avatar--72 { width: 72px; height: 72px; }
.lk-avatar--initial {
  display: inline-flex; align-items: center; justify-content: center; color: var(--lk-ink);
  border: 1px solid var(--lk-input-line); font-weight: 600;
}
.lk-avatar--72.lk-avatar--initial { font-size: 1.75rem; }

/* tag chips (game page, shelf cards, wishlist rows): shared, so every page that shows a tag link gets the look */
.lk-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lk-tag {
  padding: 2px 10px; background: var(--lk-tint); color: var(--lk-ink);
  border: 1px solid var(--lk-line); border-radius: var(--lk-radius); overflow-wrap: anywhere;
}
.lk-tags--warn .lk-tag { border-color: var(--lk-warn); }
/* a tag that links to /browse?tag=...: the chip look, with a 44px target */
.lk-tag--link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  min-width: 44px; text-decoration: none; color: var(--lk-ink);
}
.lk-tag--link:hover { border-color: var(--lk-link); }
