/* ============================================================
   windows.css — macOS-Style Window Chrome
                 Title bar, traffic-light buttons, draggable,
                 resizable
   ============================================================ */

/* ── Window Container ── */
.window {
  position: absolute;
  min-width: 300px;
  min-height: 200px;
  background: var(--bg-window);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.08) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Z-index: controlled by JS, base layer */
  z-index: 10;
  transition: box-shadow 0.2s ease;
}

/* Active window (frontmost) */
.window.active {
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.05) inset;
  z-index: 50;
}

/* ── Title Bar ── */
.window-titlebar {
  display: flex;
  align-items: center;
  height: var(--titlebar-height);
  padding: 0 12px;
  user-select: none;
  cursor: default;
  flex-shrink: 0;
  position: relative;
}

/* Draggable region */
.window-titlebar.draggable {
  cursor: grab;
}

.window-titlebar.draggable:active {
  cursor: grabbing;
}

/* ── Traffic Light Buttons ── */
.window-traffic-lights {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.traffic-light:active {
  transform: scale(0.88);
}

/* Close */
.traffic-light--close {
  background: var(--traffic-red);
}
.traffic-light--close::before,
.traffic-light--close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 1px;
  background: rgba(0,0,0,0.4);
  border-radius: 1px;
  transition: width 0.12s ease;
}

/* Minimize */
.traffic-light--minimize {
  background: var(--traffic-yellow);
}
.traffic-light--minimize::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 0;
  height: 2px;
  background: rgba(0,0,0,0.4);
  border-radius: 1px;
  transform: translateX(-50%);
  transition: width 0.12s ease;
}

/* Maximize / Zoom */
.traffic-light--maximize {
  background: var(--traffic-green);
}
.traffic-light--maximize::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 1px;
  background: rgba(0,0,0,0.4);
  border-radius: 1px;
  transition: width 0.12s ease;
}

/* Show hover indicators */
.window-titlebar:hover .traffic-light--close::before,
.window-titlebar:hover .traffic-light--close::after {
  width: 7px;
}
.window-titlebar:hover .traffic-light--minimize::after {
  width: 7px;
}
.window-titlebar:hover .traffic-light--maximize::after {
  width: 7px;
}

/* Inactive window: dim traffic lights */
.window:not(.active) .traffic-light {
  filter: brightness(0.6);
}

/* ── Title Text ── */
.window-title {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  pointer-events: none;
}

.window:not(.active) .window-title {
  opacity: 0.5;
}

/* ── Window Toolbar (optional, below titlebar) ── */
.window-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* ── Window Content Area ── */
.window-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* ── Resize Handle ── */
.window-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

.window-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: linear-gradient(
    135deg,
    transparent 33%,
    var(--text-tertiary) 33%,
    var(--text-tertiary) 38%,
    transparent 38%
  );
  background-size: 14px 14px;
  opacity: 0.25;
}

.window:hover .window-resize-handle::after {
  opacity: 0.5;
}

/* ── Window Animations ── */

/* Opening */
@keyframes windowOpen {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.window.entering {
  animation: windowOpen 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Closing */
@keyframes windowClose {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

.window.closing {
  animation: windowClose 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Minimize / Restore animation (optional) */
@keyframes windowMinimize {
  to {
    opacity: 0;
    transform: scale(0.5) translateY(100vh);
  }
}

/* ── Fullscreen / Maximized state ── */
.window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  border: none;
}
