/* =========================================================================
   patriarsch.at -- the Bad Ideas control panel and its four utilities
   Paired with desktop.js. office.css styles the pack that extends it.

   Everything here is Windows 95: #c0c0c0, outset bevels that go inset when
   pressed, a navy gradient titlebar and W95FA for the lettering. The chrome
   is deliberately the same as the fake error popups in eggs.css, because
   these are the windows you are meant to believe are the same furniture --
   the difference is that these ones work.
   ========================================================================= */

/* --- the HUD launcher ----------------------------------------------------- */
/* The HUD is a pill of round buttons; this is a labelled rectangle in the
   middle of it, so the container has to stop sizing itself to round buttons. */
#hud.has-bad-ideas { width: max-content; max-width: calc(100vw - 24px); }
#hud #bad-launcher {
  width: auto; padding: 0 10px; border-radius: 4px;
  font-weight: 700; white-space: nowrap;
  background: #c0c0c0; color: #111; border: 2px outset #eee;
  font-family: 'W95FA', 'MS Sans Serif', sans-serif;
}
#hud #bad-launcher:hover { background: #dfdfdf; }
#hud #bad-launcher:active { border-style: inset; }

/* --- the window ----------------------------------------------------------- */
/* A native <dialog>, so the backdrop and the focus containment are the
   browser's. max-width has to be cleared: the UA sheet caps dialogs at
   calc(100% - 6px - 2em), which fights the width set here on small screens. */
.bad-dialog {
  --win-gray: #c0c0c0;
  width: min(560px, calc(100vw - 24px)); max-width: none;
  max-height: calc(100dvh - 24px); padding: 3px;
  overflow-y: auto; overscroll-behavior: contain;
  border: 3px outset #eee; background: var(--win-gray); color: #151515;
  box-shadow: 8px 8px 0 #0005;
  font: 16px/1.35 'W95FA', 'MS Sans Serif', Tahoma, sans-serif;
}
.bad-dialog::backdrop { background: #0600179e; }

/* Form controls inherit nothing by default, and an app in Arial inside a
   window in W95FA looks like a bug rather than a joke. */
.bad-dialog button, .bad-dialog input, .bad-dialog textarea { font: inherit; color: inherit; }
.bad-dialog button {
  border: 2px outset #eee; background: var(--win-gray);
  padding: 7px 12px; min-height: 36px; cursor: pointer;
}
.bad-dialog button:hover { background: #d7d7d7; }
.bad-dialog button:active { border-style: inset; }
/* The engraved-grey disabled label, which is the one piece of 95 that still
   gets copied: grey text with a white shadow one pixel down. */
.bad-dialog button:disabled { color: #6a6a6a; cursor: default; text-shadow: 1px 1px #eee; }
.bad-dialog :focus-visible { outline: 2px solid #000080; outline-offset: 2px; }
.bad-dialog input, .bad-dialog textarea {
  min-width: 0; width: 100%; border: 2px inset #eee; border-radius: 0;
  background: white; padding: 8px; resize: vertical;
}

/* Sticky, because these windows scroll: the close button has to stay reachable
   on a phone without scrolling back to the top of a defragmenter. */
.bad-titlebar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 3px 4px 3px 7px; background: linear-gradient(90deg, #000080, #1084d0); color: white;
}
.bad-titlebar b { font-size: 15px; }
.bad-dialog .bad-x {
  min-height: 28px; width: 29px; padding: 0; flex-shrink: 0;
  color: #111; font: 700 24px/1 monospace;
}
.bad-titlebar :focus-visible { outline-color: white; }

.bad-body { padding: 18px; }
.bad-body h1 { font-size: 23px; line-height: 1.1; margin: 0 0 8px; }
.bad-body p { margin: 8px 0 15px; }
.bad-statusbar { display: flex; gap: 3px; font-size: 13px; color: #444; }
.bad-statusbar span { flex: 1; padding: 3px 6px; border: 1px inset #e0e0e0; }
.bad-statusbar span:last-child { text-align: right; }

/* --- the launcher panel --------------------------------------------------- */
.bad-intro { display: flex; gap: 15px; align-items: center; margin-bottom: 18px; }
.bad-intro p { margin: 0; color: #454545; }
.bad-stamp { font: italic 700 44px/1 Georgia, serif; color: #000080; border-bottom: 5px solid #008080; }

/* The tab strip and its panels. [hidden] needs restating because the grid
   display on .bad-apps would otherwise win over it and show every panel. */
.bad-apps { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.bad-apps[hidden] { display: none; }
/* Four tabs do not fit a phone in one row, so they wrap into two -- which is
   what a Windows 95 property sheet with too many tabs did as well. */
.bad-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 2px groove #eee; }
.bad-tabs button { flex: 1 1 auto; border-bottom: 0; padding: 7px; }
.bad-tabs [aria-selected="true"] { background: #ddd; font-weight: bold; box-shadow: inset 0 3px #000080; }
.bad-apps button { text-align: left; padding: 12px; }
.bad-apps button > span { display: block; font-size: 28px; margin-bottom: 5px; }
.bad-apps b, .bad-apps small { display: block; }
.bad-apps small { margin-top: 4px; color: #424242; font-size: 14px; }

.bad-classics {
  margin: 18px 0; padding: 10px; border: 2px groove #eee;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px;
}
.bad-classics legend { padding: 0 5px; }
.bad-classics button { padding: 5px 8px; white-space: nowrap; }

.bad-run > label { display: block; margin-bottom: 5px; }
.bad-run > div { display: flex; gap: 7px; }
.bad-run button { flex-shrink: 0; }

/* --- shared furniture ----------------------------------------------------- */
/* Every app uses these three, so an app is a body of markup and nothing else:
   .bad-feedback is the status line, .bad-actions the button row along the
   bottom, .bad-muted the small print. */
.bad-feedback {
  min-height: 2.6em; padding: 9px 10px;
  border: 1px inset #eee; background: #ffffff40; font-size: 14px;
}
.bad-actions {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-top: 12px;
}
.bad-actions button:last-child { margin-left: auto; }
.bad-muted { font-size: 13px; color: #454545; }

/* --- the defragmenter ----------------------------------------------------- */
/* 20 columns of 120 blocks, which is the shape the real one drew. The colours
   are its: blue for used, magenta for fragmented, green as it consolidates. */
.defrag-map {
  display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px;
  padding: 10px; border: 2px inset #eee; background: #fff; margin: 18px 0 10px;
}
.defrag-map i { aspect-ratio: 1; background: #0000a8; border: 1px solid #0006; }
.defrag-map .fragment { background: #b000b0; }
.defrag-map .load-bearing { background: #444; }
/* Load-bearing blocks never go green -- they are not going anywhere. */
.defrag-map .organized:not(.load-bearing) { background: #008c55; }
.defrag-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-bottom: 20px; }
.defrag-legend span:first-child { color: #800080; }
.defrag-legend span:nth-child(2) { color: #00683f; }
.bad-dialog progress { display: block; width: 100%; height: 24px; margin-top: 5px; accent-color: #000080; }

/* --- the CAPTCHA ---------------------------------------------------------- */
/* The navy instruction block, which is the one part of a real CAPTCHA everyone
   can picture without being shown. */
.captcha-instructions { padding: 17px; background: #000080; color: white; margin-bottom: 12px; }
.captcha-instructions small { font-size: 12px; letter-spacing: .06em; }
.captcha-instructions h1 { font-size: 21px; margin-top: 12px; }
.captcha-instructions strong { display: block; font-size: 30px; }
.captcha-instructions p { margin-bottom: 0; }
.captcha-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.captcha-grid button {
  aspect-ratio: 1.3; padding: 7px; display: grid; place-items: center;
  background: #f1f0e4; font-size: 34px; position: relative;
}
.captcha-grid img { width: 85%; max-height: 82px; object-fit: contain; pointer-events: none; }
/* Selection is drawn twice -- blue fill and a tick -- so it does not depend on
   telling two similar greys apart. */
.captcha-grid [aria-pressed="true"] { background: #bad9fa; border: 3px solid #000080; padding: 6px; }
.captcha-grid [aria-pressed="true"]::after {
  content: '✓'; position: absolute; top: 2px; right: 4px;
  font: bold 19px/1 sans-serif; color: #000080;
}

/* --- technical support ---------------------------------------------------- */
/* The paperclip is inline SVG in desktop.js, so it needs no asset and cannot
   fail to load. The bubble is Office's pale yellow. */
.clippy-scene { display: flex; align-items: center; gap: 15px; margin: 0 0 16px; }
.clippy { width: 95px; flex: 0 0 95px; }
.clippy-bubble {
  padding: 17px; background: #ffffcc; border: 1px solid #111;
  border-radius: 10px; box-shadow: 3px 3px #0003;
}
.clippy-options { display: grid; gap: 8px; }
.clippy-options button { text-align: left; }

/* --- the guestbook -------------------------------------------------------- */
.guestbook-form { display: grid; gap: 5px; }
.guestbook-form label:not(:first-child) { margin-top: 7px; }
/* overflow-wrap because a visitor will paste a 180-character word, and
   pre-wrap because their line breaks are the only formatting they have. */
.guestbook-entries article {
  background: #ffffdf; border: 1px inset #eee; padding: 10px 12px;
  margin-top: 7px; overflow-wrap: anywhere;
}
.guestbook-entries small { display: block; color: #65654b; font-size: 12px; }
.guestbook-entries p { margin: 7px 0 0; white-space: pre-wrap; }

/* --- touch and small screens ---------------------------------------------- */
/* Everything here is reachable by tap, so the hit targets have to be real
   ones: 44px is the size below which a phone user starts missing. */
@media (pointer: coarse) {
  #hud.has-bad-ideas button { min-width: 40px; min-height: 40px; }
  .has-bad-ideas #vol { height: 8px; }
  .bad-dialog button { min-height: 44px; }
  .bad-dialog .bad-x { width: 44px; }
}
@media (max-width: 640px) {
  #hud.has-bad-ideas {
    width: max-content; max-width: calc(100vw - 20px); gap: 10px;
    padding: 8px 12px; border-radius: 16px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  /* The braindead meter is the first thing to go: it is a readout, and the
     buttons either side of it are controls. */
  #hud.has-bad-ideas .bdmeter { display: none; }
  .has-bad-ideas #vol { width: 70px; }
  .bad-body { padding: 13px; }
  .bad-intro { gap: 10px; }
  .bad-body h1 { font-size: 21px; }
  .bad-classics { margin: 14px 0; padding: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bad-apps button { padding: 10px; }
  .bad-dialog .bad-actions { flex-wrap: wrap; }
  .bad-apps small { font-size: 13px; }
  .bad-stamp { font-size: 35px; }
  .clippy { width: 70px; flex-basis: 70px; }
  .clippy-bubble { padding: 12px; }
  .defrag-map { gap: 2px; padding: 6px; }
}
