/* Window manager — Mint-Y SSD decorations + CSD headerbars */
.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--window-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-window);
  box-shadow: var(--shadow-window-backdrop);
  min-width: 320px;
  min-height: 160px;
  overflow: visible;
}
.window.focused { box-shadow: var(--shadow-window); }
.window.maximized, .window.tiled { border-radius: 0; }
.window.opening { animation: win-open 170ms var(--ease-out); }
.window.closing { animation: win-close 140ms ease-in forwards; pointer-events: none; }
@keyframes win-open { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes win-close { to { opacity: 0; transform: scale(.96); } }
.window.animating { transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out); }
.window.hidden-ws { display: none; }

/* SSD titlebar */
.titlebar {
  height: var(--titlebar-height);
  flex: none;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  border-radius: calc(var(--r-window) - 1px) calc(var(--r-window) - 1px) 0 0;
  display: flex; align-items: center;
  padding: 0 5px;
  cursor: default;
}
.window.maximized .titlebar { border-radius: 0; }
.titlebar .tb-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: var(--fs-ui);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 8px;
  pointer-events: none;
}
.tb-btn {
  width: 32px; height: 26px;
  border-radius: 4px;
  display: grid; place-items: center;
  color: #404040;
  flex: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.tb-btn:hover { background: #FDFDFF; }
.tb-btn:active { background: #909092; color: #fff; }
.tb-btn.close:hover { background: var(--destructive); color: #fff; }
:root[data-dark="true"] .tb-btn { color: #c7c7cc; }
:root[data-dark="true"] .tb-btn:hover { background: #4C4C50; }
:root[data-dark="true"] .tb-btn:active { background: #949498; color: #fff; }

/* unfocused chrome dimming */
.window:not(.focused) .titlebar { background: var(--header-bg-backdrop); }
.window:not(.focused) .titlebar .tb-title { color: var(--text-dim-title); }
.window:not(.focused) .tb-btn { color: #B6B6B8; }
.window:not(.focused) .tb-btn:hover { color: #404040; }
.window:not(.focused) .headerbar { background: var(--header-bg-backdrop); }
.window:not(.focused) .headerbar .hb-title { color: var(--text-dim-title); }

/* CSD headerbar (apps draw their own toolbar/title) */
.headerbar {
  height: var(--headerbar-height);
  flex: none;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  border-radius: calc(var(--r-window) - 1px) calc(var(--r-window) - 1px) 0 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  min-width: 0;
  overflow: hidden;
}
.window.maximized .headerbar { border-radius: 0; }
.hb-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-weight: 700; font-size: var(--fs-ui);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 46%;
  pointer-events: none;
}
.headerbar { position: relative; }
.hb-spacer { flex: 1; }
.hb-btn {
  height: 34px; min-width: 34px;
  padding: 0 8px;
  border-radius: var(--r-item);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 500;
  transition: background var(--t-fast);
  flex: none;
}
.headerbar .tb-btn { flex: none; }
.headerbar .mint-entry { flex: 0 1 auto; min-width: 56px; }
/* Narrow-WINDOW handling (independent of viewport): container query + JS class fallback */
.headerbar { container-type: inline-size; }
@container (max-width: 440px) {
  .headerbar .opt-nav { display: none; }
  .hb-btn.text { padding: 0 6px; font-size: var(--fs-xsmall); }
}
.window.win-narrow .headerbar .opt-nav { display: none; }
.window.win-narrow .hb-btn.text { padding: 0 6px; font-size: var(--fs-xsmall); }
@media (max-width: 520px) {
  .hb-btn { min-width: 30px; padding: 0 5px; }
  .hb-btn.text { padding: 0 7px; font-size: var(--fs-xsmall); }
}
.hb-btn:hover { background: rgba(48, 48, 48, .1); }
.hb-btn:active { background: rgba(48, 48, 48, .16); }
.hb-btn.text { font-weight: 700; font-size: var(--fs-small); }
.hb-btn.suggested { background: var(--accent); color: #fff; }
.hb-btn.suggested:hover { background: var(--accent-hover); }
.hb-iconbtn svg { width: 17px; height: 17px; }

/* window body */
.win-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* resize handles */
.rz { position: absolute; z-index: 5; touch-action: none; }
.rz-n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.rz-s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.rz-e { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.rz-w { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
.rz-ne { top: -5px; right: -5px; width: 13px; height: 13px; cursor: ne-resize; }
.rz-nw { top: -5px; left: -5px; width: 13px; height: 13px; cursor: nw-resize; }
.rz-se { bottom: -5px; right: -5px; width: 13px; height: 13px; cursor: se-resize; }
.rz-sw { bottom: -5px; left: -5px; width: 13px; height: 13px; cursor: sw-resize; }
.window.maximized .rz, .window.tiled .rz { display: none; }

/* alt-tab switcher */
#alttab-layer {
  position: absolute; inset: 0;
  z-index: 1100;
  display: grid; place-items: center;
  pointer-events: none;
}
.switcher-list {
  background: var(--menu-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-item);
  box-shadow: var(--shadow-menu);
  padding: 18px;
  max-width: 80vw;
}
.switcher-items { display: flex; gap: 10px; }
.sw-item {
  width: 120px;
  padding: 10px 8px;
  border-radius: var(--r-item);
  border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.sw-item.selected { background: var(--pressed-fill); border-color: var(--accent); }
.sw-item .sw-icon { width: 44px; height: 44px; display: grid; place-items: center; }
.sw-item .sw-label {
  font-size: var(--fs-xsmall); text-align: center;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 760px) {
  .window { min-width: 240px; }
}
