/* Agent Studio — reset, typography and shared primitives (SPEC 11, 65). */

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

* {
  margin: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Focus (SPEC 65: focus must always be visible) ---- */
:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Screen-reader only ---- */
.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: var(--space-4);
  top: -60px;
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-weight: var(--weight-label);
  transition: top var(--duration-base) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-4);
}

/* ---- Typography helpers (SPEC 11) ---- */
.page-title {
  font-size: var(--text-page-title);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

.section-title {
  font-size: var(--text-section-title);
  font-weight: var(--weight-section);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

.field-label {
  display: block;
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  color: var(--text-primary);
}

.helper {
  font-size: var(--text-helper);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

.helper-error {
  color: var(--danger);
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Inputs ---- */
.input,
.textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.textarea {
  resize: vertical;
  min-height: 96px;
  line-height: var(--leading-relaxed);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-disabled);
}

.input:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-strong);
}

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

.input[aria-invalid='true']:focus,
.textarea[aria-invalid='true']:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  font-weight: var(--weight-label);
  border: 1px solid transparent;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-on-accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-secondary);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text-primary);
}

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

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-label);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
}

.icon {
  flex: none;
  color: currentColor;
}

/* ------------------------------ scrollbars ----------------------------- */

/*
 * Scrollbars use the product's own gradient (SPEC 10) — the same chromatic
 * language the rest of the UI is built from. No third-party brand asset is
 * involved, which keeps SPEC 14 and SPEC 74 satisfied.
 *
 * Firefox gets the standard two-colour form; Chromium and Safari get the
 * gradient thumb.
 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-image: var(--gradient-primary);
  border-radius: var(--radius-pill);
  /* The transparent border shrinks the visible thumb without changing the
     hit area, so it stays easy to grab. */
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  border-width: 1px;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* The Markdown preview sits on a tinted surface and reads better with a
   slightly recessed track. */
.preview__body::-webkit-scrollbar-track {
  background: var(--surface-secondary);
}

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