/* The row that centers [terminal-stack, player] as a pair -- player.css
   defines #player's own share of this row. Using flex here (rather than
   position:fixed on the player) is what actually guarantees no overlap:
   the terminal shrinks to make room instead of the two fighting over the
   same fixed-viewport coordinates. */
#layout-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* nowrap is load-bearing: #terminal-stack's max-width (900) + #player's
     basis (260) + gap exceeds this row's own max-width (1200) once padding
     is subtracted, so `wrap` here silently pushed the player onto an
     invisible second line that overflowed past the row's fixed height on
     EVERY desktop viewport -- not just narrow ones. Both children can
     shrink (min-width:0 / min-width:200px), so nowrap just lets them share
     the space instead of wrapping. The mobile column-stack is handled
     explicitly by the max-width:780px query in player.css. */
  flex-wrap: nowrap;
  gap: 1.25rem;
  height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  max-width: 1560px;
  padding: 0 1.5rem;
}

/* An invisible mirror of #player's width (see player.css -- same flex
   shorthand, kept in sync deliberately) sitting on the opposite side of
   #terminal-stack. Because it's an equal-width sibling rather than a
   plain justify-content:center, #terminal-stack's flex-grow naturally
   lands it centered on the page instead of centered-within-the-pair
   (which visibly skews left once the player's width is added on the
   right only). */
#layout-spacer {
  flex: 0 1 260px;
  min-width: 200px;
}

#terminal-stack {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#terminal {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.75rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(3px) saturate(140%);
  -webkit-backdrop-filter: blur(3px) saturate(140%);
  box-shadow: 0 0 70px rgba(168, 85, 247, 0.08), 0 20px 50px rgba(0, 0, 0, 0.45);
}

#mode-toggle-btn {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

#scrollback {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  font-weight: 300;
  line-height: 1.6;
  padding-bottom: 1rem;
}

#scrollback .line {
  min-height: 1.4em;
}

#scrollback .line.logo {
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(129, 140, 248, 0.4);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* These aren't scoped to .line -- they're used both as whole-line classes
   (e.g. <div class="line sys">) and as inline span classes within a line
   built by printSegments(), for actual in-line syntax-highlighting instead
   of every line being one flat color. */
#scrollback .sys {
  color: var(--fg-dim);
}

#scrollback .accent {
  color: var(--accent);
}

#scrollback .accent2 {
  color: var(--accent-2);
}

#scrollback .warn {
  color: var(--accent-3);
}

#scrollback .prompt-user {
  color: var(--accent);
  font-weight: 400;
}

#scrollback .line.welcome {
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.55;
}

#scrollback .accent-name {
  color: var(--accent-2);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(129, 140, 248, 0.4);
}

#scrollback .line.hint {
  font-size: 1rem;
  font-weight: 400;
}

#scrollback .hint-arrow {
  color: var(--accent);
  margin-right: 0.5em;
}

#scrollback .cmd {
  color: var(--accent);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(244, 114, 182, 0.35);
}

.prompt-line {
  display: flex;
  /* Not center: the label/input's TEXT sits near the bottom of its own
     line box (close to its baseline), so a geometrically height-centered
     circle next to it reads as sitting slightly high -- flex-end lines up
     the bottom edges instead, which visually reads as "on the same line"
     the way text-baseline-aligned icons usually do. */
  align-items: flex-end;
  gap: 0.5em;
  border-top: 1px solid var(--panel-border);
  padding-top: 0.75rem;
}

/* Sized close to #cmd-input's own text line height (~20px), not the
   player card's 26-32px buttons -- at 26px the circle visibly overhung
   the text above and below despite being mathematically centered on the
   same axis, which read as misaligned rather than just bigger. */
#mic-btn {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

#mic-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

/* Steady glow for the whole hands-free session (on between turns too, not
   just while actively capturing) -- .listening layers its pulse on top
   only during an actual capture cycle, so the two together read as
   "voice mode is on" vs. "and it's listening right now." */
#mic-btn.handsfree {
  border-color: var(--accent-2);
  color: var(--accent-2);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.5);
}

#mic-btn.listening {
  border-color: var(--accent);
  color: var(--accent);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(244, 114, 182, 0);
  }
}

.prompt-label {
  color: var(--accent);
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 400;
}

#cmd-input {
  flex: 1;
  /* Flex items default to a content-based min-width, not 0 -- for a text
     input that's tied to its font-size (roughly the classic default
     size=20 intrinsic width), so bumping the font-size for the iOS
     zoom-on-focus fix below also raised this floor. Without resetting it,
     the input refused to shrink enough on narrow phones, overflowing
     .prompt-line and pushing #mic-btn (the last flex child) out past the
     terminal's edge -- confirmed live, not theoretical. */
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
  font-size: 0.92rem;
  caret-color: var(--accent);
}

#cmd-input:disabled {
  opacity: 0.5;
}

@media (max-width: 780px) {
  #terminal {
    padding: 1.15rem 1.25rem;
  }

  /* iOS Safari auto-zooms the whole page on focus for any input under
     16px, which is what was causing the view to jump/refocus every time
     the terminal input got focus (including programmatically, e.g. from
     voice mode) -- 16px is the documented threshold that avoids it. */
  #cmd-input {
    font-size: 16px;
  }

  #scrollback {
    font-size: 0.85rem;
  }

  #scrollback .line.logo {
    font-size: 0.6rem;
  }

  #scrollback .line.welcome {
    font-size: 1rem;
  }
}

@media (max-width: 420px) {
  /* "guest@hypernaut:~$" is long enough that at full size on a narrow
     phone it crowds the input down to a sliver -- shrinking the label
     (not the input) keeps typing comfortable. */
  .prompt-label {
    font-size: 0.72rem;
  }

  /* Stays at 16px here too (not shrinking further like the label does) --
     see the 780px query above for why. */
  #cmd-input {
    font-size: 16px;
  }

  #scrollback .line.logo {
    font-size: 0.5rem;
  }
}
