/* ============================================================
   Accessibility Token — Global Styles
   ============================================================
   An accessibility-first design system. This service itself
   must be a model of accessible design.
   ============================================================ */

/* -- Reset & Base ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #e0e7ff;
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #596673;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --max-width: 960px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html {
  font-size: 16px;
}

/* Only enable smooth scrolling for users who haven't requested reduced motion */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
}

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

/* Focus indicators — prominent for keyboard users */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* -- Skip Link --------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--color-primary);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  z-index: 1000;
  font-weight: 600;
}

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

/* -- Layout ------------------------------------------------ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
}

nav a {
  margin-left: 24px;
  font-weight: 500;
}

main {
  padding: 48px 0 80px;
}

footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* -- Hero Section ------------------------------------------ */
.hero {
  text-align: center;
  padding: 64px 0 48px;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
}

/* -- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary-light);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* -- Cards ------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* -- Forms ------------------------------------------------- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.875rem;
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 44px;
}

.form-group input:focus-visible,
.form-group select:focus-visible {
  border-color: var(--color-primary);
  outline: 3px solid var(--color-primary);
  outline-offset: 1px;
  box-shadow: none;
}

/* -- Toggle Switches --------------------------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-label {
  flex: 1;
}

.toggle-label strong {
  display: block;
  font-size: 0.9375rem;
}

.toggle-label span {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  margin-left: 16px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #8892a0;
  border-radius: 28px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* -- Preference Sections ----------------------------------- */
.pref-section {
  margin-bottom: 24px;
}

.pref-section h2 {
  font-size: 1.125rem;
  font-weight: 700;
  padding: 12px 0;
  margin-bottom: 4px;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-primary);
}

.pref-section-desc {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 8px;
  padding-top: 8px;
}

/* -- How It Works Steps ------------------------------------ */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin: 48px 0;
}

.step {
  text-align: center;
  padding: 24px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

.step h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.step p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* -- Hash Display ------------------------------------------ */
.hash-display {
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  word-break: break-all;
  margin: 8px 0;
}

.copy-btn {
  font-size: 0.8125rem;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  min-height: 44px;
}

.copy-btn:hover {
  background: var(--color-primary);
  color: white;
}

/* -- Alerts ------------------------------------------------ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9375rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

/* -- Utilities --------------------------------------------- */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* Visually hidden but accessible to screen readers */
.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;
}

/* -- Code Block (for API example) -------------------------- */
.code-block {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  overflow-x: auto;
  line-height: 1.6;
}

/* -- Reduced Motion ---------------------------------------- */
@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;
  }
}

/* -- Responsive -------------------------------------------- */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  header .container {
    flex-direction: column;
    gap: 12px;
  }
}
