/* Abstraction: one workstation on his violet world. The grid, the window chrome and the density come
   from his reference picture (art/ref/reference-desktop.jpg); the palette, the pixels and the cube come
   from the avatar and banner he drew. Every surface here is a PNG drawn by tools/draw.mjs. */

@font-face { font-family: VG; src: url(fonts/VG5000.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: SG; src: url(fonts/Sligoil.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: SG; src: url(fonts/SligoilBold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #000000;
  --panel: #15132E;
  --well: #0B0A1C;
  --cream: #F4F0DC;
  --cream-dim: #BDB9A6;
  --dark: #0B0A1C;
  --blue: #0080F0;
  --red: #F00000;
  --green: #00B84C;
  --yellow: #F0E000;
  --violet: #4F47A8;
  --world-mid: #7880E0;

  --t-body: 18px;
  --t-label: 17px;
  --t-title: 24px;
  --t-big: 76px;

  --edge: clamp(28px, 6.9vw, 132px);
  --gutter: 8%;
  --pad: 32px;             /* the inner padding of a window body, measured from the plate's outer edge */
}

* { box-sizing: border-box; }

html { background: #3B3F86; }

body {
  margin: 0;
  font: var(--t-body)/1.5 SG, ui-monospace, monospace;
  font-synthesis: none;
  color: var(--cream);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

img { image-rendering: pixelated; }

/* ---------------------------------------------------------------- the world */
.world { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.world-ground {
  position: absolute; inset: 0;
  background: url(img/world.png) center / cover no-repeat;
  image-rendering: pixelated;
}

.world-cubes { position: absolute; inset: 0; width: 100%; height: 100%; }

main { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- the desks */
.desk {
  display: grid;
  grid-template-columns: minmax(0, 55fr) minmax(0, 23.2fr);
  column-gap: var(--gutter);
  row-gap: 30px;
  padding: 40px var(--edge) 48px;
  align-items: stretch;
}

.desk-lab {
  grid-template-areas: "head head" "a b" "band band" "c d";
  grid-template-rows: auto auto auto auto;
  min-height: 100vh;
  padding-top: 20px;
}

.desk-lab .head { grid-area: head; }
.win-a { grid-area: a; }
.win-b { grid-area: b; }
.band  { grid-area: band; }
.win-c { grid-area: c; }
.win-d { grid-area: d; }

.desk-score, .desk-day, .desk-prize { padding-top: 72px; padding-bottom: 72px; }
.desk-prize, .desk-score { grid-template-columns: minmax(0, 23.2fr) minmax(0, 55fr); }
.desk-score .win-wide { order: 2; }
.desk-score .win-narrow { order: 1; }
.win-wide { min-width: 0; }
.win-narrow { min-width: 0; }

/* the head strip: the machine facts line the reference runs over its whole screen */
.head {
  margin: 0 0 22px;
  font-size: var(--t-label);
  letter-spacing: 0.01em;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- windows */
.win {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-style: solid;
  border-width: 64px 8px 12px;
  border-image: url(img/win-blue.png) 64 8 12 fill / 64px 8px 12px / 0 stretch;
  filter: drop-shadow(0 10px 0 rgba(10, 8, 26, 0.35));
}

.win[data-role="violet"] { border-image-source: url(img/win-violet.png); }
.win[data-role="green"]  { border-image-source: url(img/win-green.png); }
.win[data-role="yellow"] { border-image-source: url(img/win-yellow.png); }
.win[data-role="red"]    { border-image-source: url(img/win-red.png); }
.win[data-role="cream"]  { border-image-source: url(img/win-cream.png); }

.win > .bar {
  position: absolute;
  top: -64px; left: -8px; right: -8px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px 0 36px;
  cursor: grab;
  user-select: none;
}

.win > .bar h2 {
  margin: 0;
  font: var(--t-title) VG, SG, monospace;
  line-height: 1;
  color: var(--dark);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.win[data-role="violet"] > .bar h2 { color: var(--cream); }

.ctl { margin-left: auto; display: flex; gap: 2px; flex: none; }

.ctl button {
  width: 44px; height: 44px;
  border: 0; padding: 0; margin: 0;
  background: center / 26px 26px no-repeat;
  cursor: pointer;
}

.ctl button:nth-child(1) { background-image: url(img/ctl-fold.png); }
.ctl button:nth-child(2) { background-image: url(img/ctl-wide.png); }
.ctl button:nth-child(3) { background-image: url(img/ctl-strip.png); }
.ctl button:hover { filter: brightness(1.25); }
.ctl button:focus-visible { outline: 3px solid var(--cream); outline-offset: -4px; }

.win > .body { flex: 1; padding: 28px 24px 24px; display: flex; flex-direction: column; min-height: 0; }
.win.folded > .body { display: none; }
.win.folded { border-bottom-width: 12px; }
.win.folded, .win.stripped { filter: none; align-self: start; }

.win.stripped { border-width: 64px 8px 12px; }
.win.stripped > .body { display: none; }
.win.stripped > .bar::after {
  content: "closed, press the square to open";
  margin-left: 18px;
  font: var(--t-label) SG, monospace;
  color: var(--dark);
  opacity: 0.8;
}

.win.wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- inside a window */
.label {
  margin: 0 0 8px;
  font-size: var(--t-label);
  color: var(--cream-dim);
  letter-spacing: 0.02em;
}

.label.under { margin: -4px 0 20px; }

.say { margin: 0; font-size: var(--t-body); color: var(--cream); overflow-wrap: anywhere; }
.say.lead { margin-bottom: 22px; max-width: 62ch; }

.name { margin: 0 0 20px; font: 38px VG, monospace; line-height: 1; color: var(--cream); }
.name b { font-family: SG, monospace; font-weight: 700; font-size: 0.78em; color: var(--yellow); }

.big { margin: 0; font: var(--t-big) VG, monospace; line-height: 1; color: var(--yellow); }

.well {
  border-style: solid;
  border-width: 12px;
  border-image: url(img/well.png) 12 fill / 12px / 0 stretch;
  padding: 16px;
  min-width: 0;
}

.chip {
  display: inline-block;
  margin: 0;
  border-style: solid;
  border-width: 8px 10px;
  border-image: url(img/chip.png) 8 10 fill / 8px 10px / 0 stretch;
  padding: 2px 14px;
  font-size: var(--t-label);
  color: var(--cream);
  white-space: nowrap;
}

.chip[data-state="solved"] { border-image-source: url(img/chip-ok.png); color: var(--dark); }
.chip[data-state="failed"] { border-image-source: url(img/chip-no.png); color: var(--cream); }

.rows { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 22px 0 0; align-content: start; }
.rows dt { font-size: var(--t-label); color: var(--cream-dim); }
.rows dd { margin: 0; font-size: var(--t-label); color: var(--cream); overflow-wrap: anywhere; }
.rows.split dd { color: var(--yellow); }

/* keys */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  border-style: solid;
  border-width: 12px 12px 16px;
  border-image: url(img/key.png) 12 12 16 fill / 12px 12px 16px / 0 stretch;
  padding: 2px 16px;
  font: var(--t-body) SG, monospace;
  color: var(--cream);
  text-decoration: none;
  cursor: pointer;
  background: none;
}

.key img { height: 20px; width: auto; }
.key.small { min-height: 48px; font-size: var(--t-label); padding: 0 10px; }
.key.go { border-image-source: url(img/key-go.png); color: var(--dark); }
.key:hover { filter: brightness(1.14); }
.key:active { border-image-source: url(img/key-down.png); }
.key.go:active { border-image-source: url(img/key-go-down.png); }
.key:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.key[disabled], .key[aria-disabled="true"] {
  filter: grayscale(0.7) brightness(0.84);
  cursor: not-allowed;
  color: var(--cream-dim);
}

.keys { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 4px; }

/* ---------------------------------------------------------------- the task grid window */
.grid-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.grid-head .label { margin: 0; }
.grid-head .chip { margin-left: auto; }

.examples { display: flex; flex-wrap: wrap; gap: 16px 22px; justify-content: space-evenly; align-items: center; }

.pair { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pair .arrow { flex: none; white-space: nowrap; font-size: var(--t-label); color: var(--cream-dim); }
.pair figure { margin: 0; flex: none; }
.pair figcaption { margin-top: 6px; font-size: 16px; color: var(--cream-dim); max-width: 108px; line-height: 1.25; }

.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; flex: 1; }
.answer-cell { display: flex; flex-direction: column; }
.answer .well { flex: 1; }
.answer-cell { min-width: 0; }
.answer .well { display: flex; align-items: center; justify-content: center; min-height: 152px; }

canvas.grid { image-rendering: pixelated; max-width: 100%; height: auto; }

/* ---------------------------------------------------------------- the team window */
.role { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.role img { flex: none; margin-top: 2px; }
.role .label { margin-bottom: 2px; }
.role-mark { display: block; margin: 0 0 16px; }

.bar-budget { height: 18px; border: 2px solid var(--ink); background: #0B0A1C; margin: 10px 0 0; }
.bar-budget i { display: block; height: 100%; background: var(--yellow); }

/* ---------------------------------------------------------------- the judge window */
.code {
  display: block;
  margin: 0 0 18px;
  font: 17px/1.55 SG, ui-monospace, monospace;
  color: var(--green);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
  flex: 1;
}

.runs { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.run { display: flex; align-items: center; gap: 12px; }
.run .pair { gap: 8px; }
.run figcaption { display: none; }

/* ---------------------------------------------------------------- the band: his world, with its name */
.band {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  min-height: clamp(168px, 19vh, 228px);
  padding: 10px 0;
}

.band-mark { width: clamp(220px, 23vw, 384px); height: auto; }
.band-cube { width: clamp(108px, 11vw, 190px); height: auto; filter: drop-shadow(0 0 28px rgba(255, 255, 255, 0.55)); }

.band-say {
  justify-self: center;
  margin: 0;
  max-width: 46ch;
  border-style: solid;
  border-width: 12px;
  border-image: url(img/well.png) 12 fill / 12px / 0 stretch;
  padding: 14px 18px;
  font-size: var(--t-body);
  color: var(--cream);
}

/* ---------------------------------------------------------------- tables, pager, chart */
.table { display: block; padding: 6px 0; }
.table .row {
  display: grid;
  grid-template-columns: 11ch max-content minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 2px solid rgba(244, 240, 220, 0.12);
  font-size: var(--t-label);
}
.table .row:last-child { border-bottom: 0; }
.table .row b { font-weight: 400; color: var(--yellow); }
.table .row .what { color: var(--cream-dim); min-width: 0; line-height: 1.35; }
.table .row a { color: var(--cream); }
.table .empty { padding: 18px 20px; color: var(--cream-dim); font-size: var(--t-label); }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .key[aria-pressed="true"] { border-image-source: url(img/key-down.png); color: var(--yellow); }

.pager { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.count { margin: 0; font-size: var(--t-label); color: var(--cream-dim); }

.chart { display: block; width: 100%; height: auto; padding: 10px; }

/* ---------------------------------------------------------------- the day's task */
.candidates { display: grid; grid-template-columns: repeat(auto-fit, minmax(188px, 1fr)); gap: 18px; align-items: end; }
@media (min-width: 1240px) { .candidates { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.candidate { display: flex; flex-direction: column; gap: 12px; }
.candidate .well { display: flex; align-items: center; justify-content: center; min-height: 164px; }
.candidate .label { min-height: 46px; margin: 0; overflow-wrap: anywhere; }
.candidate .key { width: 100%; }
.candidate .bar-vote { height: 14px; background: rgba(11, 10, 28, 0.75); border: 2px solid var(--ink); }
.candidate .bar-vote i { display: block; height: 100%; background: var(--blue); }
.day-foot { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; margin-top: 22px; }
.day-foot .label { margin: 0; }

/* ---------------------------------------------------------------- how it works */
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 26px 30px; }
.steps li { display: flex; gap: 16px; align-items: flex-start; }
.steps img { flex: none; margin-top: 4px; }
.steps b { font: 46px VG, monospace; line-height: 0.9; color: var(--yellow); font-weight: 400; }
.steps .label { margin-bottom: 4px; }

.risk { margin: 18px 0 0; font-size: 16px; color: var(--cream-dim); }
.mint {
  margin: 0;
  font-size: var(--t-body);
  color: var(--cream);
  overflow-wrap: anywhere;
  user-select: all;
  border-style: solid;
  border-width: 12px;
  border-image: url(img/well.png) 12 fill / 12px / 0 stretch;
  padding: 14px 16px;
}

/* ---------------------------------------------------------------- phone */
/* between 1100 and 1500 the reference grid stays, but the narrow column is given more of the width so
   the text in it stops turning into a ladder */
@media (min-width: 1101px) and (max-width: 1500px) {
  :root { --edge: clamp(28px, 4.4vw, 96px); --gutter: 6%; }
  .desk { grid-template-columns: minmax(0, 55fr) minmax(0, 28fr); }
  .desk-prize, .desk-score { grid-template-columns: minmax(0, 28fr) minmax(0, 55fr); }
  .win > .body { padding: 24px 24px 20px; }
}

@media (max-width: 1100px) {
  :root { --t-big: 60px; --gutter: 0px; }
  .desk, .desk-prize { grid-template-columns: minmax(0, 1fr); row-gap: 28px; }
  .desk-lab { grid-template-areas: "head" "a" "b" "band" "c" "d"; }
  .band { grid-template-columns: 1fr auto; grid-template-areas: "mark cube" "say say"; row-gap: 18px; min-height: 0; }
  .band-mark { grid-area: mark; }
  .band-cube { grid-area: cube; }
  .band-say { grid-area: say; justify-self: stretch; max-width: none; }
  .answer, .steps { grid-template-columns: 1fr; }
  .win > .bar { cursor: default; }
  /* one column, so only the control that still means something is shown, and it works */
  .ctl button:nth-child(2), .ctl button:nth-child(3) { display: none; }
}

@media (max-width: 560px) {
  :root { --t-title: 21px; --t-big: 48px; }

  .win > .bar { top: -64px; height: 64px; padding: 0 8px 0 28px; }
  .win > .body { padding: 24px 24px 22px; }
  .name { font-size: 30px; }
  .table .row { grid-template-columns: 1fr auto; }
  .table .row .what { display: none; }
  .ctl button { width: 44px; height: 44px; background-size: 24px 24px; }
  .pair { flex-wrap: nowrap; gap: 6px; }
  .examples { gap: 14px 10px; justify-content: flex-start; }
  .grid-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  /* the world still shows, it just stops moving: world.js draws one frame and never starts its clock */
  .win, .key { transition: none; }
}

#verdict { margin-top: 20px; }
#verdict dd { overflow-wrap: anywhere; }

/* feedback on the two things that are really pressable inside a window */
.table .row[role="button"]:hover { background: rgba(244, 240, 220, 0.07); }
.table .row[role="button"]:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }
.candidate:hover .well { transform: translateY(-2px); filter: drop-shadow(0 4px 0 rgba(10, 8, 26, 0.5)); }
.candidate .well { transition: transform 120ms ease; }

@media (prefers-reduced-motion: reduce) {
  .candidate .well { transition: none; }
  .candidate:hover .well { transform: none; }
}
