/* ───────────────────────────────────────────────────────
   kariochi · components-compositions.css
   Real-world component arrangements, micro-interactions,
   command palette, and gallery-specific UI controls.
   Extracted from components.css (split 2026-05-30).
   ─────────────────────────────────────────────────────── */

/* ═════════════════════════════════════════════════════════════════
   STAT / KPI CARD
   ═════════════════════════════════════════════════════════════════ */

.stat-card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  min-width: 180px;
}
.stat-card .stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-tertiary);
}
.stat-card .stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.025em;
  color: var(--fg-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.stat-card .stat-value .unit {
  font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--fg-tertiary); letter-spacing: normal;
}
.stat-card .stat-foot {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--fg-tertiary);
}
.stat-card .stat-delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.stat-card .stat-delta.up   { color: var(--status-success-fg); background: var(--status-success-bg); }
.stat-card .stat-delta.down { color: var(--status-error-fg);   background: var(--status-error-bg); }
.stat-card .stat-delta.flat { color: var(--fg-tertiary);       background: var(--bg-subtle); }
.stat-card .stat-delta svg { width: 11px; height: 11px; }

/* Sparkline trace */
.spark {
  width: 100%; height: 36px;
  display: block;
}
.spark path { fill: none; stroke: var(--brand-primary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: var(--bg-brand-soft); stroke: none; }

/* ═════════════════════════════════════════════════════════════════
   INLINE-EDITABLE TEXT
   ═════════════════════════════════════════════════════════════════ */

.editable {
  display: inline-block;
  padding: 3px 8px; margin: -3px -8px;
  border-radius: var(--radius-sm);
  cursor: text;
  outline: 0;
  transition: background var(--duration-fast), box-shadow var(--duration-fast);
  border: 0;
  background: transparent;
  color: inherit; font: inherit;
}
.editable:hover { background: var(--bg-hover); }
.editable:focus,
.editable.is-editing {
  background: var(--bg-surface);
  box-shadow: inset 0 0 0 1.5px var(--brand-primary), 0 0 0 3px rgba(26,158,110,0.15);
}
.editable-row {
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.editable-row .pencil {
  width: 14px; height: 14px;
  color: var(--fg-tertiary);
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.editable-row:hover .pencil { opacity: 1; }

/* ═════════════════════════════════════════════════════════════════
   COMPOSITIONS — real-world arrangements
   ═════════════════════════════════════════════════════════════════ */

/* Track-card composition with cover, badge, controls overlay */
.comp-track-card {
  display: flex; flex-direction: column;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: background var(--duration-fast), border-color var(--duration-fast);
  cursor: pointer;
}
.comp-track-card:hover { border-color: var(--border-default); }
.comp-track-card .cover {
  position: relative; aspect-ratio: 1/1;
  background: linear-gradient(135deg, #2db485 0%, #14704e 100%);
  display: grid; place-items: center;
  color: rgba(255,255,255,0.85);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.04em;
}
.comp-track-card .cover-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 50%);
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: var(--space-3);
}
.comp-track-card .cover-overlay .stats {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.9);
}
.comp-track-card .cover-overlay .stats svg { width: 11px; height: 11px; opacity: 0.85; }
.comp-track-card .cover-overlay .stats .stat {
  display: inline-flex; align-items: center; gap: 3px;
  font-variant-numeric: tabular-nums;
}
.comp-track-card .cover .play-fab {
  position: absolute; bottom: var(--space-3); right: var(--space-3);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              background var(--duration-fast);
}
.comp-track-card:hover .cover .play-fab,
.comp-track-card .cover .play-fab.is-on { opacity: 1; transform: translateY(0); }
.comp-track-card .cover .play-fab:hover { background: var(--brand-primary-hover); }
.comp-track-card .cover .play-fab svg { width: 14px; height: 14px; }

.comp-track-card .meta {
  padding: var(--space-3) var(--space-4) var(--space-4);
  display: flex; flex-direction: column; gap: 4px;
}
.comp-track-card .meta .title-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
}
.comp-track-card .meta .title {
  font-size: var(--text-base); font-weight: var(--weight-semibold);
  color: var(--fg-primary); letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.comp-track-card .meta .sub {
  font-size: var(--text-sm); color: var(--fg-tertiary);
  display: flex; align-items: center; gap: 6px;
}
.comp-track-card .meta .sub .sep {
  width: 2px; height: 2px; border-radius: 50%; background: var(--border-strong);
}

/* In-app shell preview — a fake browser frame */
.shell-preview {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}
.shell-preview .shell-bar {
  display: flex; align-items: center; gap: var(--space-2);
  height: 30px; padding: 0 var(--space-3);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.shell-preview .shell-bar .traffic {
  display: inline-flex; gap: 6px;
}
.shell-preview .shell-bar .traffic span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-strong); opacity: 0.6;
}
.shell-preview .shell-bar .addr {
  margin-left: var(--space-3);
  font-size: var(--text-xs); color: var(--fg-tertiary);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.shell-preview .shell-body {
  display: grid; grid-template-columns: 200px 1fr;
  min-height: 240px;
}
.shell-preview .shell-side {
  background: var(--bg-app);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-3);
  display: flex; flex-direction: column; gap: 2px;
}
.shell-preview .shell-side .sb-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px;
  font-size: var(--text-sm); color: var(--fg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.shell-preview .shell-side .sb-item.is-on {
  background: var(--bg-brand-soft); color: var(--fg-brand); font-weight: var(--weight-semibold);
}
.shell-preview .shell-side .sb-item svg { width: 13px; height: 13px; }
.shell-preview .shell-side .sb-label {
  font-size: 9px; font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--fg-tertiary);
  padding: var(--space-3) var(--space-2) 4px;
}
.shell-preview .shell-content {
  padding: var(--space-5) var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.shell-preview .shell-content h4 {
  font-size: var(--text-lg); font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}
.shell-preview .shell-content .row-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3);
}

/* ═════════════════════════════════════════════════════════════════
   POLISH — micro-interactions, rhythm refinements
   ═════════════════════════════════════════════════════════════════ */

/* Tabs — animated active indicator transition */
.tabs .tab::after { transition: opacity var(--duration-fast); }

/* TOC — scroll-spy active item */
.toc-item.is-active {
  color: var(--fg-primary);
  background: var(--bg-brand-soft);
  font-weight: var(--weight-semibold);
}
.toc-item.is-active .dot { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════
   COMMAND PALETTE (⌘+K)
   ══════════════════════════════════════════════════════════════════ */

.cmd-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 20, 17, 0.4);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.cmd-overlay.is-on { display: flex; animation: fade-in var(--duration-base) var(--ease-out); }
.cmd-palette {
  width: 100%; max-width: 520px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: scale-in var(--duration-base) var(--ease-out);
}
.cmd-input-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}
.cmd-input-row svg { width: 18px; height: 18px; color: var(--fg-tertiary); flex-shrink: 0; }
.cmd-input-row input {
  border: 0; outline: 0; background: transparent;
  width: 100%;
  font-size: var(--text-md);
  color: var(--fg-primary);
}
.cmd-input-row input::placeholder { color: var(--fg-tertiary); }
.cmd-list {
  padding: var(--space-2);
  max-height: 50vh; overflow-y: auto;
}
.cmd-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  cursor: pointer;
  color: var(--fg-primary);
}
.cmd-item .num {
  font-size: var(--text-xs); color: var(--fg-tertiary);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  background: var(--bg-subtle);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  min-width: 28px; text-align: center;
}
.cmd-item.is-active { background: var(--bg-brand-soft); color: var(--fg-brand); }
.cmd-item.is-active .num { background: var(--bg-surface); color: var(--fg-brand); }
.cmd-empty {
  padding: var(--space-4);
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}
.cmd-foot {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-app);
  font-size: var(--text-xs); color: var(--fg-tertiary);
}
.cmd-foot .item { display: inline-flex; align-items: center; gap: 5px; }

/* Buttons — refined active feel */
.btn:active:not(:disabled) { transition-duration: 60ms; }

/* Card — subtle gradient for emphasis cards */
.card.is-emphasized {
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-app) 100%);
}

/* Page-level breathing room */
.section + .section { margin-top: var(--space-12); }

/* density toggle UI control (override variables live in tokens.css) */

.density-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  margin-top: var(--space-5);
}
.density-toggle button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--fg-secondary);
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.density-toggle button.is-on {
  background: var(--bg-surface);
  color: var(--fg-primary);
  box-shadow: var(--shadow-sm);
}
.density-toggle button svg { width: 11px; height: 11px; }
