/*
 * Shared base for both art directions: reset, Korean typesetting, the screen-reader utility,
 * the focus ring and reduced motion. No colors or typefaces of its own: each variant's
 * site.css defines the tokens used here (--bg, --fg, --focus).
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* html and body both carry the variant background, so no layer falls back to the UA canvas. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg, Canvas);
  color: var(--fg, CanvasText);
}

body {
  margin: 0;
  background-color: var(--bg, Canvas);
  /* Korean: break between words only, strict punctuation rules, long strings still wrap. */
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

img,
video {
  max-width: 100%;
  height: auto;
}

/* Hidden on screen, kept for assistive technology (the anatomy structure summary uses it). */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/*
 * Markup only one art direction uses carries data-only="a" or data-only="b" and is never shown
 * in the other. The Worker writes <html data-variant>; a page without it is the static file,
 * which is variant A.
 */
html[data-variant="b"] [data-only="a"],
html:not([data-variant="b"]) [data-only="b"] {
  display: none;
}

/*
 * Skip link: above the top edge until it takes keyboard focus, then pinned in view. Only its
 * position is shared; each variant styles the focused look.
 */
.skip-link {
  position: absolute;
  z-index: 1000;
  top: 0;
  left: 0;
  transform: translateY(calc(-100% - 1rem));
}

.skip-link:focus {
  position: fixed;
  transform: none;
}

/* The ring's shape is shared; each variant picks its color through --focus. */
:focus-visible {
  outline: 2px solid var(--focus, currentColor);
  outline-offset: 3px;
}

/*
 * Reduced motion: transitions and animations end at once. Near-zero durations rather than
 * `none`, so an animation's end state still applies and animationend/transitionend still fire.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
