/*
 * Design-system layer: component tokens + the interaction rules every component shares.
 * Loaded on EVERY page type right after style.css and before all area/plugin layers (inc/enqueue.php), including
 * LearnDash focus mode and pages in the "modal" asset mode. Spec: see docs / UX/system-data/SPEC.md.
 *
 * How to use: area files (courses.css, home.css, learndash/*.css, mu-plugin CSS ...) keep their selectors and
 * reference the custom properties below instead of repeating numbers. mu-plugin CSS adds a literal fallback
 * (var(--sddsg-btn-h, 44px)) because it can load without this theme.
 * Base tokens (colours, radii sm/md/lg/pill, shadows sm/md, transition, motion) come from theme.json (tools/gen.py).
 */
:root {
	/* Focus ring: one shape everywhere; gold on surfaces that are dark in both schemes. */
	--sddsg-ring-width: 3px;
	--sddsg-ring-offset: 2px;
	--sddsg-ring: var(--sddsg-ring-width) solid var(--wp--preset--color--focus);
	--sddsg-ring-on-dark: var(--wp--preset--color--accent);

	/* Motion: state feedback (colour, border, shadow, filter) = ease; things that move (lift, slide, expand, fill) = motion. */
	--sddsg-ease: var(--wp--custom--transition, 150ms ease);
	--sddsg-motion: var(--wp--custom--motion, 220ms ease);

	/* Buttons (all roles): 44px, pill, small type. Filled primary = bold, outline roles = semibold. */
	--sddsg-btn-h: var(--sddsg-tap, 44px);
	--sddsg-btn-pad: 0.5rem 1.4rem;
	--sddsg-btn-radius: var(--wp--custom--radius--pill, 999px);
	--sddsg-btn-size: var(--wp--preset--font-size--small);
	--sddsg-btn-weight: 700;
	--sddsg-btn2-weight: 600;
	--sddsg-btn-border: 1.5px;
	/* Gold on light surfaces is only 2:1: a 1px darker edge marks the control (token accent-edge; equals accent in dark). */
	--sddsg-btn-edge: inset 0 0 0 1px var(--wp--preset--color--accent-edge);
	--sddsg-btn-shadow-hover: var(--sddsg-btn-edge), var(--wp--preset--shadow--md);
	--sddsg-btn-hover: brightness(1.08);
	--sddsg-btn-press: brightness(0.94);
	/* Secondary (outline): border-strong at rest, heading on hover, tinted fill when pressed. */
	--sddsg-btn2-border: var(--wp--preset--color--border-strong);
	--sddsg-btn2-border-hover: var(--wp--preset--color--heading);
	--sddsg-btn2-bg-hover: var(--wp--preset--color--surface);
	--sddsg-btn2-bg-press: var(--wp--preset--color--border);
	--sddsg-disabled-opacity: 0.5;

	/* Fields: 44px, radius sm, 16px type (no iOS zoom), border-strong (>= 3:1), hover = heading border. */
	--sddsg-field-h: var(--sddsg-tap, 44px);
	--sddsg-field-radius: var(--wp--custom--radius--sm, 0.5rem);
	--sddsg-field-size: max(1rem, 16px);
	--sddsg-field-border: 1px solid var(--wp--preset--color--border-strong);
	--sddsg-field-border-hover: var(--wp--preset--color--heading);

	/* Checkbox / radio: 20-24px box in a 44px row, accent-color primary; drawn boxes use this corner. */
	--sddsg-check-radius: 0.3rem;

	/* Containers */
	--sddsg-card-radius: var(--wp--custom--radius--lg, 1.25rem);
	--sddsg-tile-radius: var(--wp--custom--radius--md, 1rem);
	--sddsg-dialog-shadow: var(--wp--preset--shadow--md);
	--sddsg-backdrop: rgb(8 20 35 / 0.6); /* one dim for all dialogs (not a palette colour: always dark, both schemes) */

	/* Progress: 8px pill, track = border token, fill = accent with the same darker edge as buttons, success when complete. */
	--sddsg-bar-h: 0.5rem;
	--sddsg-bar-track: var(--wp--preset--color--border);
	--sddsg-bar-fill: var(--wp--preset--color--accent);
	--sddsg-bar-edge: inset 0 0 0 1px var(--wp--preset--color--accent-edge);

	/* Reading measure for running text (about 75 characters at the body size). */
	--sddsg-measure: var(--wp--style--global--content-size, 48rem);
}

/* ---------- Focus ring ----------
 * One ring: 3px solid "focus" token, offset 2px (theme.json: :where(a, button, input, ...):focus-visible; components repeat it
 * as `outline: var(--sddsg-ring)`). Surfaces that are dark in BOTH schemes (header, footer, hero, CTA band, navy cards and
 * banners, focus-mode header, video player) re-point the focus token to gold, so every ring inside them is gold without a
 * rule per component. Dialogs are light surfaces again and get the scheme's ring back. */
:root { --sddsg-focus-default: var(--wp--preset--color--focus); }
:is(.sddsg-header, .sddsg-footer, .sddsg-hero, .sddsg-cta, .sddsg-lhero, .sddsg-lcta, .sddsg-home-resume, .ld-focus-header, .ld-profile-summary, .ldgr-top-banner, .sddsg-player) { --wp--preset--color--focus: var(--sddsg-ring-on-dark); --sddsg-ring: var(--sddsg-ring-width) solid var(--sddsg-ring-on-dark); }
:is(dialog, [role="dialog"]) { --wp--preset--color--focus: var(--sddsg-focus-default); --sddsg-ring: var(--sddsg-ring-width) solid var(--sddsg-focus-default); }

/* ---------- Core / block buttons = primary (theme.json: accent fill, bold) ---------- */
.wp-element-button, .wp-block-button__link { box-shadow: var(--sddsg-btn-edge); }
.wp-element-button:hover, .wp-block-button__link:hover { filter: var(--sddsg-btn-hover); }
.wp-element-button:active, .wp-block-button__link:active { filter: var(--sddsg-btn-press); }
/* Outline style (hero, CTA band): no gold edge. */
.wp-block-button.is-style-outline > .wp-block-button__link { box-shadow: none; }
/* Outline style on page surfaces (e.g. 404 "Zur Startseite") = the secondary button of the SPEC; on navy surfaces
   (.sddsg-btn-on-hero, hero / CTA band) style.css keeps its own on-navy look. */
.wp-block-button.is-style-outline:not(.sddsg-btn-on-hero) > .wp-block-button__link:not(.sddsg-hero *, .sddsg-cta *) {
	border: var(--sddsg-btn-border) solid var(--sddsg-btn2-border); background: transparent; color: var(--wp--preset--color--heading); font-weight: var(--sddsg-btn2-weight);
	&:hover { border-color: var(--sddsg-btn2-border-hover); background: var(--sddsg-btn2-bg-hover); filter: none; }
	&:active { background: var(--sddsg-btn2-bg-press); filter: none; }
}

/* ---------- Running text: readable measure (about 75 characters) ----------
 * Plain pages (page.html: imprint, privacy, text pages) use a 64rem column; paragraphs and lists directly in the content
 * stay at the content width and start at the left edge of the column like the page title. Blocks with their own
 * alignment or width (wide/full, centred text, groups, shortcode output) keep it. */
.sddsg-main:not([class*="sddsg-main--"]) > .wp-block-post-content > :where(p, ul, ol, dl, blockquote):not(.alignwide, .alignfull, .has-text-align-center, .has-text-align-right) {
	max-inline-size: var(--sddsg-measure);
	margin-inline: 0 auto !important; /* the constrained layout centres its children with !important auto margins */
}
.wp-block-details > :where(p, ul, ol, dl) { max-inline-size: var(--sddsg-measure); }

/* ---------- Motion ----------
 * Convention (no global kill switch: a universal "transition-duration: 0.01ms" makes every element transition all
 * properties and changed how variable-font text was painted): every transition / animation of the theme is declared
 * inside `@media (prefers-reduced-motion: no-preference)` or has a `reduce` counterpart in the same file; plugin
 * markup is switched off per plugin area (LearnDash: learndash/base.css, Group Registration: learndash/groups-ldgr.css,
 * accordion: widgets.css). */

/* ---------- Forced colours (Windows contrast themes): state that is fill-only gets a real edge ---------- */
@media (forced-colors: active) {
	.wp-element-button, .wp-block-button__link, .sddsg-home-btn, .sddsg-course__btn, .sddsg-cp__btn, .sddsg-confirm__btn, .sddsg-gk__btn, .sddsg-cpill,
	.learndash-wrapper :is(.ld-button, .wpProQuiz_button, input[type="submit"], .sddsg-ld-cta), .ld-login-modal input[type="submit"] { border: 1px solid ButtonText; }
	:is(.sddsg-cpill, .sddsg-tabs__tab)[aria-current="true"], :is(.sddsg-cpill, .sddsg-tabs__tab, [role="tab"])[aria-selected="true"], .sddsg-cpill[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
	.sddsg-menu :is(.current-menu-item, .current-menu-ancestor) > a, .sddsg-menu a[aria-current], .sddsg-lang a[aria-current] { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.35em; }
	.sddsg-course__bar, .sddsg-home-resume__bar, .sddsg-gk__bar, .sddsg-quiz-progress__track, .learndash-wrapper .ld-progress .ld-progress-bar { border: 1px solid CanvasText; }
	:is(.sddsg-course__bar, .sddsg-home-resume__bar, .sddsg-gk__bar) > span, .sddsg-quiz-progress__bar, .learndash-wrapper .ld-progress .ld-progress-bar .ld-progress-bar-percentage { forced-color-adjust: none; background: Highlight !important; }
	.sddsg-badge, .sddsg-course__badge, .sddsg-cp-tag, .sddsg-grp-badge, .learndash-wrapper .ld-status { border: 1px solid CanvasText; }
	.sddsg-theme-toggle__icon, .sddsg-account__icon { forced-color-adjust: none; background: ButtonText; }
	.learndash-wrapper .ld-lesson-item.ld-is-current-lesson { outline: 2px solid Highlight; outline-offset: -2px; }
	:focus-visible { outline-color: Highlight; }
}
