/* ============================================================
   style.css — Layout, Terminal Window, Drag Chrome
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-page:       #0d1117;
  --bg-window:     #161b22;
  --bg-titlebar:   #1f2428;
  --bg-hover:      #1c2128;

  --text-primary:  #c9d1d9;
  --text-muted:    #6e7681;
  --text-dim:      #484f58;

  --color-blue:    #58a6ff;
  --color-green:   #7ee787;
  --color-orange:  #f0883e;
  --color-red:     #ff7b72;
  --color-purple:  #d2a8ff;

  --dot-red:       #ff5f56;
  --dot-yellow:    #ffbd2e;
  --dot-green:     #27c93f;

  --border-color:  #30363d;
  --shadow:        0 16px 64px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4);

  --radius:        8px;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-size:     14px;
  --line-height:   1.6;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Subtle grid dot pattern */
  background-image: radial-gradient(circle, #21262d 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── Backdrop glow ────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 50%, rgba(88, 166, 255, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Terminal Window ──────────────────────────────────────── */
.terminal-window {
  position: relative;
  z-index: 10;
  width: min(90vw, 860px);
  max-height: min(85vh, 680px);
  background-color: var(--bg-window);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Smooth repositioning during snap-to-center */
  transition: box-shadow 0.15s ease;

  /* Allow JS to reposition via transform */
  will-change: transform;
  user-select: none; /* prevent text selection while dragging */
}

.terminal-window:focus-within {
  box-shadow: var(--shadow), 0 0 0 1px rgba(88, 166, 255, 0.25);
}

/* ── Titlebar ─────────────────────────────────────────────── */
.titlebar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: var(--bg-titlebar);
  border-bottom: 1px solid var(--border-color);
  cursor: grab;
  border-radius: var(--radius) var(--radius) 0 0;
  -webkit-app-region: drag; /* macOS feel */
}

.titlebar:active {
  cursor: grabbing;
}

/* Traffic-light dots */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-red    { background-color: var(--dot-red); }
.dot-yellow { background-color: var(--dot-yellow); }
.dot-green  { background-color: var(--dot-green); }

.titlebar-label {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ── Terminal Body ────────────────────────────────────────── */
.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px 12px;
  gap: 0;
}

/* Scrollable output */
.output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  /* Allow text selection in output */
  user-select: text;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.output::-webkit-scrollbar {
  width: 5px;
}

.output::-webkit-scrollbar-track {
  background: transparent;
}

.output::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

/* ── Output line hover ────────────────────────────────────── */
.output-line {
  padding: 1px 6px;
  border-radius: 3px;
  border-left: 2px solid transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
  word-break: break-word;
}

.output-line:hover {
  background-color: var(--bg-hover);
  border-left-color: var(--color-blue);
}

/* ── Input Row ────────────────────────────────────────────── */
.input-row {
  display: flex;
  align-items: center;
  padding-top: 4px;
  flex-shrink: 0;
  /* Allow text selection in input */
  user-select: text;
}

/* ── Autocomplete list ────────────────────────────────────── */
.autocomplete-list {
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* hidden attribute → native display:none; this reinforces it */
.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-item {
  color: var(--color-green);
}

.autocomplete-item.current {
  color: var(--bg-page);
  background-color: var(--color-blue);
  border-radius: 2px;
  padding: 0 4px;
}

/* ── Dragging state ───────────────────────────────────────── */
.terminal-window.dragging {
  box-shadow: var(--shadow), 0 0 0 1px rgba(88, 166, 255, 0.4);
  transition: none; /* no transition while dragging */
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .terminal-window {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    position: fixed;
    top: 0;
    left: 0;
    transform: none !important; /* disable drag on mobile */
  }

  .titlebar {
    cursor: default;
    border-radius: 0;
  }
}
