/* ===================================================================
   desktop.css - wallpaper, desktop icons, start menu, boot + login,
   the Clippy agent, toast popups.
   =================================================================== */

#desktop {
  position: fixed; inset: 0 0 calc(34px + env(safe-area-inset-bottom, 0px)) 0;
  /* wallpaper on top, bliss gradient as fallback layer behind it */
  background:
    url("../assets/icons/clippy-x-banner.jpg") center center / cover no-repeat,
    linear-gradient(180deg,#4b91dd 0%, #78b3e8 45%, #6cb33f 62%, #4e9b2e 100%);
  overflow: hidden;
}
/* hide the desktop + taskbar until the user logs in */
body.booting #desktop,
body.booting #taskbar { display: none; }

/* ---------- Desktop icons ---------- */
#deskicons {
  position: absolute; top: 12px; left: 12px;
  display: flex; flex-direction: column; flex-wrap: wrap;
  gap: 2px; max-height: calc(100vh - 80px);
}
.deskicon {
  width: 78px; padding: 6px 4px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,.9);
  border: 1px solid transparent; border-radius: 3px;
  font-size: 11px; line-height: 1.15;
}
.deskicon .glyph {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 30px;
  filter: drop-shadow(1px 2px 2px rgba(0,0,0,.5));
}
.deskicon .glyph img { width: 40px; height: 40px; object-fit: contain; border-radius: 4px; }
.deskicon .label { max-width: 74px; }
.deskicon:hover { background: rgba(60,120,220,.28); border-color: rgba(140,180,240,.5); }
.deskicon.selected { background: rgba(60,120,220,.45); border-color: rgba(160,190,240,.7); }
.deskicon.selected .glyph { filter: drop-shadow(1px 2px 2px rgba(0,0,0,.5)) brightness(1.1) saturate(1.2); }

/* ---------- Start menu ---------- */
#startmenu {
  position: fixed; left: 0; bottom: 34px;
  width: 340px;
  background: #fff;
  border: 1px solid #0831d9; border-bottom: none;
  border-radius: 8px 8px 0 0;
  box-shadow: 4px -2px 16px rgba(0,0,0,.4);
  z-index: 9500;
  display: none; flex-direction: column;
  overflow: hidden;
}
#startmenu.open { display: flex; animation: startpop .12s ease-out; }
@keyframes startpop { from { transform: translateY(12px); opacity: .4; } to { transform: none; opacity: 1; } }

.start-header {
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: linear-gradient(180deg,#1f6fe5 0%, #2a7bef 45%, #1a5fd6 100%);
  color: #fff; font-weight: bold; font-size: 15px;
  border-bottom: 2px solid #eeb314;
  text-shadow: 1px 1px 2px rgba(0,0,0,.5);
}
.start-header img { width: 38px; height: 38px; border-radius: 4px; border: 2px solid #fff6; }

.start-cols { display: flex; }
.start-left { flex: 1.35; background: #fff; padding: 6px 4px; }
.start-right {
  flex: 1; padding: 6px 4px;
  background: linear-gradient(180deg,#d3e5fa 0%, #cfe0f7 100%);
  border-left: 1px solid #aac6ef;
}
.startitem {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: 3px; font-size: 12px;
}
.startitem .si-ico { width: 24px; height: 24px; display: grid; place-items: center; font-size: 19px; flex: 0 0 auto; }
.startitem .si-ico img { width: 24px; height: 24px; object-fit: contain; border-radius: 3px; }
.startitem b { font-size: 12px; }
.startitem small { display: block; color: #4b5563; font-size: 10.5px; }
.startitem:hover { background: #2f6fdd; color: #fff; }
.startitem:hover small { color: #dbe8ff; }
.start-right .startitem { font-weight: bold; }
.start-sep { height: 1px; background: #cdd7e6; margin: 5px 10px; }

.start-footer {
  height: 42px; display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  padding: 0 16px;
  background: linear-gradient(180deg,#3f8cf3 0%, #245edb 45%, #1a52cf 100%);
  border-top: 1px solid #eeb314;
}
.start-footer .sf-item { display: flex; align-items: center; gap: 6px; color: #fff; font-size: 12px; text-shadow: 1px 1px 1px rgba(0,0,0,.4); }
.start-footer .sf-item .sf-ico { width: 24px; height: 22px; border-radius: 3px; display: grid; place-items: center; font-size: 14px; background: linear-gradient(180deg,#e15a3a,#c62d18); box-shadow: inset 0 1px 0 #ffae95; }
.start-footer .sf-item.by .sf-ico { background: linear-gradient(180deg,#5aa733,#3d8113); }

/* ---------- Boot + login screens ---------- */
#boot, #login {
  position: fixed; inset: 0; z-index: 99999;
  display: grid; place-items: center;
  color: #fff; font-family: var(--tahoma);
}
#boot { background: #000; }
.boot-inner { text-align: center; }
.boot-logo { font-size: 42px; font-weight: 300; letter-spacing: .5px; }
.boot-logo b { font-weight: 700; }
.boot-logo .flag { display: inline-block; vertical-align: middle; margin-right: 14px; }
.boot-sub { margin-top: 6px; color: #9fb4d8; font-size: 14px; }
.boot-bar {
  margin: 34px auto 0; width: 200px; height: 16px;
  border: 2px solid #2a5aa0; border-radius: 9px; overflow: hidden;
  background: #0a1730;
}
.boot-bar i {
  display: block; width: 42px; height: 100%;
  background: linear-gradient(90deg,transparent, #4f8cf5, #7fb0ff, #4f8cf5, transparent);
  animation: bootslide 1.15s linear infinite;
}
@keyframes bootslide { from { transform: translateX(-46px); } to { transform: translateX(210px); } }
.boot-copy { position: absolute; bottom: 26px; width: 100%; text-align: center; color: #7d93bb; font-size: 12px; }

/* Login (welcome) */
#login {
  background: linear-gradient(180deg,#5b7fc7 0%, #2d5aa8 50%, #16408e 100%);
}
.login-topbar, .login-botbar { position: absolute; left: 0; width: 100%; height: 62px; }
.login-topbar { top: 0; background: linear-gradient(180deg,#2a5aa8,#1a4894); box-shadow: 0 3px 8px rgba(0,0,0,.3); border-bottom: 2px solid #f7b500; }
.login-botbar { bottom: 0; background: linear-gradient(180deg,#1a4894,#0f367a); box-shadow: 0 -3px 8px rgba(0,0,0,.3); border-top: 2px solid #f7b500; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; color: #cfe0ff; font-size: 12px; }
.login-split { width: 100%; max-width: 760px; display: flex; align-items: center; }
.login-left { flex: 1; text-align: right; padding-right: 34px; border-right: 1px solid #6f93cf; }
.login-left .logo { font-size: 30px; font-weight: 300; }
.login-left .logo b { font-weight: 700; }
.login-left .tip { margin-top: 10px; color: #cfe0ff; font-size: 13px; max-width: 300px; margin-left: auto; }
.login-right { flex: 1; padding-left: 34px; }
.login-user {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 8px 12px; border-radius: 6px; margin-bottom: 12px;
}
.login-user:hover, .login-user.sel { background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px #ffffff44; }
.login-user img { width: 56px; height: 56px; border-radius: 6px; border: 2px solid #fff; background: #fff; object-fit: cover; flex: 0 0 auto; }
.login-user .u-info { flex: 1; }
.login-user .u-name { font-size: 20px; font-weight: 600; line-height: 1; padding-top: 4px; }
.login-user .u-hint { font-size: 11.5px; color: #cfe0ff; margin-top: 7px; }
.login-user .u-hint.bad { color: #ffd27a; }

/* XP password field (revealed when the tile is selected) */
.u-pass { display: none; align-items: center; gap: 6px; margin-top: 8px; }
.login-user.sel .u-pass { display: flex; }
.u-pass .lock { font-size: 13px; }
.u-pass input {
  flex: 1; max-width: 190px; padding: 4px 8px; cursor: text;
  border: 1px solid #7f9db9; border-radius: 3px;
  font-size: 14px; background: #fff; color: #111; font-family: var(--tahoma);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,.15);
}
.u-pass .pass-go {
  width: 27px; height: 27px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid #2c7a2c; color: #fff; font-weight: bold; font-size: 16px;
  display: grid; place-items: center;
  background: linear-gradient(180deg,#7ed957,#3d9e1e);
  box-shadow: inset 0 1px 0 #b6f09a;
}
.u-pass .pass-go:hover { background: linear-gradient(180deg,#8ee76a,#46b023); }
.u-pass .pass-go:active { background: linear-gradient(180deg,#3d9e1e,#2c7a1a); }
.login-user.shake { animation: shakex .38s; }
@keyframes shakex { 0%,100%{transform:translateX(0)} 18%{transform:translateX(-7px)} 38%{transform:translateX(7px)} 58%{transform:translateX(-5px)} 78%{transform:translateX(4px)} }
.login-flag { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 22px; height: 20px; vertical-align: middle; }
.login-flag i { border-radius: 2px; }

/* ---------- Toast popups ---------- */
#toasts { position: fixed; right: 12px; top: 12px; z-index: 9600; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  width: 300px;
  background: linear-gradient(180deg,#fffef2,#f4f1df);
  border: 1px solid #d8b34a; border-radius: 7px;
  box-shadow: 3px 3px 12px rgba(0,0,0,.35);
  overflow: hidden;
  animation: toastin .28s ease-out;
}
@keyframes toastin { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast .t-head { display: flex; align-items: center; gap: 7px; padding: 5px 8px; background: linear-gradient(180deg,#2a7bef,#1550c8); color: #fff; font-weight: bold; font-size: 12px; }
.toast .t-head .t-x { margin-left: auto; width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid #fff; border-radius: 3px; font-size: 10px; }
.toast .t-body { padding: 9px 11px; font-size: 12px; color: #222; line-height: 1.45; }
.toast .t-body b { color: #b4400f; }

/* balloon tail for systray notifications */
.toast.balloon { border-radius: 10px; }
.toast.balloon::after { content: ""; position: absolute; }

/* ---------- Clippy agent ---------- */
#clippy-agent {
  position: fixed; right: 18px; bottom: 40px; z-index: 9400;
  width: 96px; text-align: center;
}
/* transparent PNG: size by height, keep aspect, real drop-shadow (no box) */
#clippy-agent img { height: 150px; width: auto; filter: drop-shadow(2px 5px 5px rgba(0,0,0,.4)); animation: clippyidle 3.4s ease-in-out infinite; }
@keyframes clippyidle { 0%,100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-4px) rotate(-2deg); } 60% { transform: translateY(-1px) rotate(1.5deg); } }
#clippy-agent.talking img { animation: clippytalk .5s ease-in-out infinite; }
@keyframes clippytalk { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-3px) rotate(2deg); } }

.clippy-bubble {
  position: fixed; right: 150px; bottom: 96px; z-index: 9400;
  width: 268px;
  background: #fffde7;
  border: 1px solid #b7a838;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px; line-height: 1.5; color: #222;
  box-shadow: 3px 3px 12px rgba(0,0,0,.32);
  display: none;
}
.clippy-bubble.show { display: block; animation: toastin .2s ease-out; }
.clippy-bubble::after {
  content: ""; position: absolute; right: -14px; bottom: 22px;
  border: 9px solid transparent; border-left-color: #fffde7;
  filter: drop-shadow(1px 0 0 #b7a838);
}
.clippy-bubble .cb-actions { display: flex; gap: 6px; margin-top: 10px; }
.clippy-bubble .cb-actions .xp-btn { min-width: auto; font-size: 11px; padding: 2px 10px; }
.clippy-bubble .cb-close { position: absolute; top: 4px; right: 6px; font-size: 12px; color: #888; }

/* ---------- context menu ---------- */
#ctxmenu {
  position: fixed; z-index: 9700; min-width: 180px;
  background: #f6f5ee; border: 1px solid #808080;
  box-shadow: 3px 3px 8px rgba(0,0,0,.35);
  padding: 2px; display: none; font-size: 12px;
}
#ctxmenu.open { display: block; }
#ctxmenu .ctxitem { padding: 4px 22px 4px 26px; border-radius: 2px; }
#ctxmenu .ctxitem:hover { background: #316ac5; color: #fff; }
#ctxmenu .ctxsep { height: 1px; background: #c8c4b6; margin: 3px 6px; }

/* =================== MOBILE =================== */
@media (max-width: 680px) {
  /* wallpaper: the wide banner zooms hideously in portrait and any framed
     photo shows a box, so use a clean Bliss-style gradient on mobile */
  #desktop {
    background: linear-gradient(180deg,
      #4d90e0 0%, #5f9fdc 22%, #86bbe6 42%, #b6d7ec 50%,
      #cfe3ae 55%, #8dc153 61%, #64a63a 74%, #4c8a2c 100%);
  }

  /* login: stack into a single centred column so nothing clips off-screen */
  #login .login-split { flex-direction: column; max-width: 340px; align-items: stretch; }
  #login .login-left {
    border-right: none; border-bottom: 1px solid #6f93cf;
    text-align: center; padding: 0 0 16px; margin-bottom: 16px;
  }
  #login .login-left .tip { margin: 10px auto 0; max-width: none; }
  #login .login-right { padding-left: 0; }
  #login .login-user { gap: 10px; }
  #login .login-user img,
  #login .login-user > div[style] { width: 46px !important; height: 46px !important; }
  #login .u-name { font-size: 17px; }
  .u-pass input { max-width: none; }
  #login .login-botbar { font-size: 11px; padding: 0 12px; gap: 8px; }
  #login .login-botbar span:last-child { display: none; }

  /* start menu + bubble + agent */
  .start-cols { flex-direction: column; }
  #startmenu { width: 92vw; max-width: 360px; }
  .clippy-bubble { right: 10px; left: 10px; width: auto; bottom: 132px; font-size: 13px; }
  .clippy-bubble::after { display: none; }
  #clippy-agent { right: 6px; bottom: 40px; width: 72px; }
  #clippy-agent img { height: 108px; width: auto; }

  /* toasts fit the screen */
  #toasts { left: 10px; right: 10px; align-items: stretch; }
  #toasts .toast { width: auto; max-width: none; }

  /* taskbar buttons shrink so multiple windows never overflow the bar */
  #taskbtns .taskbtn { min-width: 0; flex: 1 1 0; max-width: 160px; padding: 0 6px; }
  #systray { padding: 0 6px; gap: 5px; }
  #systray .tray-ico[title="Network"] { display: none; }
  .start-btn { font-size: 15px; padding: 0 12px 0 8px; }

  /* bigger tap targets for the window min/max/close on touch */
  .titlebar { height: 34px; }
  .titlebar-btn { width: 30px; height: 27px; font-size: 15px; }
  .titlebar .tbbtns { gap: 3px; }
}

/* very small phones */
@media (max-width: 380px) {
  .deskicon { width: 70px; }
  #clippy-agent { width: 64px; }
  #clippy-agent img { height: 92px; width: auto; }
}
