/*
 * Global Personnel Studio — progressive application-interface states.
 * Existing Core markup, labels, values, permissions and event handlers stay intact.
 * No layout, typography, resting palette or data-dependent status is introduced.
 */

/* Includes public forms and the guest portal; third-party controls stay outside. */
.gp-app :is(
  .gp-btn,
  .gp-sidebar nav button,
  .gp-mobile-menu,
  .gp-tabs button,
  .gp-service-choice,
  .gp-queue-tile,
  .gp-stat-action,
  summary
) {
  transition-property: background-color, border-color, color, box-shadow, outline-color;
  transition-duration: var(--studio-motion-base, 220ms);
  transition-timing-function: var(--studio-motion-ease, cubic-bezier(.2, .8, .2, 1));
}

.gp-app :is(
  .gp-field input,
  .gp-field select,
  .gp-field textarea,
  .gp-check input,
  .gp-workspace-search input,
  .gp-table input,
  .gp-table select,
  .gp-table textarea
) {
  transition-property: border-color, box-shadow, outline-color;
  transition-duration: var(--studio-motion-fast, 140ms);
  transition-timing-function: var(--studio-motion-ease, cubic-bezier(.2, .8, .2, 1));
}

.gp-app :is(
  .gp-card,
  .gp-advanced-row,
  .gp-row,
  .gp-list > li,
  .gp-table tbody tr
) {
  transition-property: border-color, background-color, box-shadow;
  transition-duration: var(--studio-motion-base, 220ms);
  transition-timing-function: var(--studio-motion-ease, cubic-bezier(.2, .8, .2, 1));
}

/* Focus is independent of hover, including fields inside tables and the portal. */
.gp-app :is(
  a[href],
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]
):focus-visible {
  outline: 3px solid var(--gp-teal, #236c66);
  outline-offset: 3px;
  scroll-margin-top: calc(var(--studio-header-offset, 6rem) + 1rem);
  scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
}

/* Keep the ring inside scrollable tab strips instead of clipping it. */
.gp-app .gp-tabs button:focus-visible {
  outline-offset: -3px;
}

/* The existing sidebar has a dark surface; reuse Core's light focus accent. */
.gp-app .gp-workspace .gp-sidebar :is(button, a[href]):focus-visible {
  outline-color: #edb06b;
}

.gp-app .gp-workspace [id^="gp-entity-"]:focus {
  scroll-margin-top: calc(var(--studio-header-offset, 6rem) + 1rem);
  scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
}

/* Surface feedback does not translate a control away from the pointer. */
.gp-app :is(
  .gp-btn,
  .gp-stat-action
):hover {
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .gp-app :is(
    .gp-btn,
    .gp-mobile-menu,
    .gp-tabs button,
    .gp-service-choice,
    .gp-queue-tile,
    .gp-stat-action
  ):not(:disabled):hover {
    box-shadow: inset 0 -2px 0 currentColor;
  }

  .gp-app .gp-workspace :is(
    .gp-table tbody tr,
    .gp-advanced-row,
    .gp-row,
    .gp-list > li
  ):hover {
    background-color: var(--gp-soft, #eef4f0);
  }

  .gp-app .gp-workspace :is(.gp-queue-row, .gp-action-card):hover {
    border-color: var(--gp-teal, #236c66);
  }

  .gp-app summary:hover {
    text-decoration: underline;
    text-underline-offset: .2em;
  }
}

.gp-app :is(
  .gp-btn,
  .gp-mobile-menu,
  .gp-tabs button,
  .gp-service-choice,
  .gp-queue-tile,
  .gp-stat-action
):not(:disabled):active {
  transform: none;
  box-shadow: inset 0 0 0 2px currentColor;
  transition-duration: var(--studio-motion-fast, 140ms);
}

/* These selectors reflect states already maintained by Core, never text guesses. */
.gp-app .gp-workspace .gp-sidebar nav button[aria-current="page"] {
  box-shadow: inset 3px 0 0 var(--gp-teal, #236c66);
}

.gp-app .gp-workspace .gp-tabs button[aria-pressed="true"] {
  box-shadow: inset 0 -2px 0 var(--gp-teal, #236c66), 0 2px 8px #16302a0a;
}

.gp-app .gp-workspace .gp-queue-tile[aria-pressed="true"] {
  box-shadow: inset 0 -3px 0 var(--gp-teal, #236c66), 0 0 0 1px var(--gp-teal, #236c66);
}

.gp-app .gp-workspace .gp-selection {
  box-shadow: inset 3px 0 0 var(--gp-teal, #236c66);
}

.gp-app .gp-workspace :is(
  .gp-table tbody tr,
  .gp-advanced-row,
  .gp-row,
  .gp-list > li
):focus-within {
  background-color: var(--gp-soft, #eef4f0);
}

@supports selector(:has(*)) {
  .gp-app .gp-check:has(input:focus-visible) {
    outline: 1px solid var(--gp-teal, #236c66);
    outline-offset: 5px;
  }
}

/* Native details stay native: no interception, forced opening or hidden content. */
.gp-app .gp-workspace details > summary::marker {
  color: var(--gp-teal, #236c66);
}

.gp-app .gp-workspace details.gp-advanced-detail[open] > summary {
  box-shadow: inset 3px 0 0 var(--gp-teal, #236c66);
}

/* Keep real messages and content readable while existing controls are busy. */
.gp-app :is(
  .gp-alert,
  .gp-success,
  .gp-notice,
  .gp-freshness,
  .gp-save-status,
  .gp-empty
) {
  overflow-wrap: anywhere;
}

.gp-app :is(
  #gp-workspace-content,
  .gp-advanced-root
)[aria-busy="true"] button:disabled {
  cursor: progress;
}

/* Prevent identifiers, filenames and long names from escaping their own cells. */
.gp-app :is(
  .gp-card h2,
  .gp-card h3,
  .gp-card h4,
  .gp-card p,
  .gp-list strong,
  .gp-advanced-row strong,
  .gp-advanced-row small,
  .gp-field small,
  .gp-check > span,
  .gp-queue-tile span,
  .gp-table td,
  .gp-definition dd,
  .gp-advanced dd,
  .gp-guest-dialog h2
) {
  overflow-wrap: anywhere;
}

.gp-app .gp-workspace .gp-sidebar nav button > span:not(.gp-nav-count) {
  overflow-wrap: anywhere;
}

/* The system preference applies immediately, including after a preference change. */
@media (prefers-reduced-motion: reduce) {
  .gp-app,
  .gp-app *,
  .gp-app *::before,
  .gp-app *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  /* Preserve transforms that hide the skip link or position the RTL sidebar. */
  .gp-app :is(.gp-btn, .gp-stat-action):is(:hover, :active) {
    transform: none !important;
  }
}
