/* Shell rules: the ground, the safe areas, and where the chrome sits. Screens and components style
 * themselves from tokens.css. The legacy conformance screens still paint from vendor/utilities.css
 * over palette.css (namespaced --m3-*), which is why those two files are still loaded. */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --chrome-top: calc(var(--safe-top) + 8px);                 /* the menu button */
  --content-top: calc(var(--safe-top) + 72px);               /* 8 + 44 button + 20 clear (board: 122 under a 50 status bar) */
  --dock-h: 62px;
  --dock-bottom: max(var(--safe-bottom), 16px);              /* the dock rides the home-indicator zone (board: 34) */
  --content-bottom: calc(var(--dock-bottom) + var(--dock-h) + 16px);
}

html { background: var(--canvas); }
/* touch-action: manipulation turns off double-tap-to-zoom (the page is an app, not a site) and the
 * 300ms tap delay with it. Pinch-zoom is off in the viewport meta (index.html). */
html, body { width: 100%; margin: 0; padding: 0; touch-action: manipulation; }
body { background: var(--canvas); color: var(--text); font: 400 14px/1.5 var(--font); min-height: 100dvh;
  overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
/* A finger needs no scrollbar; a pointer does (the desktop block at the end). The exact complement
 * of that block's (hover: hover) and (pointer: fine). */
@media (hover: none), (pointer: coarse), (pointer: none) { ::-webkit-scrollbar { display: none; } }
::selection { background: var(--focus); color: var(--focus-ink); }

/* Screens render into <main>. Full-bleed screens (network) position their own field; flow screens
 * get the space between the menu button and the dock. */
main#app { display: flex; flex-direction: column; min-height: 100dvh; box-sizing: border-box; padding: var(--content-top) 0 var(--content-bottom); }
/* The first frame: the app's mark on the page colour while the code is still on its way (a slow link took tens of
 * seconds, and a page with nothing to draw read as a black screen). It goes the moment the first screen mounts. */
main#app:empty { background: url(icons/icon.svg) center / 72px no-repeat; }
[data-screen] { display: contents; }

/* Visible to assistive tech, not to the eye. For headings the board does not draw but a screen
 * reader's rotor needs. Components may still scope their own copy. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Safe-area probe read by the dev overlay's env readout. */
#safe-probe { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; visibility: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }

/* The theme flip (main.js, valt:theme). The old frame holds still; the new one is revealed through a
 * circle growing from the switch knob (--vt-x / --vt-y) to the farthest corner (--vt-r). No crossfade:
 * two frames blended read as a third, muddier mode for half a second. */
::view-transition-old(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: valt-theme-reveal 520ms var(--travel) both; mix-blend-mode: normal; }
@keyframes valt-theme-reveal {
  from { clip-path: circle(0px at var(--vt-x, 50%) var(--vt-y, 50%)); }
  to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 50%) var(--vt-y, 50%)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* The paywall is a modal, not a destination: it carries its own close and restore, so the menu chip
 * and the nav dock stand down while it is up and the page keeps only the home-indicator clearance
 * the dock was reserving. main.js publishes the route section on <html>. */
html[data-route="paywall"] valt-menu,
html[data-route="paywall"] valt-dock,
/* So are the cancel screens (screens/cancel.js): a modal over Account, with its own close. */
html[data-route="cancel"] valt-menu,
html[data-route="cancel"] valt-dock,
/* First launch carries no chrome: nothing is navigable until the tunnel is up. */
html[data-route="welcome"] valt-menu,
html[data-route="welcome"] valt-dock,
/* The account flow is first launch too: nothing is navigable until there is an account, so the
   chrome stands down on every screen of it the way it does on the welcome screen. */
html[data-route="join"] valt-menu,
html[data-route="join"] valt-dock,
html[data-route="signin"] valt-menu,
html[data-route="signin"] valt-dock { display: none; }
html[data-route="account"] valt-dock,
html[data-route="settings"] valt-dock { display: none; }
/* The 72px the shell reserves for the menu button is dead space here, and it pushed
   the page 72px past the viewport. The screen carries its own top inset instead. */
html[data-route="welcome"] main#app,
html[data-route="join"] main#app,
html[data-route="signin"] main#app { padding-top: 0; padding-bottom: 0; }
/* First launch does not scroll. iOS rubber-bands the document even when there is
   nothing to scroll, and on a screen that is deliberately still that reads as jank. */
html[data-route="welcome"],
html[data-route="welcome"] body,
html[data-route="join"],
html[data-route="join"] body,
html[data-route="signin"],
html[data-route="signin"] body { overflow: hidden; overscroll-behavior: none; }
/* A route with no dock keeps only the home-indicator clearance the dock was reserving. */
html[data-route="paywall"] main#app,
html[data-route="cancel"] main#app,
html[data-route="account"] main#app,
html[data-route="settings"] main#app { padding-bottom: calc(var(--dock-bottom) + 8px); }

/* The removal section's sidebar (valt-sidebar: the website 26 shell's 208 sidebar, from md up) on a wide
 * window. Removal routes only; the VPN home keeps its full-bleed field, and Account left with its tab
 * (components/sidebar.js). The page centres in what is left of the width, and the dock centres with it. */
@media (min-width: 768px) {
  html[data-route="removal"] valt-sidebar { display: flex; }
  html[data-route="removal"] main#app { padding-left: 208px; }
  html[data-route="removal"] valt-dock { left: calc(50% + 104px); }
  /* and the refresh loader centres over the page, not the sidebar */
  html[data-route="removal"] valt-refresh { left: 208px; }
}
/* On a desktop the sidebar carries the two sections as well (components/sidebar.js), and it is the
 * only navigation. So it shows on every screen the dock used to, the VPN home included (its field
 * starts at the sidebar's edge, network.css), the pill stands down everywhere (dock.css; the dock keeps the VPN
 * home's map controls on their edge rail), and pages keep only an ordinary bottom margin. Pointer only: a touch
 * screen at this width keeps the dock, and the iOS shell's native dock never sees this rule. */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  :root { --content-bottom: 32px; }
  html:is([data-route="network"], [data-route="destinations"], [data-route="deletions"]) valt-sidebar { display: flex; }
  html:is([data-route="destinations"], [data-route="deletions"]) main#app { padding-left: 208px; }
}

/* the router hides kept-alive screens with the hidden attribute */
[hidden] { display: none !important; }

/* The status bar band: whatever scrolls up under the clock and the notch goes
 * behind a soft glass band, the way iOS 26 fades content under its own bars. It reaches past the
 * menu button (safe top + 8 + 44, and a little), so a list scrolled up blurs away before the button. Blur and a veil of the
 * canvas, faded out by a mask, so there is no hard edge. Over every screen, under the shell chrome
 * (menu 8, dock 7) and the pull loader (6), above the screens (whose own layers stop at 6 inside
 * their fixed fields, which paint below this). Nothing to tap: pointer-events none. */
body::after { content: ''; position: fixed; left: 0; right: 0; top: 0; height: calc(var(--safe-top) + 64px); z-index: 5; pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--canvas) 72%, transparent), color-mix(in srgb, var(--canvas) 0%, transparent));
  -webkit-backdrop-filter: blur(10px) saturate(130%); backdrop-filter: blur(10px) saturate(130%);
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
/* Chrome tucked (network.js, node-list.css --lift): the pinned list top rises to the status bar, so the band keeps only the
   status bar itself. No transition: a blurred band resized every frame is the costly kind, and the card's own rise covers it. */
:root[data-chrome-tucked] body::after { height: calc(var(--safe-top) + 8px); }

/* Desktop: the Mac and Windows windows, and a desktop browser (2026-10-05 desktop pass). What a mouse or a
 * trackpad changes, and only that: (hover: hover) and (pointer: fine) never matches a phone, so nothing in
 * this block reaches the iOS shell. Screens that need a desktop rule of their own (welcome, the sign-in
 * forms, the removal screens) repeat this exact query, so there is one meaning of "desktop" in the app. */
@media (hover: hover) and (pointer: fine) {
  /* The status bar band is the iPhone's: a window has no clock or notch to fade under. Left on, it veiled
     the back button on the sign-in forms and the top of the connection card on a short window. */
  body::after { display: none; }
  /* Scrollbars are the platform's own here (the touch rule at the top hides them only for a finger). A long
     page (the dashboard, the brokers list) has to say where you are and give a mouse something to drag.
     The Mac draws its thin overlay bar; the Windows window asks WebView2 for Windows 11's Fluent overlay
     bar (valt-2.0-windows MainWindow, ScrollBarStyle). Both take night or day from tokens.css's
     color-scheme. Not recoloured here: a custom scrollbar-color turns Chromium's overlay bar back into a
     classic one with arrow buttons. */
  /* Controls and chrome are not text: a drag across the drawer, or Ctrl/Cmd+A, painted the whole window
     teal. Reading text (an exit address, an email, the authorization's terms) and every field stay
     selectable. */
  button, [role="button"], [role="switch"], [role="tab"], [role="radio"], [role="option"],
  valt-menu, valt-dock, valt-sidebar, valt-dual-trigger, valt-refresh { -webkit-user-select: none; user-select: none; }
  input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
}

