/* Micropigs lab: pinks, black and white. Ink windows (decided). */
:root {
  --k: #000000;
  --w: #ffffff;
  --p0: #fff0f6;
  --p1: #ffe1ec;
  --p2: #ffbad4;
  --p3: #ff5f98;
  --p4: #c42f6c;
  --p5: #6e1238;
  --bar-dim: #3a0b22;
  --accent: #ff2e7e;

  /* Pixel faces only at their native size: one font pixel per CSS pixel. */
  --font: 'Jersey 15', monospace;
  --fs: 15px;
  --lh: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  font-weight: 400;
  font-synthesis: none;
  font-variant-ligatures: none;
  font-kerning: none;
  color: var(--k);
  background: var(--p1) radial-gradient(circle, rgba(0,0,0,.18) 1px, transparent 1.5px) 0 0 / 12px 12px;
  overflow: hidden;
  -webkit-font-smoothing: none;
}
button { font: inherit; color: inherit; line-height: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- desktop ---------- */
.desktop { position: absolute; inset: 0 0 36px 0; overflow: hidden; }

.taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 36px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 8px;
  background: var(--k); color: var(--p2);
  border-top: 2px solid var(--p3);
}
/* The logo: img/logo.png (rendered by lab/scripts/logo.html), one logo pixel per
   CSS pixel, kept hard by image-rendering. It sits on the desktop over the left
   end of the top bar (x 240, y 16, 48 tall): the bar starts behind the S, where
   the logo covers its full height, so its left edge, corners and shadow are
   hidden and it seems to come out of the logo. Taller than the bar, it sticks out above and below.
   Above the main windows, under floating ones. */
.brand-logo {
  position: absolute; left: 16px; top: 11px; z-index: 4000;
  width: 258px; height: 59px;
  image-rendering: pixelated;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
/* The bar's content starts just right of the logo (16 + 258 + 14, less the
   bar's x and border). */
.win-top .top { padding-left: 46px; }
.tasks { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.task {
  background: transparent; color: var(--p2);
  padding: 2px 10px; cursor: pointer; white-space: nowrap;
  border: 2px solid transparent;
}
.task[aria-pressed="true"] { border-color: var(--p3); color: var(--w); }
.task:hover { background: var(--p5); }
/* The button flashes when a window lands in it. Stepped, no fade. */
.task.is-landed { animation: task-land 200ms steps(1, end); }
@keyframes task-land {
  0%  { background: var(--accent); color: var(--k); }
  50% { background: var(--w); color: var(--k); }
}

/* ---------- iconize animation ---------- */
.zoom-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100000; }
.zoom-rect {
  position: fixed;
  border: 2px solid var(--k);
  outline: 2px solid var(--w); /* reads on the black taskbar too */
}
.zoom-rect.is-trail { border-color: var(--p3); outline: 0; }
.zoom-rect[hidden] { display: none; }

/* ---------- windows ---------- */
.win {
  position: absolute;
  display: flex; flex-direction: column;
  overflow: hidden;
  resize: none;
  /* Pixel-rounded corners: the border is painted as four lines that stop
     4px short of each corner, leaving the outer corner cells transparent.
     The one diagonal step pixel per corner sits inside the padding box,
     under the children, so .win::after draws it on top. A drop-shadow
     (not box-shadow) follows the stepped outline. */
  border: 2px solid transparent;
  background:
    linear-gradient(var(--k) 0 0) top    / calc(100% - 8px) 2px no-repeat border-box,
    linear-gradient(var(--k) 0 0) bottom / calc(100% - 8px) 2px no-repeat border-box,
    linear-gradient(var(--k) 0 0) left   / 2px calc(100% - 8px) no-repeat border-box,
    linear-gradient(var(--k) 0 0) right  / 2px calc(100% - 8px) no-repeat border-box,
    var(--w) padding-box;
  filter: drop-shadow(4px 4px 0 var(--p2));
}
.win::after {
  content: ''; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background:
    linear-gradient(var(--k) 0 0) left top     / 2px 2px no-repeat,
    linear-gradient(var(--k) 0 0) right top    / 2px 2px no-repeat,
    linear-gradient(var(--k) 0 0) left bottom  / 2px 2px no-repeat,
    linear-gradient(var(--k) 0 0) right bottom / 2px 2px no-repeat;
}
.win[hidden] { display: none; }
.win.is-focus { filter: drop-shadow(6px 6px 0 var(--accent)); }
.win-bar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 26px; padding: 0 4px 0 8px;
  background: var(--bar-dim); color: var(--p2);
  cursor: grab; user-select: none; touch-action: none;
}
.win.is-dragging .win-bar { cursor: grabbing; }
.win-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btn {
  width: 18px; height: 18px; padding: 0; line-height: 10px;
  border: 2px solid currentColor; background: transparent; color: inherit;
  cursor: pointer;
}
.win-btn:hover { background: var(--w); color: var(--k); }
.win.is-focus .win-bar { background: var(--k); color: var(--w); }

.win-view { position: relative; flex: 1; min-height: 0; background: var(--w); overflow: hidden; }
.px-canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; touch-action: none; }
.win-cap {
  flex: none; padding: 4px 8px;
  font-size: var(--fs);
  border-top: 2px solid var(--k);
  color: var(--bar-dim);
}
.win-tools {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 6px;
  border-bottom: 2px solid var(--k);
}
.tool-stat { margin-left: auto; padding-right: 4px; }
.tool-stat b { font-weight: inherit; color: var(--p4); }
.win-scroll { flex: 1; overflow: auto; padding: 10px 12px 14px; }

/* ---------- controls ---------- */
.seg-group { display: inline-flex; flex-wrap: wrap; }
.seg {
  border: 2px solid var(--k);
  background: var(--w); color: var(--k);
  padding: 0 8px; cursor: pointer; white-space: nowrap;
}
.seg-group .seg + .seg { margin-left: -2px; }
.seg:hover { background: var(--p1); }
.seg[aria-pressed="true"] { background: var(--k); color: var(--w); position: relative; z-index: 1; }
.seg-wide { margin-top: 14px; }

.intro { margin: 0 0 12px; max-width: 64ch; color: var(--bar-dim); }
.ctl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px 18px; }
.ctl h3 { margin: 0 0 6px; font-size: inherit; font-weight: inherit; color: var(--p4); }
.ctl p { margin: 6px 0 0; font-size: var(--fs); color: var(--bar-dim); max-width: 40ch; }

/* ---------- floor labels ---------- */
.floor-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.floor-label {
  position: absolute; left: 0; top: 0;
  padding: 0 4px;
  font-size: var(--fs); white-space: nowrap;
  background: var(--k); color: var(--w);
}
.floor-label[hidden] { display: none; }
.floor-label.is-source { background: var(--accent); color: var(--k); }
.floor-label.is-warn { background: var(--accent); color: var(--k); outline: 2px solid var(--k); }
.win-view[data-mode="link"] { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* ---------- game sidebar ---------- */
.side { display: flex; flex-direction: column; gap: 14px; }
.side-block h2 { margin: 0 0 6px; font-size: inherit; font-weight: inherit; color: var(--p4); }
.money { margin: 0; padding: 2px 8px; background: var(--k); color: var(--w); display: inline-block; }
.side-note { margin: 6px 0 0; color: var(--bar-dim); }
.mats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mat .seg { white-space: normal; text-align: left; }
.tools .seg { flex: 1; }
.builds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
/* Button tiles are round, with stepped pixel corners (an art pixel is 2px):
   the tile is the black outline, clipped to the outer steps, and ::before is
   its face, clipped to the inner ones, so the outline stays one pixel thick. */
.build, .tile {
  --tile: var(--w);
  width: 100%; text-align: left; cursor: pointer;
  border: 0; background: var(--k); color: var(--k);
  padding: 6px 10px; display: grid; gap: 2px;
  position: relative; isolation: isolate;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px), 0 4px, 2px 4px, 2px 2px, 4px 2px);
}
.build::before, .tile::before {
  content: ''; position: absolute; inset: 2px; z-index: -1;
  background: var(--tile);
  clip-path: polygon(2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px), 0 2px, 2px 2px);
}
.build:hover:not(:disabled), .build:focus-visible { --tile: var(--p1); }
.build[aria-pressed="true"] { --tile: var(--k); color: var(--w); }
.build[aria-pressed="true"] .build-about { color: var(--p2); }
.build:disabled { opacity: .45; cursor: not-allowed; }
/* Machine tiles: the machine's pictogram on the left. On a pressed (black)
   tile a white halo keeps its black lines readable. */
.build.has-icon { grid-template-columns: 48px 1fr; column-gap: 8px; align-items: start; }
.build.has-icon .build-top, .build.has-icon .build-about { grid-column: 2; }
.build-icon { grid-row: 1 / span 2; width: 48px; height: 48px; display: block; }
.build[aria-pressed="true"] .build-icon { filter: drop-shadow(2px 0 0 var(--w)) drop-shadow(-2px 0 0 var(--w)) drop-shadow(0 2px 0 var(--w)) drop-shadow(0 -2px 0 var(--w)); }
.build-top { display: flex; justify-content: space-between; gap: 8px; }
.build-top b { font-weight: inherit; }
.build-about { color: var(--bar-dim); }
.side-hint { margin: 0; padding: 6px 8px; border: 2px dashed var(--k); color: var(--bar-dim); }
#reset.is-armed { background: var(--accent); color: var(--k); }
.win-view[data-mode="build"] { outline: 2px dashed var(--accent); outline-offset: -4px; }
.win-view[data-mode="remove"] { outline: 2px dashed var(--k); outline-offset: -4px; }

/* ---------- dev menu, left of the colophon; opens upwards ---------- */
.dev { margin-left: auto; position: relative; }
.dev-menu {
  position: fixed; z-index: 100000;
  min-width: 220px; padding: 4px;
  background: var(--w); border: 2px solid var(--k);
  display: grid;
}
.dev-menu[hidden] { display: none; }
.dev-item { text-align: left; padding: 2px 8px; background: none; border: 0; color: var(--k); cursor: pointer; white-space: nowrap; }
.dev-item:hover, .dev-item:focus-visible { background: var(--k); color: var(--w); }

/* ---------- HIGH colophon, bottom right of the taskbar ---------- */
.colophon { display: flex; align-items: center; gap: 0.5em; white-space: nowrap; color: var(--p2); padding-right: 4px; }
.colophon a, .colophon hijinks-feedback { color: inherit; text-decoration: none; cursor: pointer; }
.colophon-mark { display: inline-flex; align-items: center; gap: 0.4em; }
.colophon-mark img { height: 16px; width: auto; display: block; }
.colophon-mark:hover img { opacity: 0.7; }
.colophon-mark:hover .colophon-word, .colophon-link:hover { color: var(--w); }
.colophon-sep { color: var(--p4); }

/* ---------- resize grip (snaps to the window grid) ---------- */
.win-grip {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; z-index: 5;
  background:
    linear-gradient(var(--k), var(--k)) 10px 2px / 2px 2px no-repeat,
    linear-gradient(var(--k), var(--k)) 6px 6px / 2px 2px no-repeat,
    linear-gradient(var(--k), var(--k)) 10px 6px / 2px 2px no-repeat,
    linear-gradient(var(--k), var(--k)) 2px 10px / 2px 2px no-repeat,
    linear-gradient(var(--k), var(--k)) 6px 10px / 2px 2px no-repeat,
    linear-gradient(var(--k), var(--k)) 10px 10px / 2px 2px no-repeat;
}
.win.is-resizing, .win.is-resizing * { cursor: nwse-resize !important; }

/* ---------- shifts, money, life ---------- */
.clock { display: flex; align-items: center; gap: 8px; }
.clock b { font-weight: inherit; background: var(--k); color: var(--w); padding: 0 6px; }
.shift-bar, .life-bar { flex: 1; height: 8px; border: 2px solid var(--k); background: var(--w); display: block; }
.shift-bar i, .life-bar i { display: block; height: 100%; background: var(--p3); }
/* No power: a notice over the floor. */
.floor-off { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); margin: 0; padding: 2px 10px; background: var(--k); color: var(--w); z-index: 3; pointer-events: none; white-space: nowrap; }
.floor-off[hidden] { display: none; }

/* ---------- top bar ---------- */
.top { height: 100%; display: flex; align-items: center; gap: 28px; padding: 0 14px; white-space: nowrap; }
.top-group { margin: 0; display: flex; align-items: center; gap: 10px; }
.top-shift .clock { width: 260px; }
.top-counters { gap: 16px; }
.top-counters > div { display: flex; align-items: baseline; gap: 6px; }
.top-counters dt { margin: 0; color: var(--p4); }
.top-counters dd { margin: 0; background: var(--k); color: var(--w); padding: 0 6px; }
.top-counters .is-low dd { background: var(--accent); color: var(--k); }
.top-life { flex: 1; max-width: 280px; margin-left: auto; }
.top-life > span:first-child { color: var(--p4); }
.top-life b { font-weight: inherit; min-width: 2ch; text-align: right; }
.top-life.is-low .life-bar i { background: var(--p5); }
.counters { margin: 0; display: grid; gap: 8px; }
.counters > div { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; }
.counters dt { margin: 0; }
.counters dd { margin: 0; background: var(--k); color: var(--w); padding: 0 6px; }
.counters .side-note { grid-column: 1 / 3; margin: 0; }
.paywith { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.life { display: flex; align-items: center; gap: 8px; }
.life b { font-weight: inherit; min-width: 2ch; text-align: right; }

/* ---------- distribution ---------- */
.dist { display: flex; flex-direction: column; gap: 14px; }
.dock-count { margin: 0; }
.dock-count b { font-weight: inherit; background: var(--k); color: var(--w); padding: 0 6px; }
.orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order { grid-template-columns: 1fr auto; align-items: start; gap: 0 10px; cursor: default; }
.order-text { display: grid; gap: 2px; min-width: 0; }
.trucks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.truck { display: grid; gap: 0; }
.truck b { font-weight: inherit; }
.truck .side-note { margin: 0; }
.shopfront { display: block; flex: none; background: var(--p1); border: 2px solid var(--w); box-shadow: 0 0 0 2px var(--k); margin: 2px; }
.order b { font-weight: inherit; }
.order .seg { justify-self: start; margin-top: 2px; }

/* ---------- machine window ---------- */
.machine { flex: 1; min-height: 0; display: flex; }
.machine-view { flex: 1; min-width: 0; border-right: 2px solid var(--k); }
.machine-side { width: 260px; flex: none; overflow: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.machine-status { margin: 0; padding: 2px 6px; background: var(--k); color: var(--w); }
.upgrades { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.upgrade { display: grid; gap: 2px; }
.upgrade-top { display: flex; justify-content: space-between; gap: 8px; }
.upgrade-top b { font-weight: inherit; }
.pips { color: var(--p4); letter-spacing: 1px; }
.upgrade .seg { justify-self: start; }

/* ---------- evening ---------- */
.evening { position: fixed; inset: 0 0 36px 0; z-index: 10000; display: grid; place-items: center; background: rgba(110, 18, 56, 0.55); }
.evening[hidden] { display: none; }
.evening-win { width: min(448px, calc(100vw - 32px)); max-height: calc(100vh - 80px); display: flex; flex-direction: column; background: var(--w); border: 2px solid var(--k); box-shadow: 6px 6px 0 var(--accent); }
.evening-win .win-bar { background: var(--k); color: var(--w); cursor: default; }
.evening-body { overflow: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.evening-body p { margin: 0; }
.acts { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.next-shift { background: var(--k); color: var(--w); }
/* The weekend: its own, wider window with three columns. */
.evening.is-weekend .evening-win { width: min(960px, calc(100vw - 32px)); box-shadow: 8px 8px 0 var(--p4); }
.weekend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 24px; align-items: start; }
.weekend-col { display: grid; gap: 8px; min-width: 0; }
.weekend-col h2 { margin: 0; }
.ledger { margin: 0; display: grid; gap: 4px; }
.ledger > div { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ledger dt { margin: 0; }
.ledger dd { margin: 0; background: var(--k); color: var(--w); padding: 0 6px; }
.weekend-col .seg { justify-self: start; }
.paywith-mini { margin-top: 4px; }
@media (max-width: 720px) { .weekend { grid-template-columns: 1fr; } }
.seg:disabled { opacity: .45; cursor: not-allowed; }
.seg:disabled:hover { background: var(--w); }

.win-btns { display: flex; gap: 4px; }
