/* terminal.css — DavidGPT chatbox TUI (assets/davidgpt-terminal.js).
 * Monospace, terminal-styled chat with labeled you / davidgpt message boxes.
 * Shared by the home hero (expand mode) and the About-page "Ask David" app
 * (inline mode: .dgpt-term--inline, always-open inside a macOS window).
 */
.dgpt-term {
  --term-bg: rgba(8, 11, 17, 0.82);
  --term-fg: #d2ddec;
  --term-dim: #6b7c93;
  --term-accent: #5ab0ff;
  --term-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  position: relative;
  font-family: var(--term-mono);
}

/* ---- collapsed input line (home: floating pill) ---- */
.dgpt-term__prompt {
  display: flex; align-items: center; gap: 9px;
  margin: 0; padding: 12px 14px; border-radius: 14px;
  background: var(--term-bg);
  -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 22px rgba(0, 0, 0, 0.45);
  cursor: text;
  transition: border-radius 0.25s ease, border-color 0.2s ease;
}
.dgpt-term.open .dgpt-term__prompt { border-top-left-radius: 0; border-top-right-radius: 0; border-top-color: transparent; }
.dgpt-term__ps1 { color: var(--term-accent); font-size: 13px; white-space: nowrap; font-weight: 600; }
.dgpt-term__input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--term-fg); font-family: var(--term-mono); font-size: 12.5px;
  caret-color: var(--term-accent);
}
.dgpt-term__input::placeholder { color: var(--term-dim); }

/* ---- expanding chat window (home only) ---- */
.dgpt-term__window {
  position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: -1px;
  display: flex; flex-direction: column;
  height: clamp(300px, 56vh, 540px); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12); border-bottom: none;
  border-radius: 14px 14px 0 0;
  background: var(--term-bg);
  -webkit-backdrop-filter: blur(22px) saturate(150%); backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}
.dgpt-term.open .dgpt-term__window { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 767px) {
  /* open chat = a bottom sheet: header + scrollable transcript + input, all connected
     (the input was previously stranded behind the floating window — unreachable) */
  .dgpt-term.open {
    position: fixed; left: 8px; right: 8px; top: 78px; bottom: 8px; z-index: 60;
    display: flex; flex-direction: column;
  }
  .dgpt-term.open .dgpt-term__window {
    position: static; flex: 1 1 auto; height: auto; min-height: 0; margin-bottom: 0;
    border-radius: 14px 14px 0 0; border-bottom: none;
  }
  .dgpt-term.open .dgpt-term__prompt {
    flex: 0 0 auto; border-radius: 0 0 14px 14px; border-top-color: transparent;
  }
}

/* ---- header (home: no traffic lights, just a labelled bar) ---- */
.dgpt-term__titlebar {
  display: flex; align-items: center; gap: 9px; flex: 0 0 auto;
  padding: 9px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
}
.dgpt-term__title { color: var(--term-fg); font-size: 12px; font-weight: 600; letter-spacing: 0.01em; }
.dgpt-term__status { display: flex; align-items: center; gap: 5px; color: var(--term-dim); font-size: 10.5px; }
.dgpt-term__status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #28c840; box-shadow: 0 0 6px rgba(40, 200, 64, 0.7); }
.dgpt-term__clear {
  margin-left: auto; width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--term-dim); font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.dgpt-term__clear:hover { background: rgba(255, 255, 255, 0.14); color: var(--term-fg); }

/* ---- chat transcript ---- */
.dgpt-term__out {
  flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px;
  font-size: 12.5px; line-height: 1.5; color: var(--term-fg); scrollbar-width: thin;
  text-shadow: 0 0 1px rgba(140, 190, 255, 0.18);
}
.dgpt-term__out::-webkit-scrollbar { width: 6px; }
.dgpt-term__out::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }

/* ---- ASCII portrait of Didi (assets/didi.png), shown above the intro line ---- */
.dgpt-scene { align-self: stretch; margin: 2px 0 8px; text-align: center; }
.dgpt-ascii-img {
  display: block; margin: 0 0 9px; width: auto; max-width: 100%;
  height: clamp(130px, 21vh, 220px); object-fit: contain;
  -webkit-user-select: none; user-select: none; pointer-events: none;
}

/* ---- TUI message boxes (you / davidgpt) ---- */
.dgpt-msg { display: flex; flex-direction: column; gap: 3px; max-width: 90%; }
.dgpt-msg--ai { align-self: flex-start; }
.dgpt-msg--you { align-self: flex-end; }
.dgpt-msg__head {
  display: flex; align-items: center; gap: 5px; padding: 0 3px;
  font-size: 10px; letter-spacing: 0.06em;
}
.dgpt-msg--ai .dgpt-msg__head { color: var(--term-accent); }
.dgpt-msg--ai .dgpt-msg__head::before { content: "\25CF"; font-size: 7px; }
.dgpt-msg--you .dgpt-msg__head { color: var(--term-dim); align-self: flex-end; }
.dgpt-msg--you .dgpt-msg__head::after { content: "\276F"; }
.dgpt-msg__text {
  border: 1px solid rgba(120, 180, 255, 0.22); border-radius: 3px; padding: 8px 11px;
  background: rgba(255, 255, 255, 0.025); white-space: pre-wrap; word-break: break-word;
}
.dgpt-msg--ai .dgpt-msg__text { border-color: rgba(90, 176, 255, 0.30); background: rgba(90, 176, 255, 0.06); }
.dgpt-msg__text--thinking { display: flex; align-items: center; gap: 8px; color: var(--term-dim); }
.dgpt-msg__text svg { display: none; }  /* inline icons read as clutter in a terminal */
.dgpt-msg__text strong { color: #fff; font-weight: 600; }
.dgpt-msg__text em { color: #bcd6ff; font-style: normal; }
.dgpt-msg__text a, .dgpt-link { color: var(--term-accent); text-decoration: underline; text-underline-offset: 2px; pointer-events: auto; }
.dgpt-link { display: inline-block; margin-top: 7px; font-weight: 600; }
.dgpt-openbtn {
  display: flex; width: fit-content; align-items: center; gap: 7px; margin-top: 10px;
  font-family: var(--term-mono); font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--term-accent); background: rgba(90, 176, 255, 0.12);
  border: 1px solid rgba(90, 176, 255, 0.5); border-radius: 3px; padding: 6px 13px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dgpt-msg__text a.dgpt-openbtn { text-decoration: none; }
.dgpt-openbtn:hover { background: rgba(90, 176, 255, 0.22); border-color: rgba(90, 176, 255, 0.75); }
.dgpt-openbtn__ar { font-size: 13px; }
.dgpt-cook-spin { color: var(--term-accent); display: inline-block; width: 1ch; text-align: center; text-shadow: 0 0 6px rgba(90, 176, 255, 0.5); }
.dgpt-spinner { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(90, 176, 255, 0.3); border-top-color: var(--term-accent); animation: dgpt-spin 0.8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .dgpt-spinner { animation: none; } }
@keyframes dgpt-spin { to { transform: rotate(360deg); } }
.dgpt-fig { margin: 8px 0 0; }
.dgpt-fig__img { max-width: 100%; max-height: clamp(120px, 22vh, 190px); border-radius: 3px; border: 1px solid rgba(255, 255, 255, 0.12); display: block; }

/* ---- suggestion chips (TUI option list) ---- */
.dgpt-suggest { display: flex; flex-direction: column; gap: 2px; align-self: stretch; }
.dgpt-suggest__item {
  text-align: left; background: transparent; border: none; cursor: pointer; width: 100%;
  color: var(--term-accent); font-family: var(--term-mono); font-size: 12px; padding: 3px 5px; border-radius: 6px;
  display: flex; gap: 7px; align-items: baseline; transition: background 0.15s ease;
}
.dgpt-suggest__item:hover { background: rgba(90, 176, 255, 0.1); }
.dgpt-suggest__arrow { color: var(--term-dim); }

/* ===== inline mode (About-page "Ask David" app: always-open in a macOS window) ===== */
.dgpt-term--inline { display: flex; flex-direction: column; min-height: 0; }
.dgpt-term--inline .dgpt-term__out { flex: 1 1 auto; min-height: 0; }
.dgpt-term--inline .dgpt-term__prompt {
  flex: 0 0 auto; border-radius: 0; border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none;
  padding: 12px 16px;
}

/* ---- CRT scanlines + terminal texture over the chat window ---- */
.dgpt-term__window::after, .dgpt-term--inline::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 6; border-radius: inherit;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.13) 0, rgba(0, 0, 0, 0.13) 1px, transparent 1px, transparent 3px);
}
.dgpt-term__out, .dgpt-term--inline .dgpt-term__out { position: relative; z-index: 1; }

/* ---- in-chat globe (travel / location answers) ---- */
.dgpt-globe { margin-top: 10px; }
.dgpt-globe__holder { width: min(280px, 100%); min-height: 180px; margin: 0 auto; }
.dgpt-globe__holder canvas { display: block; border-radius: 4px; }
.dgpt-globe__cap { margin-top: 5px; font-size: 11px; color: var(--term-dim); text-align: center; }
.globe-fallback { font-size: 56px; text-align: center; padding: 40px 0; }
