/* KP Equipment - views (T74, T74b): the Views button, its phone bar and its sheet. Meridian tokens only (01_tokens.css),
 * matching 81_parts_editor.css. Nothing here is drawn over the 3D model.
 *  - PC: the sheet is a drawer at the foot of the parts column, in the flow, so the part names above it stay readable
 *    and the list still scrolls (T74b; it used to float over the list and hide the names).
 *  - Phone, tablet upright: the button sits in a bar under the work area and the sheet rises over the parts list.
 * The two media queries are the same two 81_parts_editor.css uses. */
.vw-sheet[hidden], .vw-sheet [hidden], .vw-bar [hidden] { display: none !important; }

.vw-open-btn { flex: none; background: var(--surface); border-color: var(--ink-muted); color: var(--ink); font-weight: 600; }
.vw-open-btn[aria-expanded="true"] { background: var(--brand-soft); border-color: var(--brand); }
.vw-open-btn:disabled { opacity: .55; cursor: default; }

.vw-bar { display: none; flex: none; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.vw-bar-status { flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--ink-soft); font-size: 14px; line-height: 1.3; }
.vw-bar .vw-open-btn, .vw-bar .vw-btn { flex: none; width: auto; min-width: 96px; min-height: 48px; padding: 0 var(--sp-4); font-size: 16px; }

.vw-sheet { flex: none; order: 9; box-sizing: border-box; max-height: 56vh; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-4); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: var(--surface); color: var(--ink); border-top: 2px solid var(--line); font-family: var(--font); animation: vw-rise var(--dur-slow) var(--ease-out); }
.vw-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.vw-h2 { margin: 0; color: var(--ink); font-size: 18px; font-weight: 700; line-height: 1.2; }
.vw-status { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.4; }
.vw-alert { margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--danger-bg); color: var(--danger-fg); font-size: 14px; font-weight: 600; line-height: 1.4; }
.vw-acts { display: flex; flex-direction: column; gap: var(--sp-2); }
.vw-btn { box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: 48px; margin: 0; padding: var(--sp-2) var(--sp-4); border: 1px solid var(--ink-muted); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; line-height: 1.25; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.vw-btn:disabled { opacity: .55; cursor: default; }
.vw-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.vw-danger { color: var(--danger-fg); }
.vw-quiet { width: auto; min-width: 72px; border-color: transparent; background: transparent; color: var(--ink-soft); }
.vw-toggle { justify-content: space-between; text-align: left; }
.vw-toggle[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.vw-state { flex: none; min-width: 36px; padding: 2px var(--sp-2); border: 1px solid var(--ink-muted); border-radius: var(--r-pill); color: var(--ink); font-size: 13px; line-height: 1.3; text-align: center; }
.vw-ask { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-alt); }
.vw-ask-text { grid-column: 1 / -1; margin: 0; color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.35; }
.vw-btn:focus-visible, .vw-open-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media screen and (hover: hover) {
  .vw-btn:not(:disabled):hover { background: var(--surface-alt); }
  .vw-primary:not(:disabled):hover { background: var(--brand-hover); border-color: var(--brand-hover); }
  .vw-quiet:not(:disabled):hover { color: var(--ink); }
}
/* a PC with a mouse: the drawer's buttons are a little lower, so more of the parts list stays in sight above it.
 * A touch screen keeps the 48 px targets at every width. */
@media screen and (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .vw-sheet .vw-btn { min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 15px; }
}

/* FX-2: a PC or a wide tablet (1300 px and up). The sheet opens under its own button, as a side panel inside the model card.
 * The model moves over and stays whole, so the view being saved is still in sight and nothing is drawn over it. It used to
 * open at the foot of the parts column, about 900 px from the button. A browser that cannot tie one box to another (anchor
 * positioning) keeps that older place. The two fall-back numbers are only used if the model area is not there. */
@supports (anchor-name: --vw-stage) {
  @media screen and (min-width: 1300px) {
    .pe-model-panel .pe-hint-row { anchor-name: --vw-hint; } .pe-model-panel .pe-stage { anchor-name: --vw-stage; }
    .pe-work.vw-is-open .pe-model-panel .pe-hint-row, .pe-work.vw-is-open .pe-model-panel .pe-stage { margin-right: 340px; } .pe-work.vw-is-open .pe-list-panel { position: static; }
    .vw-sheet { position: absolute; z-index: 2; order: 0; top: anchor(--vw-hint top, 140px); bottom: anchor(--vw-stage bottom, 40px); left: anchor(--vw-stage right, calc(100% - 357px)); width: 340px; max-height: none; border: 0; border-left: 1px solid var(--line); border-radius: 0; box-shadow: none; }
  }
}

/* stacked (phone, tablet upright): the button sits in the bar under the work area; the sheet rises over the parts list
 * and the model keeps the top of the screen, smaller, so the pose being saved stays in sight.
 * T89c: the sheet is only as tall as its controls and sits at the foot of the list, with the same top edge, corners and
 * shadow as the More sheet (30_plan.css). It used to cover the whole list and leave an empty area under the buttons. */
@media screen and (max-width: 899px) {
  .vw-bar { display: flex; }
  .pe-work.vw-is-open { grid-template-rows: minmax(0, 45%) minmax(0, 1fr); }
  /* FX-2: the sheet is part of the list column here too. It used to lie over the list and hid Change model and Discard
   * draft at the end of it. The list above the sheet keeps at least one row and still scrolls, so both stay within reach. */
  .vw-sheet { position: relative; z-index: 5; order: 9; flex: 0 1 auto; min-height: 0; max-height: none; padding: var(--sp-3) var(--sp-3) var(--sp-4); border: 0; border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; box-shadow: var(--shadow-lg); }
  .pe-work.vw-is-open .pe-list-panel .pe-scroll { flex-shrink: 999; min-height: 88px; }
}
/* a phone on its side: model left, list right; no bar (height is short), the sheet covers the list column */
@media screen and (orientation: landscape) and (min-width: 560px) and (max-width: 1023px) and (max-height: 520px) {
  .vw-bar { display: none; }
  .pe-work.vw-is-open { grid-template-rows: minmax(0, 1fr); }
  .vw-sheet { position: absolute; z-index: 5; top: auto; right: 0; bottom: 0; left: 0; order: 0; max-height: 100%; padding: var(--sp-3) var(--sp-3) var(--sp-4); border: 0; border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; box-shadow: var(--shadow-lg); animation: none; }
}
@keyframes vw-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .vw-sheet { animation: none; } }
@media print { .vw-bar, .vw-sheet { display: none !important; } }
