/* Expanded window mode: <html data-window="expanded" data-dock="visible|autohide"> (set per page by tools/build.py
   from the page's "windowMode" / "dockMode" settings, so a direct load is right on first paint). Semantic tokens
   only. Desktop and wide tablets only (701px and up): phones keep the normal full-screen window + bottom tab bar.
   Everything here is scoped to [data-window="expanded"]: normal pages and the locked layout values are untouched.
   - The browser window is maximized: edge to edge, touching the menu bar, no outer shadow; title bar, toolbar and
     bevels stay.
     - dock "visible" (Work, Content, About, Side Quests, Collage): the window stops above the dock, which stays
       exactly where it is on Home (same size, same 16px gap above it and 10px below it).
     - dock "autohide" (detail pages like Off-White): the window runs to the bottom of the screen and the dock
       floats over it and auto-hides (components/dock-float.js adds .dock-ready and .dock-away on <html>).
       Without JavaScript it simply stays visible.
   - .zoom-rect: the OS 9 zoom outline drawn by components/site-nav.js when the window's rectangle changes. */

:root {
  --dock-peek-ms: 3000;   /* dock shows this long when an expanded page is entered */
  --dock-linger-ms: 3000; /* ...and this long after the pointer / focus leaves it */
  --dock-handle-w: 48px;
  --dock-handle-h: 6px;
  --dock-float-gap: 10px; /* space under the dock (same as the normal dock) */
  --dock-handle-bottom: 14px; /* the handle sits above the bottom edge... */
  --dock-mac-edge: 12px;      /* ...because the bottom 12px belongs to the Mac's own Dock (browser full screen):
                                 nothing of ours reveals the dock there */
  --dock-float-space: calc(var(--dock-h) + var(--dock-float-gap) + var(--dock-handle-h) + 6px); /* kept clear under the content */
}

/* The handle only exists on expanded pages once the dock script runs */
.dock-handle { display: none; }

/* The zoom outline (any mode; it only appears during a mode change) */
.zoom-rect {
  position: fixed;
  top: 0;
  left: 0;
  z-index: calc(var(--z-os-menubar) + 400); /* above the window and dock, under the CRT overlay + toggles */
  border: 2px solid var(--os-outline);
  box-shadow: 0 0 0 1px var(--os-hi), inset 0 0 0 1px var(--os-hi);
  transform-origin: 0 0;
  pointer-events: none;
}

@media (min-width: 43.8125rem) {
  /* ---- Maximized window ---- */
  html[data-window="expanded"] .os-win.os-browser {
    top: var(--menubar-total, var(--menubar-h));
    bottom: auto;
    left: 0;
    width: 100%;
    height: auto;
    margin-left: 0;
    border-bottom: 0;
    box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px 0 0 var(--os-lo); /* bevels only, no outer shadow */
    transform: none; /* a maximized window never sits where it was dragged */
  }
  /* dock visible: stop above it, exactly like the normal window does (os-browser.css) */
  html[data-window="expanded"][data-dock="visible"] .os-win.os-browser { bottom: calc(var(--dock-h) + 20px); }
  /* dock autohide: to the bottom of the screen */
  html[data-window="expanded"][data-dock="autohide"] .os-win.os-browser { bottom: 0; }
  html[data-window="expanded"] .os-win.os-browser.is-collapsed { bottom: auto; }
  html[data-window="expanded"] .os-browser .os-win__bar { cursor: default; }

  /* Content never ends up behind the floating dock */
  html[data-window="expanded"][data-dock="autohide"] .os-browser .os-win__body.os-browser__page {
    padding-bottom: var(--dock-float-space);
    scroll-padding-bottom: var(--dock-float-space);
  }

  /* ---- Floating, auto-hiding dock ---- */
  html[data-window="expanded"][data-dock="autohide"] .os-dock {
    bottom: var(--dock-float-gap);
    transition: transform 0.22s ease-out;
  }

  html[data-window="expanded"][data-dock="autohide"].dock-away .os-dock {
    transform: translateX(-50%) translateY(calc(100% + var(--dock-float-gap) + 4px));
    pointer-events: none; /* offscreen: never intercepts clicks (still focusable: focus brings it back) */
  }

  html[data-window="expanded"].dock-ready .dock-handle {
    display: block;
    position: fixed;
    bottom: var(--dock-handle-bottom);
    left: 50%;
    z-index: var(--z-os-menubar);
    width: var(--dock-handle-w);
    height: var(--dock-handle-h);
    margin-left: calc(var(--dock-handle-w) / -2);
    padding: 0;
    background: var(--os-btn-face);
    border: 1px solid var(--os-outline);
    border-radius: 3px;
    box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px -1px 0 var(--os-lo);
    cursor: pointer;
  }

  /* bigger invisible hit area around the slim bar; it never reaches into the bottom --dock-mac-edge */
  html[data-window="expanded"].dock-ready .dock-handle::before {
    content: "";
    position: absolute;
    inset: -10px -14px -2px;
  }

  html[data-window="expanded"].dock-ready .dock-handle:hover,
  html[data-window="expanded"].dock-ready .dock-handle[aria-expanded="true"] {
    background: var(--os-face-pressed);
  }

  html[data-window="expanded"].dock-ready .dock-handle:focus-visible {
    outline: 2px solid var(--os-focus);
    outline-offset: 3px;
  }
}

/* Touch screens: a 44px tall tap area for the handle */
@media (min-width: 43.8125rem) and (pointer: coarse) {
  html[data-window="expanded"].dock-ready .dock-handle::before { inset: -36px -20px -2px; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-window="expanded"][data-dock="autohide"] .os-dock { transition: none; }
}
