/*
 * OISIF WINDOW MANAGER — Component Styles
 * =========================================
 *
 * Requires: oisif-tokens.css
 *
 * The visual layer for Oisif windows: title bar, buttons,
 * body area, iframe variant, maximized state, game variant.
 * Import this + oisif-tokens.css to get fully styled windows
 * in any project.
 */

/* ══════════════════════════════════════════════════════════════
   WINDOW COMPONENT
   ══════════════════════════════════════════════════════════════ */

.win {
  position: absolute;
  background: var(--oisif-surface);
  box-shadow: var(--oisif-shadow-out);
  border-radius: var(--oisif-radius-lg);
  display: flex;
  flex-direction: column;
  min-width: 240px;
  min-height: 160px;
  max-width: calc(100vw - 16px);
  max-height: calc(var(--oisif-vh, 100dvh) - 56px);
}

@keyframes win-fade-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.96); }
}

@keyframes win-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes win-maximize {
  from { transform: scale(0.85); opacity: 0.8; }
  to   { transform: scale(1); opacity: 1; }
}

.win.win-anim-out {
  animation: win-fade-out 0.15s ease forwards;
  pointer-events: none;
}

.win.win-anim-in {
  animation: win-fade-in 0.15s ease forwards;
}

.win.win-anim-maximize {
  animation: win-maximize 0.15s ease forwards;
}

@keyframes win-restore {
  from { transform: scale(1.08); opacity: 0.8; }
  to   { transform: scale(1); opacity: 1; }
}

.win.win-anim-restore {
  animation: win-restore 0.15s ease forwards;
}

.win.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Title bar — same surface as the frame, with 3D edge highlights */
.win-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  height: 32px;
  flex-shrink: 0;
  background: var(--oisif-surface);
  box-shadow:
    inset 1px 1px 0 var(--oisif-h-light),
    inset -1px -1px 0 var(--oisif-h-dark);
  border-radius: var(--oisif-radius-lg) var(--oisif-radius-lg) 0 0;
  cursor: grab;
  user-select: none;
}

.win-title:active {
  cursor: grabbing;
}

.win-name {
  font-family: var(--oisif-font-display);
  font-size: var(--oisif-font-size);
  letter-spacing: var(--oisif-letter-spacing-lg);
  text-transform: uppercase;
  color: var(--oisif-dim);
}

.win-ctrls {
  display: flex;
  gap: 6px;
}

.win-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--oisif-surface);
  box-shadow: var(--oisif-shadow-out-sm);
  border-radius: var(--oisif-radius-lg);
  color: var(--oisif-dim);
  font-family: var(--oisif-font-body);
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, box-shadow 0.15s;
}

.win-btn:hover {
  color: var(--oisif-fg);
}

.win-btn:active {
  box-shadow: var(--oisif-shadow-in-sm);
}

/* Action button color states */
.win-action {
  font-size: 10px;
  letter-spacing: 1px;
}

.win-action-green {
  color: var(--oisif-color-projects, #7a9a6d);
}

.win-action-orange {
  color: var(--oisif-color-about, #da9a7e);
}

.win-action-white {
  color: var(--oisif-fg, #e0e0e0);
}

.win-action-blink {
  animation: win-action-breathe 3s ease-in-out infinite;
}

@keyframes win-action-breathe {
  0%, 100% { color: var(--oisif-color-about, #da9a7e); }
  50% { color: var(--oisif-dim, #555); }
}

/* Window body */
.win-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--oisif-bg);
  box-shadow: var(--oisif-shadow-in-sm);
  margin: 6px;
  border-radius: var(--oisif-radius-lg);
}

/* ══════════════════════════════════════════════════════════════
   RESIZE HANDLES
   ══════════════════════════════════════════════════════════════ */

.win-resize {
  position: absolute;
  z-index: 1;
}

/* Edge handles */
.win-resize-n  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.win-resize-s  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.win-resize-e  { top: 8px; right: -4px; bottom: 8px; width: 8px; cursor: e-resize; }
.win-resize-w  { top: 8px; left: -4px; bottom: 8px; width: 8px; cursor: w-resize; }

/* Corner handles */
.win-resize-nw { top: -4px; left: -4px; width: 12px; height: 12px; cursor: nw-resize; }
.win-resize-ne { top: -4px; right: -4px; width: 12px; height: 12px; cursor: ne-resize; }
.win-resize-sw { bottom: -4px; left: -4px; width: 12px; height: 12px; cursor: sw-resize; }
.win-resize-se { bottom: -4px; right: -4px; width: 12px; height: 12px; cursor: se-resize; }

/* Hide handles when maximized */
.win.maximized .win-resize { display: none; }

/* Prevent iframe from stealing pointer during resize */
.win-resizing iframe { pointer-events: none; }

/* Maximized state */
.win.maximized {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: var(--oisif-taskbar-h, 46px) !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0;
  transition: none;
}

.win.maximized .win-title {
  border-radius: 0;
}

/* When virtual keyboard is open — no taskbar, full height */
.keyboard-open .win.maximized {
  bottom: 0 !important;
}

.keyboard-open .oisif-taskbar,
.keyboard-open #taskbar {
  display: none !important;
}

.keyboard-open .win {
  max-height: none;
}

/* ══════════════════════════════════════════════════════════════
   IFRAME WINDOW VARIANT
   ══════════════════════════════════════════════════════════════ */

.win-body-iframe {
  padding: 0;
  overflow: hidden;
}

.win-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--oisif-bg);
  display: block;
}

/* ══════════════════════════════════════════════════════════════
   GAME WINDOW VARIANT
   ══════════════════════════════════════════════════════════════ */

.game-win .win-body {
  padding: 0;
  overflow: hidden;
  position: relative;
  background: var(--oisif-bg);
}

.game-win .win-body iframe {
  border: none;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

/* ══════════════════════════════════════════════════════════════
   SECTION HEADERS (for content inside windows)
   ══════════════════════════════════════════════════════════════ */

.win-section-label {
  font-family: var(--oisif-font-display);
  font-size: var(--oisif-font-size-sm);
  letter-spacing: var(--oisif-letter-spacing-lg);
  text-transform: uppercase;
  color: var(--oisif-text-hint);
  margin-bottom: 8px;
}

.win-section-rule {
  width: 30px;
  height: 1px;
  background: var(--oisif-text-sep);
  margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .win {
    min-width: 240px;
    max-height: calc(100dvh - 56px);
  }

  .win-title {
    height: 44px;
    padding: 0 12px;
  }

  .win-name {
    font-size: 12px;
  }

  .win-ctrls {
    gap: 8px;
  }

  .win-btn {
    width: 32px;
    height: 32px;
    font-size: 17px;
    line-height: 32px;
  }

  .win.maximized {
    bottom: var(--oisif-taskbar-h, 58px) !important;
  }

  .win-resize-n, .win-resize-s { height: 12px; }
  .win-resize-e, .win-resize-w { width: 12px; }
  .win-resize-nw, .win-resize-ne,
  .win-resize-sw, .win-resize-se { width: 18px; height: 18px; }
}
