/* ============================================================================
   Jengo Live Meeting — base layer
   Reset, document defaults, focus, and the primitives every screen shares.
   Depends on tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  /* color-scheme is set per theme in tokens.css, not globally: "light dark"
     here let the OS choose native control rendering, so an explicit in-app
     dark theme on a light OS drew light checkboxes on a dark ground. */
}

body {
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  background: var(--surface-ground);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

/* ── Focus ────────────────────────────────────────────────────────────────
   The old stylesheet set `outline: none` on inputs and gave buttons no focus
   state at all, which made the whole app un-navigable by keyboard. One ring,
   applied only for keyboard focus, on everything interactive. */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── Form controls inherit the UI font ────────────────────────────────── */
button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

::placeholder { color: var(--text-tertiary); opacity: 1; }

/* ── Scrollbars — visible enough to find, quiet enough to ignore ───────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-clip: content-box; background-color: var(--text-tertiary); }

a { color: var(--accent-text); text-underline-offset: 2px; }

img { max-width: 100%; display: block; }

/* ── Utilities ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so any
   author rule that sets display — .btn-ghost is inline-flex, a flex column
   section is flex — silently wins and the element stays on screen. Every
   component that sets display would otherwise have to remember this; one rule
   here means `el.hidden = true` does what it says everywhere. */
[hidden] { display: none !important; }

/* Visible to screen readers only — used for landmark and control labels
   where the visual design carries meaning through an icon alone. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Wide content (tables, code) scrolls inside its own box, never the page. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Shared primitives ────────────────────────────────────────────────── */

.label-caps {
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
}

.field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  padding: var(--sp-3);
  font-size: var(--fs-body);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}

.field:hover { border-color: var(--text-tertiary); }

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

textarea.field { resize: vertical; min-height: 5.5rem; line-height: var(--lh-snug); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-hover); transform: translateY(1px); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-tertiary); }
.btn-secondary:active { background: var(--surface-active); }

/* Compact, quiet control — toolbar and header actions */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn-ghost:active { background: var(--surface-active); }

/* Square icon-only variant — keeps a 36px hit target at every size */
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  flex-shrink: 0;
}

/* ── Chips ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  padding: .15rem .45rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-neutral { background: var(--surface-sunken); color: var(--text-secondary); border-color: var(--border); }
.chip-accent  { background: var(--accent-subtle);  color: var(--accent-text);   border-color: var(--accent-border); }
.chip-success { background: var(--success-subtle); color: var(--success);       border-color: var(--success-border); }
.chip-danger  { background: var(--danger-subtle);  color: var(--danger);        border-color: var(--danger-border); }
.chip-warning { background: var(--warning-subtle); color: var(--warning);       border-color: var(--warning-border); }

/* ── Motion ───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
