/**
 * @file
 * Restores rich-text (CKEditor 5) formatting stripped by Tailwind Preflight.
 *
 * Preflight ships inside dist/app-drupal/tokens.css and flattens typographic
 * markup site-wide:
 *
 *   fieldset,ol,ul{margin:0;padding:0}
 *   ol,ul{list-style:none}
 *   blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}
 *
 * Theme markup is unaffected because every element carries utility classes.
 * CKEditor 5, however, emits plain semantic HTML with no classes at all, so
 * authored bullets, numbering, indentation and paragraph spacing disappear
 * even though the <ul>/<ol>/<li>/<p> tags are present and correct in the
 * saved markup.
 *
 * The rules below re-apply browser defaults to unclassed list and paragraph
 * markup only, which in practice means CKEditor output. `:not([class])` keeps
 * every themed component out of scope, and the exception block at the end
 * re-neutralises the handful of navigation/design components that render bare
 * <ul>/<ol> of their own (mega menu, search tabs, social nav, timelines).
 *
 * Headings are deliberately left alone: many components style bare <h2>-<h6>
 * through parent selectors, so restoring them globally would regress those.
 * They are restored inside the opt-in wrappers at the bottom of this file.
 */

/* Lists ------------------------------------------------------------------- */

ul:not([class]) {
  list-style-type: disc;
}

ol:not([class]) {
  list-style-type: decimal;
}

/* Browser defaults for nested markers. */
ul:not([class]) ul:not([class]) {
  list-style-type: circle;
}

ul:not([class]) ul:not([class]) ul:not([class]) {
  list-style-type: square;
}

ol:not([class]) ol:not([class]) {
  list-style-type: lower-alpha;
}

ol:not([class]) ol:not([class]) ol:not([class]) {
  list-style-type: lower-roman;
}

/* A nested list hugs its parent item instead of adding a blank line. */
ul:not([class]) ul:not([class]),
ul:not([class]) ol:not([class]),
ol:not([class]) ul:not([class]),
ol:not([class]) ol:not([class]) {
  margin-block: 0;
}

/* CKEditor 5 wraps list item text in <p> when the list is in "block" mode. */
li > p:not([class]) {
  margin-block: 0;
}

/* Paragraph and block spacing ---------------------------------------------- */

/*
 * Only consecutive unclassed blocks are spaced. A lone <p> in a component
 * template keeps margin: 0, so single-paragraph layouts are untouched.
 */
p:not([class]) + p:not([class]),
p:not([class]) + ul:not([class]),
p:not([class]) + ol:not([class]),
p:not([class]) + blockquote:not([class]),
ul:not([class]) + p:not([class]),
ol:not([class]) + p:not([class]),
blockquote:not([class]) + p:not([class]) {
  margin-top: 1em;
}

blockquote:not([class]) {
  margin-inline-start: 1.5em;
}

dl:not([class]) {
  margin-block: 1em;
}

dd:not([class]) {
  margin-inline-start: 2.5em;
}

/* Exceptions: components that intentionally render bare lists -------------- */

nav ul:not([class]),
nav ol:not([class]),
header ul:not([class]),
header ol:not([class]),
.menu-link-contentmain ul:not([class]),
.menu-link-contentmain ol:not([class]),
.tabs ul:not([class]),
.tabs ol:not([class]),
.tabs-nav ul:not([class]),
.tabs-nav ol:not([class]),
.timeline ul:not([class]),
.timeline ol:not([class]) {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Opt-in wrapper ----------------------------------------------------------- */

/*
 * Add one of these classes to a rich-text container (field wrapper, paragraph
 * template, block content) when authored headings also need their default
 * scale back. Kept opt-in so it cannot regress existing components.
 */
.text-formatted h1,
.text-formatted h2,
.text-formatted h3,
.text-formatted h4,
.text-formatted h5,
.text-formatted h6,
.ck-content h1,
.ck-content h2,
.ck-content h3,
.ck-content h4,
.ck-content h5,
.ck-content h6,
.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4,
.rich-text h5,
.rich-text h6 {
  margin-block: 0.75em 0.5em;
  font-weight: 700;
  line-height: 1.25;
}

.text-formatted h1,
.ck-content h1,
.rich-text h1 {
  font-size: 2em;
}

.text-formatted h2,
.ck-content h2,
.rich-text h2 {
  font-size: 1.5em;
}

.text-formatted h3,
.ck-content h3,
.rich-text h3 {
  font-size: 1.25em;
}

.text-formatted h4,
.ck-content h4,
.rich-text h4 {
  font-size: 1.125em;
}

.text-formatted h5,
.ck-content h5,
.rich-text h5,
.text-formatted h6,
.ck-content h6,
.rich-text h6 {
  font-size: 1em;
}
