/* ═══════════════════════════════════════
   Chupacabra Technologies K.K. — Terminal UI
   night-vision / trail-cam phosphor
   ═══════════════════════════════════════ */

/* --- Design Tokens --- */
:root {
  --bg: #070a07;
  --fg: #9db89d;
  --green: #6ee787;
  --green2: #b7f7c2;
  --dim: #47563f;
  --prompt: #6ee787;
  --cmd: #e6f0e6;
  --accent: #e0b062;
  --red: #ff6b6b;
  --amber: #f0c674;

  --surface: #101610;
  --border: #23301f;
  --input-bg: #0b0f0b;
  --quick-bg: #0a0d0a;
  --quick-border: #1a231a;
  --quick-btn: #142014;

  --font-mono: 'Courier New', 'SF Mono', 'Monaco', monospace;
  --font-display: 'Zen Kaku Gothic New', sans-serif;
  --font-size-base: 13px;
}

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

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* absorbs mobile browser chrome */
}

/* CRT scanline + vignette overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.16) 3px,
      rgba(0, 0, 0, 0) 4px
    ),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.5) 100%);
  mix-blend-mode: multiply;
}

@media (prefers-reduced-motion: no-preference) {
  body::after { animation: flicker 4s steps(60) infinite; }
}
@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.86; }
  98% { opacity: 0.97; }
}

/* --- Title Bar --- */
.titlebar {
  height: 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  gap: 8px;
}

.titlebar__dots {
  display: flex;
  gap: 6px;
}

.titlebar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.titlebar__dot--close  { background: #ff5f57; }
.titlebar__dot--min    { background: #febc2e; }
.titlebar__dot--max    { background: #28c840; }

.titlebar__title {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: #5c6b52;
  letter-spacing: 1px;
}

/* --- Output Area --- */
.output-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px;
  scroll-behavior: smooth;
}

.output {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  text-shadow: 0 0 6px rgba(110, 231, 135, 0.18);
}

/* --- Input Bar --- */
.input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--input-bg);
  gap: 8px;
}

.input-bar__prompt {
  color: var(--prompt);
  font-weight: bold;
  white-space: nowrap;
  font-size: var(--font-size-base);
}

.input-bar__field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cmd);
  font-family: inherit;
  font-size: var(--font-size-base);
  caret-color: var(--green);
}

.input-bar__field::placeholder {
  color: #35452f;
}

/* Block cursor — shown while the field is empty (idle terminal look) */
.input-bar__cursor {
  width: 0.55em;
  height: 1.15em;
  background: var(--green);
  flex-shrink: 0;
  margin-left: -4px;
  box-shadow: 0 0 6px rgba(110, 231, 135, 0.4);
}
@media (prefers-reduced-motion: no-preference) {
  .input-bar__cursor { animation: cursor-blink 1.05s steps(2, end) infinite; }
}
@keyframes cursor-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
/* hide the block cursor once the user types; native caret takes over */
.input-bar.has-text .input-bar__cursor { display: none; }
.input-bar.has-text .input-bar__field { caret-color: var(--green); }
.input-bar:not(.has-text) .input-bar__field { caret-color: transparent; }

/* Boot static — green noise flash before the terminal appears */
.boot-static {
  position: fixed;
  inset: 0;
  z-index: 200;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.5) 0, rgba(0,0,0,0) 1px, rgba(0,0,0,0.5) 2px),
    var(--bg);
  opacity: 1;
  transition: opacity 0.3s steps(4, end);
}
.boot-static::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.43  0 0 0 0 0.9  0 0 0 0 0.53  0 0 0 0.85 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 150px 150px;
  mix-blend-mode: screen;
  opacity: 0.5;
}
.boot-static.gone { opacity: 0; pointer-events: none; }

/* --- Quick Commands --- */
.quick-cmds {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 12px 8px;
  background: var(--quick-bg);
  border-top: 1px solid var(--quick-border);
}

.quick-cmds__btn {
  padding: 5px 10px;
  background: var(--quick-btn);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.quick-cmds__btn:active,
.quick-cmds__btn:hover {
  background: #1c2c1c;
  border-color: var(--green);
}

/* --- Terminal Text Styles --- */
.t-green  { color: var(--green); }
.t-green2 { color: var(--green2); }
.t-dim    { color: var(--dim); }
.t-cmd    { color: var(--cmd); }
.t-accent { color: var(--accent); }
.t-amber  { color: var(--amber); }
.t-red    { color: var(--red); }
.t-bold   { font-weight: bold; }
.t-strike { text-decoration: line-through; color: var(--dim); }

.t-link {
  color: var(--green);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.t-link:hover { color: var(--green2); }

.t-head {
  color: var(--green2);
  font-weight: bold;
  font-size: 14px;
}

.t-main {
  color: var(--green2);
  font-weight: bold;
  font-size: 15px;
  line-height: 2;
}

.t-sub {
  color: var(--green);
  font-style: italic;
  line-height: 2;
}

.t-body {
  color: var(--fg);
  line-height: 2;
}

.t-catch {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  color: var(--green2);
  letter-spacing: 3px;
  line-height: 2.5;
}

.t-poetry {
  font-family: var(--font-display);
  color: #8aa596;
  line-height: 2.2;
  font-size: 12px;
}

.ascii-logo {
  font-size: min(2.6vw, 13px);
  line-height: 1.15;
  letter-spacing: 0;
  white-space: pre;
  color: var(--green);
}
.ascii-eye  { color: var(--amber); }
.ascii-dim  { color: var(--dim); }

/* --- Braille chupacabra art --- */
.chupacabra-art {
  /* scaleY で縮めた分の高さを吸収する */
  display: inline-block;
  overflow: hidden;
  line-height: 0;
}

.braille-art {
  margin: 0;
  padding: 0;
  color: var(--green);
  white-space: pre;

  /* 必ず等幅フォントにする */
  font-family:
    "SFMono-Regular", "Cascadia Mono", "Roboto Mono",
    "Noto Sans Mono", Menlo, Monaco, Consolas, monospace;

  font-size: clamp(9px, 2.6vw, 15px);
  line-height: 1;
  letter-spacing: 0;
  word-spacing: 0;
  tab-size: 2;

  /* 合字・疑似太字によるズレを防ぐ */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  font-synthesis: none;

  /* Braille 文字の縦長補正は環境依存が大きいので控えめに */
  transform: scaleY(0.85);
  transform-origin: top left;

  /* scaleY で余る下側 15%（14行分）を負マージンで詰める */
  margin-bottom: calc(clamp(9px, 2.6vw, 15px) * 14 * -0.15);

  text-rendering: geometricPrecision;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  body { font-size: 12px; }
  .output-wrap { padding: 10px 12px; }
  .input-bar { padding: 6px 12px; }
  .t-catch { font-size: 15px; letter-spacing: 2px; }
  .titlebar__title { display: none; }

  /* Quick commands: single scrollable row instead of wrapping */
  .quick-cmds {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .quick-cmds::-webkit-scrollbar { display: none; }
  .quick-cmds__btn { flex: 0 0 auto; }
}
