/*!
 * Five Terminal Shell —— 终端面板样式
 * ----------------------------------------------------------------
 * 固定 CRT 风格（黑底磷光绿），不随 data-style 变化；
 * 打开方式：顶栏终端按钮 / Ctrl+Shift+T。
 */

/* ---- 面板容器 ---- */
#five-terminal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  background:
    radial-gradient(ellipse at center, rgb(51 255 153 / 0.05), transparent 70%),
    #020805;
  color: #33ff99;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", "Source Code Pro",
    Menlo, Consolas, "DejaVu Sans Mono", "Noto Sans Mono CJK SC", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

#five-terminal.ft-open {
  display: flex;
}

/* CRT 扫描线 */
#five-terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgb(51 255 153 / 0.04) 0px,
    rgb(51 255 153 / 0.04) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* 半屏模式（点标题栏 — 切换） */
#five-terminal.ft-minimized {
  inset: auto 0 0 0;
  height: 55vh;
  border-top: 1px solid #1f6b41;
  box-shadow: 0 -8px 40px rgb(0 0 0 / 0.6);
}

/* ---- 标题栏 ---- */
.ft-titlebar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
  height: 2.25rem;
  padding: 0 0.8rem;
  background: #06120a;
  border-bottom: 1px solid #1f6b41;
  user-select: none;
}

.ft-dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.ft-dots i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
}

.ft-dots i:nth-child(1) {
  background: #ff5f56;
}

.ft-dots i:nth-child(2) {
  background: #ffbd2e;
}

.ft-dots i:nth-child(3) {
  background: #27c93f;
}

.ft-title {
  flex: 1;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #29cc7a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ft-titlebar button {
  background: transparent;
  border: 1px solid #1f6b41;
  color: #33ff99;
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1;
  width: 1.6rem;
  height: 1.4rem;
  border-radius: 0;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ft-titlebar button:hover {
  background: #33ff99;
  color: #020805;
}

/* ---- 屏幕 ---- */
.ft-screen {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 1.1rem 1rem;
  word-break: break-word;
  overscroll-behavior: contain;
}

.ft-screen::-webkit-scrollbar {
  width: 8px;
}

.ft-screen::-webkit-scrollbar-thumb {
  background: #1f6b41;
}

.ft-screen::-webkit-scrollbar-track {
  background: transparent;
}

.ft-line {
  white-space: pre-wrap;
  min-height: 1.4em;
}

.ft-cmd {
  color: #7dffc4;
}

.ft-err {
  color: #ff5f56;
}

.ft-ok {
  color: #7dffc4;
}

.ft-dim {
  color: #1c8a52;
}

/* ---- 输入行 ---- */
.ft-inputline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
  padding: 0.55rem 1.1rem 0.7rem;
  border-top: 1px solid #1f6b41;
  background: #04160a;
}

.ft-prompt {
  color: #33ff99;
  white-space: nowrap;
}

#ft-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #33ff99;
  caret-color: #33ff99;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  padding: 0;
}

/* 顶栏入口按钮：仅终端风格可见 */
.terminal-trigger {
  display: none;
}

html[data-style="terminal"] .terminal-trigger {
  display: list-item;
}

.terminal-trigger button {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
}

/* 键盘焦点 */
#five-terminal :focus-visible {
  outline: 1px solid #33ff99;
  outline-offset: 2px;
}

/* 移动端：全屏 + 防 iOS 缩放 */
@media (max-width: 767px) {
  #five-terminal {
    font-size: 0.95rem;
  }

  #ft-input {
    font-size: 16px;
  }

  .ft-titlebar {
    height: 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #five-terminal::after {
    display: none;
  }
}
