/* ═══════════════════════════════════════════════════════
   FAUX OS V2.1 — Upgrade Layer
   Window animations • Snap zones • Command palette •
   Cursor trail • Toast notifications • Shortcuts HUD
   ═══════════════════════════════════════════════════════ */


/* ══════════════════════════════════════════════════════
   1. WINDOW OPEN / CLOSE ANIMATIONS
   ══════════════════════════════════════════════════════ */

.window {
  /* Start invisible — animation brings it in */
  opacity: 0;
  transform: scale(0.92) translateY(8px);
  pointer-events: none;
  transition: none;
}

.window.is-active {
  pointer-events: auto;
}

/* Spring-bounce open */
.window.is-opening {
  animation: win-open 0.38s var(--ease-spring) forwards;
}

@keyframes win-open {
  0% {
    opacity: 0;
    transform: scale(0.88) translateY(12px);
    filter: blur(4px);
  }
  50% {
    opacity: 1;
    filter: blur(0.5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

/* Already active (settled state) */
.window.is-active:not(.is-opening):not(.is-fracturing):not(.is-minimized):not(.is-snap-animating) {
  opacity: 1;
  transform: none;
  filter: none;
}

/* Dragging — keep visible, kernel.css sets opacity:0.9 */
.window.is-dragging {
  opacity: 0.9;
  transform: none;
  filter: none;
}

/* Minimize slide-down */
.window.is-minimized {
  opacity: 0;
  transform: scale(0.8) translateY(40px);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
  pointer-events: none;
}

/* Restore from minimize */
.window.is-restoring {
  animation: win-restore 0.3s var(--ease-spring) forwards;
}

@keyframes win-restore {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(40px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Maximize — add smooth transition (base positioning in kernel.css) */
.window.is-maximized {
  transition: left 0.3s var(--ease-out),
              top 0.3s var(--ease-out),
              width 0.3s var(--ease-out),
              height 0.3s var(--ease-out);
}


/* ── Sound Toggle in Menubar ── */
.menubar__sound-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
  padding: 2px 7px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  line-height: 1;
}

.menubar__sound-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.menubar__sound-toggle.is-muted {
  opacity: 0.4;
}

.menubar__sound-toggle.is-muted .menubar__sound-icon {
  text-decoration: line-through;
}


/* ── Window Resize Handles ── */
.window__resize-handle {
  /* Invisible but interactive */
  background: transparent;
  transition: background 0.15s;
}

/* Subtle highlight on hover */
.window__resize-handle:hover {
  background: rgba(232, 93, 48, 0.08);
}

/* During active resize */
.window.is-resizing {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
  /* Prevent content from capturing pointer during resize */
  & .window__body {
    pointer-events: none;
  }
}


/* ══════════════════════════════════════════════════════
   2. MAGNETIC SNAP ZONES
   ══════════════════════════════════════════════════════ */

/* Edge glow indicator */
.snap-zone-indicator {
  position: fixed;
  z-index: var(--z-overlay);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.snap-zone-indicator.is-visible {
  opacity: 1;
}

.snap-zone-indicator__preview {
  position: absolute;
  inset: 4px;
  border: 2px solid var(--accent);
  border-radius: var(--r-lg);
  background: var(--accent-dim);
  opacity: 0.5;
  animation: snap-pulse 1.2s ease-in-out infinite;
}

@keyframes snap-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.6; }
}

/* Left half */
.snap-zone-indicator--left {
  top: 0; left: 0; bottom: 0;
  width: 50%;
}

/* Right half */
.snap-zone-indicator--right {
  top: 0; right: 0; bottom: 0;
  width: 50%;
}

/* Top half (maximize) */
.snap-zone-indicator--top {
  top: 0; left: 0; right: 0;
  height: 100%;
}

/* Quarter zones */
.snap-zone-indicator--top-left {
  top: 0; left: 0;
  width: 50%; height: 50%;
}
.snap-zone-indicator--top-right {
  top: 0; right: 0;
  width: 50%; height: 50%;
}
.snap-zone-indicator--bottom-left {
  bottom: 0; left: 0;
  width: 50%; height: 50%;
}
.snap-zone-indicator--bottom-right {
  bottom: 0; right: 0;
  width: 50%; height: 50%;
}

/* Snap animation on the window itself */
.window.is-snap-animating {
  transition: left 0.25s var(--ease-spring),
              top 0.25s var(--ease-spring),
              width 0.25s var(--ease-spring),
              height 0.25s var(--ease-spring),
              opacity 0.15s;
  opacity: 1;
  transform: none;
}


/* ══════════════════════════════════════════════════════
   3. COMMAND PALETTE (Ctrl+K Spotlight)
   ══════════════════════════════════════════════════════ */

.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 50);
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out);
}

.cmd-palette-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette {
  width: min(520px, 88vw);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-win), 0 0 60px rgba(232, 93, 48, 0.06);
  overflow: hidden;
  transform: scale(0.96) translateY(-8px);
  transition: transform 0.2s var(--ease-spring);
}

.cmd-palette-overlay.is-open .cmd-palette {
  transform: scale(1) translateY(0);
}

.cmd-palette__input-wrap {
  display: flex;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
}

.cmd-palette__icon {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  color: var(--accent);
  opacity: 0.7;
  user-select: none;
  flex-shrink: 0;
}

.cmd-palette__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  letter-spacing: var(--tracking-normal);
  caret-color: var(--accent);
}

.cmd-palette__input::placeholder {
  color: var(--ink-faint);
}

.cmd-palette__kbd {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-faint);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  user-select: none;
  flex-shrink: 0;
}

.cmd-palette__results {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--sp-2) 0;
}

.cmd-palette__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}

.cmd-palette__item:hover,
.cmd-palette__item.is-selected {
  background: rgba(255, 255, 255, 0.05);
}

.cmd-palette__item.is-selected {
  border-left: 2px solid var(--accent);
}

.cmd-palette__item-icon {
  font-size: 1.1em;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.cmd-palette__item-label {
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  color: var(--ink);
}

.cmd-palette__item-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.cmd-palette__empty {
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink-faint);
}

.cmd-palette__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-5);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-faint);
  user-select: none;
}


/* ══════════════════════════════════════════════════════
   4. CURSOR PARTICLE TRAIL
   ══════════════════════════════════════════════════════ */

.cursor-trail-canvas {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) - 1);
  pointer-events: none;
  opacity: 0.7;
}

body.mode--mobile .cursor-trail-canvas {
  display: none;
}


/* ══════════════════════════════════════════════════════
   5. NOTIFICATION TOASTS
   ══════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: 52px;
  right: var(--sp-4);
  z-index: var(--z-notification);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  width: 300px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  animation: toast-in 0.35s var(--ease-spring) forwards;
  opacity: 0;
  transform: translateX(30px);
}

.toast.is-leaving {
  animation: toast-out 0.25s var(--ease-out) forwards;
}

@keyframes toast-in {
  0% { opacity: 0; transform: translateX(30px) scale(0.95); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  0% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(30px) scale(0.9); }
}

.toast__icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  margin-bottom: 2px;
}

.toast__message {
  color: var(--ink-muted);
  line-height: 1.4;
}

.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.5;
  border-radius: 0 0 0 var(--r-md);
  transition: width linear;
}

/* Variant: success */
.toast--success { border-left-color: #4caf50; }
.toast--success .toast__progress { background: #4caf50; }

/* Variant: warning */
.toast--warning { border-left-color: #ffc107; }
.toast--warning .toast__progress { background: #ffc107; }

/* Variant: error */
.toast--error { border-left-color: #f44336; }
.toast--error .toast__progress { background: #f44336; }

body.mode--mobile .toast-container {
  top: auto;
  bottom: 70px;
  left: var(--sp-3);
  right: var(--sp-3);
  width: auto;
}


/* ══════════════════════════════════════════════════════
   6. KEYBOARD SHORTCUTS HUD
   ══════════════════════════════════════════════════════ */

.shortcuts-hud {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: var(--z-modal);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-6);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2) var(--sp-8);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease-spring);
}

.shortcuts-hud.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.shortcuts-hud__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}

.shortcuts-hud__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 9px;
  color: var(--ink);
  font-family: var(--font-mono);
}

.shortcuts-hud__label {
  color: var(--ink-faint);
}

body.mode--mobile .shortcuts-hud { display: none; }


/* ══════════════════════════════════════════════════════
   7. TUTORIAL OVERLAY
   ══════════════════════════════════════════════════════ */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 40);
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
  cursor: pointer;
}

.tutorial-overlay.is-visible {
  opacity: 1;
}

.tutorial-overlay.is-leaving {
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}

.tutorial-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-8) var(--sp-6);
  box-shadow: var(--shadow-win), 0 0 80px rgba(232, 93, 48, 0.06);
  max-width: 360px;
  width: 88vw;
  transform: scale(0.92) translateY(12px);
  transition: transform 0.35s var(--ease-spring);
  cursor: default;
}

.tutorial-overlay.is-visible .tutorial-card {
  transform: scale(1) translateY(0);
}

.tutorial-card__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.tutorial-card__star {
  color: var(--accent);
  font-size: var(--fs-md);
}

.tutorial-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: var(--tracking-tight);
}

.tutorial-card__hints {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.tutorial-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.tutorial-hint__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  padding: 0 var(--sp-2);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  text-align: center;
  flex-shrink: 0;
}

.tutorial-hint__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
  text-align: center;
}

.tutorial-hint__text {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
}

.tutorial-card__dismiss {
  width: 100%;
  padding: var(--sp-3);
  background: var(--accent);
  color: var(--c-black);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  cursor: pointer;
  transition: opacity 0.15s;
}

.tutorial-card__dismiss:hover {
  opacity: 0.85;
}

.tutorial-hint--sound {
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  transition: border-color 0.2s, background 0.2s;
}

.tutorial-hint--sound:hover {
  border-color: var(--accent);
  background: rgba(232, 93, 48, 0.06);
}

.tutorial-hint--sound.is-muted .tutorial-hint__sound-icon {
  color: var(--ink-faint);
  opacity: 0.5;
}

.tutorial-card__footer {
  text-align: center;
  margin-top: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-faint);
}
