@import url("./tokens.css");

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

html {
  min-width: 20rem;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--surface-page);
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-sans);
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  letter-spacing: -0.018em;
  text-wrap: balance;
}

h1 { font-size: clamp(1.75rem, 3vw, var(--font-size-3xl)); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
  color: var(--text-secondary);
}

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

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

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

button,
[role="button"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--text-brand);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--color-brand-700);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

code,
kbd,
samp,
pre,
.data-text {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums slashed-zero;
}

::selection {
  background: rgb(0 122 255 / 20%);
  color: var(--text-primary);
}

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

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

.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;
}

.surface {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.muted { color: var(--text-secondary); }
.caption { color: var(--text-tertiary); font-size: var(--font-size-xs); }

.field {
  display: grid;
  gap: var(--space-2);
}

.field-label {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

input,
textarea,
select {
  width: 100%;
  min-height: var(--control-height-md);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 94%);
  padding: 0 var(--space-3);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

textarea {
  min-height: 6rem;
  padding-block: var(--space-3);
  line-height: var(--line-height-body);
  resize: vertical;
}

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

input:hover,
textarea:hover,
select:hover {
  border-color: rgb(60 60 67 / 30%);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-brand-600);
  outline: none;
  box-shadow: var(--shadow-focus);
}

[aria-invalid="true"] {
  border-color: var(--border-danger);
}

[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgb(255 59 48 / 18%);
}

.btn,
.button {
  display: inline-flex;
  min-height: var(--control-height-md);
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
  user-select: none;
}

.btn:active,
.button:active {
  transform: scale(0.97);
  transition-duration: 90ms;
}

.btn-primary,
.button-primary {
  background: var(--surface-brand);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgb(0 122 255 / 16%);
}

.btn-primary:hover,
.button-primary:hover {
  background: var(--color-brand-700);
  color: var(--text-inverse);
}

.btn-secondary,
.button-secondary {
  border-color: var(--border-subtle);
  background: rgb(255 255 255 / 82%);
}

.btn-secondary:hover,
.button-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text-primary);
}

.btn-ghost:hover,
.button-ghost:hover {
  background: var(--surface-subtle);
}

.btn-danger,
.button-danger {
  background: var(--color-danger-600);
  color: var(--text-inverse);
}

.btn-danger:hover,
.button-danger:hover {
  background: var(--color-danger-700);
  color: var(--text-inverse);
}

.btn-sm,
.button-sm {
  min-height: var(--control-height-sm);
  padding-inline: var(--space-3);
  font-size: var(--font-size-sm);
}

.btn-lg,
.button-lg {
  min-height: var(--control-height-lg);
  padding-inline: var(--space-5);
  font-size: var(--font-size-base);
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

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

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

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background: rgb(60 60 67 / 28%);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgb(60 60 67 / 42%);
  background-clip: padding-box;
}

* {
  scrollbar-color: rgb(60 60 67 / 28%) transparent;
  scrollbar-width: thin;
}

@media (max-width: 48rem) {
  :root {
    --header-height: 3.5rem;
  }

  h2 { font-size: var(--font-size-xl); }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --border-subtle: rgb(29 29 31 / 34%);
    --border-strong: rgb(29 29 31 / 58%);
  }

  :focus-visible { outline-width: 3px; }
  .surface { border-color: var(--border-strong); box-shadow: none; }
}
