/* ============================================================================
   Varelyno on Windows (26 Nov 2026): the installed app looks and behaves like a
   Windows app. WINDOWS-PWA-PLAN.md has the full list. Loaded on every page of the
   app and the demo; most rules only apply to the installed window.

   Title bar (Window Controls Overlay): the app's own top row sits in the title
   bar beside Windows' minimise, maximise and close buttons. The empty parts of
   the band drag the window (#vxTitleDrag), every button stays clickable, and the
   right end of the row moves left so nothing sits under Windows' buttons.
   A browser tab is unchanged: none of this applies there.
   ========================================================================== */

/* ---------------------------------------------------------------- everywhere */
/* buttons, menu items and pills are not text to select (a double click on a pill selected its words) */
:is(button, [role="button"], [role="menuitem"], [role="tab"], summary, .nav-btn, .btn, .vx17-glass, .vx17-pl, .vx17-sw, label.toggle) {
  -webkit-user-select: none; user-select: none;
}
/* no rubber-band bounce of the whole page; scrolling lists keep their own */
html, body { overscroll-behavior: none; }

/* the drag strip only exists in the installed window with the title bar overlay */
#vxTitleDrag { display: none; }

/* ------------------------------------------------- installed window, any kind */
@media (display-mode: standalone), (display-mode: window-controls-overlay) {
  /* pictures and icons in the app's own chrome are not dragged out as files */
  #sidebar img, #topbar img, #vxMap17 .vx17-top img, .vx17-glass img, button img, button svg { -webkit-user-drag: none; }
  /* the app's own words in its chrome are not selectable; text in pages, notes and fields still is */
  #sidebar, #vxMap17 .vx17-top, #vxMap17 .vx17-tools, #vxMap17 .vx17-bottom { -webkit-user-select: none; user-select: none; }
  #sidebar :is(input, textarea, [contenteditable="true"]) { -webkit-user-select: text; user-select: text; }
}

/* ------------------------------------------- title bar overlay (Windows, Mac) */
@media (display-mode: window-controls-overlay) {
  :root {
    /* how much of the right edge Windows' buttons take, and the band's height */
    --vxw-r: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
    --vxw-l: env(titlebar-area-x, 0px);
    --vxw-h: env(titlebar-area-height, 33px);
  }
  #vxTitleDrag {
    display: block; position: fixed; z-index: 0; pointer-events: none;
    left: env(titlebar-area-x, 0px); top: env(titlebar-area-y, 0px);
    width: env(titlebar-area-width, 100%); height: env(titlebar-area-height, 33px);
    app-region: drag; -webkit-app-region: drag;
  }
  /* everything you can press stays a button, also inside the band */
  :is(button, a, input, select, textarea, summary, label, [role="button"], [role="menuitem"], .vx17-glass, #ownerAccess, #demoBar, .global-search, .modal, .search-pop) {
    app-region: no-drag; -webkit-app-region: no-drag;
  }

  /* The Map page: its top row keeps its place, its right end clears Windows' buttons (the row measures itself, so
     words turn into icons when the narrower row needs it). .topbar twice: these load before map17's own rules. */
  html.vx-map17 #vxMap17 .vx17-top { right: calc(16px + var(--vxw-r)) !important; }
  html.vx-map17 body #topbar.topbar.topbar:is(.vx-search-open, .vx-search-closing) > .global-search { right: calc(16px + var(--vxw-r)) !important; }
  html.vx-map17 body #topbar.topbar.topbar:is(.vx-search-open, .vx-search-closing) > .vx-search-close { right: max(calc(22px + var(--vxw-r)), calc((100vw - var(--vx17-left, 0px) - 560px) / 2 + 6px)) !important; }

  /* the glance panel on the right: its heading starts under the band, so its buttons are never under Windows' buttons */
  #vxMap17 .vx17-glance .vx17-ghead { padding-top: calc(8px + var(--vxw-h)) !important; }

  /* The other pages: the floating row ends where the band's free part ends. Its own layout (map17-topbar.js measure)
     then fits the words, icons and the account into that width, as it does in any narrower window. */
  html.vx18-bar.vx18-float:not(.vx-map17) body #topbar.topbar.topbar { right: var(--vxw-r) !important; }
  /* the side menu, when it slides over the page, starts below the band so its close button is never under Windows' buttons */
  html.vx18-upright body #sidebar.sidebar { padding-top: var(--vxw-h) !important; }
}

/* --------------------------------------------------- the small Windows notes */
/* one line at the bottom: "Saved on this PC, will sync" and the notifications question */
.vxw-note {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 2147483000;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: min(560px, calc(100vw - 32px)); box-sizing: border-box; padding: 10px 14px;
  border-radius: 14px; background: var(--surface, #fff); color: var(--text, #1d2b3e);
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  box-shadow: 0 10px 30px rgba(20, 31, 58, .16);
  font: 500 14px/20px "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  transition: opacity .6s cubic-bezier(.16, .84, .3, 1), transform .8s cubic-bezier(.16, .84, .3, 1);
}
.vxw-note.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.vxw-note .vxw-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #f6b33a; }
.vxw-note.synced .vxw-dot { background: #00b9ad; }
.vxw-note span { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.vxw-note button {
  flex: none; border: 0; border-radius: 10px; padding: 6px 12px; cursor: pointer;
  font: 600 13px/18px "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  background: color-mix(in srgb, currentColor 8%, transparent); color: inherit;
}
.vxw-note button.primary { background: var(--accent, #1e86c8); color: #fff; }
.vxw-note button:focus-visible { outline: 2px solid var(--accent, #1e86c8); outline-offset: 2px; }
html[data-mode="dark"] .vxw-note { background: #1b2233; color: #e8edf6; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
@media (prefers-reduced-motion: reduce) { .vxw-note { transition: opacity .2s linear; transform: translate(-50%, 0); } }
html[data-motion="off"] .vxw-note { transition: opacity .2s linear; transform: translate(-50%, 0); }

/* drop files here: a quiet outline over the page while a file is dragged in */
.vxw-drop {
  position: fixed; inset: 10px; z-index: 2147482000; pointer-events: none; border-radius: 22px;
  border: 2px dashed var(--accent, #1e86c8); background: color-mix(in srgb, var(--accent, #1e86c8) 7%, transparent);
  display: grid; place-items: center; opacity: 0; transition: opacity .3s cubic-bezier(.16, .84, .3, 1);
}
.vxw-drop.on { opacity: 1; }
.vxw-drop b {
  padding: 10px 16px; border-radius: 12px; background: var(--surface, #fff); color: var(--text, #1d2b3e);
  font: 600 15px/20px "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; box-shadow: 0 8px 24px rgba(20, 31, 58, .14);
  max-width: calc(100vw - 80px); overflow-wrap: anywhere; text-align: center;
}
html[data-mode="dark"] .vxw-drop b { background: #1b2233; color: #e8edf6; }

/* the keyboard shortcuts list (Ctrl+/) */
.vxw-keys { width: auto; }
.vxw-keys table { width: 100%; border-collapse: collapse; }
.vxw-keys td { padding: 7px 4px; border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent); vertical-align: top; overflow-wrap: anywhere; }
.vxw-keys td:first-child { white-space: nowrap; padding-right: 16px; width: 1%; }
.vxw-keys kbd {
  display: inline-block; min-width: 1.4em; padding: 1px 6px; margin: 0 2px; border-radius: 6px; text-align: center;
  font: 600 12px/18px "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent); background: color-mix(in srgb, currentColor 5%, transparent);
}

/* visible focus for keyboard users on the Map's own buttons and pills */
#vxMap17 :is(button, [role="button"]):focus-visible, .vxw-note button:focus-visible { outline: 2px solid var(--vx17-accent, #1e86c8); outline-offset: 2px; }
