/* This file is after component CSS: actual focus origin governs the app's cues. */
:root[data-focus-intent='pointer'] :is(:focus, :focus-visible):not(
  .rk-editorial-field:not([data-readonly])[data-settings-editing],
  .rk-editorial-field:not([data-readonly]):has(:where(.rk-editorial-heading:read-write:focus, .rk-editorial-cta-inline:read-write:focus, .rk-editorial-rich-host .tiptap[contenteditable='true']:focus), > :where(.rk-editorial-media:focus-visible))
) {
  outline: none !important;
}

:root:not([data-focus-indicators='on']) :is([data-interaction='focus'], [interaction-state='focus']):not(:focus),
:root:not([data-focus-indicators='on']) rk-editable-title[interaction-state='focus'] .rk-title-control:not(:focus),
:root:not([data-focus-indicators='on']) rk-status[interaction-state='focus'] .rk-status-control:not(:focus) {
  outline: none !important;
}

/* The preview preference affects simulated Workshop focus states. Actual keyboard
   focus stays visible even when the preview is off. Saved-invoker restoration
   stays calm until a real keyboard navigation marks its destination. */
:root[data-focus-intent='keyboard'] :where(a[href], button, input, select, textarea, summary, [tabindex], [contenteditable='true']):focus[data-keyboard-focus]:not(:where(
  .rk-title-input,
  .rk-editorial-media,
  .rk-editorial-heading:read-write,
  .rk-editorial-cta-inline:read-write,
  .rk-editorial-rich-host .tiptap[contenteditable='true'],
  .rk-editorial-field:not([data-readonly])[data-settings-editing] .rk-editorial-settings :is(input.rk-editorial-target-input, textarea.rk-editorial-description-input):read-write
)) {
  outline: var(--focus-width, 2px) solid var(--focus-color, var(--ink)) !important;
  outline-offset: var(--focus-offset, 2px) !important;
}


/* The installed service may intentionally leave programmatic focus unmarked. */
:root[data-focus-intent='keyboard'] :where(a[href],button,input,select,textarea,summary,[tabindex],[contenteditable='true']):focus:not([data-keyboard-focus]):not(:where(
  .rk-title-input,
  .rk-editorial-media,
  .rk-editorial-heading:read-write,
  .rk-editorial-cta-inline:read-write,
  .rk-editorial-rich-host .tiptap[contenteditable='true'],
  .rk-editorial-field:not([data-readonly])[data-settings-editing] .rk-editorial-settings :is(input.rk-editorial-target-input,textarea.rk-editorial-description-input):read-write
)){outline:none!important;}

/* Native temporal subcontrols can keep host focus-within without host :focus. */
:root[data-focus-intent='keyboard'] input:is([type='date'],[type='time'],[type='month'],[type='week'],[type='datetime-local'])[data-keyboard-focus]:focus-within {
  outline: var(--focus-width, 2px) solid var(--focus-color, var(--ink)) !important;
  outline-offset: var(--focus-offset, 2px) !important;
}

/* Keep the authored editorial field frame as the sole cue for media-editor focus
   when a programmatic restore is keyboard-origin but not :focus-visible. */
@container rk-editorial (width >= 1100px) {
  :root[data-focus-intent='keyboard'] .rk-editorial-field:not([data-readonly]):has(> .rk-editorial-media:focus) {
    --rk-editorial-active-frame: inset 2px 0 var(--state-edit-ink), inset 0 2px var(--state-edit-ink), inset 0 -2px var(--state-edit-ink);
    --rk-editorial-active-context: var(--state-edit-surface);
    --rk-editorial-active-divider: var(--state-edit-ink);
    --rk-editorial-identity-color: var(--state-edit-ink);
    box-shadow: var(--rk-editorial-active-frame);
  }
}
@container rk-editorial (width < 1100px) {
  :root[data-focus-intent='keyboard'] .rk-editorial-field:not([data-readonly]):has(> .rk-editorial-media:focus) {
    outline: 1px solid color-mix(in srgb, var(--state-edit-ink) 30%, transparent);
  }
}

/* Authored editor frames replace a leaf outline, including when the focus
   destination was restored programmatically and is not :focus-visible. */
:root[data-focus-intent='keyboard'] .rk-editorial-field:not([data-readonly]):has(:where(
  .rk-editorial-heading:read-write:focus,
  .rk-editorial-cta-inline:read-write:focus,
  .rk-editorial-rich-host .tiptap[contenteditable='true']:focus
), > :where(.rk-editorial-media:focus)) :is(.rk-editorial-heading, .rk-editorial-cta-inline, .rk-editorial-rich-host .tiptap, .rk-editorial-media):focus {
  outline: none !important;
}

/* Opting in previews authored/simulated cues, including Workshop state fixtures. */
:root[data-focus-indicators='on'] :is(.rk-title-control, .rk-title-rename-control, .rk-status-control, .rk-open-control, .rk-button)[data-interaction='focus'],
:root[data-focus-indicators='on'] rk-editable-title[interaction-state='focus'] .rk-title-control,
:root[data-focus-indicators='on'] rk-status[interaction-state='focus'] .rk-status-control {
  outline: var(--focus-width, 2px) solid var(--focus-color, var(--ink)) !important;
  outline-offset: var(--focus-offset, 2px);
}

@media (forced-colors: active) {
  :root[data-focus-intent='keyboard'] input:is([type='date'],[type='time'],[type='month'],[type='week'],[type='datetime-local'])[data-keyboard-focus]:focus-within { outline-color: Highlight !important; }
  :root[data-focus-intent='keyboard'] :where(a[href], button, input, select, textarea, summary, [tabindex], [contenteditable='true']):focus[data-keyboard-focus]:not(:where(
    .rk-title-input,
    .rk-editorial-media,
    .rk-editorial-heading:read-write,
    .rk-editorial-cta-inline:read-write,
    .rk-editorial-rich-host .tiptap[contenteditable='true'],
    .rk-editorial-field:not([data-readonly])[data-settings-editing] .rk-editorial-settings :is(input.rk-editorial-target-input, textarea.rk-editorial-description-input):read-write
  )) {
    outline-color: Highlight !important;
  }
  :root[data-focus-intent='keyboard'] .rk-editorial-field:not([data-readonly]):has(:where(
    .rk-editorial-heading:read-write:focus,
    .rk-editorial-cta-inline:read-write:focus,
    .rk-editorial-rich-host .tiptap[contenteditable='true']:focus
  ), > :where(.rk-editorial-media:focus)),
  :root[data-focus-intent='keyboard'] .rk-editorial-field:not([data-readonly])[data-settings-editing]:has(.rk-editorial-settings :is(input.rk-editorial-target-input, textarea.rk-editorial-description-input):focus) {
    box-shadow: none !important;
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }
  :root[data-focus-intent='keyboard'] :is(.rk-list-row-body, .rk-card-header-body):has(.rk-title-input:focus) {
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }
  :root[data-focus-intent='keyboard'] rk-editable-title:not(.rk-list-row-body rk-editable-title, .rk-card-header-body rk-editable-title):has(.rk-title-input:focus) {
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }
}

/* The marker text uses a difference blend and a moving mask. A keyboard ring
   sits inside the button’s box and bypasses that mask without changing its ink. */
:root[data-focus-intent='keyboard'] .rk-editorial-index-marker:focus {
  mask-image: linear-gradient(#000 0 0) !important;
  -webkit-mask-image: linear-gradient(#000 0 0) !important;
  outline: 2px solid var(--neutral-light) !important;
  outline-offset: -2px !important;
}
@media (forced-colors: active) {
  :root[data-focus-intent='keyboard'] .rk-editorial-index-marker-item:has(.rk-editorial-index-marker:focus) {
    mix-blend-mode: normal;
  }
  :root[data-focus-intent='keyboard'] .rk-editorial-index-marker:focus {
    forced-color-adjust: auto;
    mask-image: none !important;
    -webkit-mask-image: none !important;
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }
}
