/* Canonical screen-control feedback. Layout modules own resting/selected
   states; this file owns hover paint so identical actions cannot drift apart.
   Inset outlines do not change hit targets or toolbar measurements. */
@media screen {
  :root {
    --control-neutral-hover: #f4f1e9;
    --control-neutral-edge: #80978c;
    --control-tool-hover: #dcecef;
    --control-tool-edge: #237985;
  }
  :root[data-appearance='dark'] {
    --control-neutral-hover: #30434b;
    --control-neutral-edge: #6a8a95;
    --control-tool-hover: #2b454d;
    --control-tool-edge: #78c6d0;
  }

  /* System bar actions share the language picker's neutral treatment.
     Obstacles is a toggle, and 3D keeps its deliberately prominent treatment. */
  body
    .app-bar
    :is(button, a.button):not(#cart-open, #preview-course):is(:hover, :focus-visible):not(
      :disabled
    ),
  body .language-picker:is(:hover, :focus-within),
  body #editor-more-panel > #export-trigger:is(:hover, :focus-visible):not(:disabled) {
    background: var(--control-neutral-hover) !important;
    border-color: transparent !important;
    box-shadow: inset 0 0 0 1px var(--control-neutral-edge) !important;
    color: var(--ink, #293b40) !important;
  }

  /* Neutral menu rows, dashboard actions, viewport and preview controls.
     Selected, primary and destructive roles retain their semantic colours. */
  body
    :is(
      .dashboard,
      .auth,
      .top,
      .popover,
      .cloud-dialog,
      dialog,
      .account-grid,
      .preview-bar,
      #editor-viewport
    )
    :is(button, a.button):not(
      .primary,
      .danger,
      .danger-action,
      .card,
      .active,
      [aria-pressed='true'],
      [aria-current='true'],
      #cart-open,
      #preview-course
    ):is(:hover, :focus-visible):not(:disabled) {
    background: var(--control-neutral-hover) !important;
    border-color: transparent !important;
    box-shadow: inset 0 0 0 1px var(--control-neutral-edge) !important;
  }

  /* Physical and auxiliary tools are peers: the same blue fill and outline. */
  body
    #course-cart
    :is(
      #obstacle-tools button,
      #cart-numbers,
      #cart-note,
      #judge-tool,
      #cart-delete,
      #cart-close
    ):is(:hover, :focus-visible):not(:disabled),
  body #construction-tools .course-tools .tool:is(:hover, :focus-visible):not(:disabled),
  body #drawing-choice .drawing-choices button:is(:hover, :focus-visible):not(:disabled),
  body .app-bar #cart-open:is(:hover, :focus-visible):not(:disabled) {
    background: var(--control-tool-hover) !important;
    border-color: transparent !important;
    box-shadow: inset 0 0 0 1px var(--control-tool-edge) !important;
  }

  /* The grip manipulates the panel, not the course. Keep its neutral paint
     and the separate keyboard focus outline for accessible navigation. */
  body #course-cart #cart-drag:is(:hover, :focus-visible) {
    background: transparent !important;
    box-shadow: none !important;
    cursor: grab;
  }
}

/* A touch browser can retain :hover after a tap. History has no toggle state. */
@media screen and (hover: none) {
  body .app-bar :is(#undo, #redo):hover:not(:active):not(:focus-visible) {
    background: transparent !important;
    box-shadow: none !important;
  }
}
