/* ==========================================================
   APPS — Notebook, Draw, Calculator, Minefield, Screensavers, Wallpaper, Mouse
   ========================================================== */

/* ---------- Wspólne: pasek "menu" programu ---------- */
.menubar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 1px 0 3px;
  flex: 0 0 auto;
}
.btn--flat {
  box-shadow: none;
  min-height: 24px;
  padding: 2px 8px;
  background: transparent;
}
.btn--flat:hover { box-shadow: var(--bevel-thin-in); box-shadow: inset 1px 1px var(--light), inset -1px -1px var(--shadow); }
.btn--flat.is-pressed,
.btn--flat:active { box-shadow: var(--bevel-thin-in); }

/* ---------- Notebook ---------- */
.notebook__text {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.45;
  padding: 6px 8px;
  outline: none;
}
.window--notebook .statusbar { margin-top: 3px; }

/* ---------- Calculator ---------- */
.calc {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px;
  outline: none;
}
.calc__screen { position: relative; }
.calc__display {
  display: block;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 30px;
  line-height: 1;
  padding: 6px 8px;
  overflow: hidden;
  white-space: nowrap;
}
.calc__op {
  position: absolute;
  left: 8px;
  top: 6px;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--shadow);
}
.calc__pad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(34px, 1fr);
  gap: 5px;
}
.calc__key { font-size: 16px; padding: 0; color: #000080; }
.calc__key--op { color: #c00000; }
.calc__key--red { color: #c00000; font-size: 13px; }

/* ---------- Draw ---------- */
.window--draw .window__body { background: var(--face); }
.draw {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 4px;
}
.draw__toolbox { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.draw__tools {
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 2px;
}
.draw__tool {
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  font-size: 16px;
  font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif;
  line-height: 1;
}
.draw__sizes {
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 2px;
  background: var(--face);
}
.draw__size {
  height: 18px;
  min-height: 0;
  padding: 0 6px;
  box-shadow: none;
  background: transparent;
  display: flex;
  align-items: center;
}
.draw__size i { display: block; width: 100%; background: #000; }
.draw__size.is-pressed { background: var(--highlight); box-shadow: none; }
.draw__size.is-pressed i { background: #fff; }

.draw__stage {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--shadow);
  box-shadow: var(--bevel-field);
  padding: 6px;
}
.draw__canvas {
  display: block;
  background: #fff;
  max-width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}
.draw__canvas[data-tool="fill"] { cursor: cell; }

.draw__palette {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  flex: 0 0 auto;
}
.draw__current {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  box-shadow: var(--bevel-field);
  background: var(--face);
}
.draw__swatch {
  position: absolute;
  width: 15px;
  height: 15px;
  box-shadow: var(--bevel-field);
}
.draw__swatch--primary { left: 5px; top: 5px; }
.draw__swatch--secondary { right: 5px; bottom: 5px; }
.draw__colors {
  display: grid;
  grid-template-columns: repeat(14, 18px);
  grid-auto-rows: 18px;
  gap: 1px;
}
.draw__color {
  border: 0;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--bevel-field);
}

@container (max-width: 420px) {
  .draw { flex-direction: column; }
  .draw__toolbox { flex-direction: row; flex-wrap: wrap; }
  .draw__tools { grid-template-columns: repeat(8, 30px); }
  .draw__sizes { flex-direction: row; }
  .draw__size { width: 34px; }
  .draw__colors { grid-template-columns: repeat(14, minmax(0, 1fr)); flex: 1; grid-auto-rows: 20px; }
}

/* ---------- Minefield ---------- */
.mines { flex: 1; overflow: auto; display: flex; }
.mines__panel {
  margin: auto;
  padding: 6px;
  box-shadow: var(--bevel-out);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mines__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  box-shadow: var(--bevel-thin-in);
  box-shadow: inset 2px 2px var(--shadow), inset -2px -2px var(--light);
}
.mines__led {
  background: #000;
  color: #ff1a1a;
  font-family: var(--font-mono);
  font-size: 30px;
  line-height: 1;
  padding: 0 3px;
  letter-spacing: 2px;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--light);
  text-shadow: 0 0 6px rgba(255, 0, 0, 0.6);
}
.mines__face {
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.mines__board {
  box-shadow: inset 3px 3px var(--shadow), inset -3px -3px var(--light);
  padding: 3px;
}
.mines__grid {
  --cell: 24px;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  user-select: none;
  -webkit-touch-callout: none;
}
.mines__cell {
  border: 0;
  padding: 0;
  background: var(--face);
  box-shadow: var(--bevel-out);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.mines__cell:active:not(.is-open):not(.is-flag) { box-shadow: inset 1px 1px var(--shadow); }
.mines__cell.is-open {
  box-shadow: inset 1px 1px var(--shadow);
  cursor: default;
}
.mines__cell.is-flag { font-size: 13px; }
.mines__cell.is-boom { background: #ff0000; }
.mines__cell.is-wrong { background: #ffb0b0; }
.mines__cell[data-n="1"] { color: #0000ff; }
.mines__cell[data-n="2"] { color: #008000; }
.mines__cell[data-n="3"] { color: #ff0000; }
.mines__cell[data-n="4"] { color: #000080; }
.mines__cell[data-n="5"] { color: #800000; }
.mines__cell[data-n="6"] { color: #008080; }
.mines__cell[data-n="7"] { color: #000000; }
.mines__cell[data-n="8"] { color: #808080; }
.mines__flagmode { min-width: 36px; padding: 2px 6px; }

@media (pointer: coarse) {
  .mines__grid { --cell: 30px; }
}

/* ---------- Screensavers (Display Properties) ---------- */
.saver {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  overflow: auto;
}
.saver__monitor {
  align-self: center;
  width: 220px;
  padding: 12px 12px 26px;
  background: var(--face);
  box-shadow: var(--bevel-out);
  position: relative;
}
.saver__monitor::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 30px;
  height: 6px;
  transform: translateX(-50%);
  box-shadow: var(--bevel-in);
}
.saver__screen {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  box-shadow: var(--bevel-field);
}
.saver fieldset {
  /* rowek Win98: ciemna ramka + jasna linia; prawdziwa ramka, żeby napis (legend) ją przerywał */
  border: 1px solid var(--shadow);
  box-shadow: inset 1px 1px var(--light), 1px 1px var(--light);
  margin: 0;
  padding: 14px 12px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.saver legend { padding: 0 3px; margin-left: -2px; background: var(--face); }
.saver select { flex: 1 1 140px; min-width: 0; }
.saver input[type="number"] { width: 64px; }
.saver__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: auto;
}
.saver__actions .btn { min-width: 76px; }
.saver__note { font-size: 12px; color: #333; margin: 0; }

/* ---------- Wallpaper (Display Properties) ---------- */
.wallpaper__screen {
  background: var(--desktop-bg) center / cover no-repeat;
}
.saver .wallpaper__list { flex: 1 1 100%; padding: 2px; }
.wallpaper__list:focus { outline: none; }
.wallpaper__list option { padding: 2px 4px; }
.wallpaper__list option:checked { background: var(--highlight); color: var(--highlight-text); }

/* ---------- Mouse ---------- */
.mouse__trails { flex-wrap: nowrap !important; gap: 14px !important; }
.mouse__demo { position: relative; flex: 0 0 48px; height: 40px; }
.mouse__demo img { position: absolute; width: 12px; height: 19px; image-rendering: pixelated; }
.mouse__demo img:nth-child(1) { left: 4px;  top: 2px;  opacity: 0.35; }
.mouse__demo img:nth-child(2) { left: 14px; top: 10px; opacity: 0.65; }
.mouse__demo img:nth-child(3) { left: 24px; top: 18px; }
.mouse__controls { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mouse__check { display: flex; align-items: center; gap: 6px; }
.mouse__slider { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.mouse__slider input { flex: 1; min-width: 0; accent-color: var(--highlight); }
.mouse__slider input:disabled { opacity: 0.5; }
