/* ============================================================
   alghul.com — macOS Liquid Glass Terminal
   ============================================================ */

/* --- Design Tokens --- */
:root {
  --glass-bg: rgba(30, 30, 30, 0.55);
  --glass-bg-titlebar: rgba(45, 45, 45, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --glass-blur: 40px;
  --glass-shadow:
    0 24px 80px rgba(0, 0, 0, 0.45), 0 0 1px rgba(255, 255, 255, 0.1) inset;

  --menubar-bg: rgba(30, 30, 30, 0.55);
  --menubar-blur: 30px;
  --menubar-height: 28px;

  --dock-bg: rgba(255, 255, 255, 0.12);
  --dock-blur: 24px;
  --dock-border: rgba(255, 255, 255, 0.18);

  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-prompt: #78dcaa;
  --text-dir: #6cb6ff;
  --text-error: #f47067;
  --text-file: #d4d4d4;
  --text-exec: #7ee787;
  --text-link: #79c0ff;

  --font-mono:
    "SF Mono", "Menlo", "Monaco", "Cascadia Code", "Courier New", monospace;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --window-radius: 12px;
  --dock-radius: 18px;

  --red: #ff5f57;
  --yellow: #febc2e;
  --green: #28c840;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* --- Desktop Wallpaper --- */
#desktop-wallpaper {
  position: fixed;
  inset: 0;
  background: url("wallpaper.png") center/cover no-repeat;
  z-index: 0;
}

/* Subtle vignette overlay */
#desktop-wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 0, 0, 0.25) 100%
  );
  pointer-events: none;
}

/* --- Menubar --- */
#menubar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--menubar-height);
  background: var(--menubar-bg);
  backdrop-filter: blur(var(--menubar-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--menubar-blur)) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 1000;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.menubar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.apple-logo {
  font-size: 16px;
  opacity: 0.9;
  cursor: default;
}

.menubar-app-name {
  font-weight: 700;
}

.menubar-item {
  opacity: 0.85;
  cursor: default;
  transition: opacity 0.15s;
}

.menubar-item:hover {
  opacity: 1;
}

.menubar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menubar-icon {
  display: flex;
  align-items: center;
  opacity: 0.85;
}

.menubar-clock {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
  min-width: 130px;
  text-align: right;
}

/* --- Terminal Window --- */
#terminal-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, 90vw);
  height: min(480px, 70vh);
  display: flex;
  flex-direction: column;
  border-radius: var(--window-radius);
  overflow: hidden;
  z-index: 100;

  /* Liquid Glass */
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);

  /* Open animation */
  animation: windowOpen 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes windowOpen {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Title Bar */
#terminal-titlebar {
  display: flex;
  align-items: center;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  background: var(--glass-bg-titlebar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  position: relative;
}

#terminal-titlebar:active {
  cursor: grabbing;
}

.traffic-lights {
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s;
  padding: 0;
}

.traffic-light svg {
  opacity: 0;
  transition: opacity 0.15s;
}

.traffic-lights:hover .traffic-light svg {
  opacity: 1;
}

.traffic-light.red {
  background: var(--red);
}

.traffic-light.yellow {
  background: var(--yellow);
}

.traffic-light.green {
  background: var(--green);
}

.traffic-light:hover {
  filter: brightness(1.15);
}

.terminal-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

.titlebar-spacer {
  flex: 1;
}

/* Terminal Body */
#terminal-body {
  flex: 1;
  padding: 10px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

/* Scrollbar */
#terminal-body::-webkit-scrollbar {
  width: 6px;
}

#terminal-body::-webkit-scrollbar-track {
  background: transparent;
}

#terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

#terminal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Output */
#terminal-output {
  flex: 1;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#terminal-output .output-line {
  margin-bottom: 0;
}

#terminal-output .prompt-line {
  color: var(--text-primary);
}

#terminal-output .prompt-line .prompt {
  color: var(--text-prompt);
}

#terminal-output .prompt-line .prompt .prompt-dir {
  color: var(--text-dir);
}

#terminal-output .prompt-line .prompt .prompt-symbol {
  color: var(--text-secondary);
}

.output-text {
  color: var(--text-file);
}

.output-error {
  color: var(--text-error);
}

.output-success {
  color: var(--text-exec);
}

.output-info {
  color: var(--text-link);
}

.output-heading {
  color: #d2a8ff;
  font-weight: 700;
}

.output-bold {
  color: #fff;
  font-weight: 600;
}

.output-muted {
  color: var(--text-secondary);
}

.output-separator {
  color: rgba(255, 255, 255, 0.15);
}

/* ls coloring */
.ls-file {
  color: var(--text-file);
}

.ls-exec {
  color: var(--text-exec);
  font-weight: 500;
}

/* Input Line */
#terminal-input-line {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 22px;
  margin-top: 2px;
}

.prompt {
  color: var(--text-prompt);
  white-space: nowrap;
  margin-right: 8px;
  font-weight: 500;
}

.prompt .prompt-dir {
  color: var(--text-dir);
}

.prompt .prompt-symbol {
  color: var(--text-secondary);
}

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13.5px;
  width: 100%;
  caret-color: transparent;
}

.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 17px;
  background: rgba(255, 255, 255, 0.7);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  animation: blink 1s step-end infinite;
  pointer-events: none;
  border-radius: 1px;
}

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

  50% {
    opacity: 0;
  }
}

/* Welcome message styling */
.welcome-ascii {
  color: var(--text-prompt);
  font-size: 12px;
  line-height: 1.25;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* --- Dock --- */
#dock {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
}

.dock-container {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px 10px;
  background: var(--dock-bg);
  backdrop-filter: blur(var(--dock-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--dock-blur)) saturate(180%);
  border: 1px solid var(--dock-border);
  border-radius: var(--dock-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.dock-item:hover {
  transform: translateY(-8px) scale(1.25);
}

.dock-item:hover ~ .dock-item,
.dock-item:has(+ .dock-item:hover) {
  transform: translateY(-3px) scale(1.08);
}

/* Tooltip */
.dock-item::before {
  content: attr(data-tooltip);
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: rgba(30, 30, 30, 0.9);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dock-item:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.dock-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dock-indicator {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

.dock-divider {
  width: 1px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
  align-self: center;
}

/* --- Window Minimized State --- */
#terminal-window.minimized {
  animation: windowMinimize 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes windowMinimize {
  to {
    opacity: 0;
    transform: translate(-50%, 100vh) scale(0.3);
  }
}

#terminal-window.restored {
  animation: windowRestore 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes windowRestore {
  from {
    opacity: 0;
    transform: translate(-50%, 100vh) scale(0.3);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

#terminal-window.maximized {
  width: 100vw !important;
  height: calc(100vh - var(--menubar-height)) !important;
  top: calc(
    var(--menubar-height) + (100vh - var(--menubar-height)) / 2
  ) !important;
  left: 50% !important;
  border-radius: 0;
  animation: none;
  transform: translate(-50%, -50%);
}

/* --- Responsive --- */
@media (max-width: 600px) {
  #terminal-window {
    width: 98vw;
    height: 65vh;
    border-radius: 10px;
  }

  #dock {
    display: none;
  }

  .menubar-item {
    display: none;
  }

  #terminal-body {
    font-size: 12px;
  }
}

/* ============================================================
   CheerpX WebVM Console & Boot Animation
   ============================================================ */

/* CheerpX console — hidden by default */
#cx-console {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 10px 14px;
  background: transparent;
  color: #e8e8e8;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#cx-console::-webkit-scrollbar {
  width: 6px;
}

#cx-console::-webkit-scrollbar-track {
  background: transparent;
}

#cx-console::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* CheerpX VM output — styled inline with the fake terminal */
.vm-output {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-primary);
}

/* Boot animation text styles */
.boot-line {
  color: var(--text-secondary);
}

.boot-ok {
  color: var(--text-exec);
  font-weight: 600;
}

.boot-info {
  color: var(--text-link);
}

.boot-warn {
  color: var(--yellow);
}

.boot-highlight {
  color: #d2a8ff;
  font-weight: 700;
}

.boot-spinner {
  color: var(--text-exec);
  display: inline-block;
  animation: bootPulse 1s ease-in-out infinite;
}

@keyframes bootPulse {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

/* --- macOS Context Menu --- */
.context-menu {
  position: fixed;
  display: none;
  min-width: 220px;
  padding: 5px 0;
  background: rgba(40, 40, 40, 0.78);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 0.5px rgba(255, 255, 255, 0.08) inset;
  z-index: 9999;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  animation: ctxFadeIn 0.12s ease-out;
  user-select: none;
}

@keyframes ctxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px;
  margin: 0 5px;
  border-radius: 4px;
  cursor: default;
  white-space: nowrap;
  transition: background 0.08s;
}

.context-menu-item:hover {
  background: #3478f6;
  color: #fff;
}

.context-menu-item .ctx-shortcut {
  margin-left: 32px;
  font-size: 12px;
  opacity: 0.5;
}

.context-menu-item:hover .ctx-shortcut {
  opacity: 0.8;
}

.context-menu-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.context-menu-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 5px 12px;
}

/* --- Terminal body: click-to-focus cursor --- */
#terminal-body {
  cursor: text;
}
