/* Minimal, dependency-free web "desktop"
*/

:root{
  --bg: #0b1220;
  --paper: rgba(255,255,255,0.08);
  --glass: rgba(10, 16, 28, 0.70);
  --glass-2: rgba(10, 16, 28, 0.85);
  --border: rgba(255,255,255,0.12);
  --border-2: rgba(255,255,255,0.18);
  --text: rgba(245,248,255,0.92);
  --muted: rgba(245,248,255,0.70);
  --shadow: 0 12px 30px rgba(0,0,0,0.45);
  --shadow-2: 0 18px 44px rgba(0,0,0,0.50);

  --tb-h: 44px;
  --win-radius: 12px;
  --win-min-w: 260px;
  --win-min-h: 180px;

  --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

*{ box-sizing: border-box; }
html,body{
  height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

#app{
  position: relative;
  height: 100%;
  width: 100%;
}

#desktop{
  position: relative;
  height: 100%;
  width: 100%;
}

/* #wallpaper{
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1000px 600px at 20% 10%, rgba(100, 255, 240, 0.14), transparent 60%),
    radial-gradient(900px 500px at 85% 20%, rgba(120, 150, 255, 0.16), transparent 55%),
    radial-gradient(700px 450px at 60% 85%, rgba(255, 130, 240, 0.11), transparent 55%),
    linear-gradient(145deg, rgba(7,12,24,1), rgba(9,17,33,1));
  filter: saturate(1.05) contrast(1.02);
} */

#wallpaper {
  position: absolute;
  inset: 0;
  background-image: url("assets/wallpaper.svg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.05) contrast(1.02);
}

#desktop-icons{
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  bottom: calc(var(--tb-h) + 14px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  grid-auto-rows: 96px;
  gap: 10px;
  align-content: start;
  padding-right: 40%;
  pointer-events: auto;
}

.desktop-icon{
  user-select: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 8px;
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: start;
  cursor: default;
}
.desktop-icon:focus{
  outline: none;
  border-color: var(--border-2);
  background: rgba(255,255,255,0.06);
}
.desktop-icon:hover{
  background: rgba(255,255,255,0.05);
}
.icon-glyph{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 6px 16px rgba(0,0,0,0.20);
  font-size: 20px;
}
.icon-label{
  font-size: 0.84rem;
  color: rgba(245,248,255,0.88);
  text-align: center;
  text-shadow: 0 1px 0 rgba(0,0,0,0.35);
  line-height: 1.1;
}

#window-layer{
  position: absolute;
  inset: 0;
  padding-bottom: var(--tb-h);
  pointer-events: none; /* let clicks pass through when no windows are present */
}

/* But windows themselves should be clickable */
#window-layer .wdw{
  pointer-events: auto;
}


/* Window */
.wdw{
  position: absolute;
  min-width: var(--win-min-w);
  min-height: var(--win-min-h);
  border-radius: var(--win-radius);
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: 38px 1fr;
  backdrop-filter: blur(10px);
}

.wdw.focused{
  border-color: rgba(120, 220, 255, 0.30);
  box-shadow: var(--shadow-2);
}

.wdw.maximized{
  border-radius: 0;
}

.wdw-titlebar{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 12px;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.wdw-titlebar:active{ cursor: grabbing; }

.wdw-title{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.wdw-title .glyph{
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255,255,255,0.12);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}
.wdw-title .text{
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(245,248,255,0.95);
}

.wdw-controls{
  display: inline-flex;
  gap: 6px;
}
.wbtn{
  width: 30px;
  height: 26px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.wbtn:hover{ background: rgba(255,255,255,0.10); }
.wbtn:active{ transform: translateY(1px); }
.wbtn.close:hover{ background: rgba(255,80,110,0.18); border-color: rgba(255,80,110,0.20); }

.wdw-content{
  position: relative;
  overflow: auto;
  padding: 12px;
}

/* Resizer handles */
.resizer{
  position: absolute;
  background: transparent;
  touch-action: none;
}
.resizer.n{ top: -3px; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer.s{ bottom: -3px; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer.e{ top: 10px; bottom: 10px; right: -3px; width: 6px; cursor: ew-resize; }
.resizer.w{ top: 10px; bottom: 10px; left: -3px; width: 6px; cursor: ew-resize; }
.resizer.ne{ top: -3px; right: -3px; width: 10px; height: 10px; cursor: nesw-resize; }
.resizer.nw{ top: -3px; left: -3px; width: 10px; height: 10px; cursor: nwse-resize; }
.resizer.se{ bottom: -3px; right: -3px; width: 10px; height: 10px; cursor: nwse-resize; }
.resizer.sw{ bottom: -3px; left: -3px; width: 10px; height: 10px; cursor: nesw-resize; }

/* Taskbar */
#taskbar{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--tb-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(9, 13, 22, 0.78);
  border-top: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(10px);
}

.tb-btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
}
.tb-btn:hover{ background: rgba(255,255,255,0.12); }
.tb-btn:active{ transform: translateY(1px); }
.tb-icon{ font-size: 14px; opacity: 0.95; }
.tb-label{ font-size: 0.9rem; }

#taskbar-apps{
  display: flex;
  gap: 8px;
  overflow: auto;
  scrollbar-width: none;
}
#taskbar-apps::-webkit-scrollbar{ display: none; }

.task-item{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.task-item:hover{ background: rgba(255,255,255,0.09); }
.task-item.active{
  background: rgba(120, 220, 255, 0.16);
  border-color: rgba(120, 220, 255, 0.22);
}
.task-item .g{ width: 18px; height: 18px; display: grid; place-items: center; border-radius: 6px; background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.10); font-size: 12px; }
.task-item .t{ font-size: 0.9rem; color: rgba(245,248,255,0.92); }

#tray{
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
#clock{
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: rgba(245,248,255,0.86);
  padding: 4px 4px 4px 16px;
  border-left: 2px solid rgba(255,255,255,0.10);
}

/* Start menu */
#start-menu{
  position: absolute;
  left: 10px;
  bottom: calc(var(--tb-h) + 10px);
  width: 270px;
  border-radius: 14px;
  background: var(--glass-2);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  backdrop-filter: blur(12px);
}
.menu-header{
  padding: 10px 12px;
  font-size: 0.9rem;
  color: rgba(245,248,255,0.86);
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
#start-apps{
  padding: 8px;
  display: grid;
  gap: 6px;
}
#start-actions{
  padding: 8px;
  display: grid;
  gap: 6px;
}
.menu-item{
  display: inline-flex;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.menu-item:hover{ background: rgba(255,255,255,0.10); }
.menu-sep{
  height: 1px;
  background: rgba(255,255,255,0.10);
  margin: 8px 0;
}

/* App common */
.app-card{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px;
}
.hint{
  color: var(--muted);
  font-size: 0.88rem;
}

/* Calculator */
.calc{
  display: grid;
  gap: 10px;
}
.calc-display{
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
}
.calc-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.calc-btn{
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}
.calc-btn:hover{ background: rgba(255,255,255,0.10); }
.calc-btn:active{ transform: translateY(1px); }

/* Paint */
.paint{
  display: grid;
  gap: 10px;
}
.paint-toolbar{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.paint-toolbar label{
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
  color: rgba(245,248,255,0.90);
}
.paint-canvas{
  width: 100%;
  height: 360px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  display: block;
}


/* Inline SVG icons */
.icon{
  width: 18px;
  height: 18px;
  display: block;
}
.icon-glyph .icon{ width: 22px; height: 22px; }
.wdw-title .glyph .icon{ width: 14px; height: 14px; }
.task-item .g .icon{ width: 14px; height: 14px; }



/* ================================
   Custom Scrollbars (Global)
================================ */
.wdw-content::-webkit-scrollbar {
  width: 10px;
}

.wdw-content::-webkit-scrollbar-thumb {
  background: rgba(120,220,255,0.25);
}

.wdw-content:hover::-webkit-scrollbar-thumb {
  background: rgba(120,220,255,0.55);
}

.wdw-content {
  overscroll-behavior: contain;
}



/* Context menu */
#context-menu{
  position: absolute;
  min-width: 200px;
  border-radius: 12px;
  background: rgba(10, 16, 28, 0.92);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 44px rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  padding: 6px;
  z-index: 999999; /* above windows */
}

.cm-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(245,248,255,0.92);
  cursor: pointer;
  text-align: left;
  font-size: 0.92rem;
}
.cm-item:hover{
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.10);
}
.cm-item:active{ transform: translateY(1px); }

.cm-sep{
  height: 1px;
  background: rgba(255,255,255,0.10);
  margin: 6px 4px;
}

.cm-muted{
  color: rgba(245,248,255,0.70);
  font-size: 0.82rem;
  padding: 8px 10px;
}
/* Login screen */
#desktop.locked #desktop-icons,
#desktop.locked #window-layer,
#desktop.locked #taskbar,
#desktop.locked #start-menu,
#desktop.locked #context-menu {
  visibility: hidden;
  pointer-events: none;
}

#login-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1000000;
}

#login-screen[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 90vw);
  padding: 22px;
  border-radius: 16px;
  background: rgba(10, 16, 28, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.20);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(14px);
}

.login-brand {
  color: rgba(245, 248, 255, 0.82);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.login-title {
  margin: 10px 0 16px;
  font-size: 1.65rem;
  line-height: 1.1;
}

#login-form {
  display: grid;
  gap: 12px;
}

.login-field {
  display: grid;
  gap: 6px;
}

.login-field span {
  font-size: 0.84rem;
  color: rgba(245, 248, 255, 0.80);
}

.login-field input {
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.login-field input::placeholder {
  color: rgba(245, 248, 255, 0.58);
}

.login-field input:focus {
  outline: none;
  border-color: rgba(120, 220, 255, 0.45);
  background: rgba(255, 255, 255, 0.14);
}

.login-btn,
.guest-login-btn {
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(8px);
  margin-top: 20px;
}

.login-divider {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(245, 248, 255, 0.65);
}

.login-oauth-btn {
  margin-top: 10px;
  border-radius: 7px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.oauth-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.login-oauth-btn span {
  line-height: 1;
}

.login-btn + .login-oauth-btn {
  margin-top: 10px;
}

.login-btn:hover,
.guest-login-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.login-btn:active,
.guest-login-btn:active {
  transform: translateY(1px);
}

.login-error {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.84rem;
  color: rgba(255, 132, 153, 0.96);
}

.guest-login-btn {
  position: absolute;
  left: 20px;
  bottom: 20px;
  padding: 0 14px;
}

#login-datetime {
  position: absolute;
  right: 22px;
  bottom: 18px;
  text-align: right;
  color: rgba(245, 248, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

#login-time {
  font-size: 1.6rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

#login-date {
  font-size: 0.95rem;
  opacity: 0.9;
}

@media (max-width: 600px) {
  .guest-login-btn {
    left: 14px;
    bottom: 14px;
  }

  #login-datetime {
    right: 14px;
    bottom: 12px;
  }

  #login-time {
    font-size: 1.35rem;
  }
}
