/**
 * Low-specificity content safety layer.
 * Generic form controls and plugin-owned component classes are intentionally
 * not restyled by this file.
 */
:where(.fpsj-theme) {
  --fpsj-content-inline: min(820px, calc(100vw - 32px));
  --fpsj-wide-inline: min(1280px, calc(100vw - 32px));
}

:where(.fpsj-theme .wp-site-blocks) {
  min-height: 100vh;
  min-width: 0;
}

:where(.fpsj-theme .wp-block-post-content),
:where(.fpsj-theme .wp-block-post-content > *),
:where(.fpsj-theme .wp-block-html),
:where(.fpsj-theme .wp-block-group) {
  min-width: 0;
}

:where(.fpsj-theme .wp-block-post-content) {
  overflow-wrap: anywhere;
}

:where(.fpsj-theme .wp-block-post-content img),
:where(.fpsj-theme .wp-block-post-content video),
:where(.fpsj-theme .wp-block-post-content iframe),
:where(.fpsj-theme .wp-block-post-content svg) {
  max-width: 100%;
}

:where(.fpsj-theme .wp-block-post-content img),
:where(.fpsj-theme .wp-block-post-content video) {
  height: auto;
}

:where(.fpsj-theme .wp-block-post-content .wp-block-table) {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/*
 * Custom HTML tables do not receive the core/table figure wrapper. Modern
 * browsers can make the existing Custom HTML block the local scroll owner
 * without rewriting stored post markup.
 */
@supports selector(:has(*)) {
  :where(.fpsj-theme .wp-block-post-content .wp-block-html:has(> table)) {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
}

/*
 * Progressive fallback for browsers without :has(). The table itself becomes
 * the local scroll box; post content and database HTML remain untouched.
 */
@supports not selector(:has(*)) {
  :where(.fpsj-theme .wp-block-post-content .wp-block-html > table) {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
}

:where(.fpsj-theme .wp-block-post-content pre),
:where(.fpsj-theme .wp-block-post-content code) {
  overflow-wrap: normal;
  word-break: normal;
}

:where(.fpsj-theme .wp-block-post-content pre) {
  max-width: 100%;
  overflow-x: auto;
}

:where(.fpsj-theme .fpsj-shell),
:where(.fpsj-theme .fpsj-content-frame) {
  min-width: 0;
}

:where(.fpsj-theme .fpsj-layout-app .fpsj-content-frame),
:where(.fpsj-theme.fpsj-layout-app .fpsj-content-frame),
:where(.fpsj-theme.fpsj-layout-wide .fpsj-content-frame) {
  max-width: var(--fpsj-wide-inline);
}

:where(.fpsj-theme.fpsj-layout-app .wp-block-post-content),
:where(.fpsj-theme.fpsj-layout-wide .wp-block-post-content),
:where(.fpsj-theme.fpsj-layout-front .wp-block-post-content) {
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  :where(.fpsj-theme *) {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
