/* =====================================================
   WINDOW BASE  (WIN-01, WIN-07)
   ===================================================== */
.window {
  position: fixed;                       /* positioned within viewport */
  display: flex;
  flex-direction: column;
  border-radius: var(--window-radius);   /* 12px */
  box-shadow: var(--window-shadow);      /* 0 22px 70px rgba(0,0,0,0.45) */
  overflow: hidden;
  background: var(--window-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  /* No transition on transform — interact.js owns this property */
  /* No transform set here — JS sets transform: translate(x, y) */

  /* Windows start in the 100–199 z-index band */
  z-index: 100;
}

/* Window hidden state */
.window--hidden {
  display: none !important;
}

/* =====================================================
   WINDOW SIZE VARIANTS  (WIN-07)
   ===================================================== */
.window--bio {
  width: 480px;
  height: 360px;
}

.window--large {
  width: 760px;
  height: 540px;
}

/* =====================================================
   TITLE BAR  (WIN-01, WIN-02)
   ===================================================== */
.window-titlebar {
  height: var(--titlebar-height);        /* 36px */
  background: var(--titlebar-bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  position: relative;

  /* Title bar is the drag handle — communicate this with cursor */
  cursor: move;
  user-select: none;
  -webkit-user-select: none;

  /* Separator line between title bar and body */
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .window-titlebar {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
}

/* Window title text — centred */
.window-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.75);
  pointer-events: none;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .window-title {
    color: rgba(255, 255, 255, 0.80);
  }
}

/* =====================================================
   TRAFFIC LIGHTS  (WIN-01, WIN-03)
   ===================================================== */
.window-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-close,
.btn-minimise,
.btn-maximise {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  position: relative;
  flex-shrink: 0;

  /* Override cursor: inherit the macOS pointer from desktop.css for btn-close */
}

.btn-close    { background: var(--traffic-red);    }
.btn-minimise { background: var(--traffic-yellow); opacity: 0.7; }
.btn-maximise { background: var(--traffic-green);  opacity: 0.7; }

.btn-minimise,
.btn-maximise {
  cursor: pointer;
  opacity: 1;
}

/* Glyph symbols — hidden by default, shown on title bar hover */
.btn-close::before,
.btn-minimise::before,
.btn-maximise::before {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.btn-close::before    {
  content: '×';
  color: var(--traffic-red-glyph);
}
.btn-minimise::before {
  content: '−';
  color: var(--traffic-yellow-glyph);
}
.btn-maximise::before {
  content: '⤢';
  color: var(--traffic-green-glyph);
  font-size: 7px;
}

/* Show glyphs when hovering anywhere on the title bar */
.window-titlebar:hover .btn-close::before,
.window-titlebar:hover .btn-minimise::before,
.window-titlebar:hover .btn-maximise::before {
  opacity: 1;
}

/* =====================================================
   WINDOW BODY + IFRAME OVERLAY  (WIN-06)
   ===================================================== */
.window-body {
  flex: 1;
  overflow: hidden;
  position: relative;                    /* required for .iframe-overlay absolute positioning */
  background: var(--window-bg);
}

/* Transparent shield — prevents iframe from capturing mouse during drag */
.iframe-overlay {
  display: none;                         /* activated by WindowManager during drag start */
  position: absolute;
  inset: 0;
  z-index: 10;
  background: transparent;
}

/* =====================================================
   OPEN / CLOSE ANIMATIONS  (WIN-05)
   ===================================================== */
@keyframes window-open {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes window-close {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.85);
  }
}

.window--opening {
  animation: window-open 0.2s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.window--closing {
  animation: window-close 0.15s ease-in forwards;
}

/* =====================================================
   CORNER RESIZE HANDLES
   ===================================================== */
.resize-nw, .resize-ne, .resize-sw, .resize-se {
  position: absolute;
  width: 16px;
  height: 16px;
  z-index: 20;
}
.resize-nw { top: 0;    left: 0;  cursor: nw-resize; }
.resize-ne { top: 0;    right: 0; cursor: ne-resize; }
.resize-sw { bottom: 0; left: 0;  cursor: sw-resize; }
.resize-se { bottom: 0; right: 0; cursor: se-resize; }

/* =====================================================
   MAXIMIZED STATE
   ===================================================== */
.window--maximized {
  border-radius: 0 !important;
}

/* =====================================================
   FOCUSED WINDOW INDICATOR
   ===================================================== */
/* Slightly brighter shadow on the focused (topmost) window.
   JS sets z-index; CSS cannot target by z-index, so we use a class. */
.window--focused {
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}
