/* Frontend focus contract. Load after the component and readability styles.
   Modality is supplied by rentige-focus286.js; it never changes focus or intercepts key behavior.
   Reset only focus decoration, then add one small keyboard cue to real controls. */

.cfl-dashboard-module .cfl-v2-shell {
  --rentige-focus-ink: var(--cfl-ui-text, var(--cfl-v2-text, #242d28));
  --rentige-focus-field-border: var(--cfl-ui-border, var(--cfl-v2-line, #e5e9e2));
}
:is(.cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you) {
  --rentige-focus-ink: var(--rt-c-text, var(--cfl-cx-text, var(--cfl-account-text, #242d28)));
  --rentige-focus-field-border: var(--rt-c-line, var(--cfl-cx-line, var(--cfl-account-line, #e5e9e2)));
}
body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer {
  --rentige-focus-ink: var(--cfl-tour-text, #242d28);
}
/* These plugin dialogs are mounted directly in body, outside the app frame.
   Read the tokens of their actual surfaces rather than the staff shell. */
.cfl-handoff-dialog {
  --rentige-focus-ink: var(--cfl-v2-text, #172033);
  --rentige-focus-field-border: var(--cfl-v2-line, #dce4ee);
}
.cfl-location-change-dialog {
  --rentige-focus-ink: #172033;
  --rentige-focus-field-border: var(--cfl-location-line, var(--cfl-cx-line, #d8e1ec));
}
body.cfl-rental-theme-dark .cfl-location-change-dialog { --rentige-focus-ink: #f8fafc; }
.cfl-stab-handoff-overlay {
  --rentige-focus-ink: var(--cfl-stab-text, #152238);
  --rentige-focus-field-border: var(--cfl-stab-border, #d7e0eb);
}
/* This per-element restoration value must not leak a dialog's elevation into
   the inputs and buttons it contains. It changes no visual property by itself. */
:is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
) * { --rentige-resting-shadow: none; }

/* A click/tap may focus a text field with :focus-visible in the browser. The
   explicit modality guard also covers that case and subsequent scripted focus. */
html[data-rentige-input="pointer"] :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
) :focus,
html :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
) :focus:not(:focus-visible) {
  outline: none !important;
  box-shadow: var(--rentige-resting-shadow, none) !important;
}

/* Programmatic destinations are orientation/scroll targets, never giant rings.
   This includes main, body, dialog shells and tabindex=-1 panels in either mode. */
html body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account):focus,
html :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
):focus,
html :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
) :focus:not(:is(
  a[href], area[href], button, input, select, textarea, summary,
  [contenteditable="true"], [contenteditable=""],
  [role="button"], [role="link"], [role="tab"], [role="menuitem"],
  [role="menuitemcheckbox"], [role="menuitemradio"], [role="checkbox"],
  [role="radio"], [role="switch"], [role="option"], [role="combobox"],
  [role="listbox"], [role="slider"], [role="spinbutton"], [role="treeitem"],
  canvas[tabindex], audio[controls], video[controls]
)) {
  outline: none !important;
  box-shadow: var(--rentige-resting-shadow, none) !important;
}

/* Neutral field borders do not turn into a second focus indicator. Validation
   and selected-state borders are deliberately excluded from this reset. */
html :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay
) :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea):focus:not(
  [aria-invalid="true"], [aria-selected="true"], .is-invalid, .has-error, .error,
  .is-selected, .is-active, .woocommerce-invalid *, .is-invalid *, .has-error *,
  [data-validation-state="invalid"], [data-validation-state="invalid"] *
) {
  border-color: var(--rentige-focus-field-border, #e5e9e2) !important;
}

/* Legacy :focus-within rules must not draw a ring around an entire rental/card
   or the deposit wrapper when only one child control has received focus. */
html :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay
) :is(.cfl-deposit-value-control, .cfl-rental-list-row, .cfl-task-board-card, .cfl-extension-method-option):focus-within:not(
  .is-active, .is-selected, .is-overdue, .is-critical, [aria-invalid="true"], .has-error,
  :has(input:checked), :has([aria-invalid="true"])
) {
  border-color: var(--rentige-focus-field-border, #e5e9e2) !important;
  box-shadow: none !important;
}

/* Preserve resting elevation and state cues rather than mistaking them for
   focus halos. No selected/checked/error styles are otherwise rewritten here. */
.cfl-dashboard-module .cfl-v2-shell .cfl-queue-link186.is-active {
  --rentige-resting-shadow: inset 0 -3px 0 var(--rr-accent, var(--rentige-day-accent, var(--cfl-ui-primary)));
}
.cfl-dashboard-module .cfl-v2-shell .cfl-task-list-row285.is-overdue {
  --rentige-resting-shadow: inset 3px 0 0 var(--task-danger);
}
.cfl-dashboard-module .cfl-v2-shell .cfl-task-drawer > aside {
  --rentige-resting-shadow: -18px 0 50px rgba(2, 8, 23, .23);
}
.cfl-dashboard-module .cfl-v2-shell :is(.cfl-task-complete-dialog, .cfl-task-quick-dialog) > section {
  --rentige-resting-shadow: 0 24px 70px rgba(2, 8, 23, .3);
}
body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-tooltip {
  --rentige-resting-shadow: var(--cfl-tour-shadow);
}
.cfl-handoff-dialog .cfl-handoff-dialog-panel {
  --rentige-resting-shadow: 0 28px 90px rgba(0, 0, 0, .38);
}
.cfl-location-change-dialog .cfl-location-change-dialog__panel,
.cfl-stab-handoff-overlay .cfl-stab-handoff-dialog {
  --rentige-resting-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

/* Exactly one restrained keyboard cue, on the control itself. A no-JS browser
   keeps native :focus-visible behavior; pointer modality explicitly opts out. */
html:is([data-rentige-input="keyboard"], :not([data-rentige-input])) :is(
  .cfl-dashboard-module .cfl-v2-shell,
  .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
  .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
  body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
) :is(
  a[href], area[href], button, input:not([type="hidden"]), select, textarea, summary,
  [contenteditable="true"], [contenteditable=""],
  [role="button"], [role="link"], [role="tab"], [role="menuitem"],
  [role="menuitemcheckbox"], [role="menuitemradio"], [role="checkbox"],
  [role="radio"], [role="switch"], [role="option"], [role="combobox"],
  [role="listbox"], [role="slider"], [role="spinbutton"], [role="treeitem"],
  canvas[tabindex], audio[controls], video[controls]
):focus-visible:not(:disabled):not([aria-disabled="true"]) {
  outline: 2px solid var(--rentige-focus-ink, currentColor) !important;
  outline-offset: 2px !important;
  box-shadow: var(--rentige-resting-shadow, none) !important;
}

@media (forced-colors: active) {
  html:is([data-rentige-input="keyboard"], :not([data-rentige-input])) :is(
    .cfl-dashboard-module .cfl-v2-shell,
    .cfl-account-shell, .cfl-customer-portal, .cfl-customer-endpoint, .cfl-rental-thank-you,
    .cfl-handoff-dialog, .cfl-location-change-dialog, .cfl-stab-handoff-overlay,
    body:is(.cfl-rental-employee-portal, .cfl-rental-customer-account) .cfl-walkthrough-layer
  ) :focus-visible:is(
    a[href], area[href], button, input, select, textarea, summary,
    [contenteditable], [role="button"], [role="link"], [role="tab"],
    [role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"],
    [role="checkbox"], [role="radio"], [role="switch"], [role="option"],
    [role="combobox"], [role="listbox"], [role="slider"], [role="spinbutton"],
    [role="treeitem"], canvas[tabindex], audio[controls], video[controls]
  ) { outline-color: Highlight !important; }
}
