/*————————————————————————————————————————————————————————————
  Theme Variables
————————————————————————————————————————————————————————————*/
:root {
  /* colors */
  --bg-color: #000;
  --fg-color: #0ff;
  --fg-color-light: rgba(0, 255, 255, 0.5);
  --window-bg: rgba(0, 255, 255, 0.1);
  --header-bg: #001f1f;
  --sidebar-bg: rgba(0, 16, 16, 0.8);

  /* sizing */
  --sidebar-width: 300px;
  --sidebar-gap: 1rem;
  --content-gap: 2rem;
  --window-radius: 8px;
  --window-border: 2px;
  --resize-handle-size: 12px;
  --scrollbar-width: 8px;
  --font-mono: 'Source Code Pro', monospace;
}

/*————————————————————————————————————————————————————————————
  Global Reset & Base
————————————————————————————————————————————————————————————*/
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-color);
  color: var(--fg-color);
  font-family: monospace;
}

button {
  font-family: monospace;
  touch-action: manipulation;
}

/*————————————————————————————————————————————————————————————
  Canvas
————————————————————————————————————————————————————————————*/
canvas#spacegrid {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
}

/*————————————————————————————————————————————————————————————
  Layout: Sidebar & Content
————————————————————————————————————————————————————————————*/
#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-gap);
  padding: var(--sidebar-gap);
  overflow-y: auto;
  z-index: 5;
}

#sidebar button {
  padding: 0.8rem;
  color: var(--fg-color);
  background: transparent;
  border: 1px solid var(--fg-color-light);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

#sidebar button:hover {
  background: var(--fg-color-light);
}

#sidebar {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#content {
  position: relative;
  margin-left: calc(var(--sidebar-width) + var(--content-gap));
  width: calc(100vw - (var(--sidebar-width) + var(--content-gap)));
  height: 100vh;
  overflow-y: auto;
  padding: var(--content-gap);
  background: transparent;
}


/* Sidebar toggle button */
#sidebar-toggle {
  position: fixed;
  top: 1rem;
  right: 310px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  background: #001010cc;
  color: #0ff;
  border: 1px solid #0ff5;
  border-radius: 4px;
  z-index: 1001;
  cursor: pointer;
  transition: right 0.3s;
}

/* Hidden sidebar state */
body.sidebar-hidden #sidebar {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

body.sidebar-hidden #sidebar-toggle {
  right: 1rem;
}

/*————————————————————————————————————————————————————————————
  Code Blocks
————————————————————————————————————————————————————————————*/
code,
pre {
  font-family: var(--font-mono);
  background: #111;
  color: var(--fg-color);
  padding: 0.5rem;
  border-radius: 5px;
  overflow-x: auto;
}

/*————————————————————————————————————————————————————————————
  Common Window Styles
————————————————————————————————————————————————————————————*/
.warp-window,
.fixed-window {
  position: absolute;
  background: var(--window-bg);
  border: var(--window-border) solid currentColor;
  border-radius: var(--window-radius);
  box-shadow: 0 0 10px var(--fg-color-light);
  color: var(--fg-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* Shared scrollbar styling */
.warp-window::-webkit-scrollbar,
.fixed-window::-webkit-scrollbar {
  width: var(--scrollbar-width);
  height: var(--scrollbar-width);
}

.warp-window::-webkit-scrollbar-thumb,
.fixed-window::-webkit-scrollbar-thumb {
  background: var(--fg-color-light);
  border-radius: 4px;
}

.warp-window::-webkit-scrollbar-track,
.fixed-window::-webkit-scrollbar-track {
  background: transparent;
}

/*————————————————————————————————————————————————————————————
  Warp Windows
————————————————————————————————————————————————————————————*/
.warp-window {
  z-index: 2;
}

.warp-window:active {
  cursor: grabbing;
}

/* Title bar */
.win-header {
  background: var(--header-bg);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
}

.win-header:active {
  cursor: grabbing;
}

.win-controls button {
  background: transparent;
  border: none;
  color: inherit;
  width: 24px;
  height: 24px;
  margin-left: 0.25rem;
  cursor: pointer;
  transition: background 0.2s;
}

.win-controls button:hover {
  background: var(--fg-color-light);
}

/* Body */
.win-body {
  flex: 1;
  padding: 0.5rem;
  overflow: auto;
}

/* Resize handle */
.win-resize-handle {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: var(--resize-handle-size);
  height: var(--resize-handle-size);
  cursor: se-resize;
  z-index: 3;
}

/*————————————————————————————————————————————————————————————
  Fixed Windows
————————————————————————————————————————————————————————————*/
.fixed-window {
  width: 240px;
  height: 160px;
  padding: 0.5rem;
  z-index: 1;
  box-shadow: none;
}

/* Scrollbars for draggable windows */
.warp-window::-webkit-scrollbar,
.fixed-window::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.warp-window::-webkit-scrollbar-thumb,
.fixed-window::-webkit-scrollbar-thumb {
  background-color: rgba(0, 255, 255, 0.6); /* neon cyan */
  border-radius: 4px;
  border: 1px solid rgba(0, 255, 255, 0.3);
}

.warp-window::-webkit-scrollbar-track,
.fixed-window::-webkit-scrollbar-track {
  background: transparent;
}

/*————————————————————————————————————————————————————————————
  Terminal window
————————————————————————————————————————————————————————————*/
/* Terminal styling inside a .win-body */
.terminal {
  background: #000;
  color: #0ff;
  font-family: monospace;
  padding: 0.5rem;
  height: 300px;       /* adjust as desired */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.terminal .output {
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
}

.terminal .input-line {
  display: flex;
}

.terminal .prompt {
  flex-shrink: 0;
}

.terminal input {
  flex: 1;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  outline: none;
}

/*————————————————————————————————————————————————————————————
  Responsive (≤ 600px)
————————————————————————————————————————————————————————————*/
@media (max-width: 600px) {
  /* sidebar goes top */
  #sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
  }
  #sidebar button {
    flex: 1 0 auto;
    margin: 0 0.25rem;
    font-size: 0.9rem;
  }

  /* content full-width */
  #content {
    margin: 0;
    width: 100%;
    padding: 1rem;
    height: calc(100vh - 50px);
  }

  /* windows become static cards */
  .warp-window,
  .fixed-window {
    position: static;
    width: 90vw;
    height: auto;
    margin: 0.5rem auto;
    box-shadow: none;
    cursor: default;
  }

  .win-resize-handle,
  .win-header {
    display: none;
  }
}
