/*
 * AlteredCore design system — base rules: document defaults and the SPA plugin root.
 * Loaded by the shell in <head> and injected into every SPA plugin's shadow root
 * (js/altered-core-host.js), so .ac-plugin-root gets the same defaults as the page.
 */

/* What the browser scrolls to the top (keyboard focus, scrollIntoView, #anchors, find in page) stops under the
   sticky site header and a plugin's sticky bar instead of behind them (WCAG 2.4.11 Focus Not Obscured). */
html {
  scroll-padding-top: calc(var(--ac-page-top) + var(--ac-scroll-top-offset));
}

/* .ac-spa-placeholder: the server's skeleton of an SPA page (includes/spa.php), shown through a slot of the plugin's
   shadow root while the plugin loads. A plugin stylesheet that resets its host (`:host { all: initial }`) cuts what the
   skeleton inherits from the page: without its own font and colour it turns serif once that stylesheet loads. */
body,
.ac-plugin-root,
.ac-spa-placeholder {
  background: var(--ac-color-bg-app);
  color: var(--ac-color-text);
  font: var(--ac-font-body);
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* The page fills the window under the site header, and so does its skeleton: the site footer is never on the first
   screen while the page loads, where the page's content would push it down (a layout shift). */
.ac-plugin-root,
.ac-spa-placeholder {
  display: block;
  min-height: calc(100dvh - var(--ac-page-top));
}

.ac-plugin-root *,
.ac-plugin-root *::before,
.ac-plugin-root *::after {
  box-sizing: border-box;
}

.ac-plugin-root :where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
}

/* :where() keeps these defaults at the lowest specificity: any class (.ac-button…) wins. */
:where(body, .ac-plugin-root) :where(h1, h2, h3, h4, h5, h6) {
  color: var(--ac-color-text);
  margin-top: 0;
}

:where(body, .ac-plugin-root) :where(a) {
  color: var(--ac-color-link);
}

@media (hover: hover) {
  :where(body, .ac-plugin-root) :where(a:hover) {
    color: var(--ac-color-link-hover);
  }
}

:focus-visible {
  outline: 2px solid var(--ac-color-focus);
  outline-offset: 2px;
}

::selection {
  background: var(--ac-color-primary-soft);
  color: var(--ac-color-text);
}

/* ---- Text styles ---- */
.ac-text-display {
  font: var(--ac-font-display);
  letter-spacing: var(--ac-letter-spacing-display);
}
.ac-text-title { font: var(--ac-font-title); }
.ac-text-heading { font: var(--ac-font-heading); }
.ac-text-body { font: var(--ac-font-body); }
.ac-text-strong { font: var(--ac-font-body-strong); }
.ac-text-small { font: var(--ac-font-small); }
.ac-text-caption { font: var(--ac-font-caption); }
.ac-text-muted { color: var(--ac-color-text-muted); }
.ac-text-overline {
  font: var(--ac-font-overline);
  text-transform: uppercase;
  letter-spacing: var(--ac-letter-spacing-overline);
  color: var(--ac-color-text-muted);
}

/* Long-form content (news, rules, CMS pages). */
.ac-prose {
  font: var(--ac-font-prose);
  color: var(--ac-color-text);
  max-width: 72ch;
}
.ac-prose :is(h1, h2, h3) { font-weight: 800; letter-spacing: var(--ac-letter-spacing-display); margin: 1.6em 0 0.6em; }
.ac-prose :is(p, ul, ol) { margin: 0 0 1em; }
.ac-prose img { max-width: 100%; height: auto; border-radius: var(--ac-radius-lg); }

/* ---- Utilities ---- */
.ac-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
