/* ===== FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&display=swap');

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ===== THEMES ===== */
:root, [data-theme="default"] {
  --bg: #0d0d0d;
  --bg-win: #111;
  --bg-input: #0a0a0a;
  --border: #222;
  --titlebar: #161616;
  --text: #d4d4d4;
  --text-dim: #555;
  --accent: #00d4ff;
  --accent-dim: rgba(0,212,255,0.07);
  --red: #ff5f57;
  --yellow: #ffbd2e;
  --green: #28c841;
  --selection: rgba(0,212,255,0.18);
  --scrollbar: #2a2a2a;
  --font: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
  --radius: 10px;
  --shadow: 0 30px 90px rgba(0,0,0,.85);
}
[data-theme="matrix"] {
  --bg: #000; --bg-win: #030a03; --bg-input: #010501; --border: #0b2d0b;
  --titlebar: #020702; --text: #00ff41; --text-dim: #0a4a0a;
  --accent: #00ff41; --accent-dim: rgba(0,255,65,.08);
  --red: #ff0000; --yellow: #ccff00; --green: #00ff41;
  --selection: rgba(0,255,65,.2); --scrollbar: #0a2a0a;
}
[data-theme="amber"] {
  --bg: #0d0800; --bg-win: #120c00; --bg-input: #0a0600; --border: #3a2200;
  --titlebar: #190e00; --text: #ffb300; --text-dim: #664700;
  --accent: #ffcc00; --accent-dim: rgba(255,204,0,.08);
  --red: #ff4400; --yellow: #ffcc00; --green: #aacc00;
  --selection: rgba(255,204,0,.2); --scrollbar: #3a2200;
}
[data-theme="dracula"] {
  --bg: #1e1f29; --bg-win: #282a36; --bg-input: #191a25; --border: #44475a;
  --titlebar: #21222c; --text: #f8f8f2; --text-dim: #6272a4;
  --accent: #bd93f9; --accent-dim: rgba(189,147,249,.08);
  --red: #ff5555; --yellow: #f1fa8c; --green: #50fa7b;
  --selection: rgba(189,147,249,.2); --scrollbar: #44475a;
}
[data-theme="nord"] {
  --bg: #242933; --bg-win: #2e3440; --bg-input: #1f242c; --border: #3b4252;
  --titlebar: #292e3a; --text: #d8dee9; --text-dim: #4c566a;
  --accent: #88c0d0; --accent-dim: rgba(136,192,208,.08);
  --red: #bf616a; --yellow: #ebcb8b; --green: #a3be8c;
  --selection: rgba(136,192,208,.2); --scrollbar: #3b4252;
}

/* ===== BODY ===== */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  transition: background .4s, color .4s;
}

/* ===== WALLPAPER ===== */
.wallpaper {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 15% 50%, rgba(0,212,255,.04) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 20%, rgba(0,80,255,.03) 0%, transparent 55%),
    var(--bg);
  transition: background .4s;
}

/* ===== CANVAS ===== */
#matrixCanvas, #confettiCanvas {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
}

/* ===== TERMINAL WINDOW ===== */
.terminal-window {
  position: relative; z-index: 10;
  width: min(1100px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 40px));
  background: var(--bg-win);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  transition: background .4s, border-color .4s, transform .3s, opacity .3s;
}

/* ===== TITLEBAR ===== */
.titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--titlebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; user-select: none;
  transition: background .4s, border-color .4s;
}
.titlebar-dot {
  width: 12px; height: 12px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0; transition: opacity .2s;
}
.titlebar-dot:hover { opacity: .8; }
.titlebar-dot.red    { background: #ff5f57; }
.titlebar-dot.yellow { background: #ffbd2e; }
.titlebar-dot.green  { background: #28c841; }
.titlebar-title {
  flex: 1; text-align: center; font-size: 12px;
  color: var(--text-dim); letter-spacing: .5px;
}

/* ===== TERMINAL BODY ===== */
.terminal-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 20px 24px; scroll-behavior: smooth;
  overflow-anchor: none;
}
.terminal-body::-webkit-scrollbar { width: 5px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ===== BOOT TEXT ===== */
.boot-text { display: none; font-size: 12px; color: var(--text-dim); line-height: 1.9; margin-bottom: 12px; }
.terminal-window.booting .boot-text { display: block; }
.terminal-window.booting .ascii-name,
.terminal-window.booting .welcome-box { display: none; }

/* ===== ASCII NAME ===== */
.ascii-name {
  font-size: clamp(4.5px, .85vw, 8.5px);
  line-height: 1.15; color: var(--accent);
  margin-bottom: 20px; letter-spacing: 0;
  white-space: pre; overflow: hidden; display: block;
}

/* ===== WELCOME BOX ===== */
.welcome-box {
  display: flex; gap: 32px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 20px 24px; margin-bottom: 20px;
  background: var(--accent-dim);
  transition: border-color .4s, background .4s;
}
.welcome-left { flex: 1; min-width: 0; }
.welcome-right {
  flex: 0 0 250px;
  border-left: 1px solid var(--border);
  padding-left: 24px;
  transition: border-color .4s;
}
.greeting { font-size: 16px; font-weight: 600; color: var(--accent); margin-bottom: 4px; font-family: var(--font); }
.subtitle  { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }

.pixel-art {
  font-size: clamp(3px, 0.45vw, 5.5px);
  line-height: 1.08;
  color: var(--accent);
  opacity: .5;
  margin: 12px 0;
  display: block;
  white-space: pre;
  overflow: visible;
}

.welcome-section { margin-bottom: 16px; }
.welcome-section:last-child { margin-bottom: 0; }
.welcome-section-title {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 8px; font-family: var(--font);
}
.item { display: flex; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 4px; color: var(--text); }
.item .label { color: var(--accent); min-width: 56px; font-size: 11px; font-weight: 500; }
.command-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ===== OUTPUT ===== */
.output-area { font-size: 13px; }
.output-block { margin-bottom: 14px; animation: fadeIn .15s ease; }
.output-line {
  display: block; line-height: 1.75; font-size: 13px;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.output-line.prompt-echo { color: var(--accent); margin-bottom: 4px; }
.output-line.prompt-echo::before { content: '> '; }
.output-line.accent { color: var(--accent); }
.output-line.dim    { color: var(--text-dim); }
.output-line.red    { color: var(--red); }
.output-line.green  { color: var(--green); }
.output-line.yellow { color: var(--yellow); }
.output-line.bold   { font-weight: 600; }

/* ===== INPUT ===== */
.input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
  transition: background .4s, border-color .4s;
}
.input-prompt { color: var(--accent); font-size: 14px; font-weight: 600; flex-shrink: 0; }
.input-wrapper { position: relative; flex: 1; }
.input-field {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font); font-size: 13px;
  caret-color: var(--accent); line-height: 1.5;
}
.input-field::placeholder { color: var(--text-dim); opacity: .6; }

/* ===== AUTOCOMPLETE ===== */
.autocomplete {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--titlebar); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
  max-height: 200px; overflow-y: auto; z-index: 100; display: none;
}
.autocomplete.visible { display: block; }
.autocomplete-item {
  padding: 6px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; transition: background .1s;
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--accent-dim); }
.autocomplete-item .cmd { color: var(--accent); min-width: 120px; font-weight: 500; }
.autocomplete-item .desc { color: var(--text-dim); }

/* ===== CLOSE OVERLAY ===== */
.close-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.82); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.close-overlay.visible { display: flex; }
.close-window {
  background: var(--bg-win); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(480px, calc(100vw - 32px)); overflow: hidden;
}
.close-body { padding: 24px 28px; }
.close-body .output-line { margin-bottom: 4px; }
.close-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.close-btn {
  padding: 7px 16px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--accent-dim);
  color: var(--text); font-family: var(--font); font-size: 12px;
  cursor: pointer; text-decoration: none;
  transition: background .2s, border-color .2s, color .2s;
}
.close-btn:hover { border-color: var(--accent); color: var(--accent); }
.close-btn.primary { border-color: var(--accent); color: var(--accent); }
.close-btn.primary:hover { background: var(--accent); color: var(--bg); }

/* ===== STATES ===== */
.terminal-window.minimized { transform: scale(0.03) translateY(400px); opacity: 0; pointer-events: none; }
.terminal-window.fullscreen { position: fixed; inset: 0; width: 100vw; height: 100vh; border-radius: 0; border: none; z-index: 50; }

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

::selection { background: var(--selection); }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  body {
    min-height: 100svh;
    min-height: 100dvh;
    align-items: stretch;
    justify-content: flex-start;
  }
  .terminal-window {
    width: 100%;
    height: 100svh;
    height: 100dvh;
    min-height: 100svh;
    min-height: 100dvh;
    max-height: 100svh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .titlebar { padding: 10px 12px; }
  .titlebar-title { font-size: 10px; letter-spacing: .2px; }
  .terminal-body { padding: 16px 16px 20px; }
  .welcome-box { flex-direction: column; gap: 14px; padding: 16px; }
  .welcome-right { flex: 1; border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 14px; }
  .greeting { font-size: 14px; }
  .ascii-name {
    font-size: clamp(4.2px, 1.35vw, 6.8px);
    line-height: 1.04;
    margin-bottom: 14px;
    overflow: visible;
  }
  .pixel-art {
    font-size: clamp(1.35px, 0.42vw, 1.95px);
    line-height: 1.02;
    margin: 8px 0 12px;
    opacity: .34;
  }
  .item { font-size: 11px; }
  .command-hint { font-size: 10px; }
}
@media (max-width: 480px) {
  .terminal-body { padding: 12px 14px 18px; }
  .input-area { padding: 10px 14px; }
  .titlebar-title { font-size: 9px; }
  .ascii-name {
    font-size: clamp(3.3px, 1.15vw, 5px);
    line-height: 1.02;
  }
  .pixel-art { font-size: clamp(1.1px, 0.36vw, 1.5px); }
  .welcome-box { padding: 14px; }
  .subtitle { font-size: 10px; }
  .welcome-section-title { font-size: 9px; }
  .item { font-size: 10.5px; }
  .command-hint { font-size: 9.5px; }
}

/* ===== NOSCRIPT ===== */
/* (applied via <noscript> style tag in HTML) */
