/* ==========================================================
   Visual Systems Lab — retro CRT front page
   Stage is a fixed 1280×720 scene; JS scales it to the viewport.
   Coordinates below are in stage pixels.
   ========================================================== */

:root {
  --teal: #008080;
  --navy: #000080;
  --grey: #c0c0c0;
  --dark: #808080;
  --font-ui: Tahoma, 'MS Sans Serif', Verdana, Arial, sans-serif;   /* the Windows 95 system face */
  --font-dos: 'VT323', 'Courier New', monospace;
  --font-px: 'Silkscreen', monospace;
  --desktop-scale: 0.9318;          /* 645x457 desktop -> 601x426: the bulged screen box */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #fff; color: #000; font-family: var(--font-ui); font-size: 12px; }   /* white, so an iframe embed matches the site */
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- stage ---------- */
.stage-wrap { position: fixed; inset: 0; overflow: hidden; }
/* centred by absolute position + negative margins (a grid track would grow to the unscaled size and overflow on small viewports) */
.stage { position: absolute; left: 50%; top: 50%; width: 738px; height: 720px; margin: -360px 0 0 -369px; transform-origin: center center; user-select: none; }
.photo { position: absolute; inset: 0; width: 738px; height: 720px; display: block; }

/* ---------- screen (traced from photo) ---------- */
.screen {
  position: absolute; left: 68px; top: 68px; width: 601px; height: 426px;
  overflow: hidden; border-radius: 12px / 10px; background: #061a1a;
  /* the bezel opening bulges ~6px top/bottom and ~3px at the sides: clip to that shape (no pixel warping, so text stays crisp) */
  clip-path: path('M3 6 Q300.5 -6 598 6 Q604 213.0 598 420 Q300.5 432 3 420 Q-3 213.0 3 6 Z');
}
.tube {
  position: absolute; inset: 0; background: var(--teal);
  /* no barrel filter: feDisplacementMap resamples the raster and breaks 1px bevels and glyph edges; the glass layers carry the CRT look */
  transform-origin: 50% 50%;
  transition: transform .35s cubic-bezier(.6, 0, .9, .4), opacity .25s .3s;
  animation: flicker 5s ease-in-out infinite;
}
.tube.off { transform: scaleY(0.004); opacity: 0; }
.tube.degauss { animation: degauss .7s ease-out 1; }
.desktop-scale {
  position: absolute; left: 0; top: 0; width: 645px; height: 457px;
  transform: scale(var(--desktop-scale)); transform-origin: top left;
}
@keyframes flicker { 0%, 100% { opacity: 1 } 50% { opacity: .985 } }
@keyframes degauss {
  0%   { filter: hue-rotate(0) saturate(1);         transform: translate(0, 0) }
  15%  { filter: hue-rotate(90deg) saturate(3);     transform: translate(3px, -2px) skewX(1deg) }
  35%  { filter: hue-rotate(-120deg) saturate(2.5); transform: translate(-3px, 2px) skewX(-1deg) }
  60%  { filter: hue-rotate(40deg) saturate(1.6);   transform: translate(1px, -1px) }
  100% { filter: hue-rotate(0) saturate(1);         transform: translate(0, 0) }
}

/* optional scanlines (Help → Toggle scanlines): a sibling of .tube, so the barrel filter never bends them */
.scanlines { position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.08) 0 1px, transparent 1px 3px); }
.scanlines.hidden { display: none; }

/* glass + bezel edge treatment, in the order light builds up */
.fx { position: absolute; inset: 0; pointer-events: none; }
.falloff { background: radial-gradient(ellipse at 50% 48%, transparent 52%, rgba(0,20,20,.35) 82%, rgba(0,10,10,.75) 100%); }
.bezel-shadow { border-radius: 10px / 9px;
  box-shadow: inset 0 14px 18px -6px rgba(0,0,0,.75), inset 10px 0 16px -6px rgba(0,0,0,.6),
              inset -6px 0 12px -6px rgba(0,0,0,.45), inset 0 -8px 14px -6px rgba(0,0,0,.5); }
.glass-edge { inset: 2px; border-radius: 8px / 7px;
  box-shadow: inset 0 0 0 1px rgba(200,235,235,.18), inset 0 1px 0 rgba(255,255,255,.12); }
.reflection { opacity: .10; mix-blend-mode: screen;
  background: linear-gradient(115deg, rgba(255,255,255,0) 30%, rgba(255,255,255,.9) 46%, rgba(255,255,255,0) 60%); }
.specular { inset: auto; left: -70px; top: -150px; width: 470px; height: 330px; transform: rotate(-16deg); border-radius: 50%;
  background: radial-gradient(ellipse at 50% 60%, rgba(255,255,255,.16), rgba(255,255,255,0) 70%); }
.dust { opacity: .05; background: repeating-radial-gradient(circle at 70% 30%, rgba(255,255,255,0) 0 6px, rgba(255,255,255,.6) 6px 7px); }

.off-dot { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: #b2ffff; box-shadow: 0 0 10px 4px rgba(178,255,255,.6); pointer-events: none; }

/* ---------- bezel controls & hotspots ---------- */
.power { position: absolute; left: 616px; top: 529px; width: 40px; height: 40px; background: none; border: 0; cursor: pointer; border-radius: 6px; }
.power:focus-visible { outline: 2px dashed #fff; }
.led { position: absolute; left: 663px; top: 542px; width: 10px; height: 10px; border-radius: 50%; background: #3a2a1a; pointer-events: none; transition: background .2s, box-shadow .2s; }
.led.on { background: #35e050; box-shadow: 0 0 6px 2px rgba(53,224,80,.7); }

/* ---------- boot / screensaver ---------- */
.boot { position: absolute; inset: 0; margin: 0; background: #000; color: #c0c0c0; font: 18px/1.25 var(--font-dos);
  padding: 12px 14px; white-space: pre-wrap; }
.boot::after { content: '_'; animation: cursor 1s steps(1) infinite; }
@keyframes cursor { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }
.saver { position: absolute; inset: 0; z-index: 5; background: #000; overflow: hidden; cursor: pointer; }
.saver canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.saver::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.3) 0 1px, transparent 1px 3px); }

/* ---------- Windows-95-style desktop chrome ---------- */
.bev { background: var(--grey); border: 1px solid; border-color: #dfdfdf #000 #000 #dfdfdf; box-shadow: inset 1px 1px #fff, inset -1px -1px #808080; }
.titlebar { height: 20px; background: var(--dark); color: #c0c0c0; font-weight: bold; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: space-between; padding: 0 2px 0 3px; margin: 2px 2px 0; cursor: move; }
.titlebar > span { display: flex; align-items: center; gap: 3px; }
.titlebar > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.titlebar .ti { width: 16px; height: 16px; flex: none; }
.titlebar.main { height: 21px; cursor: default; }
.titlebar.main, .win.active > .titlebar { background: var(--navy); color: #fff; }
.sysbtn { width: 16px; height: 14px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: #000; cursor: pointer;
  background-repeat: no-repeat; background-position: center; background-size: 7px 7px; }
.sysbtn + .sysbtn[data-wm="close"], .sysbtn.x { margin-left: 2px; }
/* the familiar glyphs, drawn as 7×7 pixel art: _ minimize, □ maximize, × close */
.sysbtn[data-wm="min"], .sysbtn.min { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'><rect x='0' y='5' width='6' height='2' fill='black'/></svg>"); background-position: 3px 4px; }
.sysbtn[data-wm="max"], .sysbtn.max { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'><rect x='0' y='0' width='7' height='2' fill='black'/><rect x='0' y='0' width='1' height='7' fill='black'/><rect x='6' y='0' width='1' height='7' fill='black'/><rect x='0' y='6' width='7' height='1' fill='black'/></svg>"); }
.sysbtn[data-wm="close"], .sysbtn.x { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'><path fill='black' d='M0 0h1v1h-1zM6 0h1v1h-1zM1 1h1v1h-1zM5 1h1v1h-1zM2 2h1v1h-1zM4 2h1v1h-1zM3 3h1v1h-1zM2 4h1v1h-1zM4 4h1v1h-1zM1 5h1v1h-1zM5 5h1v1h-1zM0 6h1v1h-1zM6 6h1v1h-1z'/></svg>"); }
a.sysbtn { font-size: 10px; font-weight: bold; }
.menubar { position: relative; z-index: 50; height: 20px; display: flex; align-items: center; gap: 2px; padding: 0 4px; font-size: 12px; line-height: 1; margin: 1px 2px 0; }
.menubar > button { background: none; border: 0; padding: 2px 6px; cursor: pointer; }
.menubar > button.open { background: var(--navy); color: #fff; }
.menubar .disabled { color: var(--dark); padding: 2px 6px; text-shadow: 1px 1px #fff; }
.menu { position: absolute; top: 20px; min-width: 200px; display: flex; flex-direction: column; padding: 2px; z-index: 60; }
.menu[data-for="file"] { left: 4px } .menu[data-for="window"] { left: 100px } .menu[data-for="help"] { left: 172px }
.menu a, .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; font-size: 12px; line-height: 1; padding: 5px 22px; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--navy); color: #fff; }
.menu .sep { display: block; height: 1px; margin: 3px 2px; background: var(--dark); box-shadow: 0 1px 0 #fff; }
.workspace { position: absolute; left: 0; right: 0; top: 0; bottom: 32px; background: var(--teal); overflow: hidden; }
/* desktop icons: columns down the left, white labels with a shadow, as on a 1998 desktop */
.desk { position: absolute; left: 6px; top: 6px; display: grid; grid-auto-flow: column; grid-template-rows: repeat(6, 67px); gap: 2px 4px; }
.desk .ico { color: #fff; }
.desk .ico span { text-shadow: 1px 1px 0 #000; }
.desk .ico:hover span, .desk .ico:focus-visible span { background: var(--navy); color: #fff; outline: 1px dotted #fff; text-shadow: none; }
.desk .ico svg { filter: drop-shadow(1px 1px 0 rgba(0,0,0,.35)); }

.win { position: absolute; display: flex; flex-direction: column; overflow: hidden; }
.win .body { flex: 1; overflow: hidden; margin: 0 2px 2px; }
.win .body.icons { display: flex; flex-wrap: wrap; align-content: flex-start; padding: 8px 4px; background: #fff; }
.win .body.text { padding: 8px 10px; font-size: 13px; line-height: 1.35; display: flex; flex-direction: column; gap: 6px; }
.win .body.text p { margin: 0; }
.win .body.about { padding: 10px 12px; display: flex; gap: 12px; align-items: flex-start; font-size: 13px; line-height: 1.35; }
.win .body.about > div { display: flex; flex-direction: column; gap: 4px; }
.props-icon svg { width: 40px; height: 40px; display: block; }
#props-name { font-weight: bold; padding-bottom: 2px; }
#props-desc { line-height: 1.35; }

/* tool windows: the real page runs in an iframe on the tube */
.win .body.frame { background: #fff; border: 1px solid; border-color: #808080 #fff #fff #808080; box-shadow: inset 1px 1px #000; }
.win .body.frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.workspace.dragging iframe { pointer-events: none; }
.muted { color: #707070; }
.win[data-win="readme"] .muted { color: #000; }   /* README stays all black */
.win[data-win="readme"] .body.text { font-size: 14px; line-height: 1.4; }   /* README reads a size up */
.chart { font-family: var(--font-px); font-size: 7px; letter-spacing: .1em; padding-top: 4px; } .chart small { font-size: 6px; }
.buttons { display: flex; justify-content: flex-end; gap: 6px; padding: 0 10px 10px; }
.btn { min-width: 75px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; padding: 0 10px; }
.btn.default { outline: 1px solid #000; }
.grip { position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; cursor: nwse-resize;
  background: repeating-linear-gradient(135deg, transparent 0 2px, #fff 2px 3px, var(--dark) 3px 4px); }

.ico { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 74px; text-align: center; background: none; border: 0; padding: 2px 0; cursor: pointer; color: #000; }
.ico svg { width: 32px; height: 32px; overflow: visible; }
.ico span { font-size: 12px; line-height: 1.15; padding: 1px 3px; white-space: pre-line; }
.ico:hover span, .ico:focus-visible span { background: var(--navy); color: #fff; outline: 1px dotted #ff0; }

/* start menu (opens above the taskbar) */
.startmenu { position: absolute; left: 6px; bottom: 32px; min-width: 190px; display: flex; flex-direction: column; padding: 2px; z-index: 70; }
.startmenu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; font-size: 12px; padding: 5px 10px; cursor: pointer; }
.startmenu button:hover { background: var(--navy); color: #fff; }
.startmenu button svg { width: 24px; height: 24px; flex: none; }
.startmenu .sep { display: block; height: 1px; margin: 3px 2px; background: var(--dark); box-shadow: 0 1px 0 #fff; }

/* Minesweeper */
.ms { padding: 6px; display: flex; flex-direction: column; gap: 6px; align-items: center; user-select: none; }
.bev-in { border: 2px solid; border-color: #808080 #fff #fff #808080; }
.ms-top { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 4px 5px; }
.ms-led { font: bold 18px/1 'Courier New', monospace; color: #f00; background: #000; padding: 1px 2px; letter-spacing: 1px; border: 1px solid; border-color: #808080 #fff #fff #808080; }
.ms-face { width: 26px; height: 26px; padding: 2px; background: var(--grey); border: 2px solid; border-color: #fff #808080 #808080 #fff; cursor: pointer; }
.ms-face svg { width: 100%; height: 100%; display: block; }
.ms-face:active { border-color: #808080 #fff #fff #808080; }
.ms-grid { display: grid; grid-template-columns: repeat(9, 16px); grid-auto-rows: 16px; background: #c0c0c0; }
.ms-cell { width: 16px; height: 16px; padding: 0; margin: 0; background: var(--grey); border: 2px solid; border-color: #fff #808080 #808080 #fff;
  font: bold 11px/1 Tahoma, Verdana, sans-serif; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ms-cell.open { border: 1px solid #808080; border-width: 1px 0 0 1px; }
.ms-cell.hit { background: #f00; }
.ms-cell.wrong { background: #f00; }
.ms-cell svg { width: 14px; height: 14px; }
.ms-cell[data-n="1"] { color: #0000ff } .ms-cell[data-n="2"] { color: #008000 } .ms-cell[data-n="3"] { color: #ff0000 } .ms-cell[data-n="4"] { color: #000080 }
.ms-cell[data-n="5"] { color: #800000 } .ms-cell[data-n="6"] { color: #008080 } .ms-cell[data-n="7"] { color: #000000 } .ms-cell[data-n="8"] { color: #808080 }

/* Solitaire */
.sol { display: flex; flex-direction: column; height: 100%; background: #008000; user-select: none; }
.sol-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px; background: var(--grey); border-bottom: 1px solid var(--dark); }
.sol-bar .btn { height: 20px; min-width: 0; padding: 0 8px; }
.sol-msg { font-weight: bold; }
.sol-board { position: relative; flex: 1; overflow: auto; }
.sol-slot { position: absolute; width: 50px; height: 70px; border: 1px dashed rgba(255,255,255,.55); border-radius: 4px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.55); font-size: 22px; }
.sol-slot.stock { border-style: solid; }
.card { position: absolute; width: 50px; height: 70px; box-sizing: border-box; border-radius: 4px; background: #fff; border: 1px solid #333; cursor: pointer;
  font: bold 11px/1 Tahoma, Verdana, sans-serif; box-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.card.red { color: #c00; } .card.black { color: #000; }
.card .tl { position: absolute; left: 3px; top: 3px; } .card .br { position: absolute; right: 3px; bottom: 3px; transform: rotate(180deg); }
.card .pip { position: absolute; left: 0; right: 0; top: 22px; text-align: center; font-size: 24px; font-weight: normal; }
.card.back { background: #1a4a7a url(../assets/cvc-logo.png) center / 34px auto no-repeat; border-color: #0b2a4a;
  box-shadow: inset 0 0 0 3px #fff, 1px 1px 0 rgba(0,0,0,.35); }
.card.sel { outline: 2px solid #ffd700; outline-offset: -1px; }
.sol-win { position: absolute; left: 0; top: 0; pointer-events: none; }
.sol .sol-win { top: 29px; }

/* taskbar along the bottom of the screen */
.taskbar { position: absolute; left: 0; right: 0; bottom: 0; height: 32px; background: var(--grey); border-top: 1px solid #fff; box-shadow: 0 -1px 0 #dfdfdf;
  display: flex; align-items: center; gap: 4px; padding: 2px 6px 5px; font-size: 12px; }
.startbtn { height: 22px; display: inline-flex; align-items: center; gap: 4px; padding: 0 6px 0 4px; font-weight: bold; font-size: 12px; cursor: pointer; }
.startbtn .ti { width: 16px; height: 16px; }
.tray { flex: 1; display: flex; gap: 3px; align-items: center; min-width: 0; overflow: hidden; }
.tray .ico { flex-direction: row; width: auto; max-width: 160px; height: 22px; gap: 4px; padding: 0 8px 0 4px; }
.tray .ico svg { width: 16px; height: 16px; flex: none; }
.tray .ico span { padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray .ico:hover span { background: none; color: #000; outline: 0; }
.sunk { height: 22px; display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid; border-color: #808080 #fff #fff #808080; white-space: nowrap; }

/* ---------- phones: the handheld ----------
   A 328×613 scene (the photo is 656×1226, shown at half size for crispness) scaled to
   the viewport by fit(), so the device spans the full width of a phone. The screen is
   250×457 at (38,34); inside it the desktop chrome
   is reused at its normal sizes, stacked vertically and scrolling. */
.palm-wrap { display: none; position: fixed; inset: 0; overflow: hidden; background: #fff; }
.palm { position: absolute; left: 50%; top: 50%; width: 328px; height: 613px; margin: -307px 0 0 -164px; transform-origin: center center; }
.palm-photo { position: absolute; inset: 0; width: 328px; height: 613px; display: block; border-radius: 26px; }   /* rounds off the photo's corners against white */
.palm-screen { position: absolute; left: 38px; top: 34px; width: 250px; height: 457px; border-radius: 5px; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px; padding: 5px; background: var(--teal); color: #000; font-family: var(--font-ui);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4), inset 0 2px 6px rgba(0,0,0,.35); }
.palm-progman { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.palm-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 5px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
#palm-list { display: flex; flex-direction: column; gap: 6px; }
.pwin { display: flex; flex-direction: column; flex: none; }
.pwin .titlebar { cursor: default; color: #000; }
.palm-screen .muted { color: #000; }   /* on the handheld every word is black */
.pwin .body.icons { display: grid; grid-template-columns: repeat(3, 1fr); justify-items: center; row-gap: 6px; padding: 6px 0 5px; }
.pwin .ico { width: auto; min-width: 70px; padding: 0 2px; }
.pwin .body.text { padding: 6px 8px; font-size: 15px; line-height: 1.08; display: flex; flex-direction: column; gap: 5px; }
.pwin .body.text p { margin: 0; }
.palm-links a { text-decoration: underline; white-space: nowrap; }   /* the phone number must never break at its hyphens */
.palm-progman[hidden] { display: none; }
.palm-view .pv-title { display: flex; align-items: center; gap: 4px; }
.palm-view .pv-bar { flex: none; display: flex; gap: 4px; padding: 4px 3px; }
.palm-view .pv-bar .btn { min-width: 0; flex: 1; height: 26px; font-size: 12px; color: #000; text-decoration: none; }
.palm-view .body.frame { flex: 1; min-height: 0; margin: 0 3px 3px; background: #fff; border: 1px solid; border-color: #808080 #fff #fff #808080; box-shadow: inset 1px 1px #000; }
.palm-view iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.palm-status { flex: none; display: flex; justify-content: space-between; gap: 6px; padding: 0 2px; font-size: 10px; letter-spacing: .02em; color: #b2ffff; }
.palm-status span { white-space: nowrap; }
.palm-btn { position: absolute; display: block; width: 78px; height: 56px; border-radius: 16px; }
.palm-btn:focus-visible { outline: 3px dashed #fff; }
/* the handheld replaces the CRT when the viewport (or the embedding iframe) is portrait, so a
   narrow-but-landscape frame, e.g. two embeds side by side on a desktop, keeps the monitor */
@media (orientation: portrait) {
  .stage-wrap { display: none; }
  .palm-wrap { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .tube, .boot::after { animation: none !important; }
}
