:root {
  --bg: #0a0a0a;
  --fg: #e0e0e0;
  --accent: #ff5c2b;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-display: 'Orbitron', sans-serif;
  --taskbar-height: 40px;
}

body[data-theme="phosphor"] {
  --accent: #33ff66;
}

body[data-theme="cyber"] {
  --accent: #33ccff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  overflow: hidden;
}

/* Boot screen */
#boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--fg);
  z-index: 1000;
  padding: 24px;
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  transition: opacity 0.4s ease;
}

#boot-screen.boot-collapse {
  opacity: 0;
}

.boot-tag {
  color: var(--accent);
}

.boot-mascot {
  color: var(--accent);
  margin-top: 16px;
  white-space: pre;
}

.boot-prompt {
  margin-top: 16px;
}

/* Boot splash: mascot + title glitch reveal */
.boot-title {
  display: none;
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent), 0 0 18px var(--accent);
  margin-top: 16px;
}

#boot-screen.boot-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#boot-screen.boot-splash .boot-log {
  display: none;
}

#boot-screen.boot-splash .boot-mascot {
  margin-top: 0;
  font-size: 8px;
  line-height: 1.1;
  text-align: center;
}

#boot-screen.boot-splash .boot-title {
  display: block;
}

#boot-screen.boot-splash .boot-prompt {
  margin-top: 24px;
  font-size: 16px;
}

.boot-mascot.glitch-in,
.boot-title.glitch-in {
  animation: scanline-sweep 0.5s steps(6) infinite;
}

.boot-mascot.jitter,
.boot-title.jitter {
  transform: translate(2px, -1px);
  opacity: 0.7;
  clip-path: inset(0 0 8% 0);
}

.boot-mascot.settled,
.boot-title.settled {
  animation: text-flicker 3s infinite;
}

@keyframes scanline-sweep {
  0% { opacity: 0.3; clip-path: inset(0 0 90% 0); }
  50% { opacity: 1; clip-path: inset(0 0 0 0); }
  100% { opacity: 0.6; clip-path: inset(40% 0 0 0); }
}

@keyframes text-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.4; }
  94% { opacity: 1; }
}

/* Desktop */
#desktop {
  position: relative;
  width: 100%;
  height: calc(100% - var(--taskbar-height));
  overflow: hidden;
}

#desktop-bg-mascot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: rgba(237, 237, 237, 0.09);
  font-size: 11px;
  line-height: 1.1;
  white-space: pre;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}

#desktop-icons {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 1;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 72px;
  cursor: pointer;
  color: var(--fg);
  font-size: 12px;
  text-align: center;
  user-select: none;
}

.desktop-icon .icon-glyph {
  font-size: 20px;
  border: 1px solid var(--fg);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.desktop-icon:hover .icon-glyph {
  border-color: var(--accent);
  color: var(--accent);
}

#windows-container {
  position: absolute;
  inset: 0;
}

/* Window chrome */
.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--fg);
  min-width: 200px;
  min-height: 150px;
}

.window.focused {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.window-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--fg);
  cursor: move;
  font-size: 13px;
}

.window.focused .window-titlebar {
  color: var(--accent);
}

.window-controls span {
  cursor: pointer;
  margin-left: 8px;
}

.window-controls span:hover {
  color: var(--accent);
}

.window-body {
  flex: 1;
  overflow: auto;
  padding: 8px;
  font-size: 13px;
}

/* Taskbar */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--taskbar-height);
  background: var(--bg);
  border-top: 1px solid var(--fg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  gap: 16px;
  z-index: 500;
}

#taskbar-brand {
  color: var(--accent);
  font-weight: bold;
}

#theme-toggle {
  background: transparent;
  border: 1px solid var(--fg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 8px;
  cursor: pointer;
}

#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#taskbar-apps {
  flex: 1;
  display: flex;
  gap: 8px;
}

.taskbar-entry {
  border: 1px solid var(--fg);
  padding: 2px 8px;
  cursor: pointer;
}

.taskbar-entry.focused {
  border-color: var(--accent);
  color: var(--accent);
}

/* CRT scanline overlay */
.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.03) 0px,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* Terminal */
.app-terminal {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
}

.terminal-input-line {
  display: flex;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  caret-color: var(--accent);
}

/* File Explorer */
.app-files {
  display: flex;
  height: 100%;
  gap: 8px;
}

.files-tree {
  width: 40%;
  overflow-y: auto;
}

.files-item {
  cursor: pointer;
  white-space: nowrap;
}

.files-item:hover {
  color: var(--accent);
}

.files-view {
  flex: 1;
  border-left: 1px solid var(--fg);
  padding-left: 8px;
  margin: 0;
  white-space: pre-wrap;
  overflow-y: auto;
}

/* About */
.app-about {
  display: flex;
  gap: 12px;
  height: 100%;
}

.about-mascot {
  color: var(--accent);
  margin: 0;
  font-size: 3px;
  line-height: 1;
  white-space: pre;
  overflow: hidden;
  flex-shrink: 0;
}

.about-info {
  margin: 0;
}

/* Notes */
.app-notes {
  height: 100%;
}

.notes-textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  color: var(--fg);
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

.notes-textarea::placeholder {
  color: var(--fg);
  opacity: 0.4;
}

/* Music */
.app-music {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  height: 100%;
  justify-content: center;
}

.music-track {
  color: var(--accent);
}

.music-visualizer {
  background: var(--bg);
  border: 1px solid var(--fg);
}

.music-toggle {
  background: transparent;
  border: 1px solid var(--fg);
  color: var(--fg);
  font-family: var(--font-mono);
  padding: 4px 16px;
  cursor: pointer;
}

.music-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Living Mascot Presence */
.embercrow-eye {
  display: inline-block;
  color: var(--accent);
  text-shadow: 0 0 calc(6px * var(--presence-intensity, 0.4)) var(--accent);
  transition: transform 0.4s ease-out, text-shadow 0.6s ease;
}

@keyframes embercrow-blink {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.1); }
}

.embercrow-eye.blinking {
  animation: embercrow-blink 0.15s ease-in-out;
}

.embercrow-eye.idle {
  transform: scaleY(0.3) !important;
  opacity: 0.5;
  transition: transform 1.2s ease, opacity 1.2s ease;
}

.embercrow-ambient-message {
  position: absolute;
  white-space: nowrap;
  color: var(--fg);
  opacity: 0;
  font-size: 12px;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.embercrow-ambient-message.visible {
  opacity: 0.4;
}
