/* ReInk: from designer-preview/css/panel-collapse.css @ 827d893 (oldDesigner-redesign). Everything below this line is that file,
   unchanged. When the prototype changes it, carry the change across: docs/syncing.md. */
/*
	designer-preview/css/panel-collapse.css

	The collapsible side panel. Loaded after facelift.css. The panel starts closed.

	Close the panel with the tab on its right edge, or by clicking the rail icon that is
	already selected. The panel folds away to the 60px icon rail and the workspace grows into the
	space. Clicking any rail icon, or the tab again, opens it. js/panel-collapse.js sets
	these classes on <body>:

	  sm-panel-collapsed  the panel is closed: the aside is the icon rail only, and main, the zoom
	                      bar and the tab move left to meet it
	  sm-panel-clip       the aside's children keep their open 400px layout and the aside clips
	                      them, so the save bar and the rail keep their heights and the rail does
	                      not move (set while closed and while animating). The logo is in the top
	                      bar (css/topbar.css), so it stays put.
	  sm-panel-settled    fully closed: the hidden panel takes no height, no clicks and no focus
	  sm-panel-anim       the panel is opening or closing (200ms; none with reduced motion)
	  sm-panel-fit        set for one synchronous step while the engine refits the canvas (never painted)

	With the panel open none of these classes is set, so the open designer is exactly the
	facelift layout. The only addition is the tab (#panelCollapseHandle). At 700px and below, the
	designer stacks the panel under the canvas, so the panel does not collapse and there is no tab.
*/

:root {
  --sm-rail-w: 60px;                       /* .ui-tabs-vertical .ui-tabs-nav width in site.app.css */
  --sm-panel-speed: 200ms;                 /* keep in step with DURATION in js/panel-collapse.js */
  --sm-panel-ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ===== The collapse tab: attached to the panel's right edge, vertically centred ===== */
#panelCollapseHandle {
  position: fixed; z-index: 100; top: 50%; left: 400px;   /* aside width in site.app.css */
  display: flex; align-items: center; justify-content: center;
  box-sizing: border-box; width: 24px; height: 48px; margin: -24px 0 0 0; padding: 0;
  border: 1px solid var(--sm-divider); border-left: 0; border-radius: 0 var(--sm-r-md) var(--sm-r-md) 0;
  background-color: var(--sm-surface); color: var(--sm-ink-3);
  box-shadow: 4px 1px 6px -2px rgb(4 0 0 / 0.10);
  clip-path: inset(-12px -12px -12px 0);   /* the shadow never paints left of the panel edge (Firefox blurs wider) */
  cursor: pointer; -webkit-tap-highlight-color: transparent; }
#panelCollapseHandle svg { display: block; width: 16px; height: 16px; pointer-events: none; }
#panelCollapseHandle:hover { background-color: var(--sm-hover-solid); color: var(--sm-ink); }
#panelCollapseHandle:active { background-color: var(--sm-tile-hover); }
#panelCollapseHandle:focus { outline: none; }
#panelCollapseHandle:focus-visible { outline: 2px solid var(--sm-focus); outline-offset: -4px; }

@media (max-width: 700px) {
  #panelCollapseHandle { display: none; }
  /* the engine's tab panes are a fixed 400px (a 340px pane beside the 60px rail); on a phone they follow the sheet */
  .ui-tabs-vertical { width: 100%; }
  .ui-tabs-vertical .ui-tabs-panel { width: calc(100% - var(--sm-rail-w, 60px)); }
}

@media not all and (max-width: 700px) {   /* the exact complement of the script's narrow query, so no fractional width falls between */
  /* ===== Closed geometry ===== */
  body.sm-panel-collapsed aside { width: var(--sm-rail-w); }
  body.sm-panel-collapsed main { left: var(--sm-rail-w); }
  body.sm-panel-collapsed #floatingMenu { left: calc(var(--sm-rail-w) + 66px); }   /* same 66px from the edge as 466px - 400px */
  body.sm-panel-collapsed #panelCollapseHandle { left: var(--sm-rail-w); }
  body.sm-panel-collapsed #panelCollapseHandle svg { transform: scaleX(-1); }       /* chevron points out: "open" */

  /* Children keep the open layout (all border-box), so nothing reflows and the rail stays put.
     The aside clips them. A very short window can still scroll the rail, without a scrollbar inside 60px. */
  body.sm-panel-clip aside { overflow-x: hidden; scrollbar-width: none; }
  body.sm-panel-clip aside::-webkit-scrollbar { display: none; }
  body.sm-panel-clip aside > * { width: 400px; flex-shrink: 0; }

  /* Fully closed: the active panel stays laid out at full width (the engine can still measure it), but it takes no
     height, so the rail does not scroll for it. It cannot be seen, clicked or focused. */
  body.sm-panel-settled .ui-tabs-vertical .ui-tabs-panel { visibility: hidden; max-height: 0; overflow: hidden; }

  /* ===== Rail ===== */
  /* main's 1px border is the edge now; the rail's own divider would double it */
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav { box-shadow: none; }
  /* no rail item is highlighted while the panel is closed (the active tab is still the one that opens) */
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active .menuIcon::before { background-color: transparent; box-shadow: none; }
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active a { color: var(--sm-ink-3); }
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active .menuIcon { color: inherit; }
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active.ui-state-hover .menuIcon::before,
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active.ui-state-focus .menuIcon::before { background-color: var(--sm-hover); }
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active.ui-state-hover a,
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active.ui-state-focus a { color: var(--sm-ink-2); }

  /* ===== Save bar: the same buttons, icon-only, two to a row inside the rail's width ===== */
  /* The bar keeps its 65px height; Save + Add To Cart on the first row, Undo + Redo on the second (simple mode: one row). */
  body.sm-panel-collapsed #saveBar ul { display: grid; grid-template-columns: repeat(2, 28px); grid-auto-rows: 28px; gap: 1px 2px;
    justify-content: center; align-content: center; width: var(--sm-rail-w); height: 100%; margin: 0; }
  body.sm-panel-collapsed #saveBar ul li { width: auto; height: auto; }
  body.sm-panel-collapsed #saveBar ul li:nth-child(even) { display: none; }       /* the 2px dividers */
  body.sm-panel-collapsed #saveBar ul li button { display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; min-width: 0; margin: 0; padding: 0; font-size: 0; line-height: 0;
    border-image: var(--sm-bi-r6) 6 / 6px / 0 stretch; }                           /* label hidden; title + aria-label set by the script */
  body.sm-panel-collapsed #saveBar ul li button br { display: none; }
  body.sm-panel-collapsed #saveBar ul li button:focus-visible { border-image: var(--sm-bi-r6-focus) 6 / 6px / 0 stretch; }   /* ring inside: the rail clips anything outside */
  body.sm-panel-collapsed #saveBar ul li button .mui-btn__ripple-container { border-radius: var(--sm-r-sm); }
}

/* ===== Refit (one synchronous step after each open or close, never painted) ===== */
/* The engine sizes the ruler canvases and the canvas holder in px, and the auto-layout table cannot shrink below them,
   so when the panel opens the engine would measure the old, larger workspace. With a fixed layout the table takes the
   workspace's width, and with those px-sized boxes out of the flow its rows take the workspace's height (Firefox lets
   a zoomed canvas stretch the rows; Chromium does not). */
body.sm-panel-fit .rulerTable { table-layout: fixed; }
body.sm-panel-fit .rulerTable .canvas-container { position: absolute !important; }   /* fabric sets position: relative inline */
body.sm-panel-fit #canvdim { position: absolute; }
/* no scrollbars flashing in the workspace while it is narrower than the canvas laid out for it */
body.sm-panel-anim main { overflow: hidden; }

/* ===== Motion: only while opening or closing ===== */
@media not all and (max-width: 700px) {
  @media (prefers-reduced-motion: no-preference) {
    body.sm-panel-anim aside { transition: width var(--sm-panel-speed) var(--sm-panel-ease); }
    body.sm-panel-anim main,
    body.sm-panel-anim #floatingMenu,
    body.sm-panel-anim #panelCollapseHandle { transition: left var(--sm-panel-speed) var(--sm-panel-ease); }
  }
}

/* ===== Windows High Contrast / forced colours ===== */
@media (forced-colors: active) {
  #panelCollapseHandle { border: 1px solid ButtonText; border-left: 0; }
  #panelCollapseHandle:focus-visible { outline: 2px solid CanvasText; }
  body.sm-panel-collapsed #saveBar ul li button:focus-visible { outline: 2px solid CanvasText; outline-offset: -2px; }
  body.sm-panel-collapsed .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active .menuIcon::before { outline: none; }
}
