/*
 * SisuDent base styles — reset, typography, links, focus, skip link, reduced motion
 * Requires: design/tokens/fonts.css, design/tokens/tokens.css
 * Session 2.2 (Gate 2 proposal). Sources: Blueprint 2.9–2.17, 2.21–2.22, 3.13, 8.21; Design_System_Plan.md 4, 10, 11.
 */

/* ---------- Reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--sd-scroll-offset);  /* anchors and focused elements are not hidden under the sticky header */
}

body {
  margin: 0;
  background: var(--sd-color-surface);
  color: var(--sd-color-text-default);
  font-family: var(--sd-font-family-base);
  font-size: var(--sd-font-size-body);
  font-weight: var(--sd-font-weight-regular);
  line-height: var(--sd-line-height-body);
  font-kerning: normal;
  overflow-wrap: break-word;  /* long compound words and product codes never widen the page (Session 3.3) */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote {
  margin: 0;
}

img, svg, video, picture {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- Headings (level = semantics; size = class) ---------- */

h1, .sd-h1,
h2, .sd-h2,
h3, .sd-h3,
h4, .sd-h4 {
  color: var(--sd-color-text-heading);
  font-weight: var(--sd-font-weight-semibold);
  letter-spacing: var(--sd-letter-spacing-heading);
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: manual;
}

h1, .sd-h1 { font-size: var(--sd-font-size-h1); line-height: var(--sd-line-height-h1); }
h2, .sd-h2 { font-size: var(--sd-font-size-h2); line-height: var(--sd-line-height-h2); }
h3, .sd-h3 { font-size: var(--sd-font-size-h3); line-height: var(--sd-line-height-h3); }
h4, .sd-h4 {
  font-size: var(--sd-font-size-h4);
  line-height: var(--sd-line-height-h4);
  font-weight: var(--sd-font-weight-medium);
  letter-spacing: 0;
}

/* Neutral heading colour where blue is not meaningful (Blueprint 3.9: not every heading is blue) */
.sd-heading--neutral { color: var(--sd-color-text-default); }

/* ---------- Text styles ---------- */

/* Paths, codes and URLs have no break points; inside grid and flex items they may break anywhere (Session 3.3) */
code, kbd, samp { overflow-wrap: anywhere; }

p {
  max-width: var(--sd-measure-text);
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.sd-lead {
  font-size: var(--sd-font-size-body-lg);
  line-height: var(--sd-line-height-body);
  color: var(--sd-color-text-default);
}

.sd-small {
  font-size: var(--sd-font-size-small);
  line-height: var(--sd-line-height-small);
}

.sd-muted { color: var(--sd-color-text-muted); }

/* Eyebrow / category / status label: short text only (Blueprint 2.16) */
/* Eyebrow label above a heading: 18px semibold (owner, D-032); the gray variant keeps the small label size */
.sd-label {
  display: inline-block;
  font-size: var(--sd-font-size-eyebrow);
  font-weight: var(--sd-font-weight-semibold);
  line-height: var(--sd-line-height-label);
  letter-spacing: var(--sd-letter-spacing-label);
  text-transform: uppercase;
  color: var(--sd-color-text-accent);
}

.sd-label--muted { color: var(--sd-color-text-muted); font-size: var(--sd-font-size-label); font-weight: var(--sd-font-weight-medium); }

/* Product codes, figures in tables */
.sd-tabular { font-variant-numeric: tabular-nums; }

strong, b { font-weight: var(--sd-font-weight-semibold); }

/* ---------- Long-form content ---------- */

.sd-prose {
  max-width: var(--sd-measure-article);
  line-height: var(--sd-line-height-article);
}

.sd-prose > * + * { margin-top: var(--sd-space-4); }
.sd-prose > h2 { margin-top: var(--sd-space-7); }
.sd-prose > h3 { margin-top: var(--sd-space-6); }
.sd-prose > h2 + *,
.sd-prose > h3 + * { margin-top: var(--sd-space-3); }
.sd-prose h2 { font-size: var(--sd-font-size-h3); line-height: var(--sd-line-height-h3); }
.sd-prose h3 { font-size: var(--sd-font-size-h4); line-height: var(--sd-line-height-h4); }

.sd-prose ul,
.sd-prose ol { padding-left: 1.25em; }
.sd-prose li + li { margin-top: var(--sd-space-2); }
.sd-prose li::marker { color: var(--sd-color-brand-blue); }

.sd-prose blockquote {
  padding-left: var(--sd-space-4);
  border-left: var(--sd-border-width-strong) solid var(--sd-color-accent-copper);
  font-size: var(--sd-font-size-body-lg);
  color: var(--sd-color-text-heading);
}

/* ---------- Links ---------- */

a {
  color: var(--sd-color-link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--sd-transition-feedback), text-decoration-color var(--sd-transition-feedback);
}

a:hover {
  color: var(--sd-color-link-hover);
  text-decoration-thickness: 2px;
}

/* Standalone link with arrow (no underline; arrow carries the affordance) */
.sd-link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sd-space-2);
  min-height: var(--sd-target-min);
  font-size: var(--sd-font-size-ui);
  font-weight: var(--sd-font-weight-medium);
  letter-spacing: var(--sd-letter-spacing-ui);
  text-decoration: none;
}

/* Arrow: inline SVG (<svg class="sd-link-arrow__icon">) — the font has no reliable arrow glyph */
.sd-link-arrow__icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  transition: transform var(--sd-transition-ui);
}

.sd-link-arrow:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.sd-link-arrow:hover .sd-link-arrow__icon { transform: translateX(0.25em); }

/* ---------- Focus (never removed; Blueprint 20.31) ---------- */

:focus-visible {
  outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color);
  outline-offset: var(--sd-focus-ring-offset);
}

:focus:not(:focus-visible) { outline: none; }

/* ---------- Skip link ---------- */

.sd-skip-link {
  position: absolute;
  top: var(--sd-space-2);
  left: var(--sd-space-2);
  z-index: 1000;
  padding: var(--sd-space-2) var(--sd-space-3);
  background: var(--sd-color-action-primary);
  color: var(--sd-color-action-primary-text);
  font-weight: var(--sd-font-weight-medium);
  border-radius: var(--sd-radius-md);
  transform: translateY(-200%);
}

.sd-skip-link:focus { transform: none; }
.sd-skip-link:hover { color: var(--sd-color-action-primary-text); }

/* ---------- Utilities ---------- */

/* The hidden attribute always wins over a component's display value (Session 2.3) */
[hidden] { display: none !important; }

.sd-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--sd-color-blue-100);
  color: var(--sd-color-text-default);
}

/* ---------- Reduced motion (Blueprint 8.21) ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
