/* win95.css - shared Win95 design system for math.gumpworks.com.
 *
 * The palette and control styling follow GAUTH's theme defaults exactly:
 *   primary #000080, bg #d8d8d8, panel #ececec, chrome #d2d2d2,
 *   field #f7f7f7, ink #000000, line #000000.
 * The bevel colours (--hi/--lo) are the classic Win95 white/grey pair.
 *
 * The page is a light Win95 window floating on a warm, smoky desktop. The
 * smoke is a separate, optional layer (assets/inkfall.js); this stylesheet
 * works without it. --desktop must stay equal to inkfall's PAPER_OUTER, or
 * the page changes colour when the FX toggle is flipped.
 */

:root {
  --primary: #000080;
  --bg: #d8d8d8;
  --panel: #ececec;
  --chrome: #d2d2d2;
  --field: #f7f7f7;
  --ink: #000000;
  --line: #000000;
  --hi: #ffffff;
  --lo: #808080;
  --font: "MS Sans Serif", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --mono: "Lucida Console", "Courier New", monospace;
  --title-a: #000080;
  --title-b: #1084d0;
  --desktop: #cfc9bb;
  --shadow: rgba(0, 0, 0, 0.45);

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --measure: 72ch;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--chrome) var(--field);
}
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--desktop);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color-scheme: light;
}

/* The desktop is the area around the window. The inkfall canvas sits behind
   it at z-index 0; the window sits above at z-index 1. */
#desktop {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: clamp(14px, 4vw, 56px);
}

#inkfall {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── window ────────────────────────────────────────────────────────────── */

.window {
  width: min(1040px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow:
    inset 1px 1px 0 var(--hi),
    inset -1px -1px 0 var(--lo),
    5px 5px 0 var(--shadow);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 5px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}

.titlebar-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid #000;
  color: var(--primary);
  font: 700 11px/1 var(--mono);
}
.titlebar-icon::before { content: "∑"; }

.titlebar-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.titlebar-buttons {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.titlebar-button {
  width: 17px;
  height: 15px;
  display: grid;
  place-items: center;
  background: var(--chrome);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  color: var(--ink);
  font: 700 10px/1 var(--font);
}

.menubar {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  padding: 2px 4px;
  background: var(--chrome);
  border-bottom: 1px solid var(--lo);
  font-size: 12px;
}
.menubar a {
  padding: 2px 8px;
  color: var(--ink);
  text-decoration: none;
}
.menubar a:hover,
.menubar a:focus {
  background: var(--primary);
  color: #fff;
  outline: none;
}

.window-body {
  padding: clamp(12px, 2.2vw, 20px) clamp(12px, 2.4vw, 22px) clamp(16px, 2.6vw, 24px);
  background: var(--panel);
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  background: var(--chrome);
  border-top: 1px solid var(--hi);
  font-size: 11px;
}
.statusbar .cell {
  padding: 1px 7px;
  border: 1px solid var(--lo);
  border-top-color: var(--hi);
  border-left-color: var(--hi);
  white-space: nowrap;
}
.statusbar .cell.grow {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.statusbar .cell.live {
  font-family: var(--mono);
  font-size: 10px;
  color: #222;
}

/* ── type ───────────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  line-height: 1.25;
  text-wrap: balance;
}

.page-title {
  margin: 0 0 var(--s1);
  font-size: clamp(21px, 3vw, 29px);
  font-weight: 700;
  letter-spacing: -.015em;
}

.page-lede {
  margin: 0 0 var(--s4);
  max-width: 58ch;
  color: #333;
  font-size: 15px;
  text-wrap: pretty;
}

h2 {
  margin: 0 0 var(--s3);
  padding-bottom: 6px;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
}

h3 {
  margin: var(--s5) 0 var(--s2);
  padding: 3px 8px;
  font-size: 13px;
  background: linear-gradient(#f2f2f2, var(--chrome));
  border: 1px solid var(--line);
}

p {
  margin: 0 0 var(--s3);
  max-width: var(--measure);
  text-wrap: pretty;
}
p:last-child { margin-bottom: 0; }

small { font-size: 11px; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover, a:focus { background: var(--primary); color: #fff; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: 1px;
}

::selection { background: var(--primary); color: #fff; }

code, kbd, samp {
  font-family: var(--mono);
  font-size: .92em;
}
code {
  padding: 0 3px;
  background: #fff;
  border: 1px solid #c8c8c8;
}

.hint {
  color: #4a4a4a;
  font-size: 12px;
  max-width: var(--measure);
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

.kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 4px;
  background: var(--chrome);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  font: 11px/1.6 var(--mono);
  text-align: center;
}

/* ── inset / sunken panels ──────────────────────────────────────────────── */

.inset {
  background: var(--field);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--lo), inset -1px -1px 0 var(--hi);
  padding: var(--s3);
}

.mt { margin-top: var(--s3); }
.empty { color: #333; }

/* A small header strip for a panel. */
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  margin: 0 0 var(--s2);
  padding-bottom: var(--s1);
  border-bottom: 1px solid var(--lo);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #333;
}

/* ── controls ───────────────────────────────────────────────────────────── */

button,
input[type="submit"],
input[type="button"] {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 3px 12px;
  min-height: 26px;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  -webkit-appearance: none;
  appearance: none;
}
button:hover,
input[type="submit"]:hover { background: #e4e4e4; }
button:active,
input[type="submit"]:active {
  box-shadow: inset 1px 1px 0 var(--lo);
  padding-top: 4px;
  padding-bottom: 2px;
}
button:disabled {
  color: #6b6b6b;
  background: #cfcfcf;
  box-shadow: none;
  cursor: not-allowed;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 3px 6px;
  max-width: 100%;
  box-shadow: inset 1px 1px 0 var(--lo);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: var(--primary);
  vertical-align: -1px;
  margin: 0 4px 0 0;
}

/* A Win95 slider: a sunken groove with a raised square thumb. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--field);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--lo);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 19px;
  margin-top: -7.5px;
  background: var(--chrome);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
}
input[type="range"]:active::-webkit-slider-thumb { background: #e4e4e4; }
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--field);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--lo);
}
input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 17px;
  border-radius: 0;
  background: var(--chrome);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0h8L4 5z' fill='%23000'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
}

/* Number fields are typed into, not nudged: the native spinners are the one
   piece of modern chrome that cannot be made to look like 1995. */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── control panel ──────────────────────────────────────────────────────── */

.project-controls {
  display: grid;
  gap: 1px;
  margin-top: var(--s3);
}

/* One control per row: label, slider, exact value. */
.field {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr) 6.5em;
  align-items: center;
  gap: var(--s3);
  padding: 3px 0;
}
.field > label {
  font-size: 12px;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field input[type="range"] { width: 100%; }
.field input[type="number"] { width: 100%; }

.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--lo);
}

/* A row of colour swatches and toggles. The swatches get their own even
   cells so the labels do not run together into one sentence. */
.color-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s2) var(--s4);
  padding: 3px 0;
}
.color-row label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s2);
  font-size: 12px;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
  padding: 3px 0;
}
.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

input[type="color"] {
  width: 44px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--field);
  box-shadow: inset 1px 1px 0 var(--lo);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); }

/* ── tile grid ──────────────────────────────────────────────────────────── */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--s2);
}

.tile {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  color: var(--ink);
  text-decoration: none;
}
.tile:hover,
.tile:focus {
  background: var(--primary);
  color: #fff;
  outline: none;
}
.tile:hover .tile-desc,
.tile:focus .tile-desc { color: #d8e4ff; }
.tile:hover .tile-host,
.tile:focus .tile-host { color: #fff; }
.tile:hover .tile-go,
.tile:focus .tile-go { color: #fff; }
.tile:hover .tile-icon,
.tile:focus .tile-icon { background: #fff; }

/* A tiny application window, with the project's initial in the body. */
.tile-icon {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding-top: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  color: var(--primary);
  font: 700 15px/1 var(--mono);
}
.tile-icon::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  border-bottom: 1px solid var(--line);
}

.tile-body { min-width: 0; flex: 1 1 auto; }
.tile-title { display: block; font-weight: 700; font-size: 14px; }
.tile-desc { display: block; margin-top: 2px; color: #333; font-size: 12px; }
.tile-host {
  display: block;
  margin-top: 6px;
  color: var(--primary);
  font: 11px/1.3 var(--mono);
  overflow-wrap: anywhere;
}
.tile-go {
  flex: 0 0 auto;
  align-self: center;
  color: var(--primary);
  font: 700 14px/1 var(--mono);
}

/* ── project viewport ───────────────────────────────────────────────────── */

.viewport {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  min-height: 320px;
}
.viewport canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ── fx toggle ──────────────────────────────────────────────────────────── */

.fx-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  cursor: pointer;
  user-select: none;
}
.fx-toggle input { margin: 0; }

/* ── scrollbars ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track {
  background: var(--field);
  border-left: 1px solid var(--lo);
}
::-webkit-scrollbar-thumb {
  background: var(--chrome);
  border: 1px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
}
::-webkit-scrollbar-corner { background: var(--field); }

/* ── responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  /* No desktop frame on a phone: the window gets a little more margin and
     the heavy background is not loaded at all. */
  #desktop {
    display: block;
    padding: 10px;
  }
  .window {
    width: 100%;
    box-shadow: none;
  }
  .window-body { padding: 12px; }
  .titlebar { font-size: 11px; }
  .statusbar { flex-wrap: wrap; }
  .tile-grid { grid-template-columns: 1fr; }
  .viewport { aspect-ratio: 4 / 3; min-height: 240px; }
  .fx-toggle { display: none; }
  #inkfall { display: none !important; }
}

/* Below this the label column is more than the slider can spare, so the
   label moves above its control. */
@media (max-width: 560px) {
  .field { grid-template-columns: minmax(0, 1fr) 6.5em; }
  .field > label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  #inkfall { display: none !important; }
}
