/* ============================================================
   typography.css — kapy.ch v2
   Base typography per spec/v2/02-DESIGN-SYSTEM.md §2 + §9-CONTENT-VOICE.
   Uses fluid clamp scale from tokens.css. No new tokens.
   ============================================================ */

/* ---------- Body / Root ---------- */

html {
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body);
  color: var(--text-primary);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* iOS-Auto-Zoom-Schutz für Form-Inputs (>=16px) — bereits via --input-fs Token */

/* ---------- Headings (Fluid Scale) ---------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  line-height: var(--lh-headline);
  letter-spacing: var(--ls-headline);
  text-wrap: balance;
  margin-block-start: 0;
}

h1 {
  font-size: var(--fs-headline-xl);
}

h2 {
  font-size: var(--fs-headline-lg);
}

h3 {
  font-size: var(--fs-headline-md);
}

h4 {
  font-size: var(--fs-headline-sm);
}

h5 {
  font-size: var(--fs-body-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-body-tight);
}

h6 {
  font-size: var(--fs-body-md);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  line-height: var(--lh-caps);
  color: var(--text-secondary);
}

/* ---------- Display Classes (opt-in, for Hero/Landing) ---------- */

.display-2xl {
  font-family: var(--font-display);
  font-size: var(--fs-display-2xl);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-bold);
  text-wrap: balance;
}

.display-xl {
  font-family: var(--font-display);
  font-size: var(--fs-display-xl);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-bold);
  text-wrap: balance;
}

.display-lg {
  font-family: var(--font-display);
  font-size: var(--fs-display-lg);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-bold);
  text-wrap: balance;
}

/* ---------- Paragraphs ---------- */

p {
  font-size: var(--fs-body-md);
  line-height: var(--lh-body);
  color: var(--text-primary);
  max-width: 70ch;
  text-wrap: pretty;
}

p + p {
  margin-block-start: var(--space-3);
}

.lead {
  font-size: var(--fs-body-xl);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}

.muted {
  color: var(--text-tertiary);
}

.caption {
  font-size: var(--fs-caption);
  line-height: var(--lh-body-tight);
  color: var(--text-tertiary);
}

.overline {
  font-size: var(--fs-overline);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: var(--lh-caps);
}

/* ---------- Links ---------- */

a {
  color: var(--text-link);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) {
  a:hover {
    text-decoration-color: currentColor;
  }
}

a:visited {
  color: var(--text-link);
}

/* ---------- Lists ---------- */

ul,
ol {
  padding-inline-start: var(--space-5);
  line-height: var(--lh-body);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

ul ul,
ol ol,
ul ol,
ol ul {
  margin-block-start: var(--space-2);
  padding-inline-start: var(--space-5);
}

li + li {
  margin-block-start: var(--space-2);
}

li::marker {
  color: var(--text-tertiary);
}

/* role="list" — reset for nav/grid lists, marker entfernt */
[role='list'] {
  list-style: none;
  padding-inline-start: 0;
}

[role='list'] li + li {
  margin-block-start: 0;
}

/* Description-Lists */

dl {
  line-height: var(--lh-body);
}

dt {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

dd {
  color: var(--text-secondary);
  margin-inline-start: 0;
}

dt + dd {
  margin-block-start: var(--space-1);
}

dd + dt {
  margin-block-start: var(--space-3);
}

/* ---------- Code, Pre, Kbd, Samp, Var ---------- */

code,
kbd,
samp,
var,
pre {
  font-family: var(--font-mono);
  font-feature-settings: 'calt' 1;
}

code {
  font-size: 0.9375em;
  background-color: color-mix(in oklch, var(--brand-500) 8%, transparent);
  color: var(--brand-700);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  word-wrap: break-word;
}

[data-theme='dark'] code {
  background-color: color-mix(in oklch, var(--brand-400) 16%, transparent);
  color: var(--brand-200);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) code {
    background-color: color-mix(in oklch, var(--brand-400) 16%, transparent);
    color: var(--brand-200);
  }
}

pre {
  font-size: var(--fs-body-sm);
  line-height: var(--lh-mono);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  tab-size: 2;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

kbd {
  font-size: 0.875em;
  font-weight: var(--fw-medium);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  box-shadow: 0 1px 0 var(--border-subtle);
  white-space: nowrap;
}

samp {
  font-size: 0.9375em;
  color: var(--text-secondary);
}

var {
  font-style: italic;
  color: var(--brand-700);
}

[data-theme='dark'] var {
  color: var(--brand-300);
}

/* ---------- Blockquote / Cite / Q ---------- */

blockquote {
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body-loose);
  color: var(--text-secondary);
  padding-inline-start: var(--space-4);
  border-inline-start: 3px solid var(--brand-500);
  font-style: italic;
  max-width: 65ch;
}

blockquote p {
  color: inherit;
}

cite {
  display: block;
  font-size: var(--fs-body-sm);
  font-style: normal;
  color: var(--text-tertiary);
  margin-block-start: var(--space-2);
}

cite::before {
  content: '— ';
}

q {
  font-style: italic;
}

q::before {
  content: '«';
}
q::after {
  content: '»';
}

/* ---------- Inline Emphasis & Marks ---------- */

strong,
b {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

em,
i {
  font-style: italic;
}

mark {
  background-color: oklch(72% 0.155 210 / 0.25);
  color: var(--text-primary);
  padding: 0 0.15em;
  border-radius: var(--radius-xs);
}

[data-theme='dark'] mark {
  background-color: oklch(72% 0.155 210 / 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) mark {
    background-color: oklch(72% 0.155 210 / 0.35);
  }
}

del,
s {
  text-decoration-color: var(--danger-500);
  text-decoration-thickness: 2px;
  color: var(--text-tertiary);
}

ins,
u {
  text-decoration-color: var(--success-500);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

small {
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}

sub,
sup {
  font-size: 0.75em;
  line-height: 1;
  vertical-align: baseline;
  position: relative;
}

sup {
  top: -0.5em;
}
sub {
  bottom: -0.25em;
}

/* ---------- Abbreviations / Definitions ---------- */

abbr[title] {
  text-decoration: underline dotted var(--text-tertiary);
  text-underline-offset: 0.2em;
  cursor: help;
}

dfn {
  font-style: italic;
  font-weight: var(--fw-medium);
}

/* ---------- Horizontal Rule ---------- */

hr {
  border: 0;
  height: 1px;
  background-color: var(--border-subtle);
  margin-block: var(--space-6);
}

/* ---------- Address ---------- */

address {
  font-style: normal;
  color: var(--text-secondary);
  line-height: var(--lh-body);
}

/* ---------- Figure / Caption ---------- */

figure {
  margin: 0;
}

figcaption {
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
  line-height: var(--lh-body-tight);
  margin-block-start: var(--space-2);
}

/* ---------- Selection ---------- */

::selection {
  background-color: oklch(52% 0.22 270 / 0.25);
  color: var(--text-primary);
}

[data-theme='dark'] ::selection {
  background-color: oklch(68% 0.165 270 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) ::selection {
    background-color: oklch(68% 0.165 270 / 0.4);
  }
}

/* ---------- Details / Summary (Disclosure) ---------- */

details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

details + details {
  margin-block-start: var(--space-2);
}

summary {
  cursor: pointer;
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '+';
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  color: var(--brand-500);
  width: 1em;
  text-align: center;
  transition: transform var(--dur-fast) var(--ease-out);
}

details[open] > summary::before {
  content: '−';
}

details > *:not(summary) {
  margin-block-start: var(--space-3);
  color: var(--text-secondary);
}

/* ---------- Selection-Reset für Code ---------- */

code::selection,
pre::selection,
kbd::selection {
  background-color: oklch(52% 0.22 270 / 0.3);
}
