/* ==========================================================================
   terminal.css — David's persistent frame. Black-on-white, monospace,
   blinking cursor. MS-DOS *feel*, cleaner. Era skins retexture the inside.
   ========================================================================== */

.terminal {
  position: relative;
  width: min(var(--stage-max), 100%);
  max-height: min(92dvh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 24px 60px -30px rgba(0,0,0,0.5);
  overflow: hidden;
}

/* thin title strip — a colophon, not window chrome (mobile-light: no drag) */
.term-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--rule);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  user-select: none;
}
.term-bar .dot {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid var(--ink-faint);
}
.term-bar .term-era {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

/* scrolling log region */
.term-log {
  /* huge shrink factor: when space is tight the LOG collapses (it scrolls
     itself) so the game below stays fully visible */
  flex: 1 999 auto;
  min-height: 90px;
  padding: 18px clamp(14px, 4vw, 26px);
  overflow-y: auto;
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.65;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.term-log .line { white-space: pre-wrap; word-break: break-word; }
.term-log .line.david { color: var(--ink); }
.term-log .line.you {
  color: var(--ink-soft);
}
.term-log .line.you::before { content: "> "; color: var(--ink-faint); }
.term-log .line.sys {
  color: var(--ink-faint);
  font-size: 0.86em;
  letter-spacing: 0.06em;
}
.term-log .line + .line { margin-top: 0.5em; }

/* blinking cursor block */
.cursor {
  display: inline-block;
  width: 0.62ch; height: 1.06em;
  margin-left: 1px;
  translate: 0 0.16em;
  background: var(--ink);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

/* input line for banter */
.term-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--rule);
  padding: 10px clamp(14px, 4vw, 26px);
}
.term-input.hidden { display: none; }
.term-input .prompt { color: var(--ink-faint); }
.term-input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-size: clamp(13px, 3.6vw, 15px);
  caret-color: var(--ink);
  padding: 6px 0;
}
.term-input input::placeholder { color: var(--ink-faint); opacity: 0.7; }
.term-input .turns {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); opacity: 0.6;
}

/* mounting point for games / stage content inside the frame.
   NEVER clips: if the frame is at max height, the stage shrinks and scrolls. */
.term-stage {
  border-top: 1px solid var(--rule);
  padding: clamp(14px, 4vw, 22px);
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.term-stage:empty { display: none; }

/* a "David is typing" ellipsis affordance */
.typing-dots::after {
  content: "";
  animation: typing 1.1s steps(4, end) infinite;
}
@keyframes typing {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}
@media (prefers-reduced-motion: reduce) { .typing-dots::after { content: "…"; animation: none; } }
