:root {
  color-scheme: light dark;

  --bg: #fafaf9;
  --surface: #fff;
  --surface-2: #f4f4f2;
  --border: #e2e2de;
  --text: #1c1c1a;
  --muted: #62625d;
  --accent: #c2410c;
  --accent-contrast: #fff;
  --up: #15803d;
  --down: #b91c1c;
  --code-bg: #f4f4f2;
  --hl-keyword: #9a3412;
  --hl-string: #166534;
  --hl-name: #1e40af;
  --hl-attr: #6b21a8;
  --hl-comment: #78786f;
  --font-sans:
    system-ui, -apple-system, "Segoe UI", roboto, "Helvetica Neue", arial,
    sans-serif;
  --font-mono:
    ui-monospace, sfmono-regular, menlo, consolas, "Liberation Mono", monospace;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1e1e1c;
    --surface-2: #262624;
    --border: #353532;
    --text: #ececea;
    --muted: #a3a39c;
    --accent: #fb923c;
    --accent-contrast: #1c1c1a;
    --up: #4ade80;
    --down: #f87171;
    --code-bg: #1e1e1c;
    --hl-keyword: #fdba74;
    --hl-string: #86efac;
    --hl-name: #93c5fd;
    --hl-attr: #d8b4fe;
    --hl-comment: #8a8a82;
  }
}

/* Use `zoom` over `transform` since some tests depend on reading height and width */
#ember-testing {
  transform: none !important;
  zoom: 50%;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 4rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-top: 0.5rem;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
}

p {
  margin: 0 0 0.75rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}

h3 code {
  font-size: 0.95em;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
}

.brand {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.875rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

/* Page */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.page > section {
  margin-bottom: 3rem;
}

.intro {
  max-width: 44rem;
}

.lede {
  color: var(--muted);
  font-size: 1.0625rem;
  margin-top: 0.75rem;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  padding: 1.5rem;
  text-align: center;
}

/* Code */

.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  line-height: 1.6;
  margin: 0 0 1rem;
  overflow-x: auto;
  padding: 0.875rem 1rem;
}

.hljs {
  background: transparent;
  color: var(--text);
}

.hljs-keyword,
.hljs-meta {
  color: var(--hl-keyword);
}

.hljs-string,
.hljs-number,
.hljs-literal {
  color: var(--hl-string);
}

.hljs-name,
.hljs-title,
.hljs-tag {
  color: var(--hl-name);
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-params {
  color: var(--hl-attr);
}

.hljs-comment {
  color: var(--hl-comment);
  font-style: italic;
}

/* Controls */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.button {
  appearance: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent-contrast);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.875rem;
}

.button:hover {
  filter: brightness(0.95);
}

.button-quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-size: 0.8125rem;
  padding: 0.25rem 0.625rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.switch input {
  appearance: none;
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  margin: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 4px);
  height: calc(1.25rem - 4px);
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.15s;
}

.switch input:checked {
  background: var(--accent);
}

.switch input:checked::after {
  transform: translateX(1rem);
}

.mode-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.select {
  appearance: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 0.25rem 0.5rem;
}

.mode-description {
  color: var(--muted);
  font-size: 0.8125rem;
}

.button:focus-visible,
.switch input:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 6px;
  align-items: start;
}

.event-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  padding: 0.625rem 0.875rem;
}

.event-log-title {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.event-list {
  list-style: none;
  margin: 0.375rem 0 0;
  padding: 0;
}

.event-list li {
  display: flex;
  gap: 0.5rem;
  padding: 0.125rem 0;
}

.event-ids,
.event-count,
.event-empty {
  color: var(--muted);
}

.event-ids {
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.event-empty {
  margin: 0.375rem 0 0;
}

/* Example card: Preview | Code tabs sharing one area */

.example-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs [role="tab"] {
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* The preview sizes the card; the code panel fills it and scrolls. */
.example-stage {
  position: relative;
  min-height: 10rem;
}

.example-preview {
  padding: 6px;
}

.example-code {
  position: absolute;
  inset: 0;
  display: flex;
}

.example-stage > .is-hidden {
  visibility: hidden;
}

.example-card .code {
  flex: 1;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--code-bg);
  overflow: auto;
}

.example-card .code:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Responsive example */

.resize-toolbar {
  gap: 0.5rem;
  margin: 0 0 6px;
}

.column-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.resize-frame {
  margin-inline: auto;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  transition: max-width 0.2s;
}

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

/* Grid widgets */

.grid-stack-item-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  container-type: inline-size;
  transition: border-color 0.15s;
}

.grid-stack-item:hover > .grid-stack-item-content {
  border-color: var(--muted);
}

/* gridstack adds .grid-stack-dragging to the grid while a widget is dragged */
.grid-stack-dragging,
.grid-stack-dragging .grid-stack-item {
  cursor: grabbing;
}

.fill-frame {
  height: 240px;
}

.fill-grid {
  height: 100%;
}

.nested-host {
  padding-bottom: 0.25rem;
}

.nested-grid {
  background: var(--surface-2);
  border-radius: var(--radius);
  flex: 1;
}

/* Data mode example */

.data-mode,
.template-drops,
.keep-example {
  container-type: inline-size;
}

.data-mode-grids {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container (width <= 860px) {
  .data-mode-grids {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* one column: room for all three starting widgets (6 rows of 80px) so the
   trash below does not move while a widget changes grids */
@container (width < 400px) {
  .data-mode-grid {
    min-height: 480px;
  }
}

.data-mode-pane {
  margin: 0;
  min-width: 0;
}

.data-mode-pane > figcaption {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.data-mode-grid {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.data-mode-grid.ui-droppable-over,
.data-mode-grid.grid-stack-dragging {
  border-color: var(--accent);
}

.data-mode-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.toolbox {
  display: flex;
  gap: 0.5rem;
}

.toolbox > .toolbox-chip.grid-stack-item {
  position: relative;
  flex: none;
  width: auto;
  min-width: 5.5rem;
  height: auto;
  cursor: grab;
}

.toolbox > .toolbox-chip > .grid-stack-item-content {
  position: static;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  text-align: center;
  white-space: nowrap;
}

.data-mode-trash,
.template-drops-trash {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 10rem;
  height: 6rem;
  padding: 0 0.75rem;
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8125rem;
}

.data-mode-trash:hover,
.data-mode-trash.ui-droppable-over,
.template-drops-trash:hover,
.template-drops-trash.ui-droppable-over {
  border-color: var(--down);
  color: var(--down);
}

.example-lead {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 0.5rem;
}

.hook-legend {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.hook-legend code {
  font-family: var(--font-mono);
}

.hook-legend dd {
  color: var(--muted);
  margin: 0;
}

@media (width <= 640px) {
  .hook-legend {
    grid-template-columns: minmax(0, 1fr);
  }

  .hook-legend dd {
    margin-bottom: 0.25rem;
  }
}

.keep-example .toolbar {
  gap: 0.75rem;
}

.keep-created {
  color: var(--muted);
  font-size: 0.8125rem;
}

.keep-spinner {
  width: 1.5rem;
  height: 1.5rem;
  margin: auto;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: keep-spin 0.8s linear infinite;
}

@keyframes keep-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .keep-spinner {
    animation: none;
  }
}

.badge {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0 0.375rem;
}

.saved-json {
  margin: 0.75rem 0 0;
  max-height: 12rem;
}

.grid-stack-placeholder > .placeholder-content {
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  background: transparent;
}

.widget {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0.75rem 0.875rem;
}

.widget-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.widget-body {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0;
}

.widget .button {
  align-self: flex-start;
  margin-top: auto;
}

.widget-foot {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.stat-value {
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stat-delta {
  font-size: 0.8125rem;
}

.stat-delta.is-up {
  color: var(--up);
}

.stat-delta.is-down {
  color: var(--down);
}

.sparkline {
  flex: 1;
  width: 100%;
  min-height: 0;
}

.sparkline polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.bars {
  flex: 1;
  width: 100%;
  min-height: 0;
}

.bars rect {
  fill: var(--accent);
  opacity: 0.85;
}

.bars text {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 7px;
}

.list {
  list-style: none;
  margin: 0.25rem 0 0;
  overflow: auto;
  padding: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  padding: 0.4rem 0;
}

.list li:first-child {
  border-top: 0;
}

.list-main {
  min-width: 0;
  overflow-wrap: anywhere;
}

.list code {
  overflow-wrap: anywhere;
}

.list-aside {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.375rem;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  vertical-align: 0.05em;
}

.status-dot.is-degraded {
  border-color: var(--accent);
  background: var(--accent);
}

.status-note {
  color: var(--accent);
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

@container (width < 140px) {
  .widget {
    padding: 0.5rem;
  }

  .widget-label {
    font-size: 0.625rem;
  }

  .stat-value {
    font-size: 1.125rem;
  }

  .stat-delta {
    font-size: 0.6875rem;
  }
}

@container (width < 240px) {
  .list li {
    flex-direction: column;
    gap: 0;
  }
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

table {
  border-collapse: collapse;
  font-size: 0.875rem;
  width: 100%;
}

th,
td {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--surface-2);
  border-top: 0;
  font-weight: 600;
}

td:first-child {
  white-space: nowrap;
}

@media (width <= 1200px) {
  .demo-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (width <= 640px) {
  .site-header-inner {
    flex-wrap: wrap;
    padding: 0.625rem 1rem;
    gap: 0.375rem 1rem;
  }

  .site-nav {
    gap: 0.875rem;
  }

  .page {
    padding: 1.5rem 1rem 2rem;
  }

  h1 {
    font-size: 1.625rem;
  }

  td:first-child {
    white-space: normal;
  }
}
