/* ============================================================
   AlastairOS: System 7 flavoured personal site
   ============================================================ */

:root {
  --chicago: "Chicago", "Charcoal", "Geneva", "Tahoma", "Verdana", sans-serif;
  --geneva:  "Geneva", "Tahoma", "Verdana", "Helvetica Neue", sans-serif;
  --mono:    "Monaco", "Courier New", monospace;
  --black: #000;
  --win-bg: #fff;
  --gray-ui: #ddd;
  --desktop-a: #5d6780;
  --desktop-b: #66708a;
  --select-blue: #333399;
}

* { box-sizing: border-box; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; }
body { font-family: var(--geneva); font-size: 12px; color: var(--black); }

/* ============ STATIC (NO-JAVASCRIPT) DOCUMENT ============ */
/* Progressive enhancement: the plain document below is the real page, and
   is what crawlers and no-JS visitors get. JavaScript sets .js on <html>,
   which swaps it for the desktop. */
.js #static-content { display: none; }
html:not(.js) #power-screen,
html:not(.js) #boot-screen,
html:not(.js) #desktop,
html:not(.js) #dialog-layer,
html:not(.js) #screensaver,
html:not(.js) #crt-overlay { display: none !important; }
html:not(.js), html:not(.js) body { height: auto; overflow: auto; background: #fff; }

#static-content {
  max-width: 44rem; margin: 0 auto; padding: 40px 20px 80px;
  background: #fff; color: #000;
  font-family: var(--geneva); font-size: 14px; line-height: 1.6;
  user-select: text; -webkit-user-select: text;
}
#static-content h1 { font-family: var(--chicago); font-size: 28px; margin: 0 0 4px; }
#static-content h2 {
  font-family: var(--chicago); font-size: 18px; margin: 34px 0 8px;
  border-bottom: 1px solid #000; padding-bottom: 4px;
}
#static-content h3 { font-family: var(--chicago); font-size: 14px; margin: 18px 0 2px; }
#static-content p { margin: 0 0 10px; }
#static-content .sc-tagline { color: #555; margin-bottom: 26px; font-size: 15px; }
#static-content .sc-when {
  font-family: var(--mono); font-size: 11px; color: #555; margin: 0 0 4px;
  text-transform: uppercase; letter-spacing: 1px;
}
#static-content ul { margin: 0 0 10px; padding-left: 20px; }
#static-content li { margin-bottom: 3px; }
#static-content a { color: var(--select-blue); }
#static-content footer { margin-top: 44px; color: #555; font-size: 12px; }

/* ============ POWER SCREEN ============ */
#power-screen {
  position: fixed; inset: 0; z-index: 9000;
  background: radial-gradient(ellipse at 50% 45%, #16161d 0%, #000 75%);
  display: flex; align-items: center; justify-content: center;
}
.power-inner { text-align: center; }
#power-mac { display: inline-block; opacity: .55; margin-bottom: 28px; filter: grayscale(1) brightness(.8); }
#power-button {
  display: block; margin: 0 auto;
  width: 64px; height: 64px; border-radius: 50%;
  background: #1c1c24; color: #8a8a99;
  border: 2px solid #3a3a48; font-size: 26px; cursor: pointer;
  box-shadow: 0 0 0 6px #0c0c12, inset 0 2px 6px rgba(255,255,255,.06);
  transition: color .25s, border-color .25s, box-shadow .25s;
}
#power-button:hover { color: #d9ffd9; border-color: #5dbb63; box-shadow: 0 0 24px rgba(93,187,99,.35), 0 0 0 6px #0c0c12; }
.power-hint { margin-top: 18px; color: #555566; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }

/* ============ BOOT ============ */
#boot-screen {
  position: fixed; inset: 0; z-index: 8900;
  background: #9a9a9a;
  background-image: conic-gradient(#969696 25%, #a0a0a0 0 50%, #969696 0 75%, #a0a0a0 0);
  background-size: 2px 2px;
  display: flex; align-items: center; justify-content: center;
}
#boot-mac-holder { image-rendering: pixelated; }
#boot-splash { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.splash-box {
  background: #fff; border: 2px solid #000; border-radius: 10px;
  box-shadow: 2px 2px 0 #000;
  padding: 22px 42px 18px; text-align: center; min-width: 320px;
}
.splash-title { font-family: var(--chicago); font-weight: bold; font-size: 22px; margin-bottom: 8px; }
.splash-sub { font-size: 10px; color: #444; margin-bottom: 14px; }
.splash-progress { height: 12px; border: 1px solid #000; background: #fff; padding: 1px; }
.splash-progress-fill { height: 100%; width: 0%; background: repeating-linear-gradient(90deg, #333399 0 6px, #6666cc 6px 12px); transition: width .25s linear; }
#boot-extensions { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; }
#boot-extensions canvas { image-rendering: pixelated; }

/* ============ DESKTOP ============ */
#desktop { position: fixed; inset: 0; z-index: 10; }
#desktop::before {
  content: ""; position: absolute; inset: 0;
  background-image: conic-gradient(var(--desktop-a) 25%, var(--desktop-b) 0 50%, var(--desktop-a) 0 75%, var(--desktop-b) 0);
  background-size: 2px 2px;
}

/* ============ MENU BAR ============ */
#menubar {
  position: absolute; top: 0; left: 0; right: 0; height: 22px;
  background: #fff; border-bottom: 1px solid #000;
  display: flex; align-items: stretch; justify-content: space-between;
  z-index: 5000; font-family: var(--chicago); font-size: 13px;
  padding: 0 6px;
}
.menu-left { display: flex; align-items: stretch; }
.menu-title {
  display: flex; align-items: center; padding: 0 10px; cursor: default; white-space: nowrap;
}
.menu-title.logo-a {
  font-weight: 900; font-size: 15px; padding: 0 12px;
  background-image: linear-gradient(180deg, #61bb46 0 18%, #fdb827 18% 36%, #f5821f 36% 52%, #e03a3e 52% 68%, #963d97 68% 84%, #009ddc 84% 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.menu-title.open, .menu-title:not(.logo-a).open { background: var(--black); color: #fff; }
.menu-title.logo-a.open { background-image: none; background-color: var(--black); color: #fff; }
.menu-right { display: flex; align-items: center; gap: 12px; }
.menu-status { cursor: default; font-family: var(--chicago); }
#menu-sound { cursor: pointer; font-size: 11px; }

#menu-dropdown-layer { position: absolute; inset: 0; z-index: 4990; pointer-events: none; }
.menu-dropdown {
  position: absolute; pointer-events: auto;
  background: #fff; border: 1px solid #000; border-top: none;
  box-shadow: 2px 2px 0 rgba(0,0,0,.6);
  min-width: 180px; padding: 2px 0; font-family: var(--chicago); font-size: 13px;
}
.menu-item {
  padding: 3px 22px 3px 16px; display: flex; justify-content: space-between; gap: 24px;
  white-space: nowrap; cursor: default;
}
.menu-item .shortcut { color: inherit; opacity: .85; }
.menu-item:not(.disabled):hover { background: var(--black); color: #fff; }
.menu-item.disabled { color: #999; }
.menu-item.blinking { animation: menublink .25s steps(2, jump-none) 3; }
@keyframes menublink { 0% { background: var(--black); color: #fff; } 100% { background: #fff; color: #000; } }
.menu-sep { border-top: 1px dotted #888; margin: 3px 1px; }
.menu-item .checkmark { width: 12px; display: inline-block; margin-left: -12px; }

/* ============ DESKTOP ICONS ============ */
#icon-layer { position: absolute; inset: 22px 0 0 0; z-index: 100; }
.desk-icon {
  position: absolute; width: 76px; text-align: center; cursor: default;
  touch-action: none;
}
.desk-icon canvas { image-rendering: pixelated; display: block; margin: 0 auto 3px; }
.desk-icon .icon-label {
  display: inline-block; font-family: var(--geneva); font-size: 11px;
  background: #fff; color: #000; padding: 0 3px; line-height: 14px;
  max-width: 76px; overflow-wrap: break-word;
}
.desk-icon.selected .icon-label { background: var(--black); color: #fff; }
.desk-icon.selected canvas { filter: brightness(.55) contrast(1.2); }

/* ============ WINDOWS ============ */
#window-layer { position: absolute; inset: 0; z-index: 200; pointer-events: none; }
.mac-window {
  position: absolute; pointer-events: auto;
  background: var(--win-bg); border: 1px solid #000;
  box-shadow: 1px 1px 0 #000, 3px 3px 0 rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  min-width: 220px;
}
.mac-window.collapsed .window-body, .mac-window.collapsed .resize-grip { display: none; }

.title-bar {
  height: 20px; flex: 0 0 20px; background: #fff; border-bottom: 1px solid #000;
  position: relative; display: flex; align-items: center; justify-content: center;
  cursor: default; touch-action: none; overflow: hidden;
}
.mac-window.active .title-bar::before {
  content: ""; position: absolute; left: 3px; right: 3px; top: 3px; bottom: 3px;
  background: repeating-linear-gradient(180deg, #000 0 1px, #fff 1px 3px);
  background-position: 0 1px;
}
.title-text {
  position: relative; z-index: 2; background: #fff; padding: 0 7px;
  font-family: var(--chicago); font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 70%;
}
.mac-window:not(.active) .title-text { color: #777; }
.tb-box {
  position: absolute; top: 3px; z-index: 3; width: 13px; height: 13px;
  background: #fff; border: 1px solid #000; cursor: pointer;
}
.mac-window:not(.active) .tb-box { display: none; }
.tb-close { left: 8px; }
.tb-zoom  { right: 8px; }
.tb-zoom::after {
  content: ""; position: absolute; left: 1px; top: 1px; width: 7px; height: 7px; border: 1px solid #000;
}
/* System 7 left an empty square here, but on the web nothing signals that it
   closes the window, so draw an X in it. */
.tb-close::before,
.tb-close::after {
  content: ""; position: absolute; left: 2px; top: 5px;
  width: 7px; height: 1px; background: #000;
}
.tb-close::before { transform: rotate(45deg); }
.tb-close::after  { transform: rotate(-45deg); }
.tb-box:active { background: #000; }
/* keep both glyphs readable while the box is inverted on press */
.tb-close:active::before,
.tb-close:active::after { background: #fff; }
.tb-zoom:active::after { border-color: #fff; }

.window-body {
  flex: 1; overflow: auto; background: #fff; position: relative;
  font-family: var(--geneva); font-size: 12px; line-height: 1.55;
  user-select: text; -webkit-user-select: text;
}
.window-body::-webkit-scrollbar { width: 14px; height: 14px; }
.window-body::-webkit-scrollbar-track {
  background-image: conic-gradient(#ccc 25%, #eee 0 50%, #ccc 0 75%, #eee 0);
  background-size: 2px 2px; border-left: 1px solid #000;
}
.window-body::-webkit-scrollbar-thumb { background: #99a; border: 1px solid #000; }
.window-body::-webkit-scrollbar-corner { background: #fff; }

.resize-grip {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px;
  cursor: nwse-resize; z-index: 5;
  background:
    linear-gradient(135deg, transparent 0 6px, #000 6px 7px, transparent 7px 9px, #000 9px 10px, transparent 10px 12px, #000 12px 13px, transparent 13px);
  background-color: #fff; border-left: 1px solid #000; border-top: 1px solid #000;
  touch-action: none;
}

#drag-outline {
  position: fixed; z-index: 6000; pointer-events: none;
  border: 1px dotted #000; outline: 1px dotted #fff;
}

/* ============ WINDOW CONTENT STYLES ============ */
.pad { padding: 14px 16px; }
.window-body h1 { font-family: var(--chicago); font-size: 18px; margin: 0 0 10px; }
.window-body h2 { font-family: var(--chicago); font-size: 13px; margin: 16px 0 6px; border-bottom: 1px solid #000; padding-bottom: 3px; }
.window-body p { margin: 0 0 9px; }
.window-body a { color: var(--select-blue); }
.window-body ul { margin: 0 0 9px; padding-left: 20px; }
.window-body li { margin-bottom: 3px; }
.dim { color: #555; }
.small { font-size: 10px; }

.mac-btn {
  font-family: var(--chicago); font-size: 12px;
  background: #fff; border: 1px solid #000; border-radius: 7px;
  padding: 3px 14px; cursor: pointer;
}
.mac-btn:active { background: #000; color: #fff; }
.mac-btn.default-btn { box-shadow: 0 0 0 1px #fff, 0 0 0 3px #000; border-radius: 8px; margin: 3px; }

/* SimpleText ruler */
.ruler {
  height: 22px; border-bottom: 1px solid #000; background: #fff;
  background-image: repeating-linear-gradient(90deg, transparent 0 7px, #999 7px 8px),
                    repeating-linear-gradient(90deg, transparent 0 55px, #000 55px 56px);
  background-size: 100% 6px, 100% 12px; background-repeat: no-repeat;
  background-position: 0 14px, 0 8px;
  position: sticky; top: 0; z-index: 2;
}

/* career timeline */
.timeline { border-left: 2px solid #000; margin: 8px 0 8px 6px; padding-left: 16px; }
.timeline-entry { margin-bottom: 14px; position: relative; }
.timeline-entry::before {
  content: ""; position: absolute; left: -22px; top: 3px; width: 8px; height: 8px;
  background: #fff; border: 2px solid #000;
}
.timeline-when { font-family: var(--mono); font-size: 10px; color: #555; }
.timeline-role { font-weight: bold; font-family: var(--chicago); font-size: 13px; }

/* ============ AI LAB ============ */
.lab-list { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 12px; }
.lab-entry { border-left: 2px solid #000; padding-left: 10px; }
.lab-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.lab-name { font-family: var(--chicago); font-size: 13px; font-weight: bold; }
.lab-tag {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  border: 1px solid #000; padding: 0 4px; color: #333; background: var(--gray-ui);
}

/* ============ EMBEDDED PLAYER ============ */
.embed-box { position: relative; border: 1px solid #000; background: #fff; margin: 8px 0 4px; line-height: 0; }
.embed-box iframe { position: relative; display: block; border: 0; width: 100%; }
.embed-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 16px; line-height: 1.5; font-size: 11px; color: #555;
}

/* ============ BUTTON ROW ============ */
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .mac-btn { text-decoration: none; color: #000; }
.btn-row .mac-btn:active { color: #fff; }

/* ============ TRAVEL ============ */
.map-holder { padding: 10px 12px 4px; }
.map-holder canvas { image-rendering: pixelated; display: block; border: 1px solid #000; width: 100%; height: auto; background: #cfdce8; }
.map-caption { font-size: 10px; color: #555; padding: 4px 2px 0; }
.pin-list { padding: 6px 12px 12px; }
.pin-region {
  font-family: var(--chicago); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #333; margin: 12px 0 3px; padding-bottom: 2px; border-bottom: 1px solid #000;
}
.pin-region:first-child { margin-top: 2px; }
.pin-row { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px dotted #ccc; align-items: baseline; }
.pin-flag { width: 22px; text-align: center; }
.pin-name { font-weight: bold; min-width: 110px; font-family: var(--chicago); font-size: 12px; }

/* ============ DESK ACCESSORIES ============ */
.calc { padding: 10px; background: #cfd2d8; height: 100%; }
.calc-display {
  background: #fff; border: 1px solid #000; font-family: var(--mono);
  font-size: 16px; text-align: right; padding: 5px 8px; margin-bottom: 8px;
  overflow: hidden; white-space: nowrap;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 30px; gap: 5px; }
.calc-grid button {
  font-family: var(--chicago); font-size: 14px; background: #fff;
  border: 1px solid #000; border-radius: 5px; cursor: pointer;
  box-shadow: 1px 1px 0 #000;
}
.calc-grid button:active { background: #000; color: #fff; box-shadow: none; transform: translate(1px, 1px); }
.calc-eq { grid-column: 4; grid-row: 4 / span 2; }
.calc-zero { grid-column: 1 / span 2; }

.puzzle { padding: 12px; background: #cfd2d8; height: 100%; }
.puzzle-board {
  display: grid; grid-template-columns: repeat(4, 40px); grid-auto-rows: 40px;
  gap: 2px; border: 2px solid #000; background: #888; width: max-content;
  margin: 0 auto 10px; padding: 2px;
}
.puzzle-tile {
  background: #fff; border: 1px solid #000; font-family: var(--chicago);
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: inset -1px -1px 0 #999;
}
.puzzle-tile:active { background: #000; color: #fff; }
.puzzle-blank { background: #888; border: none; box-shadow: none; cursor: default; }
.puzzle p { text-align: center; margin: 0; }

.patterns { padding: 12px; }
.pattern-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 8px; }
.pattern-swatch { text-align: center; cursor: pointer; }
.pattern-swatch .swatch {
  height: 52px; border: 1px solid #000; image-rendering: pixelated;
  box-shadow: 1px 1px 0 #000;
}
.pattern-swatch.current .swatch { outline: 2px solid #000; outline-offset: 2px; }
.pattern-swatch .swatch-name { font-size: 10px; margin-top: 4px; font-family: var(--chicago); }

/* desktop rubber-band selection */
.marquee {
  position: absolute; z-index: 50; pointer-events: none;
  border: 1px dotted #000; background: rgba(255,255,255,.10);
}

/* ============ DIALOGS ============ */
#dialog-layer { position: fixed; inset: 0; z-index: 7000; background: transparent; }
.mac-dialog {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  background: #fff; border: 2px solid #000; outline: 1px solid #000; outline-offset: 3px;
  box-shadow: 3px 3px 0 rgba(0,0,0,.5);
  min-width: 320px; max-width: 440px; padding: 18px 20px 14px;
}
.dialog-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.dialog-row canvas { image-rendering: pixelated; flex: 0 0 auto; }
.dialog-text { font-family: var(--chicago); font-size: 13px; line-height: 1.5; padding-top: 2px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 12px; }

/* ============ SCREENSAVER / CRT ============ */
#screensaver { position: fixed; inset: 0; z-index: 9500; background: #000; cursor: none; }
#crt-overlay {
  position: fixed; inset: 0; z-index: 8500; pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0,0,0,.13) 0 1px, transparent 1px 3px);
}
#crt-overlay::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,10,.28) 100%);
}

/* ============ SMALL SCREENS ============ */
@media (max-width: 640px) {
  .menu-title { padding: 0 7px; }
  .desk-icon { width: 64px; }
}
