/* ============================================================================
   Foundation pages — shared template, dark theme (matches the landing page)
   Used by: typography, spacing, border-radius, shadows.
   Reuses pages.css for: .story-header, .content-section, .section-divider,
   .data-table, .doc-card. Adds consistent preview + guideline blocks below.
   Colors reference the shared semantic tokens in tokens.css.
   ============================================================================ */

/* Base — restores what the removed inline <style> provided (reset + body font).
   NOTE: the reset must stay UNSCOPED (plain `*`, specificity 0,0,0) — matching
   the component pages' inline reset. Scoping it to `.foundation *` raises the
   specificity to (0,1,0), which ties with `.sidebar-link` and (loading later)
   overrides the sidebar's padding/margins, collapsing the nav. */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body.foundation {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Page chrome */
.foundation .app-layout { display: flex; overflow: hidden; background: var(--bg); }
.foundation .canvas-area {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  overflow-y: auto;
  padding: 40px 48px;
}
@media (max-width: 768px) { .foundation .canvas-area { padding: 24px 20px; } }

/* Intro line under a section title */
.fnd-intro {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 24px;
  max-width: 760px;
}

/* Mono token chip used in tables / meta */
.fnd-token {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ---- Preview tile grid (radius, shadows, spacing) ------------------------- */
.fnd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.fnd-tile {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-1);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.fnd-tile:hover { box-shadow: 0 8px 22px rgba(124, 108, 255, 0.18); border-color: rgba(124, 108, 255, 0.4); transform: translateY(-2px); }
.fnd-tile__visual {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
  padding: 16px;
}
.fnd-tile__meta { padding: 12px 14px; }
.fnd-tile__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.fnd-tile__value { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* shapes inside tiles */
.fnd-swatch { width: 60px; height: 60px; background: linear-gradient(135deg, var(--accent-blue), var(--accent-deep)); }
.fnd-card-demo { width: 86px; height: 60px; background: #2A2B3A; border-radius: 10px; }

/* ---- Type scale list ----------------------------------------------------- */
.type-list { display: flex; flex-direction: column; }
.type-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line-2);
}
.type-row:last-child { border-bottom: none; }
.type-row__sample { color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-row__meta { text-align: right; flex-shrink: 0; }
.type-row__name { font-size: 13px; font-weight: 600; color: var(--ink); }
.type-row__token { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ---- Weight chips -------------------------------------------------------- */
.weight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.weight-tile { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--surface-1); }
.weight-tile__sample { font-size: 28px; color: var(--ink); line-height: 1; margin-bottom: 12px; }
.weight-tile__name { font-size: 13px; font-weight: 600; color: var(--ink); }
.weight-tile__value { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ---- Spacing scale rows -------------------------------------------------- */
.space-list { display: flex; flex-direction: column; }
.space-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.space-row:last-child { border-bottom: none; }
.space-row__meta { display: flex; align-items: baseline; gap: 10px; }
.space-row__name { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); }
.space-row__value { font-size: 13px; font-weight: 600; color: var(--ink); }
.space-row__bar { height: 16px; background: linear-gradient(90deg, var(--accent-deep), var(--accent-blue)); border-radius: 3px; min-width: 2px; }
.space-row__desc { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* ---- Inline spacing bar (merged Spacing Scale table) --------------------- */
.spacing-table td { vertical-align: middle; }
.space-bar {
  display: inline-block;
  height: 16px;
  min-width: 1px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-blue));
  border-radius: 3px;
  vertical-align: middle;
}
.space-bar--zero { width: 2px; opacity: 0.3; }
/* negative steps point left and read as muted, so the bar isn't mistaken for positive space */
.space-bar--neg {
  background: repeating-linear-gradient(45deg, rgba(124,108,255,0.35), rgba(124,108,255,0.35) 3px, rgba(124,108,255,0.12) 3px, rgba(124,108,255,0.12) 6px);
  border: 1px solid rgba(124, 108, 255, 0.3);
}

/* ---- Type Scale table (live preview cells) ------------------------------- */
.type-table td { vertical-align: middle; }
.type-table td:nth-child(2) { color: var(--ink); }

/* ---- Inline shadow preview (Elevation Modes table) ----------------------- */
.shadow-preview {
  display: inline-block;
  width: 64px;
  height: 38px;
  background: #2A2B3A;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  vertical-align: middle;
}

/* ---- 12-column grid demo ------------------------------------------------- */
.grid-demo { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.grid-demo__col {
  background: rgba(124, 108, 255, 0.12);
  border: 1px solid rgba(124, 108, 255, 0.3);
  border-radius: 6px;
  padding: 18px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
@media (max-width: 700px) { .grid-demo { grid-template-columns: repeat(6, 1fr); } }

/* ---- Do / Don't guideline cards (SVG icons, no emoji) -------------------- */
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.guide {
  display: flex;
  gap: 14px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid;
}
.guide--do { background: rgba(46, 230, 120, 0.08); border-color: rgba(46, 230, 120, 0.25); }
.guide--dont { background: rgba(243, 39, 39, 0.08); border-color: rgba(243, 39, 39, 0.25); }
.guide__icon {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.guide--do .guide__icon { background: var(--success); }
.guide--dont .guide__icon { background: #F54E4E; }
.guide__icon svg { width: 14px; height: 14px; }
.guide__body { min-width: 0; }
.guide__title { display: block; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px; }
.guide--do .guide__title { color: var(--success-text); }
.guide--dont .guide__title { color: var(--danger-text); }
.guide__text { font-size: 13px; color: var(--ink-2); line-height: 1.6; }

@media (max-width: 700px) { .guide-grid { grid-template-columns: 1fr; } }
