/*
 * PBK M1.03A — native editorial primitives and actions.
 *
 * This exact file is loaded after content-base.css on the front end and in the
 * block editor. It styles 20 native blocks without introducing a second color
 * palette or overriding colors explicitly selected by an editor.
 */

:where(.pbk-content, .editor-styles-wrapper) {
  --pbk-block-action-soft: var(--wp--preset--color--action-soft, Canvas);
  --pbk-block-on-action: var(--wp--preset--color--on-action, Canvas);
  --pbk-block-on-dark: var(--wp--preset--color--on-dark, Canvas);
}

/* Paragraph, heading, list and list item. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-paragraph,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-heading,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-list,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-list-item {
  max-inline-size: 100%;
}

:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface):not(.has-text-color) {
  color: var(--pbk-block-on-dark);
}

:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) :where(
  .wp-block-heading,
  .wp-block-paragraph,
  .wp-block-list,
  .wp-block-list-item,
  li
) {
  color: inherit;
}

:where(.pbk-content, .editor-styles-wrapper) :where(p.has-drop-cap)::first-letter {
  float: inline-start;
  margin-block-start: 0.1em;
  margin-inline-end: 0.15em;
  color: var(--pbk-content-action);
  font-size: 3.5em;
  font-weight: 600;
  line-height: 0.8;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-list {
  padding-inline-start: var(--wp--preset--spacing--lg, 1.5rem);
}

:where(.pbk-content, .editor-styles-wrapper) :where(.wp-block-list-item, .wp-block-list > li) {
  padding-inline-start: var(--wp--preset--spacing--2-xs, 0.25rem);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-list-item::marker,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-list > li::marker {
  color: currentColor;
  font-weight: 600;
}

/* Quote and pullquote. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-quote {
  margin-inline: 0;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-quote.is-style-plain {
  border-inline-start: 0;
  padding-inline-start: 0;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-pullquote {
  margin-block: var(--wp--preset--spacing--2-xl, 3rem);
  border-block: 1px solid var(--pbk-content-border);
  padding-block: var(--wp--preset--spacing--xl, 2rem);
  padding-inline: var(--wp--preset--spacing--md, 1rem);
  text-align: center;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-pullquote blockquote {
  max-inline-size: 42rem;
  margin: 0 auto;
  border: 0;
  padding: 0;
  font-size: var(--wp--preset--font-size--heading-medium, 1.5rem);
  line-height: 1.5;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-pullquote cite {
  margin-block-start: var(--wp--preset--spacing--md, 1rem);
}

/* Code, preformatted text and verse. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-code {
  border: 1px solid var(--pbk-content-dark);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-code code {
  white-space: pre;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-preformatted {
  border: 1px solid var(--pbk-content-border);
  background: var(--pbk-content-surface-strong);
  color: var(--pbk-content-text-strong);
  white-space: pre-wrap;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-verse {
  border-inline-start: 0.25rem solid var(--pbk-content-action);
  border-radius: 0.25rem;
  background: var(--pbk-content-surface);
  color: var(--pbk-content-text-strong);
  white-space: pre-wrap;
}

/* Table: Core owns the markup and editor controls; PBK supplies the frame. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table {
  max-inline-size: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table table {
  inline-size: 100%;
  margin-block: 0;
  border: 1px solid var(--pbk-content-border);
  border-radius: var(--pbk-content-radius-frame);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table thead,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table tfoot {
  border: 0;
  color: inherit;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table th,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table td {
  border: 0;
  border-inline-end: 1px solid var(--pbk-content-border);
  border-block-end: 1px solid var(--pbk-content-border);
  background-clip: padding-box;
  color: inherit;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table tr > :last-child {
  border-inline-end: 0;
}

:where(.pbk-content, .editor-styles-wrapper)
  .wp-block-table > table > :last-child > tr:last-child > * {
  border-block-end: 0;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table thead th,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table tfoot th,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table tfoot td {
  color: inherit;
  font-weight: 600;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes {
  border: 0;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
  background-color: var(--pbk-content-surface-strong);
}

:where(.pbk-content, .editor-styles-wrapper)
  .wp-block-table.is-style-stripes table.has-background tbody tr:nth-child(odd) {
  background-color: color-mix(in srgb, currentColor 8%, transparent);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes td,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes th {
  border-color: var(--pbk-content-border);
}

/* Details. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-details {
  border-block: 1px solid var(--pbk-content-border);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-details > summary {
  display: flex;
  min-block-size: 2.75rem;
  align-items: center;
  gap: var(--wp--preset--spacing--sm, 0.75rem);
  margin: 0;
  padding-block: var(--wp--preset--spacing--md, 1rem);
  color: inherit;
  font-size: var(--wp--preset--font-size--heading-small, 1.25rem);
  font-weight: 600;
  line-height: 1.5;
  list-style: none;
}

/* Core applies the selected preset class to the Details root. */
:where(.pbk-content, .editor-styles-wrapper) :where(
  .wp-block-details.has-small-font-size,
  .wp-block-details.has-base-font-size,
  .wp-block-details.has-lead-font-size,
  .wp-block-details.has-heading-small-font-size,
  .wp-block-details.has-heading-medium-font-size,
  .wp-block-details.has-heading-large-font-size,
  .wp-block-details.has-heading-x-large-font-size,
  .wp-block-details.has-display-font-size
) > summary {
  font-size: inherit;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-details > summary::-webkit-details-marker {
  display: none;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-details > summary::marker {
  color: currentColor;
  content: "";
}

/* Lucide ChevronRight, rendered as a mask so it always follows currentColor. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-details > summary::before {
  content: "";
  display: block;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  flex: 0 0 1.25rem;
  background-color: currentColor;
  -webkit-mask: url("../icons/lucide-chevron-right.svg") center / contain no-repeat;
  mask: url("../icons/lucide-chevron-right.svg") center / contain no-repeat;
  transform: rotate(0deg);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-details[open] > summary::before {
  transform: rotate(90deg);
}

[dir="rtl"] :where(.pbk-content, .editor-styles-wrapper) .wp-block-details:not([open]) > summary::before {
  transform: rotate(180deg);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-details > :last-child {
  margin-block-end: 0;
}

@media (prefers-reduced-motion: no-preference) {
  :where(.pbk-content, .editor-styles-wrapper) .wp-block-details > summary::before {
    transition: transform 160ms ease;
  }
}

/* Footnotes. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-footnotes {
  margin-block: var(--wp--preset--spacing--2-xl, 3rem) 0;
  border-block-start: 1px solid var(--pbk-content-border);
  padding-block-start: var(--wp--preset--spacing--lg, 1.5rem);
  color: var(--pbk-content-text-muted);
  font-size: var(--wp--preset--font-size--small, 0.875rem);
  line-height: 1.6;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-footnotes li:target {
  border-radius: 0.25rem;
  background: var(--pbk-block-action-soft);
  color: var(--pbk-content-text-strong);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-footnotes .fn {
  scroll-margin-block-start: var(--wp--preset--spacing--3-xl, 4rem);
}

/* Classic/freeform fallback. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-freeform,
:where(.pbk-content, .editor-styles-wrapper) .block-library-rich-text__tinymce {
  max-inline-size: 100%;
  color: var(--pbk-content-text);
  font: inherit;
  line-height: inherit;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-freeform :where(img, table, iframe),
:where(.pbk-content, .editor-styles-wrapper) .block-library-rich-text__tinymce :where(img, table, iframe) {
  max-inline-size: 100%;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-freeform table,
:where(.pbk-content, .editor-styles-wrapper) .block-library-rich-text__tinymce table {
  display: block;
  overflow-x: auto;
}

/* Math and unsupported/missing blocks. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-math,
:where(.pbk-content, .editor-styles-wrapper) math.wp-block-math {
  display: block;
  max-inline-size: 100%;
  overflow-x: auto;
  margin-block: var(--wp--preset--spacing--xl, 2rem);
  border: 1px solid var(--pbk-content-border);
  border-radius: 0.5rem;
  background: var(--pbk-content-surface);
  padding: var(--wp--preset--spacing--md, 1rem);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-missing {
  margin-block: var(--wp--preset--spacing--xl, 2rem);
  border: 2px dashed var(--pbk-content-danger);
  border-radius: 0.5rem;
  background: var(--pbk-content-surface);
  color: var(--pbk-content-text-strong);
  padding: var(--wp--preset--spacing--lg, 1.5rem);
}

/* Buttons and button groups. */
:where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wp--preset--spacing--md, 1rem);
  margin-block: var(--wp--preset--spacing--lg, 1.5rem);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons.is-vertical {
  flex-direction: column;
  align-items: flex-start;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons.is-content-justification-center {
  justify-content: center;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons.is-content-justification-right {
  justify-content: flex-end;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons.is-content-justification-space-between {
  justify-content: space-between;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button {
  max-inline-size: 100%;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link {
  box-sizing: border-box;
  display: inline-flex;
  min-block-size: 2.75rem;
  max-inline-size: 100%;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 0.375rem;
  padding: 0.625rem 1.25rem;
  font-family: inherit;
  font-size: var(--wp--preset--font-size--base, 1rem);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link:not(.has-background) {
  border-color: var(--pbk-content-action);
  background: var(--pbk-content-action);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link:not(.has-text-color),
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link:not(.has-text-color):visited {
  color: var(--pbk-block-on-action);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button:not(.is-disabled):not(.is-style-outline) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):hover,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button:not(.is-disabled):not(.is-style-outline) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):active {
  border-color: var(--pbk-content-action-hover);
  background: var(--pbk-content-action-hover);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background),
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link.is-style-outline:not(.has-background) {
  border-color: var(--pbk-content-action);
  background: transparent;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color),
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color):visited,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link.is-style-outline:not(.has-text-color),
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link.is-style-outline:not(.has-text-color):visited {
  color: var(--pbk-content-action);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-style-outline:not(.is-disabled) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):hover,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-style-outline:not(.is-disabled) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):active,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link.is-style-outline:not(.has-background):not([aria-disabled="true"]):hover,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link.is-style-outline:not(.has-background):not([aria-disabled="true"]):active {
  border-color: var(--pbk-content-action-hover);
  background: var(--pbk-block-action-soft);
  color: var(--pbk-content-action-hover);
}

:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background) {
  border-color: var(--pbk-block-on-dark);
}

:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color),
:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color):visited {
  color: var(--pbk-block-on-dark);
}

:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) .wp-block-button.is-style-outline:not(.is-disabled) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):hover,
:where(.pbk-content, .editor-styles-wrapper) :where(.has-dark-background-color, .pbk-stylebook-dark-surface) .wp-block-button.is-style-outline:not(.is-disabled) > .wp-block-button__link:not(.has-background):not([aria-disabled="true"]):active {
  border-color: var(--pbk-block-on-dark);
  background: var(--pbk-block-on-dark);
  color: var(--pbk-content-dark);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link:focus-visible {
  outline: 3px solid var(--pbk-content-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--pbk-content-canvas);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-button.is-disabled > .wp-block-button__link,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link[aria-disabled="true"],
:where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* More, next page and separator. */
:where(.pbk-content, .editor-styles-wrapper) .more-link {
  display: inline-flex;
  min-block-size: 2.75rem;
  align-items: center;
  color: var(--pbk-content-action);
  font-weight: 600;
  text-underline-offset: 0.2em;
}

:where(.pbk-content, .editor-styles-wrapper) .more-link:hover {
  color: var(--pbk-content-action-hover);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-more,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-nextpage {
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--sm, 0.75rem);
  margin-block: var(--wp--preset--spacing--2-xl, 3rem);
  color: var(--pbk-content-text-muted);
  font-size: var(--wp--preset--font-size--small, 0.875rem);
  font-weight: 600;
  text-align: center;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-more::before,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-more::after,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-nextpage::before,
:where(.pbk-content, .editor-styles-wrapper) .wp-block-nextpage::after {
  content: "";
  flex: 1 1 auto;
  border-block-start: 1px dashed var(--pbk-content-border);
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-more input {
  width: auto;
  min-block-size: 0;
  border: 0;
  background: var(--pbk-content-canvas);
  color: inherit;
  padding: 0;
  font: inherit;
  text-align: center;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-separator:not(.is-style-dots) {
  width: min(100%, 48rem);
  height: 0;
  margin-inline: auto;
  border: 0;
  border-block-start: 1px solid var(--pbk-content-border);
  opacity: 1;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-separator.is-style-wide {
  width: 100%;
}

:where(.pbk-content, .editor-styles-wrapper) .wp-block-separator.is-style-dots {
  height: auto;
  border: 0;
  color: var(--pbk-content-text-muted);
  font-size: var(--wp--preset--font-size--heading-medium, 1.5rem);
  line-height: 1;
  opacity: 1;
}

@media (max-width: 30rem) {
  :where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons:not(.is-content-justification-center):not(.is-content-justification-right) .wp-block-button {
    flex: 1 1 100%;
    inline-size: 100%;
  }

  :where(.pbk-content, .editor-styles-wrapper) .wp-block-buttons:not(.is-content-justification-center):not(.is-content-justification-right) .wp-block-button__link {
    inline-size: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(.pbk-content, .editor-styles-wrapper) .wp-block-button__link {
    transition-duration: 0.01ms;
  }
}
