/* The desktop. Everything is hard pixels: no border-radius, no blur, no
   easing. Rounded corners are the --r* clip-paths that os/main.js defines.
   Fonts are pixel fonts and must be used at their own size:
   pxUI at 12px (labels), pxUIb at 12px (menus, titles, clock, buttons).
   Both are DePixel, which fonts.css scales so that 12px is its drawn size. */

:root {
  --ink: #2b2824;
  --g1: #f4f0e7; --g2: #e3ded3; --g3: #cdc7ba; --g4: #a39c8d; --g5: #6f695d;
  --cream: #fbf8f0;
  --pink: #f2a3bd; --pink2: #f9cfdc;
  --teal: #5fbfb3; --teal2: #b5e0d9;
  --desk-a: #a9d3cb; --desk-b: #9fccc3;
  --menubar: 24px;
  --ui: 12px pxUIb, pxA12;
  --dither: conic-gradient(var(--ink) 25%, transparent 0 50%, var(--ink) 0 75%, transparent 0) 0 0 / 2px 2px;
}

* { box-sizing: border-box; -webkit-font-smoothing: none; font-synthesis: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }

#screen {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden;
  clip-path: var(--screen);
  font: 12px pxUI; color: var(--ink); cursor: default; user-select: none; -webkit-user-select: none;
  background: var(--desk-a) conic-gradient(var(--desk-b) 25%, transparent 0 50%, var(--desk-b) 0 75%, transparent 0) 0 0 / 2px 2px;
}
#screen, #screen * { image-rendering: pixelated; }
canvas { display: block; }

/* outlined, stair-cornered boxes (see rbox in os/dom.js) */
.o { background: var(--ink); padding: 1px; }
.i { height: 100%; }

#menubar {
  position: absolute; left: 0; right: 0; top: 0; height: var(--menubar); z-index: 500;
  background: var(--g1); border-bottom: 1px solid var(--ink);
  display: flex; align-items: stretch; padding: 0 8px; font: var(--ui); white-space: nowrap;
}
.menu-title { display: flex; align-items: center; padding: 0 9px; }
#clock { margin-left: auto; display: flex; align-items: center; padding: 0 4px; font: var(--ui); }

#desktop { position: absolute; left: 0; right: 0; top: var(--menubar); bottom: 0; }
#icons { position: absolute; right: 16px; top: 16px; display: grid; gap: 20px; justify-items: center; }
.icon { display: grid; justify-items: center; gap: 4px; }
.icon span { padding: 1px 3px 0; background: var(--g1); white-space: nowrap; }
.icon.on span { background: var(--ink); color: var(--g1); }

#windows { position: absolute; inset: 0; pointer-events: none; }
#windows > * { pointer-events: auto; }
#shelf { position: absolute; left: 6px; bottom: 6px; z-index: 400; }
#overlay { position: absolute; inset: 0; z-index: 900; display: none; }

/* ---- windows ---- */
.win { position: absolute; }
.shadow { position: absolute; inset: 0; transform: translate(2px, 2px); background: var(--dither); clip-path: var(--r2); }
.frame { position: absolute; inset: 0; }
.frame > .i { background: var(--g2); padding: 3px; box-shadow: inset 1px 1px var(--g1), inset -1px -1px var(--g4); display: flex; flex-direction: column; }
.tbar { height: 23px; flex: none; margin: -2px -2px 3px; padding: 0 5px; display: flex; align-items: center; gap: 3px;
  background: var(--pink2); border-bottom: 1px solid var(--ink); box-shadow: inset 1px 1px #fff; font: var(--ui); white-space: nowrap; }
.tbar .stripes { flex: 1; min-width: 6px; align-self: stretch; margin: 6px 3px 5px; background: repeating-linear-gradient(var(--pink) 0 1px, transparent 1px 2px); }
.tbar .title { padding: 0 3px; overflow: hidden; }
.tbar-pad { width: 45px; flex: none; }
.ctl .dim { display: none; }
.win.off .tbar { background: var(--g3); color: var(--g5); box-shadow: inset 1px 1px var(--g1); }
.win.off .stripes { visibility: hidden; }
.win.off .ctl .lit { display: none; }
.win.off .ctl .dim { display: block; }
.ctl:active canvas { filter: invert(1) hue-rotate(180deg); }
.grip { position: absolute; right: 2px; bottom: 2px; width: 13px; height: 13px; cursor: nwse-resize;
  background: repeating-linear-gradient(135deg, transparent 0 2px, var(--g5) 2px 3px, var(--g1) 3px 4px) 3px 3px / 9px 9px no-repeat; }
.win.zoomed .grip, .win.zoomed .shadow { display: none; }

/* ---- shelf ---- */
.tray > .i { display: flex; gap: 3px; padding: 3px; background: var(--g2); box-shadow: inset 1px 1px var(--g1), inset -1px -1px var(--g4); }
.pill > .i { display: flex; align-items: center; gap: 6px; padding: 4px 11px 3px 8px; background: var(--g1); white-space: nowrap; max-width: 160px; overflow: hidden; }
.pill.on > .i { background: var(--teal2); }
.pill.away > .i { color: var(--g5); }
.dot { width: 7px; height: 7px; flex: none; background: var(--g4); border: 1px solid var(--ink); }
.pill.on .dot { background: var(--pink); }

/* ---- buttons, fields ---- */
.btn { height: 24px; flex: none; font: var(--ui); }
.btn > .i { background: var(--g1); padding: 4px 12px 0; box-shadow: inset -1px -1px var(--g3); white-space: nowrap; }
.btn.hot > .i { background: var(--pink2); }
.btn:active > .i { background: var(--g3); box-shadow: inset 1px 1px var(--g4); }
.btn.dim > .i { color: var(--g4); }
.field { flex: 1; min-width: 0; height: 20px; }
.field > .i { background: var(--cream); padding: 2px 5px 0; box-shadow: inset 1px 1px var(--g3); }
.field input { width: 100%; border: 0; outline: 0; padding: 0; margin: 0; background: none; color: var(--ink); font: 12px pxUI; height: 14px; user-select: text; -webkit-user-select: text; }
.field input::selection { background: var(--ink); color: var(--g1); }

/* ---- Webster ---- */
.browser { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 5px; padding: 3px 2px 4px; flex: none; white-space: nowrap; }
.row .gap { flex: 1; }
.throb { width: 40px; height: 40px; flex: none; }
.throb > .i { background: var(--teal); }
.tool { height: 40px; font: 12px pxUI; }
.tool > .i { display: grid; justify-items: center; align-content: center; gap: 1px; padding: 2px 6px 0; min-width: 50px; }
.tool.dim canvas { opacity: 0.35; }
.view { flex: 1; min-height: 0; }
.view > .i { background: #c0c0c0; position: relative; }
.view iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.status { height: 18px; flex: none; padding: 4px 4px 0; color: var(--g5); white-space: nowrap; overflow: hidden; }

/* ---- dialogs ---- */
.win.fixed .grip { display: none; }
.dialog { flex: 1; display: flex; flex-direction: column; padding: 10px 12px 8px; font: var(--ui); line-height: 16px; }
.dialog-body { flex: 1; display: flex; gap: 12px; align-items: flex-start; }
.dialog p { margin: 0 0 3px; }
.dialog-buttons { display: flex; justify-content: flex-end; }

/* ---- menus ---- */
.menu-title.on { background: var(--ink); color: var(--g1); }
.menu-title.on canvas { filter: invert(1) hue-rotate(180deg); }
#menus { position: absolute; left: 0; top: 0; z-index: 600; font: var(--ui); }
.menu { position: absolute; background: var(--g1); border: 1px solid var(--ink); padding: 2px 0; white-space: nowrap; box-shadow: 2px 2px 0 var(--g5); min-width: 120px; }
.menu-item { padding: 2px 24px 0 16px; height: 20px; position: relative; }
.menu-item:hover { background: var(--ink); color: var(--g1); }
.menu-item.off, .menu-item.off:hover { background: none; color: var(--g4); }
.menu-item.more::after { content: ''; position: absolute; right: 8px; top: 6px; width: 4px; height: 7px;
  --c: linear-gradient(currentColor, currentColor);
  background: var(--c) 0 0 / 1px 7px no-repeat, var(--c) 1px 1px / 1px 5px no-repeat, var(--c) 2px 2px / 1px 3px no-repeat, var(--c) 3px 3px / 1px 1px no-repeat; }
.menu-sep { height: 1px; margin: 3px 0; background: repeating-linear-gradient(90deg, var(--g5) 0 1px, transparent 1px 2px); }

/* ---- folder windows ---- */
.info { display: flex; justify-content: space-between; padding: 3px 7px 2px; background: var(--g2); border-bottom: 1px solid var(--g4); color: var(--g5); }
.view > .i:has(.files) { background: var(--cream); display: flex; flex-direction: column; overflow: hidden; }
.files { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 16px 22px; padding: 14px 16px; overflow: auto; }
.files .icon span { background: none; max-width: 96px; overflow: hidden; }
.files .icon.on span { background: var(--ink); color: var(--g1); }
.dialog-body canvas { flex: none; }

/* ---- power and startup ---- */
#power { position: absolute; inset: 0; z-index: 1000; display: grid; place-items: center; text-align: center; }
#power.on { display: none; }
#power.off { background: #000; color: var(--g4); }
#power.boot { background: var(--g2); }
.power-off p { margin: 0 0 12px; }
.booting p { margin: 10px 0 12px; font: var(--ui); }
.booting p.small { font: 12px pxUI; color: var(--g5); margin-top: 8px; }
.boot-logo { width: 56px; height: 56px; margin: 0 auto; }
.meter { width: 160px; height: 10px; margin: 0 auto; border: 1px solid var(--ink); background: var(--cream); position: relative; overflow: hidden; }
.meter::after { content: ''; position: absolute; inset: 0; background: var(--teal); transform-origin: 0 0; animation: fill 3s steps(16) forwards; }
.dialog .meter { margin: 8px 0 0; width: 100%; }
.dialog .meter::after { animation-duration: 4s; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.win.modal .ctl { visibility: hidden; }

/* ---- sound switch in the menu bar ---- */
#sound { display: flex; align-items: center; padding: 0 6px; margin-left: auto; }
#sound + #clock { margin-left: 0; }
#sound .quiet, #sound.muted .loud { display: none; }
#sound.muted .quiet { display: block; }

/* ---- Appearance window ---- */
.theme-list { margin-top: 6px; }
.theme-row { display: flex; align-items: center; gap: 8px; height: 26px; }
.radio { width: 11px; height: 11px; flex: none; background: var(--cream); border: 1px solid var(--ink); clip-path: var(--r2); }
.theme-row.on .radio { background: var(--ink); box-shadow: inset 0 0 0 2px var(--cream); }
.chips { display: flex; border: 1px solid var(--ink); }
.chips i { width: 12px; height: 12px; }

/* ==== Cupertino: black and white, pinstripes, boxes at both ends ==== */
[data-theme="cupertino"] {
  --ink: #000; --g1: #fff; --g2: #eee; --g3: #ccc; --g4: #999; --g5: #555; --cream: #fff;
  --pink: #000; --pink2: #fff; --teal: #9999cc; --teal2: #ccccff;
  --desk-a: #c6c6c6; --desk-b: #7b7b7b;
}
[data-theme="cupertino"] .tbar { box-shadow: none; gap: 4px; }
[data-theme="cupertino"] .tbar .stripes { margin: 5px 1px 5px; }
[data-theme="cupertino"] .ctl canvas, [data-theme="redmond"] .ctl canvas { display: none; }
[data-theme="cupertino"] .ctl { width: 11px; height: 11px; flex: none; border: 1px solid #000; background: #fff; position: relative; }
[data-theme="cupertino"] .ctl:active { background: #000; }
[data-theme="cupertino"] .ctl[data-act="close"] { order: -2; }
[data-theme="cupertino"] .tbar-pad { order: -1; width: 15px; }
[data-theme="cupertino"] .ctl[data-act="min"] { order: 5; }
[data-theme="cupertino"] .ctl[data-act="zoom"] { order: 6; }
[data-theme="cupertino"] .ctl[data-act="min"]::after { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: #000; }
[data-theme="cupertino"] .ctl[data-act="zoom"]::after { content: ''; position: absolute; left: 0; top: 0; width: 6px; height: 6px; border: solid #000; border-width: 0 1px 1px 0; }
[data-theme="cupertino"] .win.off .tbar { background: #fff; color: #999; }
[data-theme="cupertino"] .win.off .ctl { visibility: hidden; }
[data-theme="cupertino"] .btn.hot > .i { box-shadow: inset 0 0 0 1px #000; }

/* ==== Redmond: grey bevels, a navy title bar, buttons at the right ==== */
[data-theme="redmond"] {
  --ink: #000; --g1: #fff; --g2: #c0c0c0; --g3: #c0c0c0; --g4: #808080; --g5: #404040; --cream: #fff;
  --pink: #000080; --pink2: #c0c0c0; --teal: #000080; --teal2: #fff;
  --desk-a: #008080; --desk-b: #008080;
  --ui: 12px pxA12;
  --bevel: inset -1px -1px #000, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
}
[data-theme="redmond"] #screen { --r1: none; --r2: none; --r3: none; --r3t: none; --r2b: none; }
[data-theme="redmond"] .shadow { display: none; }
[data-theme="redmond"] #menubar, [data-theme="redmond"] .menu { background: #c0c0c0; }
[data-theme="redmond"] #menubar { box-shadow: inset 0 1px #fff; }
[data-theme="redmond"] .menu { box-shadow: inset 1px 1px #fff, inset -1px -1px #808080, 1px 1px 0 #000; border-color: #c0c0c0 #000 #000 #c0c0c0; }
[data-theme="redmond"] .menu-title.on, [data-theme="redmond"] .menu-item:hover { background: #000080; color: #fff; }
[data-theme="redmond"] .menu-item.off, [data-theme="redmond"] .menu-item.off:hover { background: none; color: #808080; }
[data-theme="redmond"] .tbar { background: #000080; color: #fff; font-weight: bold; box-shadow: none; border-bottom: 0; height: 20px; padding: 0 2px 0 4px; gap: 0; margin: -1px -1px 3px; }
[data-theme="redmond"] .tbar .stripes { background: none; margin: 0; min-width: 0; }
[data-theme="redmond"] .tbar .stripes:first-of-type, [data-theme="redmond"] .tbar-pad { display: none; }
[data-theme="redmond"] .tbar .title { order: -1; padding: 1px 0 0; }
[data-theme="redmond"] .win.off .tbar { background: #808080; color: #c0c0c0; }
[data-theme="redmond"] .ctl { width: 16px; height: 14px; flex: none; order: 5; background: #c0c0c0; box-shadow: var(--bevel); position: relative; }
[data-theme="redmond"] .ctl[data-act="close"] { order: 6; margin-left: 2px; }
[data-theme="redmond"] .ctl:active { box-shadow: inset 1px 1px #000, inset -1px -1px #fff, inset 2px 2px #808080; }
[data-theme="redmond"] .ctl::after { content: ''; position: absolute; background: #000; }
[data-theme="redmond"] .ctl[data-act="min"]::after { left: 4px; top: 9px; width: 6px; height: 2px; }
[data-theme="redmond"] .ctl[data-act="zoom"]::after { left: 3px; top: 2px; width: 9px; height: 9px; background: none; border: 1px solid #000; border-top-width: 2px; }
[data-theme="redmond"] .ctl[data-act="close"]::after { left: 4px; top: 3px; width: 2px; height: 1px;
  box-shadow: 6px 0 #000, 1px 1px #000, 5px 1px #000, 2px 2px #000, 4px 2px #000, 3px 3px #000, 2px 4px #000, 4px 4px #000, 1px 5px #000, 5px 5px #000, 0 6px #000, 6px 6px #000; }
[data-theme="redmond"] .btn > .i, [data-theme="redmond"] .btn.hot > .i, [data-theme="redmond"] .pill > .i { background: #c0c0c0; box-shadow: inset 1px 1px #fff, inset -1px -1px #808080; }
[data-theme="redmond"] .btn:active > .i, [data-theme="redmond"] .pill.on > .i { box-shadow: inset 1px 1px #808080, inset -1px -1px #fff; }
[data-theme="redmond"] .pill.on > .i { background: #fff conic-gradient(#c0c0c0 25%, transparent 0 50%, #c0c0c0 0 75%, transparent 0) 0 0 / 2px 2px; }
[data-theme="redmond"] .throb > .i { background: #c0c0c0; }
[data-theme="redmond"] #icons .icon span { background: none; color: #fff; }
[data-theme="redmond"] #icons .icon.on span { background: #000080; }

/* --- the phone screen (os/phone.js) ---
   A reflective LCD: one flat green, and dark pixels. Everything is measured in
   display pixels; --n is how many real pixels each one takes. */
#screen[hidden] { display: none; }
.lcd {
  --n: 3; --p: calc(var(--n) * 1px); --lcd: #8fae5c; --ink: #1c2613;
  position: fixed; inset: 0; box-sizing: border-box; background: var(--lcd); color: var(--ink);
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 18px);
  font: calc(var(--n) * 12px) / calc(var(--p) * 14) pxUIb, monospace; -webkit-font-smoothing: none;
  user-select: none; -webkit-user-select: none; -webkit-text-size-adjust: none;
  /* the glass sits a little below the phone's case */
  box-shadow: inset 0 5px 10px -4px #0006, inset 0 0 30px #0000001f;
}
.lcd-panel { position: relative; width: 100%; width: round(down, 100%, var(--p)); height: 100%; height: round(down, 100%, var(--p)); }
.lcd-glass {
  display: flex; flex-direction: column; overflow: hidden; height: 100%;
  /* each dark pixel throws a soft shadow on the reflector behind the glass */
  filter: drop-shadow(calc(var(--p) / 3) calc(var(--p) / 3) 0 #1c26132e);
}
/* The gaps between pixels: hairlines of the bare display colour, seen wherever pixels are dark. */
.lcd-panel::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(var(--lcd) 0.5px, #0000 0) 0 0 / var(--p) var(--p),
              linear-gradient(90deg, var(--lcd) 0.5px, #0000 0) 0 0 / var(--p) var(--p);
}
.lcd p { margin: 0; }
.lcd-status { display: flex; justify-content: space-between; align-items: flex-end; flex: none; height: calc(var(--p) * 8); margin-bottom: calc(var(--p) * 6); }
.lcd-head { display: flex; align-items: center; flex: none; gap: calc(var(--p) * 4); padding-bottom: calc(var(--p) * 3); margin-bottom: calc(var(--p) * 3); border-bottom: var(--p) solid var(--ink); }
.lcd-bitmap { position: relative; flex: none; width: calc(var(--w) * var(--p)); height: calc(var(--h) * var(--p)); }
.lcd-blink { animation: lcd-blink 1.6s infinite; }
.lcd-bitmap i { position: absolute; left: calc(var(--x) * var(--p)); top: calc(var(--y) * var(--p)); width: var(--p); height: var(--p); background: var(--ink); }
/* liquid crystal is slow: it fades out and in rather than snapping */
@keyframes lcd-blink { 0%, 55% { opacity: 1; } 65%, 90% { opacity: 0; } 100% { opacity: 1; } }
.lcd-from, .lcd-date { flex: none; font-family: pxUI, monospace; }
.lcd-from { margin-bottom: calc(var(--p) * 3) !important; }
.lcd-text { flex: 1 0 auto; }
.lcd-date { margin: calc(var(--p) * 3) 0 !important; }
.lcd-key { flex: none; align-self: flex-start; padding: var(--p) calc(var(--p) * 6) 0; border-top: var(--p) solid var(--ink);
  margin-left: round(down, calc(50% - var(--p) * 14), var(--p)); }
@media (prefers-reduced-motion: reduce) { .lcd-blink { animation: none; } }
