/* ═══════════════════════════════════════════════════════════════
   MAC OS 1984 STAGE
   Scroll-driven zoom into a working System 1 desktop.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --mac-cream: #d8cdb0;
  --mac-bone:  #ede7c8;
  --mac-pure:  #f4eecf;
  --mac-ink:   #1a1815;
  --mac-rule:  #4a4338;
  --mac-shadow:#8d836a;
  --mac-beige: #ded3b8;
  --mac-beige2:#c4ba9d;
  --mac-bezel: #1a1815;
}

/* ─── Stage + sticky ─────────────────────────────────────────── */
.mac-stage {
  position: relative;
  height: 240vh;
  background: #050505;
  border-bottom: 0.5px solid var(--rule, #333);
}
.mac-sticky {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  min-height: 600px;
  overflow: hidden;
  background: radial-gradient(ellipse 80% 70% at center, #131313 0%, #050505 70%);
}
.mac-sticky::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(245,197,24,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.mac-sticky::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(0deg, rgba(0,0,0,0.4), transparent 30%, transparent 70%, rgba(0,0,0,0.4));
  pointer-events: none;
}

/* ─── Zoom wrapper ───────────────────────────────────────────── */
.mac-zoom {
  position: absolute;
  left: 50%; top: 50%;
  width: 1280px;
  height: 800px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--zoom, 0.28));
  transition: transform .08s linear;
  will-change: transform;
}

/* ─── Case chrome (beige plastic) ────────────────────────────── */
.mac-case-chrome {
  position: absolute;
  top: -110px; bottom: -180px; left: -110px; right: -110px;
  background:
    linear-gradient(180deg, #e7dcc0 0%, var(--mac-beige) 28%, var(--mac-beige2) 100%);
  border-radius: 32px 32px 22px 22px;
  z-index: 1;
  box-shadow:
    inset 0 6px 0 rgba(255,255,255,0.55),
    inset 0 -10px 16px rgba(0,0,0,0.22),
    inset 14px 0 24px rgba(0,0,0,0.08),
    inset -14px 0 24px rgba(0,0,0,0.08),
    0 60px 100px rgba(0,0,0,0.65),
    0 0 0 1px rgba(0,0,0,0.3);
  transition: opacity .35s ease-out;
}
.mac-stage.engaged .mac-case-chrome { opacity: 0; pointer-events: none; }

/* Apple logo at top-left of case */
.mac-case-chrome .apple-corner {
  position: absolute;
  top: 38px; left: 48px;
  width: 44px; height: 50px;
  display: flex; align-items: center; justify-content: center;
}
.mac-case-chrome .apple-corner svg { width: 100%; height: 100%; }

/* Disk slot */
.mac-case-chrome .disk-slot {
  position: absolute;
  bottom: 110px; left: 50%; transform: translateX(-50%);
  width: 340px; height: 22px;
  background: #1a1815;
  border-radius: 4px;
  box-shadow:
    inset 0 3px 6px rgba(0,0,0,0.9),
    inset 0 -1px 0 rgba(255,255,255,0.06),
    0 1px 0 rgba(255,255,255,0.25);
}
.mac-case-chrome .disk-slot::after {
  content: '';
  position: absolute;
  bottom: -22px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 5px;
  background: #1a1815;
  border-radius: 1.5px;
}

/* Macintosh brand label */
.mac-case-chrome .mac-brand {
  position: absolute;
  bottom: 52px; left: 50%; transform: translateX(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  letter-spacing: 0.18em;
  color: #6a6048;
  font-weight: 700;
}

/* Vents on side */
.mac-case-chrome .vents-l, .mac-case-chrome .vents-r {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 14px; height: 220px;
  background-image: repeating-linear-gradient(0deg, transparent 0 6px, rgba(0,0,0,0.18) 6px 9px);
}
.mac-case-chrome .vents-l { left: 22px; }
.mac-case-chrome .vents-r { right: 22px; }

/* ─── OS (the screen) ────────────────────────────────────────── */
.mac-os {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--mac-cream);
  border: 14px solid var(--mac-bezel);
  border-radius: 6px;
  z-index: 2;
  font-family: 'Space Mono', monospace;
  color: var(--mac-ink);
  overflow: hidden;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1.5px var(--mac-rule),
    inset 0 0 80px rgba(0,0,0,0.12);
  transition: border-color .4s, border-width .4s, border-radius .4s, box-shadow .4s;
}
.mac-stage.engaged .mac-os {
  border-width: 0;
  border-radius: 0;
  pointer-events: auto;
  box-shadow: none;
}

/* Screen scanlines / phosphor glow */
.mac-os::before {
  content: ''; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,0.04) 2px 3px);
  pointer-events: none;
  z-index: 9999;
  opacity: 0.6;
}
.mac-stage.engaged .mac-os::before { opacity: 0.2; }

/* ─── MENUBAR ────────────────────────────────────────────────── */
.mos-menubar {
  height: 30px;
  background: var(--mac-pure);
  border-bottom: 1.5px solid var(--mac-ink);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 200;
  user-select: none;
}
.mos-menubar .apl, .mos-menubar .m {
  background: transparent;
  border: 0;
  padding: 4px 12px;
  height: 30px;
  color: var(--mac-ink);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  display: flex; align-items: center;
}
.mos-menubar .apl { font-size: 17px; padding: 4px 10px; color: #c2722a; }
.mos-menubar .apl svg { width: 16px; height: 18px; }
.mos-menubar .m.open, .mos-menubar .apl.open,
.mos-menubar .m:hover, .mos-menubar .apl:hover {
  background: var(--mac-ink);
  color: var(--mac-pure);
}
.mos-menubar .apl:hover svg path, .mos-menubar .apl.open svg path { fill: var(--mac-pure); }
.mos-menubar .clk {
  margin-left: auto;
  padding: 0 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mac-ink);
}

/* ─── DROPDOWN MENUS ─────────────────────────────────────────── */
.mos-dropdown {
  position: absolute;
  top: 30px;
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.35);
  min-width: 200px;
  padding: 4px 0;
  z-index: 250;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  display: none;
}
.mos-dropdown.open { display: block; }
.mos-dropdown .dd-item {
  padding: 5px 18px 5px 22px;
  cursor: pointer;
  color: var(--mac-ink);
  display: flex; justify-content: space-between; align-items: center;
  gap: 18px;
}
.mos-dropdown .dd-item.disabled { color: var(--mac-shadow); cursor: default; }
.mos-dropdown .dd-item:hover:not(.disabled) {
  background: var(--mac-ink); color: var(--mac-pure);
}
.mos-dropdown .dd-item .kbd {
  font-size: 12px; letter-spacing: 0.06em; opacity: 0.7;
}
.mos-dropdown .dd-sep {
  height: 1.5px;
  background: var(--mac-ink);
  margin: 4px 12px;
  opacity: 0.5;
}

/* ─── DESKTOP ────────────────────────────────────────────────── */
.mos-desktop {
  position: absolute;
  top: 30px; left: 0; right: 0; bottom: 0;
  /* Classic Mac 50% dither background */
  background-color: var(--mac-cream);
  background-image:
    radial-gradient(circle at 1px 1px, var(--mac-ink) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
  overflow: hidden;
}

/* ─── DESKTOP ICONS ──────────────────────────────────────────── */
.mos-icon {
  position: absolute;
  width: 88px;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.mos-icon .ico {
  width: 52px; height: 42px;
  display: flex; align-items: center; justify-content: center;
}
.mos-icon .ico svg { width: 100%; height: 100%; }
.mos-icon .lbl {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--mac-ink);
  background: transparent;
  padding: 1px 6px;
  text-align: center;
  letter-spacing: 0.02em;
  font-weight: 700;
  line-height: 1.1;
  text-shadow:
    -1px -1px 0 var(--mac-cream), 1px -1px 0 var(--mac-cream),
    -1px 1px 0 var(--mac-cream), 1px 1px 0 var(--mac-cream);
}
.mos-icon:hover .lbl { background: var(--mac-ink); color: var(--mac-pure); text-shadow: none; }
.mos-icon.selected .lbl { background: var(--mac-ink); color: var(--mac-pure); text-shadow: none; }
.mos-icon.selected .ico { filter: brightness(0.6); }

.mos-trash {
  position: absolute;
  bottom: 26px; right: 32px;
  width: 64px;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
  user-select: none;
}
.mos-trash .ico { width: 36px; height: 42px; }
.mos-trash .lbl {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--mac-ink);
  font-weight: 700;
  text-shadow:
    -1px -1px 0 var(--mac-cream), 1px -1px 0 var(--mac-cream),
    -1px 1px 0 var(--mac-cream), 1px 1px 0 var(--mac-cream);
}
.mos-trash.full .ico svg path:first-child { fill: var(--mac-shadow); }

/* Welcome panel on left of desktop */
.mos-welcome {
  position: absolute;
  top: 60px;
  left: 50px;
  max-width: 460px;
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.35);
  padding: 28px 28px 26px;
}
.mos-welcome::before {
  content: '';
  position: absolute;
  top: -1.5px; left: -1.5px; right: -1.5px;
  height: 22px;
  background-image: repeating-linear-gradient(0deg, var(--mac-ink) 0 1px, transparent 1px 3px);
  border-bottom: 1.5px solid var(--mac-ink);
}
.mos-welcome::after {
  content: 'Welcome.app';
  position: absolute;
  top: -2px; left: 50%; transform: translateX(-50%);
  background: var(--mac-pure);
  padding: 2px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  border-left: 1.5px solid var(--mac-ink);
  border-right: 1.5px solid var(--mac-ink);
  z-index: 1;
}
.mos-welcome > div:first-child { margin-top: 18px; }

/* ─── WINDOWS ────────────────────────────────────────────────── */
.mos-windows {
  position: absolute;
  top: 30px; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.mos-window {
  position: absolute;
  width: 540px;
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.4);
  pointer-events: auto;
  font-family: 'Space Mono', monospace;
  color: var(--mac-ink);
  transform-origin: top left;
  animation: winOpen .22s cubic-bezier(.22,1,.36,1);
}
.mos-window.closing { animation: winClose .18s ease-in forwards; }
@keyframes winOpen {
  0%   { transform: scale(0.18); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes winClose {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.12); opacity: 0; }
}
.mos-window.focused { box-shadow: 5px 5px 0 rgba(0,0,0,0.5); }

.win-tb {
  height: 22px;
  display: grid;
  grid-template-columns: 22px 1fr auto 1fr 22px;
  align-items: center;
  border-bottom: 1.5px solid var(--mac-ink);
  background: var(--mac-pure);
  position: relative;
  cursor: grab;
  user-select: none;
}
.win-tb:active { cursor: grabbing; }
.mos-window.focused .win-tb {
  background:
    repeating-linear-gradient(0deg, var(--mac-ink) 0 1px, transparent 1px 3px);
}
.win-close {
  width: 14px; height: 14px;
  margin: 0 4px;
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  padding: 0;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.win-close:hover { background: var(--mac-ink); }
.win-zoom {
  width: 14px; height: 14px;
  margin: 0 4px;
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  padding: 0;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.win-zoom::after {
  content: '';
  position: absolute; inset: 2px;
  border: 1.5px solid var(--mac-ink);
}
.win-title {
  background: var(--mac-pure);
  padding: 1px 16px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  color: var(--mac-ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-align: center;
  position: relative;
  z-index: 1;
  border-left: 1.5px solid var(--mac-ink);
  border-right: 1.5px solid var(--mac-ink);
}
.win-tb .stripes-l, .win-tb .stripes-r {
  height: 100%;
  min-width: 0;
}
.mos-window.focused .win-tb .stripes-l,
.mos-window.focused .win-tb .stripes-r {
  /* stripes show by background of win-tb */
}

.win-body {
  background: var(--mac-pure);
  display: flex; flex-direction: column;
  max-height: 480px;
  overflow: hidden;
}
.win-art {
  height: 180px;
  background: #c2bb98;
  border-bottom: 1.5px solid var(--mac-ink);
  position: relative;
  overflow: hidden;
}
.win-art svg { width: 100%; height: 100%; display: block; }
.win-art .art-overlay {
  position: absolute; top: 8px; right: 10px;
  font-family: 'Space Mono', monospace; font-size: 10px;
  background: var(--mac-pure); border: 1.5px solid var(--mac-ink);
  padding: 2px 7px; letter-spacing: 0.1em; font-weight: 700;
}
.win-text {
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
  font-family: 'Space Mono', monospace;
  color: var(--mac-ink);
  font-size: 13px;
}
.win-text h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  line-height: 1;
  margin: 0;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--mac-ink);
}
.win-text h3 .outline { color: transparent; -webkit-text-stroke: 1.2px var(--mac-ink); }
.win-text p {
  font-size: 13px;
  line-height: 1.5;
  color: #3a342a;
  margin: 0;
}
.win-text .tags {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.win-text .tag {
  border: 1px solid var(--mac-ink);
  padding: 2px 7px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mac-ink);
  font-weight: 700;
}
.win-text .win-meta {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1.5px solid var(--mac-ink);
  margin-top: 4px;
  padding-top: 10px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
}
.win-text .status {
  display: flex; align-items: center; gap: 6px;
  letter-spacing: 0.15em; text-transform: uppercase;
  font-weight: 700;
}
.win-text .status .dot { width: 8px; height: 8px; background: var(--mac-ink); border-radius: 50%; }
.win-text .status.live .dot { background: var(--mac-ink); animation: dotpulse 1.6s infinite; }
@keyframes dotpulse { 0%,100% { transform: scale(1);} 50% { transform: scale(0.5);} }
.win-text .metric b { font-weight: 700; }
.win-text .win-open {
  background: var(--mac-pure);
  border: 1.5px solid var(--mac-ink);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  padding: 6px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--mac-ink);
  align-self: flex-start;
  cursor: pointer;
  margin-top: 6px;
  transition: transform .1s, box-shadow .1s;
}
.win-text .win-open:hover { background: var(--mac-ink); color: var(--mac-pure); }
.win-text .win-open:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(0,0,0,0.4); }

/* "About this Mac" window special */
.mos-window.about .win-body { padding: 20px 24px; font-size: 13px; line-height: 1.6; }
.mos-window.about h2 { font-family: 'Bebas Neue', sans-serif; font-size: 36px; margin-bottom: 8px; }
.mos-window.about .credit-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--mac-rule); }
.mos-window.about .credit-row:last-child { border-bottom: none; }

/* ─── HINTS ──────────────────────────────────────────────────── */
.mac-hint {
  position: absolute;
  bottom: 32px; left: 50%; transform: translateX(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #f5c518;
  background: rgba(10,10,10,0.85);
  padding: 8px 16px;
  border: 1px solid rgba(245,197,24,0.4);
  z-index: 50;
  transition: opacity .3s;
  pointer-events: none;
  white-space: nowrap;
}
.mac-hint .blink {
  display: inline-block; width: 6px; height: 6px; background: #f5c518;
  border-radius: 50%; margin-right: 10px;
  animation: dotpulse 1.4s infinite;
}
.mac-stage.engaged .mac-hint { opacity: 0; }

.mac-exit {
  position: absolute;
  top: 24px; right: 32px;
  z-index: 60;
  background: transparent;
  border: 1px solid #f5c518;
  color: #f5c518;
  padding: 8px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity .3s, background .2s;
  pointer-events: none;
}
.mac-stage.engaged .mac-exit { opacity: 1; pointer-events: auto; }
.mac-exit:hover { background: #f5c518; color: #0a0a0a; }

/* Boot scan line on engage */
.mac-os.booting::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 80px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
  z-index: 9998;
  animation: bootScan 0.9s ease-out 1 forwards;
}
@keyframes bootScan {
  from { transform: translateY(-100%); }
  to   { transform: translateY(900px); opacity: 0; }
}

/* ─── Mobile / small viewport ─────────────────────────────────
   The JS clamps fullScale to fit the viewport, so the same
   scroll-zoom path works at every size. We only tweak the hint. */
@media (max-width: 980px) {
  .mac-hint { font-size: 10px; padding: 6px 12px; letter-spacing: 0.2em; }
  .mac-exit { font-size: 10px; padding: 6px 10px; top: 16px; right: 16px; }
}
