/* EMA Design System — documentation site styles */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  font-family: var(--ema-font-sans);
  font-size: var(--ema-text-md);
  color: var(--ema-text);
  background: var(--ema-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.doc-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--ema-surface) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ema-border);
}
.doc-logo {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 800; font-size: 1.05rem;
  color: var(--ema-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.doc-logo__mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--ema-primary), var(--ema-secondary));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.8rem; font-weight: 800;
  box-shadow: var(--ema-shadow-md);
}
.doc-logo__tag {
  font-size: var(--ema-text-xs);
  font-weight: 600;
  color: var(--ema-primary);
  background: var(--ema-primary-soft);
  padding: 0.1rem 0.5rem;
  border-radius: var(--ema-radius-full);
}
.doc-topbar__nav { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.doc-topbar__nav a {
  color: var(--ema-text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--ema-text-sm);
  padding: 0.4rem 0.7rem;
  border-radius: var(--ema-radius-md);
  transition: all 120ms;
}
.doc-topbar__nav a:hover { color: var(--ema-text); background: var(--ema-surface-3); }
.doc-topbar__nav a.active { color: var(--ema-primary); background: var(--ema-primary-soft); }
.doc-topbar__spacer { flex: 1; }
.doc-theme-picker { display: flex; gap: 0.3rem; align-items: center; }
.doc-theme-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ema-border-strong);
  cursor: pointer;
  padding: 0;
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 120ms;
}
.doc-theme-dot:hover { transform: scale(1.18); }
.doc-theme-dot.active { border-color: var(--ema-primary); box-shadow: var(--ema-focus-ring); }
.doc-settings-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--ema-border-strong);
  border-radius: var(--ema-radius-md);
  background: var(--ema-surface);
  color: var(--ema-text-2);
  cursor: pointer;
  transition: all 150ms;
}
.doc-settings-btn:hover { color: var(--ema-primary); border-color: var(--ema-primary); transform: rotate(30deg); }
.doc-settings-btn svg { width: 15px; height: 15px; }
.doc-set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.45rem;
  font-size: var(--ema-text-sm);
  color: var(--ema-text-2);
}
.doc-set-row input[type="color"] {
  width: 56px; height: 26px;
  border: 1px solid var(--ema-border-strong);
  border-radius: var(--ema-radius-sm);
  background: var(--ema-surface);
  padding: 1px; cursor: pointer;
}
.doc-set-row select {
  height: 26px; min-width: 110px;
  border: 1px solid var(--ema-border-strong);
  border-radius: var(--ema-radius-sm);
  background: var(--ema-surface);
  color: var(--ema-text);
  font: inherit; font-size: var(--ema-text-sm);
  cursor: pointer; outline: none;
}
.doc-theme-dot--light   { background: linear-gradient(135deg, #f7f9fc 50%, #1f5fa8 50%); }
.doc-theme-dot--dark    { background: linear-gradient(135deg, #151d2a 50%, #5495db 50%); }
.doc-theme-dot--navy    { background: linear-gradient(135deg, #0a1626 50%, #6db3f2 50%); }
.doc-theme-dot--emerald { background: linear-gradient(135deg, #f4faf6 50%, #178a53 50%); }

/* ---------- Layout ---------- */
.doc-shell { display: flex; padding-top: 56px; min-height: 100vh; }
.doc-sidebar {
  position: sticky;
  top: 56px;
  align-self: flex-start;
  width: 230px;
  flex: none;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 1.25rem 0.75rem 2rem;
  border-right: 1px solid var(--ema-border);
  scrollbar-width: thin;
}
.doc-sidebar h5 {
  margin: 1.2rem 0.6rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ema-text-3);
}
.doc-sidebar h5:first-child { margin-top: 0; }
.doc-sidebar a {
  display: block;
  padding: 0.32rem 0.6rem;
  border-radius: var(--ema-radius-sm);
  color: var(--ema-text-2);
  text-decoration: none;
  font-size: var(--ema-text-sm);
  transition: all 100ms;
}
.doc-sidebar a:hover { color: var(--ema-text); background: var(--ema-surface-3); }
.doc-sidebar a.active { color: var(--ema-primary); background: var(--ema-primary-soft); font-weight: 600; }

.doc-main {
  flex: 1;
  min-width: 0;
  padding: 2rem 3rem 5rem;
  max-width: 1060px;
}
@media (max-width: 900px) {
  .doc-sidebar { display: none; }
  .doc-main { padding: 1.25rem 1rem 4rem; }
}

/* ---------- Typography ---------- */
.doc-main h1 { font-size: 2rem; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.doc-main h2 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 3rem 0 0.75rem;
  padding-top: 0.5rem;
  scroll-margin-top: 70px;
}
.doc-main h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
.doc-main p.lead { font-size: 1.05rem; color: var(--ema-text-2); margin: 0 0 1.5rem; max-width: 640px; }
.doc-main p { color: var(--ema-text-2); line-height: 1.65; }
.doc-main code:not(pre code) {
  font-family: var(--ema-font-mono);
  font-size: 0.85em;
  background: var(--ema-surface-3);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: var(--ema-primary);
}
.doc-divider { height: 1px; background: var(--ema-border); margin: 2.5rem 0; border: none; }

/* ---------- Demo blocks ---------- */
.demo {
  background: var(--ema-surface);
  border: 1px solid var(--ema-border);
  border-radius: var(--ema-radius-lg) var(--ema-radius-lg) 0 0;
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  position: relative;
}
.demo--col { flex-direction: column; align-items: stretch; }
.demo--grid2 { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 700px) { .demo--grid2 { grid-template-columns: 1fr; } }
.demo + .demo-code-bar, .demo-code-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  background: var(--ema-surface-2);
  border: 1px solid var(--ema-border);
  border-top: none;
  border-radius: 0 0 var(--ema-radius-lg) var(--ema-radius-lg);
  padding: 0.3rem 0.5rem;
  margin-bottom: 1.25rem;
}
.demo-code-bar button {
  border: none;
  background: none;
  font: inherit;
  font-size: var(--ema-text-xs);
  font-weight: 600;
  color: var(--ema-text-3);
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  border-radius: var(--ema-radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 120ms;
}
.demo-code-bar button:hover { color: var(--ema-primary); background: var(--ema-primary-soft); }
.demo-code-bar button svg { width: 0.85rem; height: 0.85rem; }

pre.doc-code {
  background: #0f1722;
  color: #d7e3f4;
  font-family: var(--ema-font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  border-radius: var(--ema-radius-lg);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--ema-border);
  tab-size: 2;
}
[data-theme="light"] pre.doc-code, [data-theme="emerald"] pre.doc-code { border-color: transparent; }
pre.doc-code .tk-tag { color: #7fc1ff; }
pre.doc-code .tk-attr { color: #8be9b6; }
pre.doc-code .tk-str { color: #ffd587; }
pre.doc-code .tk-cmt { color: #5c7795; font-style: italic; }
pre.doc-code.collapsed { display: none; }

/* ---------- Tables (docs API tables) ---------- */
table.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ema-text-sm);
  margin: 0.75rem 0 1.5rem;
  background: var(--ema-surface);
  border: 1px solid var(--ema-border);
  border-radius: var(--ema-radius-lg);
  overflow: hidden;
}
table.doc-table th, table.doc-table td {
  text-align: left;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--ema-border);
  vertical-align: top;
}
table.doc-table th {
  background: var(--ema-surface-2);
  font-size: var(--ema-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ema-text-3);
}
table.doc-table tr:last-child td { border-bottom: none; }
table.doc-table code { white-space: nowrap; }
table.doc-table td:first-child code { color: var(--ema-primary); }

/* ---------- Token swatches ---------- */
.swatch-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.swatch {
  width: 84px;
  border-radius: var(--ema-radius-md);
  overflow: hidden;
  border: 1px solid var(--ema-border);
  font-size: 0.62rem;
  background: var(--ema-surface);
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 150ms;
}
.swatch:hover { transform: translateY(-3px); box-shadow: var(--ema-shadow-md); }
.swatch__color { height: 48px; }
.swatch__meta { padding: 0.3rem 0.4rem; color: var(--ema-text-3); font-family: var(--ema-font-mono); }
.swatch__meta b { display: block; color: var(--ema-text); font-weight: 600; }

/* ---------- Hero (index) ---------- */
.doc-hero {
  margin: 0.5rem 0 2.5rem;
  padding: 2.5rem;
  border-radius: var(--ema-radius-xl);
  background:
    radial-gradient(1000px 380px at 0% 0%, color-mix(in srgb, var(--ema-primary) 16%, transparent), transparent 60%),
    radial-gradient(800px 320px at 100% 100%, color-mix(in srgb, var(--ema-secondary) 14%, transparent), transparent 60%),
    var(--ema-surface);
  border: 1px solid var(--ema-border);
  box-shadow: var(--ema-shadow-md);
}
.doc-hero h1 { font-size: 2.4rem; margin: 0 0 0.5rem; }
.doc-hero .gradient-text {
  background: linear-gradient(90deg, var(--ema-primary), var(--ema-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.doc-hero p { max-width: 560px; font-size: 1.05rem; }
.doc-hero .ema-row { margin-top: 1.5rem; }

.doc-feature-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.5rem 0; }
@media (max-width: 800px) { .doc-feature-cards { grid-template-columns: 1fr; } }
.doc-feature {
  background: var(--ema-surface);
  border: 1px solid var(--ema-border);
  border-radius: var(--ema-radius-lg);
  padding: 1.25rem;
  transition: transform 200ms var(--ema-ease), box-shadow 200ms;
}
.doc-feature:hover { transform: translateY(-3px); box-shadow: var(--ema-shadow-lg); }
.doc-feature__icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ema-primary-soft);
  color: var(--ema-primary);
  margin-bottom: 0.7rem;
}
.doc-feature__icon svg { width: 19px; height: 19px; }
.doc-feature:nth-child(even) .doc-feature__icon { background: var(--ema-secondary-soft); color: var(--ema-secondary); }
.doc-feature h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.doc-feature p { margin: 0; font-size: var(--ema-text-sm); }

/* kbd */
kbd {
  font-family: var(--ema-font-mono);
  font-size: 0.75rem;
  background: var(--ema-surface-3);
  border: 1px solid var(--ema-border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  color: var(--ema-text);
}
