/* Office Doorbell: Windows 3.1-era look. 16-colour palette, 1px black lines, 2px bevels. */

/* Jersey 15 (OFL): bold pixel sans like the old System font, and its þ/Þ don't read as b. */
@font-face {
  font-family: 'Jersey 15';
  src: url('/fonts/jersey-15.woff2') format('woff2');
  font-display: swap;
}

:root {
  --black: #000;
  --white: #fff;
  --silver: #c0c0c0;
  --gray: #808080;
  --navy: #000080;
  --teal: #008080;
  --teal-dark: #006f6f;
  --font: 'Jersey 15', 'MS Sans Serif', 'Microsoft Sans Serif', Arial, sans-serif;
  color-scheme: light; /* the era had no dark mode; keeps native pickers light too */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.25;
  color: var(--black);
  background-color: var(--teal);
  background-image: repeating-conic-gradient(var(--teal-dark) 0 25%, transparent 0 50%);
  background-size: 4px 4px;
  font-synthesis: none;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--navy);
  color: var(--white);
}

u {
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* ── Desktop ─────────────────────────────────────────────────────────────── */

.desktop {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr; /* the window, then the rest of the desktop for the wallpaper */
  justify-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

@media (min-width: 600px) {
  .desktop {
    padding-top: 10vh;
  }
}

.desktop-icon {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 4px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--white);
  cursor: pointer;
}

.desktop-icon-label {
  padding: 0 4px;
}

.desktop-icon:focus-visible {
  outline: none;
}

.desktop-icon:focus-visible .desktop-icon-label {
  background: var(--navy);
}

/* Centred in the desktop space below the window (and in the whole desktop when it's minimised). */
.wallpaper {
  grid-row: 2;
  align-self: center;
  padding: 24px 0;
  color: var(--white);
}

.wallpaper svg {
  display: block;
  width: 192px; /* 4 screen pixels per logo pixel */
  height: auto;
}

@media (min-width: 600px) {
  .wallpaper svg {
    width: 240px; /* 5 per pixel */
  }
}

.about-logo svg {
  display: block;
}

/* ── Windows ─────────────────────────────────────────────────────────────── */

/* Sizing border: a silver band between black lines, notched where the resize corners begin. */
.window {
  --notch: 26px;
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--black);
  padding: 4px;
  background:
    linear-gradient(var(--black) 0 0) var(--notch) 0 / 1px 4px no-repeat,
    linear-gradient(var(--black) 0 0) calc(100% - var(--notch)) 0 / 1px 4px no-repeat,
    linear-gradient(var(--black) 0 0) var(--notch) 100% / 1px 4px no-repeat,
    linear-gradient(var(--black) 0 0) calc(100% - var(--notch)) 100% / 1px 4px no-repeat,
    linear-gradient(var(--black) 0 0) 0 var(--notch) / 4px 1px no-repeat,
    linear-gradient(var(--black) 0 0) 100% var(--notch) / 4px 1px no-repeat,
    linear-gradient(var(--black) 0 0) 0 calc(100% - var(--notch)) / 4px 1px no-repeat,
    linear-gradient(var(--black) 0 0) 100% calc(100% - var(--notch)) / 4px 1px no-repeat,
    var(--silver);
}

.window.maximized {
  position: fixed;
  inset: 0;
  max-width: none;
  display: flex;
}

.window.maximized .window-body {
  flex: 1;
}

.window-body {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--black);
  background: var(--white);
}

.titlebar {
  display: flex;
  height: 28px;
  flex: none;
  background: var(--navy);
  color: var(--white);
  border-bottom: 1px solid var(--black);
}

.title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0 6px;
  font-size: 20px;
  line-height: 27px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Control-menu box: the little "spacebar" on the left. Decorative. */
.sysmenu {
  position: relative;
  width: 27px;
  flex: none;
  background: var(--silver);
  border-right: 1px solid var(--black);
}

.sysmenu::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 11px;
  width: 13px;
  height: 4px;
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 1px 1px 0 var(--gray);
}

.winbtn {
  position: relative;
  width: 27px;
  flex: none;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--black);
  background: var(--silver);
  box-shadow:
    inset 1px 1px var(--white),
    inset -2px -2px var(--gray);
  cursor: pointer;
}

.winbtn:active {
  box-shadow: inset 1px 1px var(--gray);
}

.winbtn:focus-visible {
  outline: 1px dotted var(--white);
  outline-offset: -4px;
}

.winbtn::before,
.winbtn::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 9px;
  height: 5px;
  margin-left: -5px;
  background: var(--black);
}

.winbtn.min::before {
  top: 11px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.winbtn.max::before {
  top: 10px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.winbtn.max.restore::before {
  top: 6px;
}

.winbtn.max.restore::after {
  top: 14px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.winbtn:not(.restore)::after {
  display: none;
}

.winbtn:active::before,
.winbtn:active::after {
  translate: 1px 1px;
}

/* ── Menus ───────────────────────────────────────────────────────────────── */

.menubar {
  display: flex;
  flex: none;
  border-bottom: 1px solid var(--black);
  background: var(--white);
}

.menu-title {
  min-height: 32px;
  padding: 2px 10px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--black);
  cursor: pointer;
}

.menu-title:hover,
.menu-title:focus-visible,
.menu-title.open {
  outline: none;
  background: var(--navy);
  color: var(--white);
}

.menu-list {
  /* top/left are set from the menu title's position when it opens */
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 190px;
  padding: 2px 0;
  border: 1px solid var(--black);
  background: var(--white);
  color: var(--black);
  box-shadow: 2px 2px 0 var(--black);
}

.menu-item {
  position: relative;
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 4px 16px 4px 28px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  outline: none;
  background: var(--navy);
  color: var(--white);
}

/* Pixel check mark for the selected language */
.menu-item[aria-checked='true']::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  background: currentColor;
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges'%3E%3Cpath d='M6 0h1v1h-1zM5 1h2v1h-2zM0 2h1v1h-1zM4 2h2v1h-2zM0 3h2v1h-2zM3 3h2v1h-2zM1 4h3v1h-3zM2 5h1v1h-1z'/%3E%3C/svg%3E");
  -webkit-mask: var(--check) no-repeat center / contain;
  mask: var(--check) no-repeat center / contain;
}

/* ── Window contents ─────────────────────────────────────────────────────── */

.client {
  padding: 16px;
}

.intro {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.intro h2 {
  margin: 0 0 2px;
  font-size: 32px;
  font-weight: inherit;
  line-height: 1.1;
}

.intro p {
  margin: 0;
}

.icon {
  display: inline-block;
  flex: none;
}

.icon svg {
  display: block;
  width: 32px;
  height: 32px;
}

.icon-lg svg {
  width: 48px;
  height: 48px;
}

label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 600;
}

.hint {
  font-weight: 400;
}

/* Edit controls were flat in 3.1: white box, 1px black line. */
input,
select {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--black);
  border-radius: 0;
  background: var(--white);
  font: inherit;
  font-size: 22px; /* 16px+ stops iOS zooming in on focus */
  color: var(--black);
  caret-color: var(--black);
}

input:focus,
select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--black);
}

.combo {
  position: relative;
}

.combo select {
  appearance: none;
  padding-right: 36px;
  cursor: pointer;
}

/* The focused drop-down list shows its value highlighted, as it did in 3.1 */
.combo select:focus {
  background: linear-gradient(var(--navy) 0 0) 3px 3px / calc(100% - 36px) calc(100% - 6px) no-repeat var(--white);
  color: var(--white);
}

.combo select:focus option {
  color: var(--black);
  background: var(--white);
}

.combo select:disabled {
  color: var(--gray);
  cursor: default;
}

/* Drop-down button: arrow over a short bar */
.combo-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 100%;
  border: 1px solid var(--black);
  background: var(--silver);
  box-shadow:
    inset 1px 1px var(--white),
    inset -2px -2px var(--gray);
  pointer-events: none;
}

.combo-btn::before,
.combo-btn::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 9px;
  margin-left: -5px;
  background: var(--black);
}

.combo-btn::before {
  top: 15px;
  height: 5px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.combo-btn::after {
  top: 22px;
  height: 2px;
}

/* ── Push buttons ────────────────────────────────────────────────────────── */

.btn {
  min-width: 112px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--black);
  border-radius: 4px;
  background: var(--silver);
  box-shadow:
    inset 2px 2px var(--white),
    inset -2px -2px var(--gray);
  font: inherit;
  font-size: 22px;
  color: var(--black);
  cursor: pointer;
  touch-action: manipulation;
}

/* The default button gets a heavier black border */
.btn.default {
  border-width: 2px;
}

.btn > span {
  display: inline-block;
  padding: 0 2px;
}

.btn:active:not(:disabled) {
  box-shadow: inset 2px 2px var(--gray);
}

.btn:active:not(:disabled) > span {
  translate: 1px 1px;
}

.btn:focus-visible {
  outline: none;
}

.btn:focus-visible > span {
  outline: 1px dotted var(--black);
  outline-offset: 2px;
}

.btn:disabled {
  color: var(--gray);
  text-shadow: 1px 1px var(--white);
  cursor: default;
}

.actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.actions .btn {
  min-width: min(100%, 240px);
}

.fineprint {
  margin: 16px 0 0;
  font-size: 16px;
  text-align: center;
}

/* ── Status bar ──────────────────────────────────────────────────────────── */

.statusbar {
  flex: none;
  margin-top: auto;
  padding: 3px;
  border-top: 1px solid var(--black);
  background: var(--silver);
}

.statusbar span {
  display: block;
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid;
  border-color: var(--gray) var(--white) var(--white) var(--gray);
}

/* ── Dialogs ─────────────────────────────────────────────────────────────── */

.dialog {
  width: min(100% - 32px, 380px);
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.dialog::backdrop {
  background: transparent;
}

/* Modal frame: a thick band in the title bar colour */
.dialog-frame {
  display: block;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--black);
  background: var(--navy);
}

.dialog .client p {
  margin: 0 0 8px;
}

.message {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.message-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.progress {
  --p: 0%;
  position: relative;
  height: 28px;
  margin-top: 12px;
  border: 1px solid var(--black);
  background: var(--white);
}

.progress-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
}

/* The filled part is a copy of the label in reverse colours, clipped to the progress */
.progress-label.fill {
  background: var(--navy);
  color: var(--white);
  clip-path: inset(0 calc(100% - var(--p)) 0 0);
}

.noscript {
  margin: 16px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--black);
}

/* ── Admin pages (/api/admin) ────────────────────────────────────────────── */

.admin p {
  margin: 0 0 12px;
}

.admin ul {
  margin: 0 0 12px;
  padding-left: 24px;
}

.admin-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.admin-actions form {
  margin: 0;
}

.admin-actions .btn {
  width: 100%;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--black);
  text-decoration: none;
}

.admin-pause {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.admin-pause label {
  margin: 0;
}
