/* ValleyFold controls, loaded after app.css.
 * Source: valleyfold-core/parts/component/button/button.css and the child
 * theme's brand.css. Compact desktop sizing belongs to the product; canonical
 * color roles, 600 weight, 1.2 line height and 160ms easing belong to controls.
 * Filled actions deliberately keep the tested blue/white pair in both themes.
 */
:root { --vf-control-fast: 160ms; --vf-control-focus-offset: 2px; }

.btn {
  font-weight: 600;
  line-height: 1.2;
  transition: background-color var(--vf-control-fast) var(--ease),
    border-color var(--vf-control-fast) var(--ease), color var(--vf-control-fast) var(--ease);
}
.btn-p, .btn-s {
  background: var(--btn-p-from);
  color: #fff;
  border-color: var(--btn-p-from);
  box-shadow: none;
  filter: none;
}
.btn-p:hover:not(:disabled):not([aria-disabled="true"]),
.btn-s:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--btn-p-to);
  border-color: var(--btn-p-to);
  color: #fff;
  box-shadow: none;
  filter: none;
}
.btn-g { background: transparent; border-color: var(--line-2); color: var(--text1); }
.btn-g:hover:not(:disabled):not([aria-disabled="true"]):not(.on) {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-g.on, .btn-g.on:hover { background: var(--btn-p-from); border-color: var(--btn-p-from); color: #fff; }
.btn:active, .chip:active, .insp-chipbtn:active, .bg-mode-btn:active, .align-action:active { transform: none; }

/* Text commands follow Core's ghost variant; no layout or display changes. */
.insp-link, .lnk { color: var(--accent); text-underline-offset: 4px; }
.insp-link:hover:not(:disabled):not([aria-disabled="true"]),
.lnk:hover:not(:disabled):not([aria-disabled="true"]) { color: var(--accent); text-decoration: underline; }
.insp-link.insp-danger, .insp-link.insp-danger:hover { color: var(--red); }
.btn.settings-danger-button, .settings-danger .btn.settings-danger-button:hover,
.btn.danger, .btn.guide-delete, .btn.motion-delete { color: var(--red); }

/* Other button families share quiet borders and hover roles while retaining
 * their existing selected fills, grid layouts and sizing. */
.chip, .insp-chipbtn, .bg-mode-btn, .align-action, .tmpl-chip,
.color-mode button, .lp-act, .lp-del, .layer-icon, .layer-ord,
.color-eyedropper, .lp-asset-preview-btn, .lp-asset-folder-menu, .lp-asset-folder-toggle {
  transition: background-color var(--vf-control-fast) var(--ease),
    color var(--vf-control-fast) var(--ease), border-color var(--vf-control-fast) var(--ease);
}
.chip:not(.on), .insp-chipbtn:not(.on), .bg-mode-btn:not(.on), .align-action,
.tmpl-chip:not(.on) { background: transparent; border-color: var(--line-2); color: var(--text1); }
.chip:hover:not(.on):not(:disabled), .insp-chipbtn:hover:not(.on):not(:disabled),
.bg-mode-btn:hover:not(.on):not(:disabled), .align-action:hover:not(:disabled),
.tmpl-chip:hover:not(.on):not(:disabled) { background: var(--accent-08); border-color: var(--accent); color: var(--accent); }
.chip.insp-danger:hover:not(:disabled), .insp-chipbtn.insp-danger:hover:not(:disabled) { color: var(--red); border-color: var(--red); }

.lp-act, .lp-del, .layer-icon, .layer-ord, .color-eyedropper,
.lp-asset-preview-btn, .lp-asset-folder-menu, .lp-asset-folder-toggle, .mp .mc {
  min-width: 24px;
  min-height: 24px;
}
.lp-act, .layer-icon, .layer-ord { color: var(--text2); }
.lp-act:hover:not(:disabled), .layer-icon:hover:not(:disabled), .layer-ord:hover:not(:disabled),
.lp-asset-preview-btn:hover, .lp-asset-folder-menu:hover, .lp-asset-folder-toggle:hover {
  background: var(--accent-14);
  color: var(--accent);
}
.lp-asset-row:focus-within .lp-asset-preview-btn { display: inline-flex; align-items: center; justify-content: center; }

/* Flat tracks retain their original thumb travel. The expanded touch hit
 * regions below do not make a 44px-tall visible switch. */
.settings-switch, .tog { background: var(--line-2); box-shadow: none; }
.settings-switch.on, .tog.on { background: var(--btn-p-from); border-color: var(--btn-p-from); box-shadow: none; }
.settings-switch::after, .tog::after { box-shadow: none; transition: transform var(--vf-control-fast) var(--ease); }
.csw:hover { transform: none; }
.csw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* One state contract must outrank old per-family disabled declarations. Native
 * disabled remains the behavioral guard; aria-disabled needs the JS guard.
 * Keep pointer events so the not-allowed cursor and tooltip can be presented. */
button:disabled, button[aria-disabled="true"], .btn[aria-disabled="true"] {
  opacity: .55 !important;
  cursor: not-allowed !important;
  pointer-events: auto !important;
  transform: none !important;
  filter: none !important;
}
.btn-g:disabled:not(.on), .btn-g[aria-disabled="true"]:not(.on),
.chip:disabled:not(.on), .insp-chipbtn:disabled:not(.on), .bg-mode-btn:disabled:not(.on),
.align-action:disabled, .tmpl-chip:disabled:not(.on) {
  background: transparent; border-color: var(--line-2); color: var(--text1);
}
.btn-p:disabled, .btn-s:disabled, .btn-p[aria-disabled="true"], .btn-s[aria-disabled="true"] {
  background: var(--btn-p-from); border-color: var(--btn-p-from); color: #fff; box-shadow: none;
}

/* Canonical 3px focus weight with a compact 2px offset. Insets on clipped
 * scrolling rows keep the full ring visible without increasing their boxes. */
button:focus-visible, select:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible, [role="button"]:focus-visible,
[role="treeitem"]:focus-visible, .settings-nav button:focus-visible,
.settings-switch:focus-visible, .align-action:focus-visible {
  outline: 3px solid var(--accent) !important;
  outline-offset: var(--vf-control-focus-offset) !important;
  box-shadow: none;
}
.lp-layer:focus-visible, .lp-slide:focus-visible, .menu-item:focus-visible,
.cmdk-row:focus-visible, .motion-step-block:focus-visible,
.settings-nav button:focus-visible { --vf-control-focus-offset: -3px; }
.settings-file-action:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Busy appearance is independent of whether an operation remains cancellable.
 * Existing progress text supplies its accessible status; no generated labels. */
button[aria-busy="true"], .btn[aria-busy="true"] { cursor: progress; border-style: dashed; }
button[aria-busy="true"] .lf-editor-icon, .btn[aria-busy="true"] .lf-editor-icon { opacity: .7; }

@media (max-width: 1023px), (pointer: coarse) {
  button:not(.motion-step-block), .btn, .btn-sm, .tb-tool, .tb-tool.tb-insert, .tb-tool-label,
  .dsw-manage, .sheet-close, .color-mode button, .color-preset,
  .stage-pill, .zb-btn, .zb-pct, .chip, .insp-chipbtn, .bg-mode-btn, .tmpl-chip,
  .color-trigger, .insp-sw, .csw, .lp-tab, .insp-link, .color-eyedropper,
  .lp-asset-folder-toggle, .lp-asset-folder-menu, .lp-asset-preview-btn,
  .layer-icon, .layer-ord, .mp .mc, .anchor-cell, .align-action {
    min-width: 44px;
    min-height: 44px;
  }
  .tb-tool, .tb-tool.tb-insert, .tb-tool-label, .dsw-manage,
  .lp-asset-folder-toggle, .lp-asset-folder-menu, .lp-asset-preview-btn { height: 44px; }
  .btn, .btn-sm { white-space: normal; }
  .lp-asset-folder-menu { opacity: 1; }
  .lp-asset-preview-btn { display: inline-flex; align-items: center; justify-content: center; }
  .lp-layer { display: grid; grid-template-columns: 44px 20px minmax(0, 1fr); gap: 4px; flex-shrink: 0; }
  .lp-layer .lp-name { min-width: 0; }
  .lp-layer .lp-acts { display: flex; grid-column: 1 / -1; justify-content: flex-end; flex-wrap: wrap; gap: 4px; margin-left: 0; }
  .lp-layer .lp-act { min-width: 44px; min-height: 44px; }
  .lp-layer > span.lp-act[aria-hidden="true"] { min-height: 0; }
  .layer-order, .layer-actions, .align-row, .sel-tools { flex-wrap: wrap; }
  .set-actions { grid-template-columns: repeat(2, minmax(44px, 1fr)); }
  .set-actions .btn { min-width: 44px; }
  .anchor-grid, .inspector.mobile-open .anchor-grid, .inspector.sheet-open .anchor-grid { width: 150px; height: 150px; flex: 0 0 150px; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 4px; padding: 4px; }
  .color-presets { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .guide-row { grid-template-columns: 44px minmax(0, 1fr) 78px 44px 44px; }
  .guide-axis, .guide-row .guide-delete { width: 44px; min-width: 44px; height: 44px; }
  .settings-switch, .tog, .surface-modal .settings-switch, .dmodal .settings-switch {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex-basis: 44px;
    padding: 0; border: 0; background: transparent; box-shadow: none;
  }
  .settings-switch::before, .tog::before, .surface-modal .settings-switch::before, .dmodal .settings-switch::before {
    content: ''; position: absolute; top: 10px; left: 0; width: 44px; height: 24px;
    border: 1px solid var(--line-3); border-radius: var(--r-pill); background: var(--line-2);
  }
  .settings-switch.on::before, .tog.on::before,
  .surface-modal .settings-switch.on::before, .dmodal .settings-switch.on::before {
    background: var(--btn-p-from); border-color: var(--btn-p-from); box-shadow: none;
  }
  .settings-switch::after, .tog::after, .surface-modal .settings-switch::after, .dmodal .settings-switch::after {
    width: 18px; height: 18px; top: 13px; left: 3px;
  }
  .settings-switch.on::after, .tog.on::after { transform: translateX(20px); }
  /* A timeline block's width represents time; inflating short blocks would
   * overlap the next step. Its companion step list supplies the full target. */
  .motion-track-row, .motion-track-lane { min-height: 54px; }
  .motion-step-block { min-height: 44px; }
}
@media (max-width: 560px) {
  .guide-row { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .guide-row > input[type="text"] { grid-column: 2 / -1; }
  .guide-row .guide-pos-field { grid-column: 1 / 3; }
  .guide-row .guide-delete { grid-column: 3; }
  .guide-row > .btn:not(.guide-delete) { grid-column: 3; grid-row: 2; }
}
@media (min-width: 1024px) and (pointer: coarse) {
  .studio-stage-footer { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  button, .btn, button::before, button::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .btn, .chip, .insp-chipbtn, .bg-mode-btn, .align-action, .tmpl-chip,
  .tb-tool, button.lp-act, .lp-del, .layer-icon, .layer-ord { border: 1px solid ButtonText; }
  .btn-p, .btn-s, .btn-g.on, .chip.on, .insp-chipbtn.on, .bg-mode-btn.on,
  .tmpl-chip.on, .tb-tool.active {
    /* Native button colors keep Chromium's text backplates readable. */
    background: ButtonFace !important; color: ButtonText !important; border-color: ButtonText !important;
  }
  .btn-g.on, .chip.on, .insp-chipbtn.on, .bg-mode-btn.on, .tmpl-chip.on, .tb-tool.active {
    outline: 2px solid ButtonText; outline-offset: -4px;
  }
  button:disabled, button[aria-disabled="true"] { color: GrayText !important; border-color: GrayText !important; }
  :focus-visible { outline-color: Highlight !important; }
  .settings-switch::after, .tog::after { background: ButtonText; }
  .settings-switch.on::after, .tog.on::after { background: Highlight; }
  /* Color choices remain actual image/content swatches, not UI state colors. */
  .csw, .insp-sw, .color-preset, .color-trigger-preview { forced-color-adjust: none; }
}

/* Inline icon geometry is scoped to product chrome, never artwork/export. */
.lf-editor-icon { display: inline-block; flex: 0 0 auto; vertical-align: -3px; pointer-events: none; }
button > .lf-editor-icon, .menu-item > .lf-editor-icon { margin-inline-end: 3px; }
button > .lf-editor-icon:only-child { margin: 0; }
.lp-glyph, .insp-chip, .cmdk-icon, .layer-type { display: inline-flex; align-items: center; justify-content: center; }
.align-action-icon .lf-editor-icon { width: 20px; height: 20px; fill: none; stroke-width: 2.25; }
.insp-lock { min-width: 24px; min-height: 24px; }
@media (max-width: 1023px), (pointer: coarse) { .insp-lock { min-width: 44px; min-height: 44px; } }

.btn, .insp-chipbtn, .menu-item { column-gap: 6px; }
@media (max-width: 1023px) {
  .legacy-workflow-toggle::before { content: none; }
  .legacy-workflow-toggle > span { display: none; }
  .legacy-workflow-toggle > .lf-editor-icon { width: 20px; height: 20px; margin: 0; }
}
.insp-details summary::before, .details-lite summary::before, .insp-scope-toggle::after {
  content: ''; display: inline-block; width: 16px; height: 16px; background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m9%204%208%208-8%208%22/%3E%3C/svg%3E") center / contain no-repeat;
  vertical-align: -3px;
}
.insp-details[open] summary::before { content: ''; transform: rotate(90deg); }

@media (max-width: 1023px), (pointer: coarse) {
  .artboard-row, .layer-row { flex-wrap: wrap; }
  .artboard-row .ab-acts, .layer-row .layer-order { flex-basis: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
  .artboard-row .ab-meta { white-space: normal; overflow-wrap: anywhere; }
}
@media (forced-colors: active) {
  .insp-details summary::before, .details-lite summary::before, .insp-scope-toggle::after {
    background: ButtonText; forced-color-adjust: none;
  }
}

.details-lite[open] summary::before { content: ""; transform: rotate(90deg); }
