/**
 * WordPress block editor content - front & editor.
 * Scoped to :is(.entry-content, .editor-styles-wrapper) so raw Gutenberg output inherits IKONU styling.
 */

/* ── Flow & spacing ─────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) > * + * {
  margin-top: 1.35em;
}

:is(.entry-content, .editor-styles-wrapper) > .wp-block-heading + *,
:is(.entry-content, .editor-styles-wrapper) > h2 + *,
:is(.entry-content, .editor-styles-wrapper) > h3 + *,
:is(.entry-content, .editor-styles-wrapper) > h4 + * {
  margin-top: 0.85em;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-spacer + * {
  margin-top: 0;
}

/* ── Images & figures ───────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-lg);
}

:is(.entry-content, .editor-styles-wrapper) figure {
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) figure img {
  display: block;
  border: 1px solid var(--ikn-steel);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image,
:is(.entry-content, .editor-styles-wrapper) figure.wp-block-image {
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image img,
:is(.entry-content, .editor-styles-wrapper) figure.wp-block-image img {
  width: auto;
  max-width: 100%;
  height: auto;
}

/* Image block styles - pick in editor: Styles → Illustration / Capture / Pleine largeur */

:is(.entry-content, .editor-styles-wrapper) .wp-block-image.is-style-illustration {
  max-width: min(400px, 100%);
  margin-inline: auto;
  text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image.is-style-illustration img {
  width: 100%;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image.is-style-screenshot {
  max-width: min(820px, 100%);
  margin-inline: auto;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image.is-style-screenshot img {
  width: 100%;
  border: 1px solid var(--ikn-steel);
  box-shadow: var(--shadow-md);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image.is-style-full-width img {
  width: 100%;
}

/* Legacy class (classic editor / custom HTML) */
:is(.entry-content, .editor-styles-wrapper) .wp-block-image.ikn-img-illustration,
:is(.entry-content, .editor-styles-wrapper) img.ikn-img-illustration {
  display: block;
  max-width: min(400px, 100%);
  margin-inline: auto;
}

:is(.entry-content, .editor-styles-wrapper) .aligncenter,
:is(.entry-content, .editor-styles-wrapper) .wp-block-image.aligncenter,
:is(.entry-content, .editor-styles-wrapper) .wp-block-image.aligncenter img,
:is(.entry-content, .editor-styles-wrapper) figure.aligncenter {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .aligncenter img,
:is(.entry-content, .editor-styles-wrapper) .wp-block-image.aligncenter img {
  display: block;
}

:is(.entry-content, .editor-styles-wrapper) .alignleft {
  float: left;
  margin: 0.25em var(--s-5) var(--s-4) 0;
  max-width: min(100%, 360px);
}

:is(.entry-content, .editor-styles-wrapper) .alignright {
  float: right;
  margin: 0.25em 0 var(--s-4) var(--s-5);
  max-width: min(100%, 360px);
}

:is(.entry-content, .editor-styles-wrapper) .alignwide {
  width: 100%;
  max-width: min(960px, 100%);
  margin-left: auto;
  margin-right: auto;
}

:is(.entry-content, .editor-styles-wrapper) .alignfull {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  border-radius: 0;
}

:is(.entry-content, .editor-styles-wrapper) .alignfull img {
  border-radius: 0;
}

:is(.entry-content, .editor-styles-wrapper) figcaption,
:is(.entry-content, .editor-styles-wrapper) .wp-element-caption {
  margin-top: var(--s-3);
  font-family: var(--ikn-font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--ikn-ash);
  text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-image figcaption {
  margin-bottom: 0;
}

/* ── Buttons ───────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button {
  margin: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button__link,
:is(.entry-content, .editor-styles-wrapper) .wp-element-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 12px 22px;
  font-family: var(--ikn-font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none !important;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button:not(.is-style-outline):not(.is-style-link) .wp-block-button__link {
  background-color: var(--ikn-signal) !important;
  color: var(--ikn-ivory) !important;
  border-color: var(--ikn-signal) !important;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button:not(.is-style-outline):not(.is-style-link) .wp-block-button__link:hover {
  background-color: var(--ikn-signal-bright) !important;
  border-color: var(--ikn-signal-bright) !important;
  box-shadow: var(--shadow-glow);
  color: var(--ikn-ivory) !important;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button.is-style-outline .wp-block-button__link {
  background: transparent !important;
  color: var(--ikn-signal) !important;
  border-color: var(--ikn-signal-line) !important;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button.is-style-outline .wp-block-button__link:hover {
  background: var(--ikn-signal-wash) !important;
  border-color: var(--ikn-signal) !important;
  color: var(--ikn-signal-bright) !important;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button.is-style-link .wp-block-button__link {
  background: transparent !important;
  color: var(--ikn-signal-bright) !important;
  border-color: transparent !important;
  padding-inline: 0;
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-button__link:active {
  transform: translateY(1px);
}

/* ── Quotes ────────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) blockquote,
:is(.entry-content, .editor-styles-wrapper) .wp-block-quote {
  margin: var(--s-6) 0;
  padding: var(--s-5) var(--s-5) var(--s-5) var(--s-6);
  border-left: 2px solid var(--ikn-signal);
  background: var(--ikn-graphite);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  color: var(--ikn-ivory);
}

:is(.entry-content, .editor-styles-wrapper) blockquote p,
:is(.entry-content, .editor-styles-wrapper) .wp-block-quote p {
  margin: 0;
  font-family: var(--ikn-font-display);
  font-size: clamp(18px, 2.2vw, 20px);
  line-height: 1.45;
  color: var(--ikn-ivory);
}

:is(.entry-content, .editor-styles-wrapper) blockquote cite,
:is(.entry-content, .editor-styles-wrapper) .wp-block-quote cite {
  display: block;
  margin-top: var(--s-3);
  font-family: var(--ikn-font-mono);
  font-size: 12px;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ikn-ash);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote {
  margin: var(--s-7) 0;
  padding: var(--s-6);
  border-top: 1px solid var(--ikn-steel);
  border-bottom: 1px solid var(--ikn-steel);
  text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote blockquote {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote p {
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.35;
}

/* ── Lists ─────────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) ul,
:is(.entry-content, .editor-styles-wrapper) ol {
  padding-left: 1.35em;
  margin: 1.25em 0;
}

:is(.entry-content, .editor-styles-wrapper) li + li {
  margin-top: 0.45em;
}

:is(.entry-content, .editor-styles-wrapper) li::marker {
  color: var(--ikn-signal);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-list {
  padding-left: 1.35em;
}

/* ── Separator ─────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) hr,
:is(.entry-content, .editor-styles-wrapper) .wp-block-separator {
  border: 0;
  border-top: 1px solid var(--ikn-steel);
  margin: var(--s-7) auto;
  max-width: 120px;
  opacity: 1;
}

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

:is(.entry-content, .editor-styles-wrapper) .wp-block-separator.is-style-dots {
  border: 0;
  max-width: none;
  text-align: center;
  background: none;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-separator.is-style-dots::before {
  color: var(--ikn-fog);
  letter-spacing: 1em;
}

/* ── Embeds & media ────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-embed,
:is(.entry-content, .editor-styles-wrapper) .wp-block-video {
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-embed__wrapper {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--ikn-steel);
  background: var(--ikn-graphite);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-embed.is-type-video .wp-block-embed__wrapper {
  aspect-ratio: 16 / 9;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-embed.is-type-video .wp-block-embed__wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-embed figcaption {
  text-align: center;
}

/* ── Gallery ───────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-gallery {
  gap: var(--s-3);
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-gallery .blocks-gallery-item img,
:is(.entry-content, .editor-styles-wrapper) .wp-block-gallery .wp-block-image img {
  border: 1px solid var(--ikn-steel);
}

/* ── Columns & groups ──────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-columns {
  gap: var(--s-5);
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-column > *:first-child {
  margin-top: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-group {
  margin: var(--s-6) 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-group.has-background {
  padding: var(--s-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--ikn-steel);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-media-text {
  gap: var(--s-5);
  margin: var(--s-6) 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--ikn-steel);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-media-text__media img {
  border-radius: 0;
  border: 0;
  height: 100%;
  object-fit: cover;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-media-text__content {
  padding: var(--s-5);
}

/* ── Tables ────────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-table,
:is(.entry-content, .editor-styles-wrapper) table {
  width: 100%;
  margin: var(--s-6) 0;
  border-collapse: collapse;
  font-size: 15px;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--ikn-steel);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-table table {
  margin: 0;
  border: 0;
}

:is(.entry-content, .editor-styles-wrapper) th,
:is(.entry-content, .editor-styles-wrapper) td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--ikn-steel);
  text-align: left;
  vertical-align: top;
}

:is(.entry-content, .editor-styles-wrapper) th {
  background: var(--ikn-graphite);
  color: var(--ikn-ivory);
  font-family: var(--ikn-font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

:is(.entry-content, .editor-styles-wrapper) tr:last-child td {
  border-bottom: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Code & pre ────────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) code {
  padding: 0.15em 0.45em;
  font-family: var(--ikn-font-mono);
  font-size: 0.9em;
  background: var(--ikn-graphite);
  border: 1px solid var(--ikn-steel);
  border-radius: var(--r-sm);
  color: var(--ikn-ivory);
}

:is(.entry-content, .editor-styles-wrapper) pre,
:is(.entry-content, .editor-styles-wrapper) .wp-block-code,
:is(.entry-content, .editor-styles-wrapper) .wp-block-preformatted {
  margin: var(--s-6) 0;
  padding: var(--s-5);
  overflow-x: auto;
  font-family: var(--ikn-font-mono);
  font-size: 14px;
  line-height: 1.6;
  background: var(--ikn-graphite);
  border: 1px solid var(--ikn-steel);
  border-radius: var(--r-lg);
  color: var(--ikn-ivory);
}

:is(.entry-content, .editor-styles-wrapper) pre code {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

/* ── File download ─────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  padding: var(--s-4) var(--s-5);
  background: var(--ikn-graphite);
  border: 1px solid var(--ikn-steel);
  border-radius: var(--r-lg);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-file a:not(.wp-block-file__button) {
  color: var(--ikn-ivory);
  text-decoration: none;
  font-weight: 500;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-file__button {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  color: var(--ikn-ivory) !important;
  background: var(--ikn-signal) !important;
  border-radius: var(--r-md);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-file__button:hover {
  background: var(--ikn-signal-bright) !important;
}

/* ── Cover block ───────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper) .wp-block-cover {
  margin: var(--s-6) 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  min-height: 280px;
}

/* ── Clear floats ──────────────────────────────────────────────── */

:is(.entry-content, .editor-styles-wrapper)::after {
  content: "";
  display: table;
  clear: both;
}

@media (max-width: 720px) {
  :is(.entry-content, .editor-styles-wrapper) .alignleft,
  :is(.entry-content, .editor-styles-wrapper) .alignright {
    float: none;
    margin: var(--s-4) auto;
    max-width: 100%;
  }

  :is(.entry-content, .editor-styles-wrapper) .wp-block-columns:not(.is-not-stacked-on-mobile) {
    flex-wrap: wrap !important;
  }

  :is(.entry-content, .editor-styles-wrapper) .wp-block-column {
    flex-basis: 100% !important;
  }
}
