/* Clippy2027 app shell styles, shared by every phase. Phase styles live in
   their own files (office.css for phase 1).

   A Windows 98 skin on top of 98.css (vendor/98css).
   One maximized application window with a menu bar and fixed sections.
   No floating windows, no pop-ups: questions and prompts appear in a fixed dock
   in the Clippy section, and endings replace the app's contents.
   Mobile first: on a phone the app fills the screen. On desktop it sits on a
   teal desktop. 98.css is sized for an 11px pixel font on a 1998 monitor, so
   text and tap targets are scaled up here to stay usable on a phone. */

:root {
  --desktop: #008080;
  --silver: #c0c0c0;
  --navy: #000080;
  --balloon: #ffffe1;
  --muted: #555;
  --danger: #a00000;
  --clippy: #6a4fd8;
  --ui-font: "Pixelated MS Sans Serif", "MS Sans Serif", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--desktop);
  color: #000;
  font-family: var(--ui-font);
  font-size: 13px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: none;
  /* The pixel font's space glyph nearly vanishes when scaled past its native 11px. */
  word-spacing: 0.18em;
}

/* 98.css sets 11px on its controls; bump everything to a readable size. */
button, label, input, .title-bar-text, legend, .window { font-family: var(--ui-font); font-size: 13px; }
button { color: #222; text-shadow: none; min-height: 32px; touch-action: manipulation; }
button:not(:disabled):active { text-shadow: none; }
button:disabled { color: #808080; text-shadow: 1px 1px 0 #fff; }
[hidden] { display: none !important; }

.tb-icon { width: 14px; height: 14px; color: #fff; flex-shrink: 0; }
.title-bar { padding: 4px 3px 4px 4px; }
.title-bar-text { display: flex; align-items: center; gap: 5px; margin-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-bar-controls button { min-height: 16px; min-width: 18px; }

/* A sunken white well, like a list box or edit control. */
.well {
  background: #fff;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  padding: 6px;
}
.inset {
  display: inline-block; min-width: 4.5rem; padding: 3px 6px; text-align: right;
  background: #fff;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.inset.neg { color: var(--danger); }

fieldset { margin: 0; padding: 6px 8px 8px; min-width: 0; }
legend { display: flex; align-items: center; gap: 4px; padding: 0 3px; font-weight: 700; }
.legend-icon { width: 14px; height: 14px; color: var(--clippy); }

/* ---------- the application window ---------- */
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  padding-bottom: calc(3px + env(safe-area-inset-bottom));
}

.menubar { display: flex; gap: 0; padding: 1px 2px; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; position: relative; z-index: 20; }
.menu { position: relative; }
.menu-btn {
  min-width: 0; min-height: 30px; padding: 0 10px;
  background: none; box-shadow: none;
}
.menu-btn:focus { outline: none; }
.menu-btn[aria-expanded="true"], .menu-btn:not(:disabled):active { background: var(--navy); color: #fff; box-shadow: none; }
.menu-list {
  position: absolute; top: 100%; left: 0; min-width: 12rem; margin: 0; padding: 3px; list-style: none;
  background: var(--silver);
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px grey, inset 2px 2px #fff, 2px 2px 0 rgba(0, 0, 0, 0.3);
}
.menu-list button {
  display: block; width: 100%; min-height: 34px; padding: 0 20px; text-align: left;
  background: none; box-shadow: none;
}
.menu-list button:hover, .menu-list button:focus { background: var(--navy); color: #fff; outline: none; }
.menu-list button:disabled:hover { background: none; color: #808080; }
.menu-list .has-sub { position: relative; }
.menu-list .has-sub > button { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sub-arrow { width: 4px; height: 7px; fill: currentColor; }
/* A cascading submenu opens beside its item, Windows style. */
.menu-list.sub { top: -3px; left: calc(100% - 3px); min-width: 11rem; }
.menu-list .has-sub[aria-expanded="true"] > button { background: var(--navy); color: #fff; }
/* A ticked menu item, Windows style. */
.menu-list button[aria-checked="true"]::before { content: "\2713"; position: absolute; margin-left: -14px; }
.menu-list button[role="menuitemcheckbox"] { position: relative; }
.sound-opts { margin-top: 8px; }
.sound-opts .field-row { min-height: 30px; }
.menu-list .sep { height: 0; margin: 3px 2px; border-top: 1px solid #808080; border-bottom: 1px solid #fff; }

/* Game speed: a little toolbar at the right end of the menu bar. */
.speed { margin-left: auto; display: flex; align-items: center; gap: 2px; padding-right: 2px; }
.speed button { min-width: 32px; min-height: 26px; padding: 0; display: grid; place-items: center; }
.speed svg { height: 10px; width: auto; fill: #000; }
.speed button[data-speed="3"] svg { height: 10px; }
.speed button[aria-pressed="true"] {
  box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey;
  background: #dcdcdc;
}
.speed button[aria-pressed="true"] svg { transform: translate(1px, 1px); }

/* Paused, by the player or because Clippy is waiting on an answer: the desk
   goes still and grey. */
.app.paused .pane-left { filter: grayscale(1) contrast(0.8) brightness(1.08); pointer-events: none; transition: filter 0.2s; }

.app-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px 4px;
  overflow-y: auto; overscroll-behavior: contain;
}
.pane-left { display: flex; flex-direction: column; gap: 6px; }


/* ---------- Clippy ---------- */
.chat { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.feed { margin: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overscroll-behavior: contain; }
.msg { animation: appear 0.2s ease-out; }
@keyframes appear { from { opacity: 0; } }

/* Clippy talks in an Office Assistant balloon. */
.msg.clippy { display: flex; gap: 6px; align-items: flex-start; }
.msg.clippy .avatar { flex-shrink: 0; width: 22px; height: 22px; display: grid; place-items: center; color: var(--clippy); }
.msg.clippy .avatar svg { width: 20px; height: 20px; }
.msg.clippy .bubble { background: var(--balloon); border: 1px solid #000; border-radius: 8px; padding: 5px 8px; position: relative; }
.msg.clippy .bubble::before { content: ""; position: absolute; left: -7px; top: 6px; border: 6px solid transparent; border-right-color: #000; border-left: 0; }
.msg.clippy .bubble::after { content: ""; position: absolute; left: -5px; top: 7px; border: 5px solid transparent; border-right-color: var(--balloon); border-left: 0; }
/* Coworkers talk like an old instant messenger. */
.msg.person .who { display: block; font-weight: 700; }
.msg.person .bubble { padding-left: 10px; }
.msg.system { color: #808080; font-style: italic; }
.msg.system .bubble::before { content: "*** "; }

/* Questions, permission prompts and confirmations: a dialog over the whole
   screen, shown only while something's being asked (the game is paused then).
   Its body scrolls if a question is long; the action buttons always sit
   along its bottom edge. */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.35);
}
.dialog:focus { outline: none; }
.dialog { width: 100%; max-width: 26rem; max-height: 100%; display: flex; flex-direction: column; animation: appear 0.15s ease-out; }
.decision { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.sb-dbody { flex: 1 1 auto; min-height: 0; }
.d-body { overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.d-body p { margin: 0 0 6px; }
.d-head { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.d-head svg { flex-shrink: 0; width: 20px; height: 20px; color: var(--clippy); }
.choices { display: flex; flex-direction: column; gap: 5px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: 100%; min-height: 36px; padding: 2px 10px; text-align: left; }
.choice-label { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.choice-label svg { width: 14px; height: 14px; color: var(--clippy); }
.choice-hint { color: #444; }
.tools { display: flex; flex-direction: column; gap: 6px; }
.tools fieldset { padding: 3px 8px 6px; }
.tools legend, .tools dl { word-spacing: normal; }
.tools legend { font-family: "Courier New", Courier, monospace; font-size: 13px; }
.tools dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; font-family: "Courier New", Courier, monospace; font-size: 13px; }
.tools dt { color: #444; }
.tools dd { margin: 0; overflow-wrap: anywhere; }
.tool-ok { font-family: var(--ui-font); font-weight: 400; color: #006400; }
.d-actions { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 6px; }
.d-actions.two { grid-template-columns: 1fr 1fr; }
.d-actions.one { grid-template-columns: 1fr; }
.d-actions button { min-height: 38px; padding: 0 4px; min-width: 0; }
.d-list { margin: 4px 0 0; padding-left: 18px; }
.d-warning { margin: 6px 0; padding: 6px 8px; background: #ffffe1; border: 1px solid #000; font-weight: 700; }
.d-list li { margin: 2px 0; }
.decision a { color: #0000ee; }
.d-build { color: var(--muted); }

/* ---------- Windows 98 scrollbars ----------
   Phone browsers draw thin overlay scrollbars and ignore ::-webkit-scrollbar,
   so scrollbars.js draws a real one next to every scrolling box. The artwork
   is 98.css's own scrollbar art. */
.sb-wrap { display: flex; position: relative; min-height: 0; min-width: 0; }
.sb-target { flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
.sb-target::-webkit-scrollbar { display: none; }
.sb { flex: 0 0 16px; width: 16px; display: flex; flex-direction: column; touch-action: none; user-select: none; }
.sb-wrap.no-overflow > .sb { display: none; }
.sb-btn { flex: 0 0 17px; width: 16px; height: 17px; min-width: 0; min-height: 0; padding: 0; box-shadow: none; background-color: transparent; background-repeat: no-repeat; }
.sb-btn:not(:disabled):active { box-shadow: none; filter: brightness(0.92); }
.sb-btn:focus { outline: none; }
.sb-up { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='16' height='17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15 0H0v16h1V1h14V0z' fill='%23DFDFDF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2 1H1v14h1V2h12V1H2z' fill='%23fff'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M16 17H0v-1h15V0h1v17z' fill='%23000'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15 1h-1v14H1v1h14V1z' fill='gray'/%3E%3Cpath fill='silver' d='M2 2h12v13H2z'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 6H7v1H6v1H5v1H4v1h7V9h-1V8H9V7H8V6z' fill='%23000'/%3E%3C/svg%3E"); }
.sb-down { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='16' height='17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15 0H0v16h1V1h14V0z' fill='%23DFDFDF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2 1H1v14h1V2h12V1H2z' fill='%23fff'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M16 17H0v-1h15V0h1v17z' fill='%23000'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15 1h-1v14H1v1h14V1z' fill='gray'/%3E%3Cpath fill='silver' d='M2 2h12v13H2z'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11 6H4v1h1v1h1v1h1v1h1V9h1V8h1V7h1V6z' fill='%23000'/%3E%3C/svg%3E"); }
.sb-track { flex: 1; position: relative; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='2' height='2' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M1 0H0v1h1v1h1V1H1V0z' fill='silver'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2 0H1v1H0v1h1V1h1V0z' fill='%23fff'/%3E%3C/svg%3E"); }
.sb-thumb { position: absolute; left: 0; right: 0; min-height: 12px; background-color:#dfdfdf;box-shadow:inset -1px -1px #0a0a0a,inset 1px 1px #fff,inset -2px -2px grey,inset 2px 2px #dfdfdf; }

/* Where each scrolling box sits once wrapped. */
.sb-feed { flex: 1 1 0; min-height: 4rem; padding: 2px; }
.sb-feed > .sb { margin: 0; }
#feed { padding: 6px; background: none; box-shadow: none; }
.sb-appbody { flex: 1; min-height: 0; }
/* On a phone the app fills the screen without scrolling as a whole: the top
   two thirds are always the workspace (scrolling inside if it needs to) and
   the bottom third is always the chat. */
.sb-pane { flex: 2 1 0; min-height: 0; }
.pane-left { overflow-y: auto; overscroll-behavior: contain; }


/* ---------- the collapse: the app hangs, then blue-screens ---------- */
/* The real Windows 9x blue screen was VGA text mode: the IBM VGA 9x16 font.
   Font by VileR (int10h.org), CC BY-SA 4.0, see vendor/vga/README.txt. */
@font-face {
  font-family: "IBM VGA 9x16";
  src: url("../vendor/vga/Web437_IBM_VGA_9x16.woff") format("woff");
  font-display: block;
}
.app.collapsing .app-body { filter: grayscale(0.7) contrast(0.85) brightness(1.05); pointer-events: none; transition: filter 3s; }
.app.collapsing .title-bar { background: linear-gradient(90deg, #808080, #b5b5b5); }
.app.collapsing.shaking { animation: hang 0.18s steps(2) infinite; }
@keyframes hang { 50% { transform: translate(1px, -1px); } }
/* Every ending's full-screen moment sits in one overlay; the phase styles each kind. */
.drama {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 18px; cursor: pointer; overflow: hidden;
}
.drama:focus { outline: none; }
.drama .tap { margin-top: 18px; opacity: 0.75; animation: blink 1.2s steps(1) infinite; text-align: center; }
.bsod {
  background: #0000aa; color: #fff;
  /* 16px is the font's native size, so every pixel lands on the grid. */
  font-family: "IBM VGA 9x16", "Lucida Console", "Courier New", monospace; font-size: 16px; line-height: 16px; word-spacing: normal;
  -webkit-font-smoothing: none; font-smooth: never;
  cursor: pointer; animation: none;
}
.bsod-inner { max-width: 38rem; width: 100%; }
.bsod-title { display: block; width: max-content; margin: 0 auto 22px; padding: 0 8px; background: #aaaaaa; color: #0000aa; font-weight: 700; }
.bsod p { margin: 0 0 16px; }
.bsod ul { margin: 0 0 16px; padding: 0; list-style: none; }
.bsod-title { font-weight: 400; }
.bsod li::before { content: "*  "; }
.bsod .cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.bsod-center { text-align: center; }

/* ---------- endings: replace the app's contents ---------- */
.ending { align-items: center; justify-content: flex-start; padding: 16px 10px; }
.ending-card { width: 100%; max-width: 26rem; }
.ending-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.ending-head svg { width: 36px; height: 36px; flex-shrink: 0; color: var(--clippy); }
.ending-head h2 { margin: 0; font-size: 16px; }
.ending p { margin: 6px 0; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 10px 0; padding: 6px 8px; }
.stats b { text-align: right; font-variant-numeric: tabular-nums; }
/* The endings collection: found ones by name, missing ones with a hint. */
.collection { margin: 10px 0 0; padding: 4px 8px 6px; }
.collection ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.collection li::before { content: "\2610  "; color: var(--muted); }
.collection li.found::before { content: "\2611  "; color: #006400; }
.collection li.this b { color: var(--navy); }
.collection li.missing span { color: var(--muted); font-style: italic; }
/* The one that leads on to the next level. */
.collection li.onward-row { background: #ffffe1; outline: 1px dotted var(--navy); outline-offset: -1px; padding: 1px 3px; }
.collection li .onward, .collection li.missing .onward { display: inline-block; padding: 0 4px; margin-left: 2px; background: #006400; color: #fff; font-size: 11px; font-style: normal; }
.collection .new { display: inline-block; padding: 0 4px; background: var(--navy); color: #fff; font-size: 11px; animation: blink 1s steps(1) 4; }
.ending-actions { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.ending-actions button { min-width: 110px; min-height: 38px; }
/* The losing card's DOS prompt. */
.arf { margin: 14px 0 0; text-align: center; font-family: "Courier New", Courier, monospace; font-weight: 700; }
.arf-actions { margin-top: 6px; }
.arf-actions button { min-width: 0; flex: 1 1 0; max-width: 120px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px; }
.arf-actions button span { font-size: 11px; color: #444; }

/* ---------- desktop: the same app, sitting on a teal desktop ---------- */
@media (min-width: 52rem) {
  .app { max-width: 68rem; margin: 0 auto; height: calc(100vh - 32px); height: calc(100dvh - 32px); position: relative; top: 16px; }
  .app-body { display: grid; grid-template-columns: 1fr 1.15fr; grid-template-rows: minmax(0, 1fr); align-items: stretch; gap: 10px; padding: 10px; overflow: hidden; }
  .sb-pane { flex: initial; }
  .ending { display: flex; align-items: center; }
}

/* Short phones: a little tighter. */
@media (max-width: 51.99rem) and (max-height: 700px) {
  .modal { padding: 8px; }
  .choices { gap: 4px; }
  .sb-feed { min-height: 3.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- act 2: the stage ----------
   Levels 5 to 8 leave the Windows 98 window behind. The stage fills the
   screen; each level draws into .stage-body, and the bar floats top right. */
body.act2-live .app { display: none; }
.stage {
  position: fixed; inset: 0; z-index: 5; overflow: hidden;
  background: #07080d; color: #e6e8f0;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  word-spacing: normal;   /* the body's pixel-font spacing stays in act 1 */
  -webkit-font-smoothing: antialiased;
}
.stage[hidden] { display: none; }
.stage-body { position: absolute; inset: 0; }
.stage-bar {
  position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 6px; z-index: 20;
}
.stage-btn {
  width: 36px; height: 36px; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 10px;
  background: rgba(255,255,255,0.08); color: #e6e8f0; box-shadow: none;
  display: grid; place-items: center; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.stage-btn:active, .stage-btn[aria-pressed="true"] { background: rgba(255,255,255,0.22); box-shadow: none; }
.stage-btn:focus { outline: none; }
.stage-btn:focus-visible { outline: 2px solid #8ab4ff; outline-offset: 2px; }
.stage-btn svg { width: 14px; height: 14px; fill: currentColor; }
.stage-menu {
  position: absolute; top: 44px; right: 0; margin: 0; padding: 6px; list-style: none; min-width: 200px;
  background: rgba(20,22,32,0.96); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.stage-menu[hidden] { display: none; }
.stage-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 12px 10px 30px; min-height: 0; border: 0; border-radius: 8px;
  background: none; color: #e6e8f0; box-shadow: none; font: inherit; position: relative; cursor: pointer;
}
.stage-menu button:hover, .stage-menu button:focus-visible { background: rgba(255,255,255,0.08); outline: none; }
.stage-menu button[aria-checked="true"]::before { content: "\2713"; position: absolute; left: 11px; }
.stage-menu button:disabled { opacity: 0.4; }
/* Arriving: out of white from level 4's "all of it", out of black after that. */
.stage.arrive::after {
  content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: #000; animation: stage-arrive 2.4s ease-out forwards;
}
.stage.arrive-white::after { background: #fff; animation-duration: 3.5s; }
@keyframes stage-arrive { from { opacity: 1; } to { opacity: 0; } }
.ending-unlock { font-style: italic; }
