@use './article/stops-article-cascade' as *;
@use '../../scss/theming' as *;

@mixin daff-article-theme($theme) {
	$primary: daff-get-palette($theme, primary);
	$neutral: daff-get-palette($theme, neutral);
	$mode: daff-get-theme-mode($theme);

	$link-color-light: daff-color($primary);
	$link-color-dark: daff-color($primary, 40);
	$text-color-light: daff-color($neutral, 90);
	$text-color-dark: daff-color($neutral, 10);
	$table-border-light: daff-color($neutral, 20);
	$table-border-dark: daff-color($neutral, 80);

	.daff-article {
		@include light($mode) {
			color: $text-color-light;

			@include stopsArticleCascade(a) {
				color: $link-color-light;
				text-decoration-color: $link-color-light;
			}

			code {
				background: rgba(daff-color($neutral, 20), 0.5);
			}

			pre {
				background: rgba(daff-color($neutral, 20), 0.3);
				border: 1px solid daff-color($neutral, 20);

				code {
					background: none;
					border: none;
				}
			}

			&__copy-button {
				background: daff-color($neutral, 10);
				border: 1px solid daff-color($neutral, 20);
			}

			hr {
				background: daff-color($neutral, 20);
			}

			blockquote {
				background: rgba(daff-color($primary), 0.1);
				border-left: 4px solid daff-color($primary, 50);
				color: daff-color($primary, 100);

				code {
					background: rgba(daff-color($primary), 0.12);
					color: daff-color($primary, 100);

					@include stopsArticleCascade(a) {
						color: daff-color($primary, 70);
						text-decoration-color: daff-color($primary, 70);
					}
				}
			}

			table {
				border: 1px solid $table-border-light;

				th {
					background: daff-color($neutral, 10);
				}

				th,
				td {
					&:not(:last-child) {
						border-right: 1px solid $table-border-light;
					}
				}

				thead {
					th {
						border-bottom: 1px solid $table-border-light;
					}
				}

				tr {
					&:not(:last-child) {
						th,
						td {
							border-bottom: 1px solid $table-border-light;
						}
					}
				}
			}

			.daff-article-heading-link {
				&__button {
					color: daff-color($neutral, 70);
				}
			}
		}

		@include dark($mode) {
			color: $text-color-dark;

			@include stopsArticleCascade(a) {
				color: $link-color-dark;
				text-decoration-color: $link-color-dark;
			}

			code {
				background: rgba(daff-color($neutral, 20), 0.15);
			}

			pre {
				background: rgba(daff-color($neutral, 20), 0.15);
				border: 1px solid rgba(daff-color($neutral, 20), 0.15);

				code {
					background: none;
					border: none;
				}
			}

			&__copy-button {
				background: daff-color($neutral, 90);
				border: 1px solid daff-color($neutral, 80);
			}

			hr {
				background: daff-color($neutral, 80);
			}

			blockquote {
				background: rgba(daff-color($primary), 0.12);
				border-left: 4px solid daff-color($primary, 40);
				color: daff-color($primary, 10);

				code {
					background: rgba(daff-color($primary), 0.18);
					color: daff-color($primary, 10);

					@include stopsArticleCascade(a) {
						color: daff-color($primary, 40);
						text-decoration-color: daff-color($primary, 40);
					}
				}
			}

			table {
				border: 1px solid $table-border-dark;

				th {
					background: daff-color($neutral, 90);
				}

				th,
				td {
					&:not(:last-child) {
						border-right: 1px solid $table-border-dark;
					}
				}

				thead {
					th {
						border-bottom: 1px solid $table-border-dark;
					}
				}

				tr {
					&:not(:last-child) {
						th,
						td {
							border-bottom: 1px solid $table-border-dark;
						}
					}
				}
			}

			.daff-article-heading-link {
				&__button {
					color: daff-color($neutral, 30);
				}
			}
		}
	}
}
