/**
 * Copyright 2026 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* ===================================================================
   LLM TERMINAL — the reading drawer docked at the bottom of the
   interactive tour shell (llm-shell.css).

   The bar is terminal chrome in both colour schemes; the body keeps the
   page's own scheme so tables, admonitions, code and math render with
   the regular content styles. Height is the shell's --llm-terminal-h.
   =================================================================== */

.llm-terminal {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  height: var(--llm-terminal-h);
  overflow: hidden;
  border-top: 1px solid color-mix(in srgb, var(--gemma-white) 12%, transparent);
  background: var(--gemma-surface);
  box-shadow: 0 -10px 36px color-mix(in srgb, var(--gemma-ink) 18%, transparent);
  transition: height 260ms var(--gemma-ease);
}

body[data-md-color-scheme="slate"] .llm-terminal { box-shadow: 0 -10px 36px color-mix(in srgb, var(--gemma-home-bg-deep) 70%, transparent); }

/* Drag edge, only while open. */
.llm-terminal__handle { position: absolute; z-index: 2; top: -0.3rem; right: 0; left: 0; height: 0.75rem; cursor: ns-resize; }
.llm-shell:not(.is-terminal-open) .llm-terminal__handle { display: none; }

/* -------------------------------------------------------------------
   Title bar
   ------------------------------------------------------------------- */
.llm-terminal__bar {
  display: flex;
  flex: 0 0 var(--llm-terminal-bar-h);
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: 0 0.6rem 0 1rem;
  background: var(--gemma-ink);
  color: var(--gemma-n200);
  font-family: var(--md-code-font-family, monospace);
  font-size: 0.74rem;
  cursor: pointer;
  user-select: none;
}

body[data-md-color-scheme="slate"] .llm-terminal__bar { background: var(--gemma-surface-sunken); border-bottom: 1px solid var(--gemma-border); }
.llm-terminal__dots { display: inline-flex; flex-shrink: 0; gap: 0.35rem; }
.llm-terminal__dots i { width: 0.62rem; height: 0.62rem; border-radius: 50%; background: var(--gemma-status-danger); opacity: 0.9; }
.llm-terminal__dots i:nth-child(2) { background: var(--gemma-status-warning); }
.llm-terminal__dots i:nth-child(3) { background: var(--gemma-status-success); }
.llm-terminal__path { flex-shrink: 0; font-weight: 600; color: var(--gemma-blue-300); }
.llm-terminal__cmd { min-width: 0; overflow: hidden; color: var(--gemma-n50); text-overflow: ellipsis; white-space: nowrap; }
.llm-terminal__hint { flex-shrink: 0; margin-left: auto; color: var(--gemma-n400); white-space: nowrap; }

.llm-terminal__btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.4rem;
  height: 1.8rem;
  padding: 0 0.65rem;
  border: 1px solid color-mix(in srgb, var(--gemma-white) 14%, transparent);
  border-radius: var(--gemma-radius-pill);
  background: color-mix(in srgb, var(--gemma-white) 6%, transparent);
  color: var(--gemma-n50);
  font: inherit;
  cursor: pointer;
  transition: background-color var(--gemma-duration) var(--gemma-ease), border-color var(--gemma-duration) var(--gemma-ease);
}

.llm-terminal__btn:hover { background: color-mix(in srgb, var(--gemma-white) 14%, transparent); border-color: color-mix(in srgb, var(--gemma-white) 26%, transparent); }
.llm-terminal__btn:focus-visible { outline: 2px solid var(--gemma-blue-300); outline-offset: 1px; }
.llm-terminal__btn[aria-pressed="true"] { background: var(--gemma-accent-fill); border-color: var(--gemma-accent-fill); color: var(--gemma-white); }
.llm-terminal__btn .llm-shell__icon { width: 0.9rem; height: 0.9rem; }
.llm-terminal__btn[aria-pressed="false"] .llm-terminal__icon-shrink,
.llm-terminal__btn[aria-pressed="true"] .llm-terminal__icon-expand { display: none; }

/* Chevron points up while collapsed (expand), down while open (collapse). */
.llm-terminal__chevron {
  width: 0.42rem;
  height: 0.42rem;
  margin-top: 0.2rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg);
  transition: transform 200ms var(--gemma-ease), margin-top 200ms var(--gemma-ease);
}

.llm-shell.is-terminal-open .llm-terminal__chevron { margin-top: -0.2rem; transform: rotate(45deg); }

/* -------------------------------------------------------------------
   Body
   ------------------------------------------------------------------- */
.llm-terminal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; background: var(--gemma-surface); }
.llm-terminal__screen { width: min(100%, 60rem); margin: 0 auto; padding: 1rem 1.5rem 2rem; }
.llm-terminal__prompt { margin: 0 0 1rem !important; font-family: var(--md-code-font-family, monospace); font-size: 0.78rem; font-weight: 600; color: var(--gemma-accent); }
.llm-terminal__prompt--end { margin: 1.75rem 0 0 !important; }
.llm-terminal__caret { display: inline-block; width: 0.55em; height: 1em; vertical-align: -0.15em; background: var(--gemma-accent); animation: llmCaretBlink 1.1s steps(1) infinite; }
@keyframes llmCaretBlink { 50% { opacity: 0; } }

/* The hero carries the visible H1; the body's copy would repeat it. */
.llm-terminal__content > h1 { display: none; }
.llm-terminal__content > [hidden], .llm-terminal__content .llm-doc[hidden] { display: none; }
.llm-terminal__content > :first-child, .llm-terminal__content .llm-doc > :first-child { margin-top: 0; }
.md-typeset .llm-terminal__content h2 { margin-top: 1.8em; font-size: 1.2rem; }
.md-typeset .llm-terminal__content h2:first-child { margin-top: 0; }
.md-typeset .llm-terminal__content .mermaid { display: flex; justify-content: center; }

/* Anchor targets inside the drawer land under the prompt, not the bar. */
.llm-terminal__content :is(h2, h3, h4)[id] { scroll-margin-top: 1rem; }
.llm-terminal__content .llm-doc > p:last-child { margin-bottom: 0; }

/* Lead paragraph above the first file. */
.llm-terminal__content > p[data-llm-preamble] {
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--gemma-accent);
  border-radius: 0 var(--gemma-radius-md) var(--gemma-radius-md) 0;
  background: var(--gemma-surface-sunken);
  color: var(--gemma-text-secondary);
}

@media screen and (max-width: 48em) {
  .llm-terminal__path, .llm-terminal__hint { display: none; }
  .llm-terminal__bar { gap: 0.5rem; padding-left: 0.75rem; }
  .llm-terminal__screen { padding: 0.85rem 0.9rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .llm-terminal, .llm-terminal__chevron { transition: none; }
  .llm-terminal__caret { animation: none; }
}
