/* Groundhog Interactive Ghostty CLI Demos
   Consumes Catppuccin Mocha design tokens from docs/style.css.
   Editorial hard-line aesthetic: 1px hairlines, zero neon glow, zero mobile overflow. */

.demo-shell {
  --mocha-blue: #89b4fa;
  --mocha-sky: #89dceb;
  --mocha-mauve: #cba6f7;
  --mocha-yellow: #f9e2af;
  --mocha-red: #f38ba8;

  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  max-width: 100%;
}

.demo-shell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Ghostty Titlebar Chrome (minimal, authentic, zero clutter) ─────────── */
.demo-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.3;
}

.demo-chrome-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.demo-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  flex-shrink: 0;
}

.demo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface1);
  border: 1px solid rgba(205, 214, 244, 0.14);
}

.demo-title {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-title strong {
  color: var(--subtext1);
  font-weight: 600;
}

.demo-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.demo-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.demo-shell[data-state='paused'] .demo-status-dot {
  background: var(--peach);
}

.demo-shell[data-state='done'] .demo-status-dot {
  background: var(--green);
}

.demo-step-counter {
  color: var(--subtext1);
  font-variant-numeric: tabular-nums;
}

/* ── Crisp 2px Progress Hairline ────────────────────────────────────────── */
.demo-progress-track {
  height: 2px;
  width: 100%;
  background: var(--surface-2);
  overflow: hidden;
}

.demo-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.22s ease;
}

.demo-shell[data-state='done'] .demo-progress-fill {
  background: var(--green);
}

.demo-shell[data-instant='true'] .demo-progress-fill {
  transition: none;
}

/* ── Scene Tabs Bar ─────────────────────────────────────────────────────── */
.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.58rem 0.85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem;
  min-width: 0;
}

.demo-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.32rem 0.52rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.demo-tab:hover {
  color: var(--text);
  background: rgba(205, 214, 244, 0.04);
}

.demo-tab.active {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--hairline-strong);
}

.demo-tab:focus-visible,
.demo-ctrl:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Playback Controls ──────────────────────────────────────────────────── */
.demo-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.demo-ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.34rem 0.66rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.demo-ctrl:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.demo-ctrl[aria-pressed='true'],
.demo-ctrl.is-active {
  border-color: var(--hairline-strong);
  color: var(--accent);
  background: rgba(148, 226, 213, 0.08);
}

.demo-ctrl:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* ── Terminal Output Viewport ───────────────────────────────────────────── */
.demo-body {
  padding: 1.15rem 1.25rem;
  min-height: 340px;
  max-height: 440px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.62;
  background: var(--bg);
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: var(--surface1) var(--bg);
}

.t-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-bottom: 0.24rem;
}

.t-line:last-child {
  margin-bottom: 0;
}

.t-line-cmd {
  margin-top: 0.38rem;
}

.t-line-cmd:first-child {
  margin-top: 0;
}

.t-prompt {
  color: var(--accent);
  font-weight: 600;
}

.t-cmd {
  color: var(--text);
}

/* Nushell / Ghostty syntax highlighting (Catppuccin Mocha, WCAG AA) */
.tok-bin {
  color: var(--mocha-blue);
  font-weight: 600;
}

.tok-sub {
  color: var(--mocha-sky);
}

.tok-flag {
  color: var(--peach);
}

.tok-str {
  color: var(--green);
}

.tok-path {
  color: var(--mocha-yellow);
}

.tok-op {
  color: var(--mocha-mauve);
  font-weight: 600;
}

.tok-arg {
  color: var(--text);
}

/* Output line semantic classes */
.t-muted {
  color: var(--muted);
}

.t-info {
  color: var(--subtext1);
}

.t-teal {
  color: var(--accent);
}

.t-ok {
  color: var(--green);
}

.t-peach {
  color: var(--peach);
}

.t-warn {
  color: var(--mocha-yellow);
}

.t-spinner-glyph {
  color: var(--accent);
  display: inline-block;
  width: 1.35ch;
  font-weight: 600;
}

.t-badge-ok {
  color: var(--green);
  font-weight: 700;
}

.t-badge-teal {
  color: var(--accent);
  font-weight: 700;
}

.t-meter {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Realistic blinking Ghostty block cursor */
.t-cursor {
  display: inline-block;
  width: 0.56em;
  height: 1.08em;
  background: var(--accent);
  vertical-align: -0.14em;
  margin-left: 2px;
  animation: demo-cursor-blink 1.05s steps(1) infinite;
}

.t-cursor.is-typing {
  animation: none;
  opacity: 1;
}

@keyframes demo-cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Footer Bar ─────────────────────────────────────────────────────────── */
.demo-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.72rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.demo-footer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  min-width: 0;
}

.demo-hint {
  color: var(--subtext1);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.demo-kbd-hint {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.demo-footer .copy-btn {
  font-size: 0.8125rem;
  padding: 0.34rem 0.72rem;
}

/* ── Responsive Layout (Zero Overflow on 390x844 Mobile) ────────────────── */
@media (max-width: 720px) {
  .demo-chrome {
    padding: 0.55rem 0.75rem;
  }

  .demo-title-detail {
    display: none;
  }

  .demo-bar {
    padding: 0.6rem 0.75rem;
    gap: 0.6rem;
  }

  .demo-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
  }

  .demo-tab {
    text-align: left;
    padding: 0.38rem 0.42rem;
    letter-spacing: -0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .demo-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .demo-ctrl {
    flex: 1 1 auto;
    padding: 0.4rem 0.55rem;
  }

  .demo-body {
    padding: 0.9rem 0.85rem;
    min-height: 300px;
    max-height: 390px;
    font-size: 0.8125rem;
    line-height: 1.56;
  }

  .demo-footer {
    padding: 0.65rem 0.75rem;
  }

  .demo-kbd-hint {
    display: none;
  }
}

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

  .demo-progress-fill {
    transition: none;
  }
}
