/* 系统界面：开机、墙纸、桌面、窗口、任务栏、开始菜单、右键菜单、toast */

.scene { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- 开机 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 3000;
  display: grid; place-items: center;
  background: var(--night);
  transition: opacity .5s var(--ease);
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot__inner { width: min(360px, 86vw); display: grid; justify-items: center; gap: 12px; }
.boot__st { height: 150px; animation: hop 1.1s steps(2) infinite; filter: drop-shadow(0 8px 0 #0006); }
.boot__name { font-size: 48px; line-height: 1; color: var(--stitch-hi); text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 var(--ear); }
.boot__ver { color: var(--ear); }
.boot__bar { width: 100%; height: 12px; margin: 6px 0; background: var(--ink); position: relative; }
.boot__bar::after {
  content: ''; position: absolute; inset: 0; width: calc(var(--p, 0) * 100%);
  background: repeating-linear-gradient(90deg, var(--stitch) 0 9px, var(--stitch-hi) 9px 12px);
  transition: width .3s steps(4);
}
.boot__log { width: 100%; min-height: calc(8 * 24px); color: var(--stitch-hi); }
.boot__log li { animation: rise .25s steps(3) both; }
.boot__log li:last-child { color: var(--sun); }
.boot__skip { color: var(--dim); animation: blink 1.2s steps(1) infinite; }

/* ---------- 桌面 ---------- */
.desk { position: fixed; inset: 0 0 var(--bar-h) 0; }
.hero {
  position: absolute; top: 13vh; left: max(330px, 24vw); pointer-events: none; /* 留出最多三列桌面图标 */
  opacity: 0; transform: translateY(12px);
  transition: opacity .8s var(--ease) .2s, transform .8s var(--ease) .2s;
}
.is-on .hero { opacity: 1; transform: none; }
.hero__kicker { color: var(--sand); letter-spacing: .2em; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); }
.hero__title { font-size: 48px; line-height: 1.25; margin: 12px 0; text-shadow: 3px 3px 0 var(--stitch), 6px 6px 0 var(--ink); }
.hero__sub { color: var(--stitch-hi); line-height: 24px; text-shadow: 1px 1px 0 var(--ink); }

.icons {
  position: absolute; top: 12px; left: 10px; bottom: 12px;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 84px); gap: 4px 6px;
}
.icon {
  width: 92px; height: 84px; padding: 6px 2px;
  display: grid; justify-items: center; align-content: start; gap: 4px;
  background: none; border: 0;
  opacity: 0; transform: translateX(-12px);
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.is-on .icon { opacity: 1; transform: none; }
.icon canvas { width: 40px; height: 40px; filter: drop-shadow(3px 3px 0 #0008); }
.icon span { padding: 0 4px; line-height: 18px; text-align: center; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); }
.icon:hover span, .icon:focus-visible span { background: var(--stitch); text-shadow: none; }
.icon:hover canvas { animation: hop .5s steps(2) infinite; }
.icon.is-kicked { animation: kick .7s var(--pop); }
@keyframes kick { 20% { transform: translate(8px, -10px) rotate(14deg); } 45% { transform: translate(-6px, 0) rotate(-10deg); } 70% { transform: rotate(5deg); } }

/* ---------- 窗口 ---------- */
.wins { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.win {
  --pf-extra: 0 24px 60px -12px #00030ecc;
  position: absolute; top: 0; left: 0;
  width: min(var(--w, 440px), calc(100vw - 24px));
  max-height: calc(100vh - var(--bar-h) - 24px);
  display: flex; flex-direction: column;
  background: var(--panel); pointer-events: auto;
  animation: pop .22s steps(4) both;
}
.win.has-h { height: min(var(--h), calc(100vh - var(--bar-h) - 24px)); }
.win.is-active { --pf: var(--sun); }
.win:focus { outline: none; }
.win.is-max { left: 8px !important; top: 8px !important; width: calc(100vw - 16px); height: calc(100vh - var(--bar-h) - 16px); max-height: none; }
.win.is-chewed { animation: chew .3s steps(2) 3; }
@keyframes chew { 50% { transform: translateY(3px) rotate(.6deg); } }
.win__bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  height: 32px; padding: 0 6px 0 8px;
  background: repeating-linear-gradient(0deg, var(--panel-2) 0 3px, var(--panel) 3px 6px);
  cursor: grab; touch-action: none; user-select: none;
}
.win.is-active .win__bar { background: repeating-linear-gradient(0deg, var(--stitch) 0 3px, #3a6ad8 3px 6px); }
.win.is-drag .win__bar { cursor: grabbing; }
.win__ic { width: 24px; height: 24px; }
.win__title { flex: 1; font-size: 12px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 var(--ink); }
.win__btns { display: flex; gap: 6px; }
.win__btn { width: 22px; height: 22px; padding: 0; line-height: 18px; border: 2px solid var(--ink); background: var(--sand); color: var(--ink); }
.win__btn:hover { background: var(--sun); }
.win__btn--close:hover { background: var(--hibiscus); color: #fff; }
.win__body { flex: 1; min-height: 0; padding: 16px 18px 18px; overflow: auto; scrollbar-color: var(--stitch) var(--panel); position: relative; }
.win__body h3 { margin: 18px 0 8px; font-size: 12px; font-weight: normal; color: var(--sun); }
.win__body h3::before { content: '▸ '; }

/* ---------- 任务栏 ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: var(--bar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 10px;
  background: linear-gradient(#141d55f2, #070b28fa);
  box-shadow: 0 -2px 0 #ffc94a80, 0 -4px 0 #0006;
  transform: translateY(110%); transition: transform .45s var(--ease) .1s;
}
.is-on .taskbar { transform: none; }
.start-btn {
  --pf: var(--ink);
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 4px; border: 0;
  background: var(--stitch); color: var(--sand);
}
.start-btn img { height: 30px; margin-top: -6px; }
.start-btn:hover, .start-btn[aria-expanded="true"] { background: var(--sun); color: var(--ink); }
.tasks { flex: 1; display: flex; gap: 10px; min-width: 0; overflow-x: auto; padding: 4px; scrollbar-width: none; }
.task { --pf: var(--line); display: flex; align-items: center; gap: 6px; max-width: 170px; height: 28px; padding: 0 10px 0 6px; border: 0; background: var(--panel-2); flex: none; }
.task canvas { width: 18px; height: 18px; flex: none; }
.task span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task[aria-pressed="true"] { --pf: var(--sun); background: var(--stitch); }
.tray { display: flex; align-items: center; gap: 12px; }
.tray__sound { width: 28px; height: 28px; border: 2px solid var(--line); background: var(--panel-2); line-height: 22px; padding: 0; }
.tray__sound[aria-pressed="false"] { color: var(--hibiscus); }
.clock { display: grid; text-align: right; line-height: 16px; }
.clock span { color: var(--dim); }

/* ---------- 开始菜单 / 右键菜单 ---------- */
.start {
  --pf: var(--sun); --pf-extra: 0 24px 60px -12px #00030ecc;
  position: fixed; left: 10px; bottom: calc(var(--bar-h) + 12px); z-index: 1100;
  width: 300px; background: var(--panel); animation: pop .18s steps(3) both;
}
.start__head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: repeating-linear-gradient(0deg, var(--stitch) 0 3px, #3a6ad8 3px 6px); }
.start__avatar { height: 64px; margin: -22px 0 -4px; filter: drop-shadow(2px 2px 0 var(--ink)); }
.start__name { font-size: 24px; line-height: 1.2; text-shadow: 2px 2px 0 var(--ink); }
.start__motto { color: var(--ink); }
.start__apps { padding: 8px; display: grid; grid-template-columns: 1fr 1fr; max-height: 50vh; overflow: auto; }
.start__app { width: 100%; display: flex; align-items: center; gap: 8px; padding: 3px 6px; border: 0; background: none; text-align: left; }
.start__app:hover, .start__app:focus-visible { background: var(--stitch); }
.start__app canvas { width: 24px; height: 24px; flex: none; }
.start__foot { display: flex; justify-content: flex-end; gap: 12px; padding: 10px 12px 12px; border-top: 2px solid var(--line); }

.ctx { --pf: var(--sand); position: fixed; z-index: 1200; display: grid; min-width: 180px; padding: 4px; background: var(--panel); animation: pop .12s steps(2) both; }
.ctx__item { border: 0; background: none; text-align: left; padding: 2px 10px; }
.ctx__item:hover, .ctx__item:focus-visible { background: var(--stitch); outline: none; }

.toasts { position: fixed; right: 14px; top: 14px; z-index: 2500; display: grid; gap: 14px; width: min(320px, calc(100vw - 28px)); pointer-events: none; }
.toast { --pf: var(--ink); display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; background: var(--sand); color: var(--ink); line-height: 20px; animation: toast-in .35s var(--pop) both; }
.toast img { height: 44px; flex: none; }
.toast.is-out { opacity: 0; transform: translateX(20px); transition: all .35s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 4000; background: var(--night); }

/* ---------- 手机 ---------- */
@media (max-width: 720px) {
  .icons { bottom: auto; right: 6px; left: 6px; top: 6px; grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); }
  .icon { width: auto; height: 74px; }
  .icon canvas { width: 32px; height: 32px; }
  .icon span { font-size: 12px; white-space: nowrap; }
  .hero { display: none; }
  .win, .win.has-h { left: 6px !important; top: 6px !important; width: calc(100vw - 12px); height: calc(100vh - var(--bar-h) - 12px); max-height: none; }
  .win__btn[data-act="max"] { display: none; }
  .clock span { display: none; }
  .start { left: 6px; right: 6px; width: auto; }
}
