/*
 * xwos.css -- the shell: desktop, windows, taskbar, launcher.
 *
 * Every colour is a token. A theme redefines tokens and nothing else, so a
 * new theme cannot miss a component -- which is the failure mode of themes
 * that override raw colours on a hand-maintained selector list.
 *
 * This file lives in the filesystem at /system/src/styles/xwos.css and is
 * loaded from there, so editing it inside xwOS restyles xwOS.
 */

:root {
  /* Surfaces, back to front. */
  --bg: #0b0f16;
  --bg-deep: #070a10;
  --surface: #141a24;
  --surface-2: #1b2331;
  --surface-3: #232d3d;
  --line: #2a3546;
  --line-soft: #1e2734;

  --text: #e8eef6;
  --text-dim: #9aabbf;
  --text-faint: #64748b;

  --accent: #f0b54d;
  --accent-2: #6fe0d8;
  --accent-ink: #17202c;
  --danger: #ff6b6b;
  --ok: #4ade80;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;

  --shadow-window: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.45);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "Consolas", monospace;

  --taskbar-h: 52px;
  --titlebar-h: 34px;

  color-scheme: dark;
}

/* Light theme: tokens only, no component selectors below this line. */
:root[data-theme="light"] {
  --bg: #e8ecf2;
  --bg-deep: #dde3ec;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --surface-3: #e9edf4;
  --line: #cdd5e0;
  --line-soft: #dde3ec;
  --text: #131820;
  --text-dim: #4a5769;
  --text-faint: #7b8798;
  --accent: #b4791b;
  --accent-2: #10827a;
  --accent-ink: #ffffff;
  --shadow-window: 0 18px 50px rgba(15, 25, 40, 0.18);
  --shadow-pop: 0 12px 32px rgba(15, 25, 40, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* [hidden] is only display:none in the UA sheet, so any author rule setting
   display beats it. Without !important, hiding a flex container does nothing. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ shell */

.shell {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  user-select: none;
}

.desktop-surface {
  position: absolute;
  inset: 0 0 var(--taskbar-h) 0;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(111, 224, 216, 0.10), transparent 60%),
    radial-gradient(900px 600px at 110% 10%, rgba(240, 181, 77, 0.10), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-deep));
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.desktop-icons {
  position: absolute;
  inset: 0;
}

.desktop-icon {
  position: absolute;
  width: 84px;
  padding: 10px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.06);
}

.desktop-icon.selected {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--line);
}

.desktop-icon-glyph {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 6px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--surface-3), var(--surface));
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
}

.desktop-icon small {
  display: block;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-dim);
  word-break: break-word;
}

.desktop-icon.selected small {
  color: var(--text);
}

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

.window-layer {
  position: absolute;
  inset: 0 0 var(--taskbar-h) 0;
  pointer-events: none;
}

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  pointer-events: auto;
}

.window.hidden {
  display: none;
}

.window.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.window.maximized {
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0;
  border-width: 0 0 1px 0;
}

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--titlebar-h);
  padding: 0 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  cursor: grab;
  flex: 0 0 auto;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-chrome {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.window-dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.9;
}

.window-dot:hover { opacity: 1; }
.window-dot.close { background: #ff6f70; }
.window-dot.min { background: #ffcf5d; }
.window-dot.max { background: #64d2c4; }

.window-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.window-title strong {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window-title span {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.window-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
}

.window-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--surface);
}

.window-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

.window-resize::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  border-radius: 0 0 2px 0;
}

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

.taskbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--taskbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--surface) 92%, black);
  border-top: 1px solid var(--line);
  z-index: 40;
}

.start-button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  flex: 0 0 auto;
}

.start-button:hover { background: var(--surface-3); }
.start-button[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.taskbar-windows {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.taskbar-windows::-webkit-scrollbar { display: none; }

.taskbar-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 180px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.taskbar-chip:hover { background: var(--surface-3); color: var(--text); }

.taskbar-chip.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: inset 0 -2px 0 var(--accent);
}

.taskbar-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.system-user {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.system-user:hover { color: var(--text); }

.user-chip-avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
}

/* --------------------------------------------------------------- launcher */

.start-menu {
  position: absolute;
  left: 10px;
  bottom: calc(var(--taskbar-h) + 8px);
  width: 340px;
  max-height: min(460px, calc(100% - var(--taskbar-h) - 30px));
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 50;
}

.start-menu.open { display: flex; }

.start-menu header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.launcher-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
  overflow-y: auto;
}

.launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.launcher-item:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.launcher-glyph {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line);
  font-size: 18px;
}

.launcher-item small {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.2;
}

/* ----------------------------------------------------------------- toasts */

.toast-stack {
  position: absolute;
  right: 14px;
  bottom: calc(var(--taskbar-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  width: 300px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.18s ease;
}

.toast strong { display: block; font-size: 13px; margin-bottom: 2px; }
.toast span { font-size: 12px; color: var(--text-dim); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------- context menu */

.context-menu {
  position: absolute;
  min-width: 180px;
  padding: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 70;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.context-menu button:hover { background: var(--surface-3); }
.context-menu button.danger { color: var(--danger); }

/* ------------------------------------------------------------------- boot */

.boot-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-deep);
  z-index: 100;
  transition: opacity 0.35s ease;
}

.boot-screen.done {
  opacity: 0;
  pointer-events: none;
}

.boot-card {
  width: min(320px, 80vw);
  text-align: center;
}

.boot-mark {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin-bottom: 18px;
}

.boot-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.boot-progress span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--accent);
  animation: boot-slide 1.1s ease-in-out infinite;
}

@keyframes boot-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.boot-status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  min-height: 1.2em;
}

/* ---------------------------------------------------------------- sign in */

.login-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 600px at 30% 0%, rgba(111, 224, 216, 0.10), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg-deep));
  z-index: 90;
}

.login-card {
  width: min(360px, 88vw);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  text-align: center;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 0.1em;
}

.login-card p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.login-btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}

.login-btn:hover { filter: brightness(1.08); }

.login-alt {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}

.login-alt:hover { color: var(--text); border-color: var(--text-faint); }

.login-error {
  margin-top: 12px;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--danger);
}
