/* ==========================================================================
   Journey Tracker Design System — Base
   Uses tokens from tokens.css. Lives across light, dark, and both themes.
   Fonts (Graphik) are declared in tokens.css.
   ========================================================================== */

/* ---------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg-app);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: var(--font-feature);
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 { margin: 0; color: var(--fg-1); letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; line-height: 1.3; }
h4 { font-size: 15px; font-weight: 600; line-height: 1.3; }

p { margin: 0; line-height: 1.55; color: var(--fg-2); text-wrap: pretty; }

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

/* Editorial display (used in Grove for hero titles, e.g. challenge headers) */
.display {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

/* ---------------------------------------------------------------
   Style guide shell
   --------------------------------------------------------------- */
.sg-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sg-side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-1);
  padding: 24px 16px;
  overflow-y: auto;
}

.sg-side .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 18px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-1);
}
.sg-side .brand-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--fg-on-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sg-side .brand-name {
  font-size: 14px; font-weight: 700; color: var(--fg-1);
  letter-spacing: -0.01em; line-height: 1.15;
}
.sg-side .brand-tag {
  font-size: 11px; color: var(--fg-3); letter-spacing: 0.4px; text-transform: uppercase; font-weight: 600;
}

.sg-side .group {
  font-size: 11px; font-weight: 600; color: var(--fg-3);
  letter-spacing: 0.6px; text-transform: uppercase;
  padding: 16px 8px 6px;
}
.sg-side a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--fg-2);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.sg-side a:hover { background: var(--bg-subtle); color: var(--fg-1); }
.sg-side a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sg-side .num {
  margin-left: auto;
  font-size: 11px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.sg-main {
  padding: 32px 56px 120px;
  max-width: 1200px;
  width: 100%;
}

.sg-section {
  padding: 24px 0 56px;
  border-bottom: 1px solid var(--border-1);
  scroll-margin-top: 24px;
}
.sg-section:last-of-type { border-bottom: 0; }
.sg-section > .sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 24px;
}
.sg-section > .sec-head .num-tag {
  font-size: 11px; color: var(--fg-3);
  letter-spacing: 0.6px; text-transform: uppercase; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sg-section h2 { margin-bottom: 8px; }
.sg-section .lede {
  color: var(--fg-3);
  font-size: 14px;
  max-width: 60ch;
  margin-bottom: 24px;
}

/* Subsection (for grouping demos within a section) */
.sg-sub {
  margin-top: 32px;
}
.sg-sub-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.sg-sub-head h3 { margin: 0; font-size: 15px; }
.sg-sub-head .meta {
  font-size: 11px; color: var(--fg-3); font-weight: 500;
  letter-spacing: 0.4px; text-transform: uppercase;
}

/* Demo frame — what wraps every example */
.demo {
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.demo.col   { flex-direction: column; align-items: stretch; gap: 10px; }
.demo.tight { padding: 16px; gap: 10px; }
.demo.flush { padding: 0; }

/* ---------------------------------------------------------------
   THEME SWITCHER — pinned top-right
   --------------------------------------------------------------- */
.sg-controls {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  padding: 6px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}

.sg-controls .seg {
  display: inline-flex;
  background: var(--bg-offset);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.sg-controls .seg button {
  appearance: none; border: 0;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}
.sg-controls .seg button:hover { color: var(--fg-1); }
.sg-controls .seg button.active {
  background: var(--bg-surface);
  color: var(--fg-1);
  box-shadow: var(--shadow-xs);
}

.sg-controls .mode-toggle {
  width: 32px; height: 32px;
  border-radius: 9999px;
  border: 0;
  background: var(--bg-offset);
  color: var(--fg-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.sg-controls .mode-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.sg-controls .mode-toggle [data-lucide] { width: 16px; height: 16px; }

/* ---------------------------------------------------------------
   Foundations specific
   --------------------------------------------------------------- */

/* Color swatches */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.swatch {
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}
.swatch .chip {
  height: 56px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.swatch .meta { display: flex; flex-direction: column; gap: 2px; }
.swatch .name { font-size: 13px; font-weight: 600; color: var(--fg-1); letter-spacing: -0.01em; }
.swatch .var  { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); }
.swatch .val  { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); }

/* Type specimen */
.type-spec { display: flex; flex-direction: column; gap: 18px; }
.type-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-1);
}
.type-row:last-child { border-bottom: 0; }
.type-row .meta { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); line-height: 1.5; }
.type-row .meta b { color: var(--fg-1); font-weight: 600; display: block; font-family: var(--font-body); font-size: 12px; }
.type-row .sample { color: var(--fg-1); }

/* Spacing scale */
.space-row {
  display: grid;
  grid-template-columns: 80px 60px 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
}
.space-row .name { color: var(--fg-1); font-weight: 600; }
.space-row .bar  { height: 16px; background: var(--accent); border-radius: 2px; }

/* Radius preview */
.radius-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
}
.radius-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.radius-box {
  width: 100%; height: 76px;
  background: var(--accent-soft);
  border: 1px solid var(--border-1);
}
.radius-cell .nm { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); text-align: center; }
.radius-cell .nm b { color: var(--fg-1); display: block; font-weight: 600; font-family: var(--font-body); font-size: 12px; }

/* Shadow preview */
.shadow-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.shadow-cell { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.shadow-box {
  width: 100%; height: 80px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
}
.shadow-cell .nm { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); text-align: center; }
.shadow-cell .nm b { color: var(--fg-1); display: block; font-weight: 600; font-family: var(--font-body); font-size: 12px; }

/* Code chip — small inline reference */
code, .code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-offset);
  color: var(--fg-2);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

/* Helper utilities */
.muted { color: var(--fg-3); }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.gap-sm { gap: 8px; } .gap-md { gap: 16px; } .gap-lg { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
