/* ============================================================
   Base — reset, typography, forms, scrollbar, accessibility
   ============================================================ */

/* ---- CSS Reset ---- */

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

/* Alpine.js cloak: hide elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* ---- Body ---- */

body {
  background: var(--bg-primary);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: fade-in 150ms ease;
}

/* ---- Page fade-in ---- */

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---- Typography ---- */

h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* ---- Links ---- */

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

a:hover {
  text-decoration: underline;
}

/* ---- Images ---- */

img {
  max-width: 100%;
  height: auto;
}

/* ---- Selection ---- */

::selection {
  background: var(--accent-blue);
  color: white;
}

/* ---- Scrollbar — Webkit ---- */

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ---- Scrollbar — Firefox ---- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

/* ---- Form base styles ---- */

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

input,
textarea,
select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
}

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

textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
}

textarea:focus::placeholder,
input:focus::placeholder {
  color: transparent;
}

/* ---- Focus styles ---- */

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

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

/* ---- Accessibility ---- */

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

.skip-link {
  position: absolute;
  top: -9999px;
  left: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: var(--accent-blue);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  z-index: 1000;
  text-decoration: none;
}

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

/* ---- Loading spinner ---- */

.loading {
  display: none;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: var(--space-sm);
}

.loading.on {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent-blue);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Utility classes ---- */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.color-inherit {
  color: inherit;
}

.no-underline {
  text-decoration: none;
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.p-3xl {
  padding: var(--space-3xl);
}

.opacity-75 {
  opacity: 0.75;
}

.icon-align {
  vertical-align: -1px;
}

/* ---- Responsive form elements ---- */

@media (width <= 768px) {
  input,
  textarea,
  select {
    min-height: 44px;
  }
}
