/* Preview shell: app bodies retain their own layouts and visual identities. */
:root {
  /* Mirrored spacing foundations from design-system/tokens.css. */
  --ds-space-2: 4px;
  --ds-space-3: 6px;
  --ds-color-border-muted: #808080;
  --ds-window-content-border: 1px solid var(--ds-color-border-muted);
  --ds-window-content-inset: 2px;
  --chrome-border: var(--ds-color-border-muted);
  --chrome-title-height: 24px;
  --chrome-control-size: 18px;
  --chrome-footer-height: 20px;
  --chrome-focus: #123b93;
  --taskbar-safe-left: env(safe-area-inset-left,0px);
  --taskbar-safe-right: env(safe-area-inset-right,0px);
}
.preview-chrome .window {
  border:1px solid var(--chrome-border);
  box-shadow:none;
  padding-bottom:0;
}
.preview-chrome .window::after { display:none; }
.preview-chrome .window > .titlebar,
.preview-chrome .app-help-dialog[data-app-help-dialog] > .titlebar,
.preview-chrome #about-window > .titlebar {
  height:var(--chrome-title-height); min-height:var(--chrome-title-height);
  padding:2px 4px 2px 6px; box-shadow:none;
  background:linear-gradient(90deg,var(--title-dark),var(--title));
}
.preview-chrome .window.is-active:not(.is-front) > .titlebar { background:linear-gradient(90deg,#4d5358,#70777b); }
.preview-chrome .window > .titlebar .window-actions { gap:3px; flex-shrink:0; }
.preview-chrome .window > .titlebar .window-actions button,
.preview-chrome .app-help-dialog[data-app-help-dialog] > .titlebar .window-actions button,
.preview-chrome #about-window > .titlebar .window-actions button {
  width:var(--chrome-control-size); height:var(--chrome-control-size);
  min-height:var(--chrome-control-size); padding:0; border-radius:0; box-shadow:none;
}
.preview-chrome .window > .window-footer-meta {
  position:static; inset:auto; width:auto; margin:0;
  height:var(--chrome-footer-height); min-height:var(--chrome-footer-height); flex-shrink:0;
  padding:0 8px; border-top:1px solid var(--chrome-border);
  background:var(--work-white); color:#4b5358; font-weight:400;
}
.preview-chrome #welcome-window { padding:2px; }
.preview-chrome #welcome-window > .window-footer-meta { background:var(--welcome-gray); }
/* Keep the live box model; the inset outline paints without consuming space. */
.preview-chrome .window > .window-body { border-top:1px solid var(--chrome-border); }
.preview-chrome .window > .window-body,
.app-help-dialog > .app-help-copy {
  outline: var(--ds-window-content-border);
  outline-offset: calc(-1 * (var(--ds-window-content-inset) + 1px));
}

/* My Andunny's full welcome heading opens the existing Welcome app. */
.preview-chrome #about-window .root-header {
  padding: 0;
  border-color: var(--window-dark);
}
.root-welcome-button {
  display: block;
  width: 100%;
  padding: 2px;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.preview-chrome #about-window .root-welcome-button:focus-visible {
  outline: 1px dotted var(--window-dark);
  outline-offset: -3px;
}
.root-welcome-button:active { box-shadow: var(--button-shadow-pressed); }
.preview-chrome :is(.explorer-toolbar,.portfolio-archive-toolbar,.portfolio-viewer-toolbar,.paint-menu,.text-editor-toolbar) {
  border-color:var(--chrome-border); box-shadow:none;
}
.preview-chrome :is(.explorer-toolbar,.portfolio-archive-toolbar,.text-editor-toolbar) button,
.preview-chrome .dialog-actions button {
  border-width:1px; border-radius:0; box-shadow:none;
}
/* Preserve the viewer's intentionally large navigation and all canvas/player controls. */
.preview-chrome .window button:focus-visible,
.preview-chrome .taskbar button:focus-visible {
  outline:2px solid var(--chrome-focus); outline-offset:-3px;
}
.preview-chrome .taskbar {
  grid-template-columns:auto minmax(0,1fr) auto;
  padding-left:max(4px,var(--taskbar-safe-left));
  padding-right:max(4px,var(--taskbar-safe-right));
}
.preview-chrome .task-buttons {
  align-items:center; overflow-x:auto; overflow-y:hidden;
  scrollbar-width:thin; overscroll-behavior-x:contain;
}
.preview-chrome .task-buttons button { flex:0 0 auto; }
.preview-chrome .task-buttons img { object-fit:contain; display:block; }
@media (max-width:760px), (pointer:coarse) {
  .preview-chrome { --taskbar-height:52px; --chrome-title-height:32px; --chrome-control-size:28px; }
  .preview-chrome .taskbar { gap:4px; padding-top:3px; padding-bottom:3px; }
  .preview-chrome .start-button { height:44px; padding:2px 5px; gap:4px; font-size:14px; }
  .preview-chrome .task-buttons {
    height:44px; gap:4px; justify-content:flex-start; scrollbar-width:none;
    scroll-snap-type:x proximity; touch-action:pan-x;
  }
  .preview-chrome .task-buttons::-webkit-scrollbar { display:none; }
  .preview-chrome .task-buttons button {
    width:44px; min-width:44px; max-width:44px; height:44px;
    padding:0; gap:0; justify-content:center; align-items:center; scroll-snap-align:center;
  }
  .preview-chrome .task-buttons button span {
    position:absolute; width:1px; height:1px; padding:0; margin:-1px;
    overflow:hidden; clip-path:inset(50%); white-space:nowrap;
  }
  .preview-chrome .task-buttons img { width:20px; height:20px; margin:0; }
  .preview-chrome .task-buttons button:active { transform:none; }
  .preview-chrome .tray { height:44px; min-width:0; padding:2px 3px; gap:2px; }
  .preview-chrome .tray-volume,.preview-chrome .tray-weather { width:32px; min-width:32px; height:36px; padding:2px; }
  .preview-chrome .tray time { font-size:12px; white-space:nowrap; font-variant-numeric:tabular-nums; }
  .preview-chrome #welcome-window .welcome-body { max-height:calc(100dvh - var(--taskbar-height) - var(--taskbar-safe-bottom) - 92px); }
}
/* Short phones/landscape: retain each body layout inside a scrollable shell. */
@media (max-height:600px) and (max-width:900px) {
  .preview-chrome .window { top:8px; max-height:calc(100dvh - var(--taskbar-height) - var(--taskbar-safe-bottom) - 16px); }
  .preview-chrome .window.is-active:not(.is-minimized) { display:flex; flex-direction:column; }
  .preview-chrome .window > .titlebar,
.preview-chrome #about-window > .titlebar { flex-shrink:0; }
  .preview-chrome .window:not(.qr-maker-window) > .window-body { min-height:0; flex:0 1 auto; overflow:auto; }
}

/* Shared File / Help idiom; popover escapes clipped app bodies. */
.preview-chrome .app-menubar {
  display:flex; align-items:center; gap:2px; padding:2px 5px 1px;
  height:22px; min-height:22px; flex-shrink:0; border-bottom:1px solid var(--chrome-border);
  background:#fff; color:#111; position:relative;
}
.preview-chrome .app-menubar > button,
.preview-chrome .app-menubar .paint-menu-group > button {
  height:18px; min-height:18px; padding:1px 5px; border:1px solid transparent;
  border-radius:0; box-shadow:none; background:transparent; color:#111; font:11px/12px var(--font);
}
.preview-chrome .app-menubar button:hover,
.preview-chrome .app-menubar button[aria-expanded=true] { border-color:var(--chrome-border); background:#fff; }
.app-file-popup {
  z-index:var(--ds-z-menu-popup);
  position:fixed; inset:auto; margin:0; width:max-content; min-width:var(--ds-file-menu-min-width); max-width:calc(100vw - 8px);
  padding:2px; border:1px solid var(--chrome-border); background:var(--window); color:var(--work-ink); font:var(--button-font-size-compact)/14px var(--font);
  box-shadow:2px 2px 0 #0004;
}
.app-file-popup button { display:block; width:100%; min-height:var(--ds-file-menu-row-height); padding:var(--ds-file-menu-row-padding); text-align:left; border:0; border-radius:0; background:transparent; color:inherit; font:inherit; }
.app-file-popup button:hover,.app-file-popup button:focus-visible { background:#042b8f; color:white; outline:0; }
.app-help-dialog {
  width:min(340px,calc(100vw - 24px)); max-height:calc(100dvh - 32px);
  padding:0; border:1px solid #808080; background:#cfcfcf; color:#111; font:12px var(--font);
  box-shadow:3px 3px 0 #0004; overflow:auto;
}
.app-help-dialog::backdrop { background:#0003; }
.app-help-dialog .titlebar { min-height:24px; height:auto; cursor:default; background:linear-gradient(90deg,#042b8f,#075bde); box-shadow:none; }
.app-help-dialog .titlebar span { min-width:0; overflow-wrap:anywhere; }
.app-help-dialog:not([data-app-help-dialog]) .titlebar button { flex:none; width:20px; height:20px; padding:0; border:1px solid #808080; background:#e8e8e8; color:#111; }
.app-help-copy { padding:8px 12px; line-height:1.45; }
.app-help-copy p { margin:0 0 8px; }
.app-help-copy p:last-child { margin-bottom:0; }
.app-help-actions { display:flex; justify-content:flex-end; padding:0 12px 10px; }
.app-help-actions button { min-width:64px; min-height:24px; border:1px solid #808080; background:#e8e8e8; color:#111; }
.app-help-dialog button:focus-visible,.app-menubar button:focus-visible { outline:2px solid #123b93; outline-offset:-3px; }
@media(max-width:760px),(pointer:coarse) {
  .app-help-dialog:not([data-app-help-dialog]) .titlebar { min-height:32px; }
  .app-help-dialog:not([data-app-help-dialog]) .titlebar button { width:28px; height:28px; }
  .app-help-dialog:not([data-app-help-dialog]) .app-help-actions button { min-height:36px; }
}
/* Help uses the window control hooks and existing compact command tokens. */
.app-help-dialog[data-app-help-dialog],
.app-help-dialog[data-app-help-dialog] .app-help-copy {
  background: var(--window);
}
/* Keep the 10px vertical allowance while moving OK down and right. */
.app-help-dialog[data-app-help-dialog] .app-help-actions {
  padding: var(--ds-space-3) var(--ds-space-2) var(--ds-space-2);
}
.app-help-dialog[data-app-help-dialog] .app-help-actions button {
  min-height: var(--button-height-command-compact);
  padding: var(--button-padding-command-compact);
  border: 1px solid var(--chrome-border);
  border-radius: 0;
  background: var(--window);
  color: var(--window-dark);
  box-shadow: none;
  font: inherit;
}
/* Selected tasks keep their pressed border without shifting the aligned row. */
.preview-chrome .task-buttons button.is-selected { transform:none; }

/* Unconfigured code prompt: shares the existing compact dialog chrome. */
.authenticate-dialog { width:min(300px,calc(100vw - 24px)); }
.authenticate-copy { padding:8px 10px; }
.authenticate-copy label { display:flex; align-items:center; gap:8px; }
.authenticate-copy input { min-width:0; flex:1; width:100%; height:20px; box-sizing:border-box; border:1px solid var(--shadow,#808080); border-radius:0; font:inherit; }
.authenticate-copy p { margin:6px 0 0; font-size:11px; }
.authenticate-dialog .app-help-actions { padding:0 10px 8px; }

/* Restrained preview motion: layout stays square, immediate and interactive. */
.preview-chrome .window { transform-origin:50% 24px; }
.preview-chrome :is(.window-actions,.app-menubar,.dialog-actions,.app-help-actions,.taskbar,.welcome-sidebar,.welcome-pager) button { transition:scale var(--preview-control-duration) var(--preview-control-ease); }
.preview-chrome :is(.window-actions,.app-menubar,.dialog-actions,.app-help-actions,.taskbar,.welcome-sidebar,.welcome-pager) button:active { scale:.96; }
@media(prefers-reduced-motion:reduce) {
  .preview-chrome :is(.window-actions,.app-menubar,.dialog-actions,.app-help-actions,.taskbar,.welcome-sidebar,.welcome-pager) button { transition:none; scale:1; transform:none; }
  .preview-chrome .work-hero { transition:none; }
}

/* Closing windows remain input-blocked until their short visual exit completes. */
.window-exit-blocker { background:transparent; touch-action:none; }
.preview-chrome .window.is-closing { pointer-events:none; }
@media(hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference) {
  .preview-chrome :is(.window-actions,.app-menubar,.dialog-actions,.app-help-actions,.taskbar,.welcome-sidebar,.welcome-pager) button:hover:not(:active):not(:disabled) { scale:1.025; }
}
@keyframes preview-start-enter { from { transform:translateY(8px); opacity:.65; } to { transform:none; opacity:1; } }
@keyframes preview-submenu-enter { from { transform:translateX(var(--submenu-enter-x,-8px)); opacity:.7; } to { transform:none; opacity:1; } }
.preview-chrome .start-menu.is-open { animation:preview-start-enter 150ms cubic-bezier(.2,.8,.3,1); }
.preview-chrome .start-menu-submenu { max-height:calc(100dvh - var(--taskbar-height) - 20px); overflow-y:auto; }
.preview-chrome .start-menu-submenu[data-side="left"] { --submenu-enter-x:8px; }
.preview-chrome .start-menu-node.is-open > .start-menu-submenu { animation:preview-submenu-enter 130ms cubic-bezier(.2,.8,.3,1); }
@media(prefers-reduced-motion:reduce) {
  .preview-chrome .start-menu.is-open,.preview-chrome .start-menu-node.is-open > .start-menu-submenu { animation:none; }
}

/* Start rows keep stationary text and icon geometry. */
.preview-chrome .start-menu-row { position:relative; overflow:hidden; isolation:isolate; }
.preview-chrome .start-menu-row:is(:hover,:focus),.preview-chrome .start-menu-node.is-open > .start-menu-row { background:var(--work-white); color:var(--work-ink); }
.preview-chrome .start-menu-row > :not(.menu-fill-background) { position:relative; z-index:1; }
.menu-fill-background { position:absolute; inset:0; z-index:0; pointer-events:none; color:var(--title); background:linear-gradient(to right,currentColor max(0px,calc(var(--fill-x,0px) - 8px)),transparent var(--fill-x,0px)); opacity:0; }

/* A single restrained shimmer travels with the slower blue fill. */
.menu-fill-background {
 background:linear-gradient(90deg,transparent 36%,rgb(255 255 255 / .18) 50%,transparent 64%) var(--shimmer-x,-40%) 0 / 45% 100% no-repeat,linear-gradient(90deg in srgb,var(--menu-fill-blue),var(--menu-fill-mid) 52%,var(--menu-fill-deep));
 mask-image:linear-gradient(to right,#000 max(0px,calc(var(--fill-x,0px) - 8px)),transparent var(--fill-x,0px));
}
.preview-chrome .start-menu-row .start-menu-arrow { border-left-color:var(--work-ink); }
@media(prefers-reduced-motion:reduce) { .menu-fill-background { background:var(--menu-fill-blue); } }

/* Stationary white copy is exposed only over sufficiently dark fill pixels. */
.preview-chrome .start-menu-row,.preview-chrome .start-menu-row:is(:hover,:focus),.preview-chrome .start-menu-node.is-open > .start-menu-row { color:#000; }
.preview-chrome .start-menu-row > .menu-fill-foreground { position:absolute; inset:0; z-index:2; pointer-events:none; display:grid; grid-template-columns:inherit; align-items:center; gap:inherit; padding:inherit; color:#fff; }
.preview-chrome .start-menu-node .start-menu-row .start-menu-arrow { border-left-color:#000; }
.preview-chrome .start-menu-row .menu-fill-foreground .start-menu-arrow { border-left-color:#fff; }

@media(prefers-reduced-motion:reduce) {
  .preview-chrome :is(.welcome-sidebar,.welcome-pager) button:active { scale:1; transform:none; }
}
