/* css/style.css — dark theme tokens + all FakeOS styling (CSS only, no image assets) */

:root {
  --bg-deep: #0d1220;
  --panel: #1a2032;
  --panel-raised: #232b42;
  --border: #35406280;
  --text: #e7ebf5;
  --muted: #9aa5c4;
  --accent: #5b8cff;
  --accent-soft: #5b8cff33;
  --danger: #ff6b6b;
  --taskbar-h: 42px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg-deep);
}

/* ---- desktop & wallpaper ------------------------------------------------ */

#desktop {
  position: fixed;
  inset: 0 0 var(--taskbar-h) 0; /* leave room for the taskbar */
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 75% -10%, #3b4d8f66, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, #1e5a5a55, transparent 55%),
    linear-gradient(135deg, #101728 0%, #1b2440 45%, #232c52 70%, #16203a 100%);
}

/* ---- desktop icons ------------------------------------------------------- */

.icon {
  position: absolute;
  left: 24px; /* default before any saved position is applied */
  top: 24px;
  width: 84px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: grab; /* draggable region */
  user-select: none;
}

/* Distinct defaults on first launch (no saved layout): stack vertically so icons never overlap */
.icon[data-app-id="calculator"] { top: 156px; /* one icon height + gap below Notepad's 24px default */ }

.icon:hover { background: #ffffff14; }

/* Single-click selection highlight (double click opens) */
.icon.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-glyph { font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 4px #0009); }

.icon-label {
  font-size: 12px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 5px;
  background: #0d1220aa;
}

/* ---- windows ------------------------------------------------------------- */

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 140px;
  background: var(--panel);
  border: 1px solid #3a467088;
  border-radius: 10px;
  box-shadow: 0 10px 30px #00000090, 0 2px 6px #00000055;
  overflow: hidden; /* keeps content inside the rounded chrome */
}

/* Minimized = display:none: not clickable, hence non-focusable/non-interactable. */
.window.minimized { display: none; }

.titlebar {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  background: var(--panel-raised);
  border-bottom: 1px solid #ffffff12;
  cursor: grab; /* title bar is the ONLY drag hit target */
  user-select: none;
}

.titlebar.dragging { cursor: grabbing; }

/* Distinct focused style for the frontmost window's title bar. */
.window.focused .titlebar {
  background: linear-gradient(180deg, #2c3a66, #24305a);
  border-bottom-color: var(--accent);
}

.win-title {
  flex: 1 1 auto;
  min-width: 0; /* required for ellipsis inside a flex item */
  font-family: Consolas, "Cascadia Mono", monospace; /* monospace so 1ch = exactly one character */
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18ch; /* titles longer than 18 characters truncate, e.g. "Untitled — Notep…" */
}

.tb-buttons { flex: 0 0 auto; display: flex; gap: 4px; }

.win-btn {
  width: 26px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.win-btn:hover { background: #ffffff20; color: var(--text); }
.btn-close:hover { background: var(--danger); color: #fff; }

.window-body { flex: 1 1 auto; min-height: 0; position: relative; }

/* ---- taskbar -------------------------------------------------------------- */

#taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  background: #131a2ce6;
  border-top: 1px solid #ffffff18;
  backdrop-filter: blur(6px);
  z-index: 999999; /* always above windows */
}

.tb-brand { font-size: 12px; color: var(--muted); letter-spacing: 0.5px; }

#taskbar-buttons { display: flex; gap: 6px; overflow-x: auto; min-width: 0; }

/* One button per open window (minimized ones stay listed, dimmed). */
.tb-btn {
  max-width: 180px;
  height: 30px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border: 1px solid #ffffff1c;
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.tb-btn:hover { background: #30407088; }

/* Active (focused) window's taskbar button */
.tb-btn.active { border-color: var(--accent); background: var(--accent-soft); }

/* Minimized windows keep their entry, visually dimmed. */
.tb-btn.tb-minimized { opacity: 0.55; }

.tb-label {
  font-family: Consolas, "Cascadia Mono", monospace; /* matches the title-bar truncation metric */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* taskbar labels ellipsize like title bars */
}

/* ---- Notepad --------------------------------------------------------------- */

.notepad-area {
  position: absolute;
  inset: 0; /* fills the client area below the title bar */
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  outline: none;
  background: #141a2c;
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
}

.notepad-area::placeholder { color: var(--muted); }

/* ---- Calculator -------------------------------------------------------------- */

/* Calculator fills the client area below its title bar */
.calc-app { display: flex; flex-direction: column; min-height: 0; padding: 8px; gap: 8px; background: #141a2c; }

.calc-display {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  border-radius: 8px;
  background: #0d1322;
  border: 1px solid #ffffff14;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 26px;
  overflow: hidden; /* long results clip instead of breaking the layout */
}

.calc-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.calc-key {
  border: none;
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: filter 0.06s ease;
}

.calc-key:hover { filter: brightness(1.25); }
.calc-key:active { filter: brightness(0.85); }

/* C spans the full top row */
.calc-clear { grid-column: span 4; background: #3a2740; color: var(--danger); font-weight: 600; }

/* "0" spans two columns in the bottom row */
.calc-zero { grid-column: span 2; }

/* Equals gets an accent to stand out */
.calc-eq { background: #2c3a66; color: var(--accent); font-weight: 700; }
