/* Synapse base styles and shared components. Colors come from tokens.css. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

h1, h2, h3, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon {
  display: block;
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.display {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, box-shadow .15s ease, color .15s ease, transform .06s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn--secondary {
  padding: 0 12px;
  background: var(--surface);
  box-shadow: var(--shadow-control);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}

.btn--secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--quiet {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--control);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.btn--quiet:hover {
  background: var(--control-hover);
  color: var(--text);
}

.btn--outline {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--text-2);
  font-size: 13px;
}

.btn--outline:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--lg {
  height: 48px;
  font-size: 15px;
}

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

.btn[aria-busy='true'] {
  cursor: progress;
  opacity: .78;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
}

/* ── Segmented control ───────────────────────────────────── */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--track);
}

.segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.segmented__btn:hover {
  color: var(--text);
}

.segmented__btn[aria-pressed='true'] {
  background: var(--seg-on);
  box-shadow: var(--shadow-pressed);
  color: var(--text);
  font-weight: 600;
}

/* ── Theme switcher ──────────────────────────────────────── */

.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--track);
}

.theme-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.theme-switch__btn:hover {
  color: var(--text);
}

.theme-switch__btn[aria-pressed='true'] {
  background: var(--seg-on);
  box-shadow: var(--shadow-pressed);
  color: var(--text);
  font-weight: 600;
}

.theme-switch--compact .theme-switch__btn {
  padding: 0;
  width: 34px;
  min-width: 0;
}

.theme-switch--compact .theme-switch__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ── Pills, badges and alerts ────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-full);
  background: var(--track);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill--accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--warn {
  padding: 0 8px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.4;
}

.alert .icon {
  margin-top: 1px;
}

.alert--error {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.alert--info {
  background: var(--accent-tint);
  color: var(--text-2);
}

/* ── Form fields ─────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input::placeholder {
  color: var(--text-4);
}

.input:hover {
  border-color: var(--axis);
}

.input:focus,
.input:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.input[aria-invalid='true'] {
  border-color: var(--danger-ink);
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-right: 50px;
}

.input-wrap__btn {
  position: absolute;
  top: 3px;
  right: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-3);
}

.input-wrap__btn:hover {
  background: var(--control);
  color: var(--text);
}

.kbd {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--kbd-bg);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
}

@media (max-width: 640px) {
  .input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
