/* ============================================================
   TOKENS — CSS custom properties
   ============================================================ */
:root {
  /* color */
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #666666;
  --color-border: #e0e0e0;
  --color-accent: #0066cc;

  /* type */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;

  /* space */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
}

[data-theme="dark"] {
  --color-bg: #121212;
  --color-text: #f0f0f0;
  --color-muted: #999999;
  --color-border: #333333;
  --color-accent: #6699ff;
}

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

/* ============================================================
   ELEMENTS — default styling for native HTML
   ============================================================ */
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  margin-bottom: var(--space-sm);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }

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

small {
  font-size: 0.8125rem;
  color: var(--color-muted);
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration: none; }

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

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: var(--space-md);
  color: var(--color-muted);
  margin-bottom: var(--space-md);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-border);
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  background: var(--color-border);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}
pre code {
  background: transparent;
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-md);
}
th, td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
th { font-weight: 600; }

/* ============================================================
   FORMS — buttons and inputs
   ============================================================ */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  width: 100%;
  max-width: 20rem;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: var(--space-xs);
}

label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-right: var(--space-md);
}

/* ============================================================
   COMPONENTS — project-specific components
   ============================================================ */
.btn {
  display: inline-block;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   PROTOTYPE CHROME — styleguide-environment classes only.
   These are NEVER part of a real page; they exist to frame the
   styleguide, component previews, and page previews. All classes
   are namespaced `.prototype-*` so they are easy to find and
   delete if the project ever outgrows this scaffold.
   ============================================================ */

.prototype-page {
  max-width: 48rem;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

.prototype-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.prototype-title h1 {
  margin-bottom: 0;
}
.prototype-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  margin: 0;
}
.prototype-title-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.prototype-title-actions a {
  color: var(--color-muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.prototype-title-actions a:hover { color: var(--color-text); }
.prototype-title-actions button {
  background: transparent;
  border: 1px solid var(--color-muted);
  color: var(--color-muted);
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.prototype-title-actions button:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

.prototype-toc {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.prototype-toc li { margin: 0; }
.prototype-toc a { font-family: var(--font-mono); font-size: 0.875rem; }

.prototype-section {
  margin-bottom: var(--space-xl);
  padding-top: var(--space-lg);
}
.prototype-section > h2 {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.prototype-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: var(--space-md);
}
.prototype-swatch {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.prototype-swatch-box {
  aspect-ratio: 2 / 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.prototype-swatch-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
}

.prototype-space-scale {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.prototype-space-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.prototype-space-bar {
  height: 0.75rem;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
}
.prototype-space-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  min-width: 6rem;
}

.prototype-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-border);
  border-bottom: 1px dashed var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
}
.prototype-header a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.prototype-header a:hover { text-decoration: none; }
.prototype-header-spacer { flex: 1; }

.prototype-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.prototype-breadcrumb span { opacity: 0.6; }
.prototype-header button {
  background: transparent;
  border: 1px solid var(--color-muted);
  color: inherit;
  font: inherit;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
