/* Follow the Token: Design System */

/* ============================================================================
   Design Tokens
   ============================================================================ */

:root {
  /* Color palette */
  --color-paper: #F2F4F7;
  --color-ink: #13203A;
  --color-ink-hover: #1E2E54;
  --color-ink-active: #0D1524;
  --color-muted: #4A5568;
  --color-rule: #C9D0DB;
  --color-surface: #FFFFFF;

  /* Token type colors */
  --color-token-saml: #9C2F55;
  --color-token-id: #1F7A63;
  --color-token-access: #C07F20; /* True amber with navy text for contrast */
  --color-token-access-text: var(--color-ink); /* Access tokens use dark text */
  --color-token-refresh: #5B45A0;
  --color-token-code: #2F64C8;
  --color-token-opaque: #5F6B7D;

  /* Type scale */
  --font-size-14: 0.875rem;
  --font-size-16: 1rem;
  --font-size-18: 1.125rem;
  --font-size-21: 1.3125rem;
  --font-size-24: 1.5rem;
  --font-size-36: 2.25rem;
  --font-size-48: 3rem;
  --font-size-60: 3.75rem;

  /* Font families */
  --font-heading: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Source Serif 4', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --reading-width: 1100px;
  --breakout-width: 90rem;
  --focus-ring: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-ink);
}

/* ============================================================================
   Base Styles
   ============================================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--font-size-18);
  line-height: 1.6;
  font-weight: 400;
}

/* ============================================================================
   Typography
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: var(--space-lg);
}

h1 {
  font-size: var(--font-size-60);
  margin-bottom: var(--space-xl);
}

h2 {
  font-size: var(--font-size-48);
  margin-top: var(--space-3xl);
}

h3 {
  font-size: var(--font-size-36);
  margin-top: var(--space-2xl);
}

h4 {
  font-size: var(--font-size-24);
  font-weight: 600;
  margin-top: var(--space-xl);
}

h5 {
  font-size: var(--font-size-21);
  font-weight: 600;
  margin-top: var(--space-lg);
}

h6 {
  font-size: var(--font-size-18);
  font-weight: 600;
  margin-top: var(--space-lg);
}

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

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

.muted {
  color: var(--color-muted);
}

/* ============================================================================
   Layout
   ============================================================================ */

.container {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

.breakout {
  max-width: var(--breakout-width);
  margin-left: calc(-1 * var(--space-lg));
  margin-right: calc(-1 * var(--space-lg));
  padding: var(--space-xl) var(--space-lg);
  background-color: var(--color-surface);
  border-radius: 4px;
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-3xl) var(--space-xl);
  }

  .breakout {
    margin-left: 0;
    margin-right: 0;
    padding: var(--space-2xl);
    border: 1px solid var(--color-rule);
  }
}

/* ============================================================================
   Code and HTTP Blocks
   ============================================================================ */

code {
  font-family: var(--font-mono);
  font-size: var(--font-size-16);
  background-color: var(--color-surface);
  padding: 0.125rem 0.375rem;
  border-radius: 2px;
  border: 1px solid var(--color-rule);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-14);
  line-height: 1.5;
  background-color: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: 4px;
  padding: var(--space-lg);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* ============================================================================
   Tables
   ============================================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-xl);
  font-family: var(--font-heading);
  font-size: var(--font-size-16);
  background-color: var(--color-surface);
}

thead {
  background-color: var(--color-paper);
}

th {
  font-weight: 600;
  text-align: left;
  padding: var(--space-md);
  border-bottom: 2px solid var(--color-rule);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-rule);
}

tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 767px) {
  table {
    font-size: var(--font-size-14);
  }

  th, td {
    padding: var(--space-sm);
  }
}

/* ============================================================================
   Token Components
   ============================================================================ */

.token-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: var(--font-size-14);
  font-weight: 600;
  color: var(--color-surface);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none;
  text-decoration: none;
}

.token-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.token-chip:active {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .token-chip {
    transition: none;
  }

  .token-chip:hover {
    transform: none;
  }

  .token-chip:active {
    transform: none;
  }
}

.token-saml {
  background-color: var(--color-token-saml);
}

.token-id {
  background-color: var(--color-token-id);
}

.token-access {
  background-color: var(--color-token-access);
  color: var(--color-token-access-text);
}

.token-refresh {
  background-color: var(--color-token-refresh);
}

.token-code {
  background-color: var(--color-token-code);
}

.token-opaque {
  background-color: var(--color-token-opaque);
}

/* Token legend */
.token-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-lg);
  background-color: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: 4px;
  margin-bottom: var(--space-xl);
}

.token-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-heading);
  font-size: var(--font-size-14);
}

.token-legend-swatch {
  width: 2rem;
  height: 1.25rem;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.button {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-heading);
  font-size: var(--font-size-16);
  font-weight: 600;
  color: var(--color-surface);
  background-color: var(--color-ink);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.button:hover {
  background-color: var(--color-ink-hover);
  transform: translateY(-1px);
}

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

.button:active {
  background-color: var(--color-ink-active);
  transform: translateY(0);
}

.button-secondary {
  background-color: var(--color-surface);
  color: var(--color-ink);
  border: 2px solid var(--color-ink);
}

.button-secondary:hover {
  background-color: var(--color-paper);
  border-color: var(--color-ink-hover);
}

.button-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }

  .button:hover {
    transform: none;
  }

  .button:active {
    transform: none;
  }
}

/* ============================================================================
   Links
   ============================================================================ */

a {
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: text-decoration-thickness 0.15s ease;
}

a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}

/* ============================================================================
   Lists
   ============================================================================ */

ul, ol {
  margin-bottom: var(--space-lg);
  padding-left: var(--space-xl);
}

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

/* ============================================================================
   Horizontal Rule
   ============================================================================ */

hr {
  border: none;
  border-top: 1px solid var(--color-rule);
  margin: var(--space-2xl) 0;
}

/* ============================================================================
   Verification Notes
   ============================================================================ */

.verify-note {
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-ink);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
  border-radius: 4px;
}

.verify-note p:last-child {
  margin-bottom: 0;
}

.verify-note pre {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

/* ============================================================================
   Citations
   ============================================================================ */

/* Inline citation markers */
.citation,
sup a[href^="#source-"] {
  font-family: var(--font-heading);
  font-size: var(--font-size-14);
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: none;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  transition: background-color 0.15s ease;
}

.citation:hover,
sup a[href^="#source-"]:hover {
  background-color: var(--color-rule);
  text-decoration: none;
}

.citation:focus,
sup a[href^="#source-"]:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  background-color: var(--color-rule);
}

/* Sources section */
.sources {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--color-rule);
}

.sources h2 {
  font-size: var(--font-size-36);
  margin-bottom: var(--space-xl);
}

.sources ol {
  list-style: none;
  counter-reset: source-counter;
  padding-left: 0;
}

.sources li {
  counter-increment: source-counter;
  margin-bottom: var(--space-lg);
  padding-left: var(--space-2xl);
  position: relative;
  font-family: var(--font-heading);
  font-size: var(--font-size-16);
  line-height: 1.5;
}

.sources li::before {
  content: counter(source-counter) ".";
  position: absolute;
  left: 0;
  font-weight: 600;
  color: var(--color-muted);
}

.sources li a {
  font-weight: 600;
}

.sources .source-meta {
  color: var(--color-muted);
  font-weight: 400;
}

/* ============================================================================
   Accessibility
   ============================================================================ */

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

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

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 767px) {
  h1 {
    font-size: var(--font-size-48);
  }

  h2 {
    font-size: var(--font-size-36);
    margin-top: var(--space-2xl);
  }

  h3 {
    font-size: var(--font-size-24);
    margin-top: var(--space-xl);
  }

  body {
    font-size: var(--font-size-16);
  }
}

@media (max-width: 390px) {
  h1 {
    font-size: var(--font-size-36);
  }

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

  h3 {
    font-size: var(--font-size-21);
  }
}
