/* 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.
 */

: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);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--desktop);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  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(1100px, 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: 16px 18px 20px;
  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;
}

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

h1, h2, h3, h4 { line-height: 1.3; }

.page-title {
  margin: 0 0 4px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -.01em;
}

.page-lede {
  margin: 0 0 16px;
  max-width: 60ch;
  color: #333;
}

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

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

p { margin: 0 0 10px; }
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; }

/* ── 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: 10px;
}

.mt { margin-top: 12px; }
.empty { 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;
}

input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: var(--primary);
  background: transparent;
}

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

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  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-icon {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-top: 2px;
}
.tile-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 28px;
  height: 20px;
  background: #ffd75e;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 #fff3b0;
}
.tile-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 7px;
  background: #ffd75e;
  border: 1px solid #000;
  border-bottom: 0;
}

.tile-body { min-width: 0; }
.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;
}

/* -- 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%;
}

.project-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.project-controls label {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.project-controls output { font-family: var(--mono); }

/* ── 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; }

/* -- 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: 10px; }
  .titlebar { font-size: 11px; }
  .statusbar { flex-wrap: wrap; }
  .tile-grid { grid-template-columns: 1fr; }
  .viewport { aspect-ratio: 4 / 3; min-height: 240px; }
  .project-controls { grid-template-columns: 1fr; }
  .fx-toggle { display: none; }
  #inkfall { display: none !important; }
}

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