/* ============================================================
   Motion Studies — Mac OS X 10.0 Aqua Shell
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* --- Menu Bar --- */
#menu-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  z-index: 900000;
  background: linear-gradient(to bottom, #ffffff 0%, #e8e8e8 50%, #d0d0d0 100%);
  border-bottom: 1px solid #999;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 13px;
  color: #000;
  gap: 16px;
}

#menu-apple {
  height: 14px;
  width: auto;
  cursor: default;
  vertical-align: middle;
}

#menu-app-name {
  font-weight: bold;
  cursor: default;
}

.menu-item {
  cursor: default;
  padding: 0 2px;
}

.menu-item:hover {
  background: #3366cc;
  color: #fff;
  border-radius: 2px;
}

#menu-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #333;
  font-size: 12px;
}

#menu-clock {
  cursor: default;
}

/* --- Desktop --- */
#desktop {
  position: fixed;
  top: 22px;
  left: 0;
  right: 0;
  bottom: 0;
  /* Aqua blue gradient wallpaper */
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(0,0,0,0.1) 0%, transparent 50%),
    linear-gradient(180deg, #3a7bd5 0%, #1a5aaa 30%, #104080 70%, #0a2a60 100%);
  background-color: #1a5aaa;
}

#desktop.has-wallpaper {
  background-size: cover;
  background-position: center;
}

/* --- Desktop Icons --- */
#desktop-icons {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  padding: 4px;
  border-radius: 4px;
  cursor: default;
  text-align: center;
}

.desktop-icon:hover {
  background: rgba(255,255,255,0.15);
}

.desktop-icon.selected {
  background: rgba(59,130,246,0.5);
}

.desktop-icon img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  pointer-events: none;
}

.desktop-icon-label {
  margin-top: 4px;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  line-height: 1.2;
  word-wrap: break-word;
  max-width: 76px;
}

.desktop-icon.disabled,
.dock-icon.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Dock --- */
#dock {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#dock-shelf {
  display: flex;
  align-items: flex-end;
  padding: 4px 10px 4px 10px;
  gap: 2px;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#dock-icons {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.dock-separator {
  width: 1px;
  height: 40px;
  background: rgba(255,255,255,0.3);
  margin: 0 4px;
  align-self: center;
}

.dock-icon {
  width: 48px;
  height: 48px;
  cursor: default;
  transition: transform 0.15s ease;
  border-radius: 10px;
  position: relative;
}

.dock-icon:hover {
  transform: scale(1.3) translateY(-8px);
}

.dock-icon img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  pointer-events: none;
}

.dock-icon-label {
  display: none;
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.dock-icon:hover .dock-icon-label {
  display: block;
}

.dock-icon-dot {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #333;
  border-radius: 50%;
  display: none;
}

.dock-icon.running .dock-icon-dot {
  display: block;
}

/* --- Window Layer --- */
#window-layer {
  position: fixed;
  top: 22px;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 100000;
}

/* --- Aqua Window Chrome --- */
.aqua-window {
  position: absolute;
  min-width: 280px;
  min-height: 120px;
  background: #ececec;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 5px 25px rgba(0,0,0,0.4), 0 0 1px rgba(0,0,0,0.3);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aqua-window.focused {
  box-shadow: 0 8px 35px rgba(0,0,0,0.5), 0 0 1px rgba(0,0,0,0.4);
}

/* Titlebar */
.aqua-titlebar {
  height: 22px;
  min-height: 22px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  cursor: grab;
  position: relative;
  /* Pinstripe title bar */
  background:
    repeating-linear-gradient(
      to bottom,
      #f6f6f6 0px,
      #f6f6f6 1px,
      #e6e6e6 1px,
      #e6e6e6 2px
    );
  border-bottom: 1px solid #b0b0b0;
  border-radius: 6px 6px 0 0;
}

.aqua-window.focused .aqua-titlebar {
  background:
    repeating-linear-gradient(
      to bottom,
      #fafafa 0px,
      #fafafa 1px,
      #e0e0e0 1px,
      #e0e0e0 2px
    );
}

.aqua-titlebar:active {
  cursor: grabbing;
}

/* Traffic Lights */
.aqua-traffic-lights {
  display: flex;
  gap: 6px;
  z-index: 2;
}

.aqua-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0.5px solid rgba(0,0,0,0.25);
  cursor: default;
  position: relative;
}

/* invisible expanded hit area */
.aqua-btn::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
}

.aqua-btn::after {
  content: '';
  position: absolute;
  top: 1.5px;
  left: 2.5px;
  width: 6px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center top, rgba(255,255,255,0.7) 0%, transparent 100%);
}

.aqua-btn-close {
  background: radial-gradient(circle at 35% 35%, #f77, #d32f2f);
}

.aqua-btn-minimize {
  background: radial-gradient(circle at 35% 35%, #fdd835, #f9a825);
}

.aqua-btn-zoom {
  background: radial-gradient(circle at 35% 35%, #81c784, #388e3c);
}

/* Unfocused traffic lights */
.aqua-window:not(.focused) .aqua-btn {
  background: #ccc;
  border-color: #aaa;
}

.aqua-window:not(.focused) .aqua-btn::after {
  display: none;
}

/* Title text */
.aqua-title-text {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  pointer-events: none;
}

.aqua-window:not(.focused) .aqua-title-text {
  color: #888;
}

/* Window content area */
.aqua-window-content {
  flex: 1;
  overflow: auto;
  background: #fff;
}

/* --- Window minimize animation --- */
.aqua-window.minimizing {
  transition: transform 0.3s ease-in, opacity 0.3s ease-in;
  transform: scale(0.1) translateY(100vh);
  opacity: 0;
}

.aqua-window.minimized {
  display: none;
}

/* --- Drag state --- */
.aqua-window.dragging .aqua-titlebar {
  cursor: grabbing;
}

/* --- Resizable windows --- */
.aqua-window.resizable {
  overflow: visible;
}

.aqua-window.resizing .aqua-window-content {
  pointer-events: none;
}

/* Resize handles (invisible hit zones) */
.aqua-resize {
  position: absolute;
  z-index: 10;
}

/* Edge handles — 6px wide/tall */
.aqua-resize-n { top: -3px;    left: 6px;   right: 6px;  height: 6px; cursor: n-resize; }
.aqua-resize-s { bottom: -3px; left: 6px;   right: 6px;  height: 6px; cursor: s-resize; }
.aqua-resize-e { top: 6px;     right: -3px; bottom: 6px; width: 6px;  cursor: e-resize; }
.aqua-resize-w { top: 6px;     left: -3px;  bottom: 6px; width: 6px;  cursor: w-resize; }

/* Corner handles — 12×12px */
.aqua-resize-ne { top: -3px;    right: -3px;  width: 12px; height: 12px; cursor: ne-resize; }
.aqua-resize-nw { top: -3px;    left: -3px;   width: 12px; height: 12px; cursor: nw-resize; }
.aqua-resize-se { bottom: -3px; right: -3px;  width: 12px; height: 12px; cursor: se-resize; }
.aqua-resize-sw { bottom: -3px; left: -3px;   width: 12px; height: 12px; cursor: sw-resize; }
