/* Keep focus marks close to their controls, including in clipped toolbars. */
:focus-visible {
  outline-offset: -2px !important;
}

/* Leave room around native controls whose painted area can be very small. */
:is(input[type=checkbox], input[type=radio], input[type=range]):focus-visible {
  outline-offset: 1px !important;
}

/* Filled controls need a mark that contrasts with their own surface. */
:is(.primary-btn, .btn-primary, .learn-tutor-launcher):focus-visible {
  outline-color: currentColor !important;
}

/* Preserve the focus target for navigation and announcements without
   painting a frame around a block of static content. */
:is(main, h1, h2, h3, h4, h5, h6):where([tabindex="-1"]:not([role])):focus,
:is(#communityFeed, #content, #creditTopup, #billingPackages, #billingLedger)[tabindex="-1"]:focus {
  outline: none;
}

/* Text actions use an underline that stays clear of neighbouring controls. */
:is(.learn-text-button, .text-link):focus-visible,
:where(p, dd, figcaption) > a[href]:not([class]):focus-visible {
  outline: none;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* These visible wrappers represent a hidden choice, upload, or seek control. */
:is(.sample-voice-card, .onboarding-choice, .learn-option, .sc-template,
    .music-segment label, .tts-pace label, .pv-start-consent, .pd-wave):has(:focus-visible),
:is(.affiliate-destination-grid label, .support-file-field, .ab-file, .sv-upload,
    .sc-upload-label, .cover-style-card, .reply-file, .social-wave, .social-wave-wrap):focus-within,
:is(.occasion-choice-options, .wellness-goals, .wellness-duration, .community-category-picker,
    .sv-sample-kind, .pv-consent-language) input:focus-visible + span {
  outline-offset: -2px !important;
}

/* A field with its own visual wrapper needs just one mark. Limit the wrapper
   to the focused input so Tab still distinguishes its adjacent buttons. */
:is(.voice-search, .docs-search, .blog-search > div, .circle-search-form,
    .project-music-picker-search, .cp-caption-box, .library-search):focus-within {
  outline: none !important;
  box-shadow: none !important;
}

:is(.voice-search, .docs-search, .blog-search > div, .circle-search-form,
    .project-music-picker-search, .cp-caption-box, .library-search):has(:is(input, textarea):focus-visible) {
  outline: 2px solid var(--public-accent, var(--blog-accent, var(--ui-accent, currentColor))) !important;
  outline-offset: -2px !important;
}

:is(.voice-search, .docs-search, .blog-search > div, .circle-search-form,
    .project-music-picker-search, .cp-caption-box, .library-search) :is(input, textarea):focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.library-select:focus-within {
  box-shadow: none;
}

.podly-select-trigger:focus-visible,
.podly-select-list [role=option]:focus-visible {
  outline: 2px solid var(--ui-accent, currentColor);
  box-shadow: none;
}

/* Replace older field halos, including fields that explicitly cleared outlines. */
:is(.admin-shell, .admin-settings-page, .dialogue-form, .form-panel, .support-form)
    :is(input:not([type=checkbox], [type=radio], [type=range], [type=file]), textarea, select):focus-visible:not(:where(.voice-search > input, .docs-search > input)) {
  outline-style: solid;
  outline-width: 2px;
  outline-color: var(--ui-accent, var(--admin-primary-hover, currentColor));
  box-shadow: none !important;
}

/* Keep native high contrast mode in charge of indicator colours. */
@media (forced-colors: active) {
  :is(.primary-btn, .btn-primary, .learn-tutor-launcher):focus-visible {
    outline-color: Highlight !important;
  }
}
