/* =========================================================================
   GianOS — Terminal app styles
   Committed dark in-fiction palette (this app only; not global dark mode).
   Deep phosphor terminal aesthetic: green/amber on near-black, Geist Mono.
   All colors OKLCH only. Scoped under .app-screen[data-app=terminal] and
   body[data-app=terminal] overrides for statusbar + app-head.

   Contrast: --term-text on --term-bg ≥ 4.5:1 (verified: ~7.8:1 at these
   oklch values). --term-amber on --term-bg ≥ 4.5:1 (~5.1:1).

   These tokens are fixed — they do not follow --seed (Terminal's art direction
   is deliberately immune to the theme toy, per plan).
   ========================================================================= */

/* ---- dark statusbar override when Terminal is the active app ------------ */
body[data-app="terminal"] {
  --statusbar-ink: oklch(0.88 0.08 150);   /* phosphor green, light enough to read */
  --statusbar-bg:  oklch(0.14 0.02 150 / 0.92);
}

/* ---- app-head dark variant -------------------------------------------- */
/* iOS: translucent dark glass. Android: dark tonal surface.
   Both override the shared .app-head which inherits the warm-paper theme. */
.app-screen[data-app="terminal"] .app-head {
  background: oklch(0.16 0.025 150 / 0.96);
  border-bottom-color: oklch(0.30 0.06 150 / 0.4);
  backdrop-filter: blur(16px) saturate(1.2);
  color: oklch(0.85 0.08 150);
}
.app-screen[data-app="terminal"] .app-head__back {
  color: oklch(0.70 0.12 150);
}
.app-screen[data-app="terminal"] .app-head__back:hover {
  color: oklch(0.88 0.10 150);
}
.app-screen[data-app="terminal"] .app-head__title {
  color: oklch(0.88 0.08 150);
}

/* Android tonal variant */
body[data-os="android"] .app-screen[data-app="terminal"] .app-head {
  background: oklch(0.18 0.025 150 / 0.98);
  border-bottom-color: oklch(0.28 0.06 150 / 0.5);
}

/* ---- Terminal screen surface ------------------------------------------ */
.app-screen[data-app="terminal"] {
  /* scoped token palette — immune to --seed */
  --term-bg:        oklch(0.18 0.02 150);   /* deep green-black */
  --term-surface:   oklch(0.22 0.025 150);  /* slightly lighter for UI elements */
  --term-text:      oklch(0.82 0.10 150);   /* phosphor green — main text */
  --term-text-dim:  oklch(0.60 0.07 150);   /* dimmer for secondary info */
  --term-amber:     oklch(0.78 0.14 85);    /* amber for emphasis / dirs */
  --term-prompt:    oklch(0.72 0.12 150);   /* prompt prefix */
  --term-line:      oklch(0.28 0.04 150 / 0.6);
  --term-chip-bg:   oklch(0.24 0.03 150);
  --term-chip-border: oklch(0.38 0.07 150 / 0.7);
  --term-selection: oklch(0.40 0.09 150 / 0.5);
}

.app-screen[data-app="terminal"] .app-body {
  background: var(--term-bg);
  color: var(--term-text);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
}

/* selection */
.app-screen[data-app="terminal"] ::selection {
  background: var(--term-selection);
  color: var(--term-text);
}

/* ---- scrollback log ---------------------------------------------------- */
.term-scrollback {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  font-size: 0.84rem;
  line-height: 1.6;
  /* smooth scroll unless reduced motion */
  scroll-behavior: smooth;
  /* extra bottom padding so last line never hides behind prompt bar */
  padding-bottom: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .term-scrollback { scroll-behavior: auto; }
}

/* ---- output lines ------------------------------------------------------ */
.term-line {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  color: var(--term-text);
  min-height: 1.1em;   /* blank lines have height */
}

/* dimmed decorative lines (e.g. separators, hints) */
.term-line--dim { color: var(--term-text-dim); }

/* amber tinted lines: directories, emphasis */
.term-line--amber { color: var(--term-amber); }

/* error / not-found lines */
.term-line--err { color: oklch(0.72 0.18 30); }

/* command echo (what the user "typed") */
.term-line--cmd {
  color: var(--term-prompt);
  font-weight: 500;
}

/* key: value alignment helper — spans inside .term-line */
.term-kv {
  display: inline-grid;
  grid-template-columns: 10ch 1fr;
  gap: 0 0.5ch;
  width: 100%;
}
.term-kv__k { color: var(--term-amber); }
.term-kv__v { color: var(--term-text); }

/* spacer between command blocks */
.term-spacer { display: block; height: 0.6em; }

/* ---- prompt row -------------------------------------------------------- */
.term-prompt-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.55rem 1rem 0.5rem;
  border-top: 1px solid var(--term-line);
  background: var(--term-bg);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  /* sticky bottom; safe-area respected */
  padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
}

.term-prompt-prefix {
  color: var(--term-prompt);
  white-space: nowrap;
  flex: 0 0 auto;
  margin-right: 0.5ch;
  user-select: none;
}

.term-input-buffer {
  flex: 1 1 auto;
  color: var(--term-text);
  font-family: inherit;
  font-size: inherit;
  white-space: pre;
  letter-spacing: inherit;
  min-width: 0;
  /* not a real input; just a display span */
}

/* blinking block cursor — reuses the stream-cursor concept */
.term-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--term-text);
  margin-left: 0.05em;
  animation: term-blink 1.1s step-start infinite;
}

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

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

/* ---- suggested command chips ------------------------------------------- */
.term-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.5rem;
  /* extra bottom room so chips clear the navind home bar (z40) that floats
     over the device bottom edge, plus the iOS/Android safe-area inset.
     Mirrors the same calc used by the Messages composer. */
  padding: 0.5rem 1rem calc(1.5rem + max(0.3rem, env(safe-area-inset-bottom)));
  border-top: 1px solid var(--term-line);
  background: var(--term-surface);
  /* hide scrollbar but keep scrollable */
  scrollbar-width: none;
}
.term-chips::-webkit-scrollbar { display: none; }

.term-chip {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--term-text);
  background: var(--term-chip-bg);
  border: 1px solid var(--term-chip-border);
  border-radius: 0.35rem;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
              border-color 0.18s var(--ease), transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.term-chip:hover {
  background: oklch(0.28 0.05 150);
  border-color: oklch(0.50 0.10 150 / 0.8);
  color: oklch(0.90 0.10 150);
}
.term-chip:active { transform: scale(0.96); }
.term-chip:focus-visible {
  outline: 2px solid var(--term-amber);
  outline-offset: 2px;
}

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

/* ---- app-head typing indicator (optional) ------------------------------ */
/* reuse the existing .stream-cursor CSS pattern; no new keyframe needed */
