/* ============================================================
   Terminal CLI — Base & Layout
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--fg-muted);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-dim);
}

/* ---------- CRT Scanline Overlay (仅终端主题) ---------- */
[data-theme="terminal"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* Faint vignette (仅终端主题) */
[data-theme="terminal"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 55%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-12);
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover {
  text-shadow: var(--glow);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--fg);
  background: transparent;
  border: none;
  outline: none;
}

/* ---------- Utilities ---------- */
.cursor::after {
  content: '█';
  display: inline-block;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
  color: var(--fg);
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.amber { color: var(--fg-amber); text-shadow: var(--glow-amber); }
.error { color: var(--fg-error); text-shadow: var(--glow-error); }
.muted { color: var(--fg-muted); }
.dim   { color: var(--fg-dim); }
.glow  { text-shadow: var(--glow); }

.glow-strong {
  text-shadow: var(--glow-strong);
}

.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

/* ASCII separator */
.ascii-sep {
  display: block;
  color: var(--fg-muted);
  margin: var(--sp-3) 0;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  font-size: var(--fs-sm);
}

/* Visually-hidden for a11y */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  #app { padding: var(--sp-4) var(--sp-3) var(--sp-10); }
  :root {
    --fs-2xl: 22px;
    --fs-3xl: 28px;
  }
}
