/* KillSlop base: fonts, design tokens and the primitives every surface
   shares. Two identical copies live at extension/src/ui/base.css and
   worker/public/ui/base.css, and test/design.test.mjs keeps them in step.

   The design language follows Vercel's Geist system: Geist Sans and Geist
   Mono, black on white, hairline gray borders, tight headings. Only the
   language is borrowed; the mark and the name are our own. The Geist fonts
   are OFL-1.1, see ../fonts/OFL.txt. */

@font-face {
  font-family: 'Geist';
  src: url('../fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('../fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --fg: #171717;
  --fg-muted: #666666;
  --fg-faint: #8f8f8f;
  --border: #ebebeb;
  --border-strong: #c9c9c9;
  --fill: #f2f2f2;
  --hover: rgb(0 0 0 / 0.05);
  --inverse: #171717;
  --inverse-fg: #ffffff;
  --inverse-hover: #383838;

  /* Colour is for meaning only: focus, status, and the one verdict red. */
  --focus: #0070f3;
  --green: #45a557;
  --red: #e5484d;
  --red-fg: #cb2a2f;
  --red-bg: #fff0f0;
  --amber-fg: #a35200;
  --amber-bg: #fff6e5;

  --radius: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-menu: 0 0 0 1px var(--border), 0 4px 8px -4px rgb(0 0 0 / 0.04),
    0 16px 24px -8px rgb(0 0 0 / 0.08);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-subtle: #000000;
    --fg: #ededed;
    --fg-muted: #a1a1a1;
    --fg-faint: #737373;
    --border: #2e2e2e;
    --border-strong: #454545;
    --fill: #1a1a1a;
    --hover: rgb(255 255 255 / 0.06);
    --inverse: #ededed;
    --inverse-fg: #0a0a0a;
    --inverse-hover: #cccccc;

    --focus: #52a8ff;
    --green: #62c073;
    --red: #e5484d;
    --red-fg: #ff6166;
    --red-bg: #2a1215;
    --amber-fg: #ffa01c;
    --amber-bg: #291800;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-menu: 0 0 0 1px var(--border), 0 8px 16px -4px rgb(0 0 0 / 0.6);

    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ reset */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

::selection {
  background: var(--inverse);
  color: var(--inverse-fg);
}

.mono {
  font-family: var(--font-mono);
}

/* A small uppercase mono label: section heads, eyebrows, table heads. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* ------------------------------------------------------------------- mark */

/* The KillSlop mark: a ring struck through, on a rounded square. Inline SVG
   with class "mark"; the square takes the text colour, the glyph the page. */
.mark {
  display: block;
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--fg);
}

.mark__glyph {
  fill: none;
  stroke: var(--bg);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.wordmark {
  font-weight: 600;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--fg);
  font: 500 14px/20px var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.btn:hover {
  background: var(--fill);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn--primary {
  background: var(--inverse);
  box-shadow: none;
  color: var(--inverse-fg);
}

.btn--primary:hover {
  background: var(--inverse-hover);
}

.btn--ghost {
  background: transparent;
  box-shadow: none;
}

.btn--ghost:hover {
  background: var(--hover);
}

.btn--danger {
  background: var(--red);
  box-shadow: none;
  color: #ffffff;
}

.btn--danger:hover {
  background: #d93036;
}

.btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn--lg {
  height: 40px;
  padding: 0 16px;
}

.btn--pill {
  border-radius: 999px;
}

.btn--block {
  display: flex;
  width: 100%;
}

/* Last, so it wins over every variant and its hover. */
.btn:disabled,
.btn[aria-disabled='true'] {
  background: var(--fill);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--fg-faint);
  cursor: not-allowed;
}

/* ----------------------------------------------------------------- inputs */

.input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--fg);
  font: 400 14px/20px var(--font-sans);
  transition: box-shadow 150ms ease;
}

.input::placeholder {
  color: var(--fg-faint);
}

.input:hover {
  box-shadow: 0 0 0 1px var(--border-strong);
}

.input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--fg-muted), 0 0 0 4px var(--hover);
}

textarea.input {
  height: auto;
  padding: 10px 12px;
  line-height: 22px;
  resize: vertical;
}

/* ----------------------------------------------------------------- switch */

/* <button role="switch" aria-checked> with no children. */
.switch {
  position: relative;
  flex: none;
  width: 32px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.switch[aria-checked='true'] {
  background: var(--inverse);
  box-shadow: none;
}

.switch[aria-checked='true']::after {
  background: var(--bg);
  transform: translateX(14px);
}

.switch:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.switch:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* -------------------------------------------------------------- segmented */

/* A row of mutually exclusive buttons. Layout (inline-flex, grid) is left to
   the page; the selected one is marked with aria-selected, -pressed or
   -checked, whichever role the page gives it. */
.segmented {
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

.segmented button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font: 500 13px/20px var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.segmented button:hover {
  color: var(--fg);
}

.segmented button[aria-selected='true'],
.segmented button[aria-pressed='true'],
.segmented button[aria-checked='true'] {
  background: var(--fill);
  color: var(--fg);
}

.segmented button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ------------------------------------------------------------- small bits */

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--fg-muted);
  font: 500 11px/1 var(--font-sans);
  white-space: nowrap;
}

.badge--inverse {
  background: var(--inverse);
  color: var(--inverse-fg);
}

.badge--red {
  background: var(--red-bg);
  color: var(--red-fg);
}

.badge--amber {
  background: var(--amber-bg);
  color: var(--amber-fg);
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--fg-muted);
  font: 500 11px/1 var(--font-sans);
}

/* A status dot, as in "Ready". Green when on, gray when paused. */
.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.dot--off {
  background: var(--fg-faint);
}

.dot--red {
  background: var(--red);
}

.link {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease;
}

.link:hover {
  text-decoration-color: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
