/* ===========================
   BASE STRUCTURE (Applied only to Badge Styles)
   Default "Text" style remains untouched (standard inline links)
   =========================== */

/* List all badge style classes to scope structural styles */
.wp-block-post-terms[class*='is-style-badge-'],
.wp-block-post-terms[class*='is-style-primary'],
.wp-block-post-terms[class*='is-style-secondary'],
.wp-block-post-terms[class*='is-style-critical'],
.wp-block-post-terms[class*='is-style-warning'],
.wp-block-post-terms[class*='is-style-success'],
.wp-block-post-terms[class*='is-style-info'] {
  display: flex;
  flex-wrap: wrap;
  /* Default Gap (Medium) */
  gap: var(--wp--custom--component--badge--gap--m, var(--wp--custom--semantic--spacing--050, 4px));
  /* Reset line-height to avoid huge badges */
  line-height: normal;
}

/* ===========================
   Legacy / Specific Taxonomies
   Default style has no background - just text links with link color
   =========================== */
.wp-block-post-terms a {
  color: var(
    --wp--custom--semantic--color--text--link--default,
    var(--wp--custom--semantic--color--primary, currentColor)
  );
}

/* Base Link Appearance for Badges */
.wp-block-post-terms[class*='is-style-badge-'] a,
.wp-block-post-terms[class*='is-style-primary'] a,
.wp-block-post-terms[class*='is-style-secondary'] a,
.wp-block-post-terms[class*='is-style-critical'] a,
.wp-block-post-terms[class*='is-style-warning'] a,
.wp-block-post-terms[class*='is-style-success'] a,
.wp-block-post-terms[class*='is-style-info'] a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  line-height: 100%;
  border-radius: var(
    --wp--custom--component--badge--border-radius,
    var(--wp--custom--semantic--border--radius--full, 999px)
  );

  /* Default Padding (User defined: Top/Bottom None, Left/Right L Horizontal) */
  padding-top: var(--wp--custom--semantic--spacing--none, 0);
  padding-bottom: var(--wp--custom--semantic--spacing--none, 0);
  padding-left: var(
    --wp--custom--component--badge--padding--l--horizontal,
    var(--wp--custom--semantic--spacing--base, 8px)
  );
  padding-right: var(
    --wp--custom--component--badge--padding--l--horizontal,
    var(--wp--custom--semantic--spacing--base, 8px)
  );

  /* Default Height (Medium - xs) */
  height: var(--wp--custom--semantic--size--xs, 24px);

  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

/* ===========================
   SIZES (Controlled by font-size classes)
   =========================== */

/* Small (Label 3) */
.wp-block-post-terms.has-label-3-font-size[class*='is-style-'] {
  gap: var(--wp--custom--component--badge--gap--s, var(--wp--custom--semantic--spacing--050, 4px));
}
.wp-block-post-terms.has-label-3-font-size[class*='is-style-'] a {
  padding-left: var(
    --wp--custom--component--badge--padding--s--horizontal,
    var(--wp--custom--primitive--spacing--6, 6px)
  );
  padding-right: var(
    --wp--custom--component--badge--padding--s--horizontal,
    var(--wp--custom--primitive--spacing--6, 6px)
  );
  height: var(--wp--custom--semantic--size--xxs, 20px);
}

/* Medium (Explicit Class - Label 2) */
.wp-block-post-terms.has-label-2-font-size[class*='is-style-'] a {
  height: var(--wp--custom--semantic--size--xs, 24px);
}

/* Large (Label 1) */
.wp-block-post-terms.has-label-1-font-size[class*='is-style-'] {
  gap: var(--wp--custom--component--badge--gap--l, var(--wp--custom--semantic--spacing--base, 8px));
}
.wp-block-post-terms.has-label-1-font-size[class*='is-style-'] a {
  padding-left: var(
    --wp--custom--component--badge--padding--l--horizontal,
    var(--wp--custom--semantic--spacing--base, 8px)
  );
  padding-right: var(
    --wp--custom--component--badge--padding--l--horizontal,
    var(--wp--custom--semantic--spacing--base, 8px)
  );
  height: var(--wp--custom--semantic--size--s, 32px);
}

/* ===========================
   VARIENTS (Primary, Secondary, Alerts)
   Must support "Filled" (Default) and "Light" (Tinted)
   =========================== */

/* --- Primary (Brand) --- */
.wp-block-post-terms.is-style-primary a,
.wp-block-post-terms.is-style-badge-primary a,
.wp-block-post-terms.is-style-badge-primary-initial a {
  background: var(
    --wp--custom--semantic--color--background--surface--brand,
    var(--wp--preset--color--primary-300)
  ) !important;
  color: var(--wp--custom--semantic--color--foreground--brand-on-secondary, #ffffff) !important;
}
.wp-block-post-terms.is-style-primary a:hover,
.wp-block-post-terms.is-style-badge-primary a:hover,
.wp-block-post-terms.is-style-badge-primary-initial a:hover {
  background: var(--wp--preset--color--primary-400) !important;
}

.wp-block-post-terms.is-style-primary-light a,
.wp-block-post-terms.is-style-badge-primary-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--accent--lightest,
    var(--wp--preset--color--primary-100)
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--brand-on-light,
    var(--wp--preset--color--on-primary-100)
  ) !important;
}
.wp-block-post-terms.is-style-primary-light a:hover,
.wp-block-post-terms.is-style-badge-primary-light a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--accent--lighter,
    var(--wp--preset--color--primary-200)
  ) !important;
}

/* --- Secondary (Neutral) --- */
.wp-block-post-terms.is-style-secondary a,
.wp-block-post-terms.is-style-badge-secondary a,
.wp-block-post-terms.is-style-badge-secondary-initial a {
  background: var(
    --wp--custom--semantic--color--background--surface--inverse,
    var(--wp--preset--color--neutral-900)
  ) !important;
  color: var(--wp--custom--semantic--color--foreground--inverse, #ffffff) !important;
}
.wp-block-post-terms.is-style-secondary a:hover,
.wp-block-post-terms.is-style-badge-secondary a:hover,
.wp-block-post-terms.is-style-badge-secondary-initial a:hover {
  background: var(--wp--preset--color--neutral-800) !important;
}

.wp-block-post-terms.is-style-secondary-light a,
.wp-block-post-terms.is-style-badge-secondary-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--secondary,
    var(--wp--preset--color--secondary-100)
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--primary,
    var(--wp--preset--color--neutral-900)
  ) !important;
}
.wp-block-post-terms.is-style-secondary-light a:hover,
.wp-block-post-terms.is-style-badge-secondary-light a:hover {
  background: var(--wp--preset--color--secondary-200) !important;
}

/* --- Critical (Red) --- */
.wp-block-post-terms.is-style-critical a,
.wp-block-post-terms.is-style-badge-critical a {
  background: var(
    --wp--custom--semantic--color--background--surface--critical--default,
    #c80e0e
  ) !important;
  color: var(--wp--custom--semantic--color--foreground--inverse, #ffffff) !important;
}
.wp-block-post-terms.is-style-critical a:hover,
.wp-block-post-terms.is-style-badge-critical a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--critical--hover,
    #960b0b
  ) !important;
}

.wp-block-post-terms.is-style-critical-light a,
.wp-block-post-terms.is-style-badge-critical-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--critical--lightest,
    #fcf3f3
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--action--critical--default,
    #c80e0e
  ) !important;
}
.wp-block-post-terms.is-style-critical-light a:hover,
.wp-block-post-terms.is-style-badge-critical-light a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--critical--lighter,
    #f9e7e7
  ) !important;
}

/* --- Warning (Yellow/Gold) --- */
.wp-block-post-terms.is-style-warning a,
.wp-block-post-terms.is-style-badge-warning a {
  background: var(
    --wp--custom--semantic--color--background--surface--warning--default,
    #f1c40f
  ) !important;
  /* Warning often needs dark text on filled background for contrast, checking contrast... if yellow, usually dark text */
  color: var(--wp--custom--semantic--color--foreground--primary, #121212) !important;
}
.wp-block-post-terms.is-style-warning a:hover,
.wp-block-post-terms.is-style-badge-warning a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--warning--hover,
    #f39c12
  ) !important;
}

.wp-block-post-terms.is-style-warning-light a,
.wp-block-post-terms.is-style-badge-warning-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--warning--lightest,
    #fef9e7
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--action--warning--default,
    #e67e22
  ) !important;
}
.wp-block-post-terms.is-style-warning-light a:hover,
.wp-block-post-terms.is-style-badge-warning-light a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--warning--lighter,
    #fcf3cf
  ) !important;
}

/* --- Success (Green) --- */
.wp-block-post-terms.is-style-success a,
.wp-block-post-terms.is-style-badge-success a {
  background: var(
    --wp--custom--semantic--color--background--surface--success--default,
    #27ae60
  ) !important;
  color: var(--wp--custom--semantic--color--foreground--inverse, #ffffff) !important;
}
.wp-block-post-terms.is-style-success a:hover,
.wp-block-post-terms.is-style-badge-success a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--success--hover,
    #2ecc71
  ) !important;
}

.wp-block-post-terms.is-style-success-light a,
.wp-block-post-terms.is-style-badge-success-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--success--lightest,
    #eafaf1
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--action--success--default,
    #27ae60
  ) !important;
}
.wp-block-post-terms.is-style-success-light a:hover,
.wp-block-post-terms.is-style-badge-success-light a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--success--lighter,
    #d5f5e3
  ) !important;
}

/* --- Information (Blue/Navy) --- */
.wp-block-post-terms.is-style-info a,
.wp-block-post-terms.is-style-information a,
.wp-block-post-terms.is-style-badge-info a {
  background: var(
    --wp--custom--semantic--color--background--surface--information--default,
    #2980b9
  ) !important;
  color: var(--wp--custom--semantic--color--foreground--inverse, #ffffff) !important;
}
.wp-block-post-terms.is-style-info a:hover,
.wp-block-post-terms.is-style-information a:hover,
.wp-block-post-terms.is-style-badge-info a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--information--hover,
    #3498db
  ) !important;
}

.wp-block-post-terms.is-style-info-light a,
.wp-block-post-terms.is-style-information-light a,
.wp-block-post-terms.is-style-badge-info-light a {
  background: var(
    --wp--custom--semantic--color--background--surface--information--lightest,
    #ebf5fb
  ) !important;
  color: var(
    --wp--custom--semantic--color--foreground--action--information--default,
    #2980b9
  ) !important;
}
.wp-block-post-terms.is-style-info-light a:hover,
.wp-block-post-terms.is-style-information-light a:hover,
.wp-block-post-terms.is-style-badge-info-light a:hover {
  background: var(
    --wp--custom--semantic--color--background--surface--information--lighter,
    #d6eaf8
  ) !important;
}

/* Optional: Support for other blocks with .is-style-badge class */
.wp-block-categories.is-style-badge a,
.wp-block-tag-cloud.is-style-badge a {
  display: inline-block;
  padding: 2px 10px 0 10px;
  border-radius: var(--wp--custom--semantic--border--radius--full, 999px);
  text-decoration: none;
  background: var(
    --wp--custom--semantic--color--background--surface--secondary,
    var(--wp--preset--color--secondary-300)
  );
  color: var(
    --wp--custom--semantic--color--foreground--on-secondary,
    var(--wp--preset--color--on-secondary-300)
  );
  gap: var(--wp--custom--semantic--badge--gap--l, 8px);
}
