/**
 * RoccOS Desktop, Taskbar, Start Menu, Icons
 * Warm neutral: frosted glass taskbar, rounded menus, gradient mesh wallpaper
 */

/* ── Pre-boot element hiding ──
   Elements are CSS-hidden until boot completes.
   No GSAP race condition — browser hides elements on first paint. */
body:not(.os-booted) .menu-bar,
body:not(.os-booted) .dock,
body:not(.os-booted) #desktop-icons {
  opacity: 0;
  pointer-events: none;
}

/* ── Accessibility ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--os-accent);
  color: var(--os-accent-text);
  padding: var(--sp-2) var(--sp-4);
  z-index: var(--z-mega-menu-panel);
  font-family: var(--font-system);
}

.skip-link:focus {
  top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Desktop ── */
.desktop {
  position: fixed;
  z-index: var(--z-desktop);
  font-family: var(--font-system);
  color: var(--os-text);
  user-select: none;
  -webkit-user-select: none;

  /* Lock to monitor aspect-ratio and scale-to-fit */
  aspect-ratio: 16 / 10;
  width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  max-width: 100vw;
  /* Center in viewport */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* The glass corner. Kept small on purpose: the tube curve, not this
     radius, defines the screen edge, so nothing at the perimeter is lost. */
  --desktop-radius: 18px;
  --desktop-corner-safe-inset: var(--sp-2);
  /* Set by crt-homepage.js: how far the bulge pulls each edge midpoint in. */
  --crt-bow-x: 0px;
  --crt-bow-y: 0px;
}

/* The curved glass sits inside a dark monitor housing. This backdrop is what
   shows around the bowed screen edge. */
.scene {
  background: #10130d;
}

/* ── CRT Screen ──
   The homepage keeps its own colour and typography; this is optical texture,
   not a theme. A live displacement map bulges the whole surface (content is
   drawn slightly INWARD toward the centre so every pixel stays on screen),
   which makes the screen outline itself barrel outward like real glass. */
.desktop {
  border-radius: var(--desktop-radius);
  overflow: hidden;
}

.desktop::before,
.desktop::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: var(--z-crt-overlay);
  pointer-events: none;
}

.crt-glare {
  display: block;
  position: absolute;
  inset: 0;
  z-index: var(--z-crt-overlay);
  pointer-events: none;
}

.desktop.has-crt-warp {
  /* The fractional beam blur is intentional: it blends the 8-bit displacement
     increments into a continuous CRT phosphor edge instead of a jagged line. */
  filter: url('#crt-barrel-filter') blur(0.45px);
}

/* Scanlines + phosphor triads. They live inside the filtered element, so the
   same tube curve bends them: straight at centre, visibly bowed at the edges.
   Contrast is high enough to read on white app windows, and a slow bright
   band rolls down the tube the way a camera catches a real CRT refresh. */
.desktop::before {
  background:
    /* rolling refresh band */
    linear-gradient(180deg,
      transparent 0%,
      rgba(255, 252, 237, 0.05) 42%,
      rgba(255, 252, 237, 0.11) 50%,
      rgba(255, 252, 237, 0.05) 58%,
      transparent 100%),
    /* scanlines */
    repeating-linear-gradient(0deg,
      rgba(6, 12, 8, 0.24) 0px,
      rgba(6, 12, 8, 0.24) 1px,
      transparent 1px,
      transparent 3px),
    /* RGB phosphor triads */
    repeating-linear-gradient(90deg,
      rgba(255, 48, 48, 0.03) 0px,
      rgba(255, 48, 48, 0.03) 1px,
      rgba(64, 255, 100, 0.024) 1px,
      rgba(64, 255, 100, 0.024) 2px,
      rgba(70, 100, 255, 0.03) 2px,
      rgba(70, 100, 255, 0.03) 3px);
  background-size: 100% 220px, 100% 3px, 3px 100%;
  background-repeat: no-repeat, repeat, repeat;
  animation:
    crt-roll 9s linear infinite,
    crt-scan-drift 8s steps(2, end) infinite;
  mix-blend-mode: multiply;
}

/* Soft tube vignette: darker toward the glass edge, with a slow breathe. */
.desktop::after {
  box-shadow: inset 0 0 60px 18px rgba(12, 16, 10, 0.22);
  animation: crt-breathe 4.8s ease-in-out infinite;
}

.crt-glare {
  background:
    radial-gradient(ellipse 60% 50% at 35% 25%,
      rgba(255, 252, 237, 0.075) 0%,
      rgba(255, 252, 237, 0.025) 40%,
      transparent 100%),
    radial-gradient(ellipse 90% 25% at 50% 6%,
      rgba(255, 252, 237, 0.045) 0%,
      transparent 100%);
}

.crt-glare::after {
  content: '';
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 252, 237, 0.14) 20%,
      rgba(255, 252, 237, 0.24) 50%,
      rgba(255, 252, 237, 0.14) 80%,
      transparent 100%);
}

/* An old computer deserves the old arrow. The XP cursor set is defined in
   tokens.css; controls pick their own hand/text/resize variants there. */
.desktop {
  cursor: var(--cur-arrow); --crt-cursor: arrow;
}

@keyframes crt-roll {
  0% { background-position: 0 -260px, 0 0, 0 0; }
  100% { background-position: 0 calc(100% + 260px), 0 0, 0 0; }
}

@keyframes crt-scan-drift {
  0%, 100% { opacity: 0.96; }
  47% { opacity: 1; }
  48% { opacity: 0.86; }
  48.6% { opacity: 1; }
  61% { opacity: 0.94; }
}

@keyframes crt-breathe {
  0%, 100% { opacity: 0.96; }
  52% { opacity: 1; }
  53% { opacity: 0.9; }
  55% { opacity: 0.98; }
}

@media (prefers-reduced-motion: reduce) {
  .desktop::before,
  .desktop::after {
    animation: none;
  }
}

@media (max-width: 768px) {
  /* The physical tube reads at desktop scale. On a handset keep its texture
     light so the interface stays legible at the smaller viewing distance. */
  .desktop.has-crt-warp {
    filter: none;
  }
  .desktop::before {
    background-image:
      repeating-linear-gradient(0deg,
        rgba(6, 12, 8, 0.12) 0px,
        rgba(6, 12, 8, 0.12) 1px,
        transparent 1px,
        transparent 3px);
    background-size: 100% 3px;
    animation: none;
  }
  .desktop::after { box-shadow: inset 0 0 24px 8px rgba(18, 23, 15, 0.12); }
}

/* ── Wallpaper — Nezu atmospheric mist ── */
.wallpaper {
  position: absolute;
  inset: 0;
  z-index: var(--z-wallpaper);
  background: var(--os-desktop-bg);
  overflow: hidden;
}

/* Orbs — soft atmospheric gradient clouds */
.wallpaper .orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.wallpaper .orb--peach {
  width: 400px;
  height: 400px;
  background: var(--os-gradient-peach);
  filter: blur(120px);
  opacity: 0.3;
  top: -12%;
  left: 55%;
}

.wallpaper .orb--rose {
  width: 360px;
  height: 360px;
  background: var(--os-gradient-rose);
  filter: blur(115px);
  opacity: 0.25;
  top: 20%;
  left: 2%;
}

.wallpaper .orb--lilac {
  width: 320px;
  height: 320px;
  background: var(--os-gradient-lilac);
  filter: blur(110px);
  opacity: 0.2;
  top: 48%;
  left: 48%;
}

.wallpaper .orb--peach-sm {
  width: 200px;
  height: 200px;
  background: var(--os-gradient-peach);
  filter: blur(90px);
  opacity: 0.15;
  top: 68%;
  left: 5%;
}

/* Dark theme wallpaper */
[data-theme="dark"] .wallpaper {
  background: var(--os-desktop-bg);
}

[data-theme="dark"] .wallpaper .orb--peach { opacity: 0.15; }
[data-theme="dark"] .wallpaper .orb--rose { opacity: 0.12; }
[data-theme="dark"] .wallpaper .orb--lilac { opacity: 0.10; }
[data-theme="dark"] .wallpaper .orb--peach-sm { opacity: 0.06; }

/* Retro theme wallpaper — black, no orbs */
[data-theme="retro"] .wallpaper {
  background: #0a0a0a;
}
[data-theme="retro"] .wallpaper .orb { display: none; }

.wallpaper[data-time="custom"] {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}


/* ── Menu Bar — hidden (empty, all content removed) ── */
.menu-bar {
  display: none !important;
}

.menu-bar-left,
.menu-bar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.menu-bar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}

.menu-bar-logo:hover {
  background: rgba(0, 0, 0, 0.08);
}

.menu-bar-logo img {
  width: 16px;
  height: 16px;
  border-radius: 2px;
}

.menu-bar-app-name {
  display: none;
}

.menu-bar-clock {
  display: none;
}

/* ── Menu Bar Quick Links ── */
.menu-bar-links {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.menu-bar-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--os-menu-text);
  opacity: 0.7;
  cursor: var(--cur-hand); --crt-cursor: hand;
  transition: opacity var(--duration-fast);
  text-decoration: none;
}

.menu-bar-link:hover {
  opacity: 1;
}

/* ── Menu Bar Responsive ── */
@media (max-width: 900px) {
  .menu-bar-links {
    display: none;
  }
}

/* ── Desktop Icons — rounded, soft ── */
.desktop-icons {
  position: absolute;
  top: var(--desktop-padding);
  left: var(--desktop-padding);
  bottom: calc(var(--taskbar-height) + var(--taskbar-padding) * 2 + var(--desktop-padding));
  z-index: var(--z-desktop-icons);
  display: grid;
  grid-template-rows: repeat(4, auto);
  grid-auto-flow: column;
  gap: var(--icon-grid-gap);
  padding: var(--sp-2);
  align-content: start;
  justify-items: center;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  width: var(--icon-size);
  padding: var(--sp-2);
  border-radius: var(--radius-md);
  cursor: var(--cur-hand); --crt-cursor: hand;
  text-align: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.15s ease;
}

@media (hover: hover) {
  .desktop-icon:hover {
    transform: translateY(-2px) scale(1.03);
    background: var(--os-accent-muted);
  }
}

.desktop-icon:active {
  transform: translateY(0) scale(0.97);
  background: var(--os-accent-muted);
}

.desktop-icon.selected {
  background: var(--os-accent-muted);
  outline: 2px solid var(--os-accent);
  outline-offset: -2px;
}

.desktop-icon:focus-visible {
  outline: 2px solid var(--os-accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.desktop-icon-img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  pointer-events: none;
}

.desktop-icon-label {
  font-size: 11px;
  color: var(--os-text);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-medium);
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .desktop-icon-label {
  color: var(--os-text);
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 0 6px rgba(0, 0, 0, 0.5);
}

[data-theme="retro"] .desktop-icon-label {
  color: #33ff33;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 0 6px rgba(0, 255, 0, 0.3);
}

/* ── Window Container ── */
.window-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(var(--taskbar-height) + var(--taskbar-padding) * 2);
  z-index: var(--z-windows);
  pointer-events: none;
}

/* ── Dock — HIDDEN (replaced by taskbar) ── */
.dock {
  display: none !important;
}

.dock-items {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-1);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--sp-1);
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: var(--radius-md);
  transition: transform 0.15s ease-out;
  position: relative;
}

@media (hover: hover) {
  .dock-item:hover {
    transform: translateY(-4px) scale(1.15);
  }

  /* Neighbor magnification via adjacent selectors */
  .dock-item:hover+.dock-item,
  .dock-item:has(+ .dock-item:hover) {
    transform: translateY(-2px) scale(1.05);
  }
}

.dock-item:active {
  transform: translateY(-2px) scale(1.05);
}

.dock-item-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  pointer-events: none;
}

/* Running indicator — solid square, not circle */
.dock-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--os-accent);
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.dock-item.running .dock-item-dot {
  opacity: 1;
}

/* ── Dock Badge ── */
.dock-item-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--os-coral);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  font-family: var(--font-system);
  line-height: 18px;
  text-align: center;
  border-radius: var(--radius-full);
  border: 2px solid var(--os-dock-bg);
  z-index: 1;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

.dock-item-badge[hidden] {
  display: none;
}

.dock-item-label {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-1) var(--sp-2);
  background: var(--os-surface);
  color: var(--os-text);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--os-border);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  box-shadow: var(--shadow-md);
}

@media (hover: hover) {
  .dock-item:hover .dock-item-label {
    opacity: 1;
  }
}

.dock-separator {
  width: 2px;
  height: 32px;
  background: var(--os-border);
  margin: 0 var(--sp-1);
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════
   TASKBAR — Windows 98 grey bevel bar
   ══════════════════════════════════════════════════════════════════════ */

.taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--taskbar-height);
  z-index: var(--z-taskbar);
  display: flex;
  align-items: center;
  padding: var(--taskbar-padding) var(--desktop-corner-safe-inset);
  background: var(--os-taskbar-bg);
  border: 0;
  border-top: 1px solid var(--os-taskbar-border);
  box-shadow: inset 0 1px 0 var(--win98-hilight);
  border-radius: 0;
  font-size: var(--text-xs);
  font-family: var(--font-system);
  color: var(--win98-text);
  gap: 0;
}

/* ── Start Button — raised 3D bevel ── */
.start-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  height: calc(var(--taskbar-height) - 6px);
  border: none;
  background: var(--win98-face);
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: 0;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--win98-text);
  flex-shrink: 0;
  box-shadow:
    inset -1px -1px 0 var(--win98-dark),
    inset 1px 1px 0 var(--win98-light),
    inset -2px -2px 0 var(--win98-shadow),
    inset 2px 2px 0 var(--win98-hilight);
}

/* Sunken/pressed — Start menu open — with the classic dithered texture */
.start-btn:active,
.start-btn.active {
  box-shadow:
    inset 1px 1px 0 var(--win98-dark),
    inset -1px -1px 0 var(--win98-light),
    inset 2px 2px 0 var(--win98-shadow),
    inset -2px -2px 0 var(--win98-hilight);
  background-color: var(--win98-face);
  background-image: repeating-conic-gradient(var(--win98-light) 0 25%, var(--win98-face) 0 50%);
  background-size: 2px 2px;
}

.start-btn-icon {
  width: 16px;
  height: 16px;
}

.start-btn-label {
  pointer-events: none;
}

/* ── Taskbar Separator — Win98 groove ── */
.taskbar-separator {
  width: 2px;
  height: calc(var(--taskbar-height) - 6px);
  margin: 0 4px;
  background: linear-gradient(to right, var(--win98-shadow) 50%, var(--win98-light) 50%);
  flex-shrink: 0;
}

/* ── Quick Launch — flat, raised on hover, sunken on press ── */
.quick-launch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
  flex-shrink: 0;
}

.quick-launch-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: 0;
}

.quick-launch-btn:hover {
  box-shadow:
    inset -1px -1px 0 var(--win98-shadow),
    inset 1px 1px 0 var(--win98-light);
}

.quick-launch-btn:active {
  box-shadow:
    inset 1px 1px 0 var(--win98-shadow),
    inset -1px -1px 0 var(--win98-light);
}

.quick-launch-btn img {
  width: 20px;
  height: 20px;
}

/* Win98 tooltip — pale yellow, hard 1px border, no radius/shadow */
.quick-launch-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-1) var(--sp-2);
  background: var(--win98-tooltip);
  color: var(--win98-text);
  font-size: var(--text-xs);
  border-radius: 0;
  border: 1px solid var(--win98-dark);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 50ms ease-out;
  box-shadow: none;
}

@media (hover: hover) {
  .quick-launch-btn:hover .quick-launch-tooltip {
    opacity: 1;
  }
}

/* ── Task List (open windows) — same raised bevel as Start ── */
.task-list {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.task-list-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--taskbar-height) - 8px);
  padding: 2px 8px;
  border: none;
  background: var(--win98-face);
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: 0;
  font-family: var(--font-system);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--win98-text);
  text-align: left;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 120px;
  max-width: 160px;
  box-shadow:
    inset -1px -1px 0 var(--win98-dark),
    inset 1px 1px 0 var(--win98-light),
    inset -2px -2px 0 var(--win98-shadow),
    inset 2px 2px 0 var(--win98-hilight);
}

/* Active (focused) window button — sunken bevel + dithered texture, bold */
.task-list-btn.active {
  box-shadow:
    inset 1px 1px 0 var(--win98-dark),
    inset -1px -1px 0 var(--win98-light),
    inset 2px 2px 0 var(--win98-shadow),
    inset -2px -2px 0 var(--win98-hilight);
  background-color: var(--win98-face);
  background-image: repeating-conic-gradient(var(--win98-light) 0 25%, var(--win98-face) 0 50%);
  background-size: 2px 2px;
  color: var(--win98-text);
  font-weight: var(--weight-bold);
}

.task-list-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.task-list-btn-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── System Tray — sunken well ── */
.system-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 2px 8px;
  border: none;
  box-shadow:
    inset 1px 1px 0 var(--win98-shadow),
    inset -1px -1px 0 var(--win98-light);
  background: var(--win98-face);
  height: calc(var(--taskbar-height) - 8px);
  flex-shrink: 0;
}

.system-tray-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.system-tray-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--win98-text);
  opacity: 0.75;
  cursor: var(--cur-hand); --crt-cursor: hand;
  text-decoration: none;
}

.system-tray-link:hover {
  opacity: 1;
}

.system-tray-clock {
  color: var(--win98-text);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ══════════════════════════════════════════════════════════════════════
   START MENU — Win98 grey panel
   ══════════════════════════════════════════════════════════════════════ */

.start-menu {
  position: absolute;
  bottom: var(--taskbar-height);
  left: 0;
  z-index: var(--z-start-menu);
  width: 320px;
  max-height: 70vh;
  background: var(--win98-face);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset -1px -1px 0 var(--win98-dark),
    inset 1px 1px 0 var(--win98-light),
    inset -2px -2px 0 var(--win98-shadow),
    inset 2px 2px 0 var(--win98-hilight);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.start-menu[hidden] {
  display: none;
}

/* Vertical sidebar banner (Win98/XP style) — dark green gradient tying into the desktop band */
.start-menu-sidebar {
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  width: 26px;
  background: linear-gradient(to top, #0B1F17, var(--os-band));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--sp-2);
}

.start-menu-sidebar-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #F2E7D0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: 2px;
  opacity: 0.9;
}

.start-menu-body {
  margin-left: 28px;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.start-menu-apps {
  flex: 1;
  overflow-y: auto;
  padding: 4px 2px;
}

.start-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--win98-text);
  font-size: var(--text-sm);
  font-family: var(--font-system);
  width: 100%;
  text-align: left;
  cursor: var(--cur-hand); --crt-cursor: hand;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 0;
}

.start-menu-item:hover,
.start-menu-item:focus-visible {
  background: var(--win98-select);
  color: var(--win98-select-text);
}

.start-menu-item-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.start-menu-separator {
  height: 2px;
  background: linear-gradient(to bottom, var(--win98-shadow) 50%, var(--win98-light) 50%);
  margin: 4px 8px;
}

.start-menu-system {
  padding: 4px 2px;
}

/* ── Start menu cascades: Tools ▸ / Games ▸ (built by taskbar.js) ── */
.start-menu-item-text {
  flex: 1;
}

.start-menu-arrow {
  margin-left: auto;
  padding-left: var(--sp-3);
  font-size: 8px;
  line-height: 1;
}

.start-menu-item--cascade.is-open {
  background: var(--win98-select);
  color: var(--win98-select-text);
}

/* Flyouts reuse .start-menu's bevel; they size to content and are placed
   beside their anchor row in desktop coordinates. */
.start-flyout {
  width: auto;
  min-width: 200px;
  max-height: none;
  padding: 3px;
  animation: start-flyout-in 140ms var(--ease-out);
}

.start-flyout .start-menu-item {
  padding: 5px 14px 5px 8px;
  white-space: nowrap;
}

@keyframes start-flyout-in {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .start-flyout { animation: none; }
}

/* ── Context Menu — Win98 grey panel ── */
.context-menu {
  position: fixed;
  z-index: var(--z-context-menu);
  min-width: 180px;
  padding: 2px;
  background: var(--win98-face);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset -1px -1px 0 var(--win98-dark),
    inset 1px 1px 0 var(--win98-light);
  animation: scaleIn 0.1s var(--ease-out);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border: none;
  background: none;
  color: var(--win98-text);
  font-size: var(--text-sm);
  font-family: var(--font-system);
  width: 100%;
  text-align: left;
  cursor: var(--cur-hand); --crt-cursor: hand;
  border-radius: 0;
}

.context-menu-item:hover,
.context-menu-item:focus-visible {
  background: var(--win98-select);
  color: var(--win98-select-text);
}

.context-menu-separator {
  height: 2px;
  background: linear-gradient(to bottom, var(--win98-shadow) 50%, var(--win98-light) 50%);
  margin: 4px 8px;
}

/* ── Spotlight Search (CMD+K) ── */
.spotlight-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-spotlight);
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  animation: fadeIn 0.15s var(--ease-out);
}

.spotlight-dialog {
  width: 480px;
  max-width: 90vw;
  background: var(--os-glass);
  backdrop-filter: blur(var(--os-glass-blur));
  -webkit-backdrop-filter: blur(var(--os-glass-blur));
  border: 1px solid var(--os-glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: scaleIn 0.15s var(--ease-spring);
  font-family: var(--font-system);
}

.spotlight-input {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: none;
  border-bottom: 1px solid var(--os-border-subtle);
  background: transparent;
  color: var(--os-text);
  font-family: var(--font-system);
  font-size: var(--text-md);
  outline: none;
  box-sizing: border-box;
}

.spotlight-input::placeholder {
  color: var(--os-text-muted);
}

.spotlight-results {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--sp-2);
}

.spotlight-result {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  cursor: var(--cur-hand); --crt-cursor: hand;
  transition: background var(--duration-fast);
}

.spotlight-result:hover,
.spotlight-result.selected {
  background: var(--os-accent-muted);
  color: var(--os-accent);
}

.spotlight-result.selected .spotlight-result-label {
  color: var(--os-accent);
}

.spotlight-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.spotlight-result-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--os-text);
}

.spotlight-empty {
  padding: var(--sp-4);
  text-align: center;
  color: var(--os-text-muted);
  font-size: var(--text-sm);
}

.spotlight-overlay[hidden] {
  display: none;
}

/* ── Image Rendering — smooth for icons, pixelated for sprites ── */
.desktop-icon-img,
.dock-item-img,
.boot-logo-img,
.finder-file-icon,
.about-award,
.spotlight-result-icon {
  image-rendering: auto;
}

.greta-sprite {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Case Studies is a managed app window, sharing the standard OS chrome. */
.case-studies-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #E9E5DC;
  color: #2A2420;
  container-type: inline-size;
  container-name: case-studies;
}
.case-studies-index {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
}
.case-studies-masonry {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  gap: 14px;
  height: 100%;
  min-height: 540px;
}
.case-studies-masonry > [data-app-id="briefcase"] { grid-column: 1; grid-row: 1 / 8; }
.case-studies-masonry > [data-app-id="tia"] { grid-column: 2; grid-row: 1 / 6; }
.case-studies-masonry > [data-app-id="pages-builder"] { grid-column: 1; grid-row: 8 / 13; }
.case-studies-masonry > [data-app-id="hours"] { grid-column: 2; grid-row: 6 / 13; }
.case-studies-masonry > [data-app-id="finder"] { grid-column: 3; grid-row: 1 / 13; }
.case-studies-masonry .case-study-folder-card { min-height: 0; }
.case-studies-masonry .study-cover { flex: 1; min-height: 0; aspect-ratio: auto; }
.case-studies-masonry .case-study-folder-body { flex: 0 0 auto; min-height: 0; box-sizing: border-box; padding: 14px; }
.case-studies-masonry .case-study-folder-headline { min-height: 0; font-size: clamp(17px, 2.2cqw, 27px); }
.mob-appview-content:has(> .case-studies-app) { height: 100%; margin: 0; }
/* Film tiles: the loop fills the whole card and the copy sits on a gradient over it (no colour block). */
.case-studies-masonry .case-study-folder-card:has(.study-cover-film) { position: relative; overflow: hidden; background: #000; }
.case-studies-masonry .case-study-folder-card:has(.study-cover-film) > .study-cover { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
.case-studies-masonry .case-study-folder-card:has(.study-cover-film) > .case-study-folder-body {
  position: relative;
  margin-top: auto;
  padding-top: clamp(90px, 28%, 190px);
  --film-shade: color-mix(in srgb, var(--study-bg, #000) 55%, #000);
  background: linear-gradient(to top,
    var(--film-shade) 0%,
    var(--film-shade) 38%,
    color-mix(in srgb, var(--film-shade) 70%, transparent) 62%,
    transparent 100%);
  text-shadow: 0 1px 12px #0008;
}

.case-studies-masonry .case-studies-gallery-card { background: #254C3D; color: #F5F0E8; }
.case-studies-preview-viewport {
  display: block;
  position: relative;
  flex: 1;
  min-height: 120px;
  overflow: hidden;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, transparent, #000 6%, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 6%, #000 78%, transparent);
}
.case-studies-preview-host { display: block; position: absolute; top: 0; left: 0; width: 900px; transform-origin: top left; pointer-events: none; }
.case-studies-preview-host .finder-gallery-back { display: none; }
.case-studies-preview-host .finder-gallery-root {
  --poster-bg: transparent !important;
  --poster-text: #F5F0E8 !important;
  background: transparent;
}
.case-studies-preview-host .finder-gallery-title,
.case-studies-preview-host .finder-gallery-meta { display: none; }
.case-studies-preview-host .finder-gallery-row:not(.finder-gallery-row--case-study) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 0;
  padding: 0;
}
.case-studies-preview-host .finder-gallery-row:not(.finder-gallery-row--case-study) .finder-gallery-img-wrap {
  width: var(--gallery-tile-width) !important;
}

/* Launchpad's static art tile only; with a film it uses the shared film-tile gradient. */
@container case-studies (min-width: 901px) {
  .case-studies-masonry > [data-app-id="pages-builder"]:not(:has(.study-cover-film)) { position: relative; overflow: hidden; }
  .case-studies-masonry > [data-app-id="pages-builder"]:not(:has(.study-cover-film)) .study-cover { position: absolute; inset: 0; }
  .case-studies-masonry > [data-app-id="pages-builder"]:not(:has(.study-cover-film)) .study-cover > img {
    position: absolute;
    width: 145%;
    max-width: none;
    height: auto;
    right: -36%;
    top: 50%;
    transform: translateY(-50%);
  }
  .case-studies-masonry > [data-app-id="pages-builder"]:not(:has(.study-cover-film)) .study-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #1B2F6B 20%, #1B2F6BEE 42%, #1B2F6B66 66%, transparent 90%);
  }
  .case-studies-masonry > [data-app-id="pages-builder"]:not(:has(.study-cover-film)) .case-study-folder-body {
    position: relative;
    z-index: 1;
    max-width: 64%;
    margin-top: auto;
  }
}

.case-study-folder-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: var(--study-bg, #254C3D);
  color: var(--study-ink, #FFF);
  text-align: left;
  cursor: var(--cur-hand);
  --crt-cursor: hand;
  transition: transform 180ms ease-out;
}

.case-study-folder-card:hover { transform: translateY(-2px); }
.case-study-folder-card:focus-visible { outline: 2px solid #254C3D; outline-offset: 3px; }
.case-study-folder-cover { display: block; width: 100%; aspect-ratio: 2.3; object-fit: cover; }
.case-study-folder-body { display: flex; flex-direction: column; flex: 1; padding: 16px; }
.case-study-folder-name { font: 700 10px/1.4 var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; }
.case-study-folder-headline { display: block; min-height: 2.24em; margin: 8px 0 14px; font: 400 26px/1.12 var(--font-serif); text-wrap: balance; }
.case-study-folder-action { margin-top: auto; font: 500 11px/1.5 var(--font-sans); text-decoration: underline; text-underline-offset: 3px; }
.case-study-folder-card > .study-cover { aspect-ratio: 1.6; }

.study-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 2.65;
  overflow: hidden;
  background: var(--study-bg, #254C3D);
  container-type: inline-size;
}
.study-cover > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.study-cover--film { background: #000; }
.study-cover-film { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.study-cover-window {
  display: block;
  width: 76%;
  border: 1px solid #211D18;
  background: #211117;
  box-shadow: 8px 10px 0 #0003;
  text-align: left;
  line-height: 1.4;
}
.study-cover-window-bar { display: block; padding: 3px 7px; background: #E9E5DC; color: #2A2420; font: 700 2cqw/1.4 var(--font-sans); }
.study-cover-chat { display: flex; flex-direction: column; gap: 7px; padding: 12px; }
.study-cover-message { display: block; max-width: 92%; padding: 7px 10px; border-radius: 7px; font: 500 2.25cqw/1.4 var(--font-sans); }
.study-cover-message--user { align-self: flex-end; background: #E885AF; color: #301421; }
.study-cover-message--assistant { align-self: flex-start; background: #F2E9D5; color: #301421; }
.study-cover-sources { display: block; font: 700 1.8cqw/1.4 var(--font-sans); color: #E885AF; }
.study-cover-window--website { transform: rotate(-4deg); }
.study-cover-window--website > img { display: block; width: 100%; aspect-ratio: 2.2; object-fit: cover; object-position: top; }

.case-study-preview-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  pointer-events: none;
}
.case-study-preview-visual > .hf { align-self: stretch; }
/* Hold the assembled pages before folding them away for the next cascade. */
.case-study-preview-visual .hf[data-state="playing"] .hf-win {
  animation-name: case-study-page-loop;
  animation-duration: 6s;
  animation-iteration-count: infinite;
}
@keyframes case-study-page-loop {
  0%, 100% { opacity: 0; transform: translate(var(--hf-x), var(--hf-y)) scale(0.94); }
  8%, 75% { opacity: 1; transform: translate(var(--hf-x), var(--hf-y)) scale(1); }
  85% { opacity: 0; transform: translate(var(--hf-x), var(--hf-y)) scale(0.94); }
}
.case-study-preview-visual--chat { box-sizing: border-box; padding: 14px; }
.case-study-preview-visual .cs-hero-chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100%;
  margin: 0;
}
.case-study-preview-visual .cs-hero-chat-header { padding: 5px 8px; flex-shrink: 0; }
.case-study-preview-visual .cs-hero-chat-body { min-height: 0 !important; overflow-y: auto; padding: 8px; gap: 6px; scrollbar-width: none; }
.case-study-preview-visual .cs-hero-chat-name { font-size: 10px; }
.case-study-preview-visual .cs-hero-bubble { font-size: clamp(9px, 2.3cqw, 12px); padding: 6px 8px; }
.case-study-preview-visual .cs-hero-source { font-size: 7px; padding: 2px 3px; }
.case-study-preview-video { display: block; width: 100%; aspect-ratio: 2.2; object-fit: cover; }

@container case-studies (min-width: 901px) {
  .case-studies-masonry > [data-app-id="pages-builder"] .case-study-preview-visual .hf-stage {
    left: 85%;
    width: 72%;
  }
}

@container case-studies (max-width: 640px) {
  .case-studies-masonry { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; height: auto; min-height: 0; }
  .case-studies-masonry > .case-study-folder-card { grid-column: auto; grid-row: auto; height: 300px; }
  .case-studies-masonry > .case-studies-gallery-card { grid-column: 1 / -1; grid-row: 1; height: 280px; }
  .case-studies-masonry .case-study-folder-headline { font-size: clamp(18px, 4.8cqw, 22px); }
  .case-studies-masonry .study-cover { min-height: 100px; }
}

@media (max-width: 768px) {
  .case-study-folder-cover { aspect-ratio: 1.6; }
  .case-study-folder-card > .study-cover { aspect-ratio: 1.6; }
  .study-cover-chat { padding: 6px; gap: 4px; }
  .study-cover-message { padding: 4px; }
  .case-study-folder-body { padding: 10px; }
  .case-study-folder-name { font-size: 9px; letter-spacing: 0; }
  .case-study-folder-headline { font-size: 18px; line-height: 1.15; }
}

@media (prefers-reduced-motion: reduce) {
  .case-study-folder-card { transition: none; }
  .case-study-folder-card:hover { transform: none; }
}

/* ── Spotlight Category Label ── */
.spotlight-result-category {
  font-size: var(--text-xs);
  color: var(--os-text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.spotlight-result.selected .spotlight-result-category {
  color: var(--os-accent);
  opacity: 0.7;
}

/* ── Dock Separator ── */
.dock-separator[hidden] {
  display: none;
}

/* ── Mobile Folder Overlay ── */
.mobile-folder-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s var(--ease-out);
}

.mobile-folder-panel {
  width: 85vw;
  max-width: 320px;
  background: var(--os-glass);
  backdrop-filter: blur(var(--os-glass-blur));
  -webkit-backdrop-filter: blur(var(--os-glass-blur));
  border: 1px solid var(--os-glass-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  animation: scaleIn 0.15s var(--ease-out);
}

.mobile-folder-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--os-text);
  text-align: center;
  margin-bottom: var(--sp-3);
}

.mobile-folder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

.mobile-folder-close {
  display: block;
  margin: var(--sp-3) auto 0;
  padding: var(--sp-2) var(--sp-4);
  background: none;
  border: 1px solid var(--os-border);
  border-radius: var(--radius-md);
  color: var(--os-text-secondary);
  font-family: var(--font-system);
  font-size: var(--text-xs);
  cursor: var(--cur-hand); --crt-cursor: hand;
}

.mobile-folder-close:hover {
  background: var(--os-surface-hover);
}

/* ── Keyboard Shortcut Cheat Sheet ── */
.shortcut-help-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-spotlight);
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcut-help-overlay[hidden] {
  display: none;
}

.shortcut-help-dialog {
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--os-surface);
  border: 1px solid var(--os-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-system);
}

.shortcut-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--os-border-subtle);
  background: var(--os-surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.shortcut-help-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--os-text);
}

.shortcut-help-close {
  background: none;
  border: none;
  color: var(--os-titlebar-text);
  font-size: 18px;
  cursor: var(--cur-hand); --crt-cursor: hand;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.shortcut-help-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.shortcut-help-body {
  padding: var(--sp-3) var(--sp-4);
}

.shortcut-help-section {
  margin-bottom: var(--sp-4);
}

.shortcut-help-section:last-child {
  margin-bottom: 0;
}

.shortcut-help-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--os-text-muted);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--os-border-subtle);
}

.shortcut-help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-1) 0;
  gap: var(--sp-3);
}

.shortcut-help-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.shortcut-help-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--os-surface-raised);
  border: 1px solid var(--os-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  color: var(--os-text);
  box-shadow: 0 1px 0 var(--os-border);
}

.shortcut-help-plus {
  font-size: 10px;
  color: var(--os-text-muted);
}

.shortcut-help-desc {
  font-size: var(--text-sm);
  color: var(--os-text-secondary);
  text-align: right;
}

/* ── Screensaver ── */
.screensaver-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: #000;
  cursor: none; --crt-cursor: none;
}

.screensaver-logo {
  position: absolute;
  top: 0;
  left: 0;
  width: 80px;
  height: 80px;
  will-change: transform, filter;
  pointer-events: none;
}

/* ── In-glass cursor ──
   The tube filter draws the page slightly inward at the edges, so the OS
   cursor would float off the thing it is actually over. When the warp is
   live, the native cursor is hidden and this sprite is drawn INSIDE the
   filtered desktop: it is displaced exactly like the content under it, and
   it disappears behind the glass edge like anything else off screen. */
.crt-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  z-index: calc(var(--z-crt-overlay) + 1);
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 32px 32px;
  will-change: transform;
  display: none;
}
html.crt-cursor-live .crt-cursor { display: block; }
html.crt-cursor-live .desktop,
html.crt-cursor-live .desktop *,
html.crt-cursor-live .boot-glass,
html.crt-cursor-live .boot-glass * { cursor: none !important; }

/* ── Me in the wallpaper (js/features/me-wallpaper.js) ──
   A painted Rocco peeks over the taskbar, bottom-right, under every window.
   Sprite cells are 376 x 324 with the wall line at y 305 (94.14%), so the element
   is placed with that line on the taskbar's top edge. The fingertips below the line
   are drawn again on .me-peek-tips, which sits above the taskbar. */
.me-peek,
.me-peek-tips {
  --me-h: clamp(170px, 31%, 300px);
  --me-line: 0.9414;
  position: absolute;
  right: clamp(150px, 13%, 240px);
  /* taskbar is content-box: height + 2 x padding + 1px top border */
  bottom: calc(var(--taskbar-height) + var(--taskbar-padding) * 2 + 1px - var(--me-h) * (1 - var(--me-line)));
  height: var(--me-h);
  aspect-ratio: 376 / 324;
}
.me-peek {
  z-index: 2;                       /* over the wallpaper, under icons, Greta and windows */
  pointer-events: none;
  background: url('/agentic/img/me/me-still.webp') center / 100% 100% no-repeat;
}
.me-peek.is-live { background: none; }
.me-peek-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: var(--cur-arrow); --crt-cursor: arrow;
}
/* set by JS while the pointer is over a painted (opaque) pixel of him */
.me-peek-canvas.is-hot { cursor: var(--cur-hand); --crt-cursor: hand; }
.me-peek-tips {
  z-index: calc(var(--z-taskbar) + 1);
  pointer-events: none;
  clip-path: inset(94.14% 0 0 0);   /* == --me-line */
}
/* Mirror in the window container: he always sits in front of About (only About).
   JS sets its z-index to About's and clips it to About's box plus a small margin. */
.me-peek-over {
  position: absolute;
  pointer-events: none;
}
@media (max-width: 767px), (max-height: 560px) {
  .me-peek, .me-peek-tips, .me-peek-over { display: none !important; }
}
@media print {
  .me-peek, .me-peek-tips, .me-peek-over { display: none; }
}
