/* =============================================================================
   Netopyr GmbH — Michael Heinrichs
   Single hand-written stylesheet. Palette A "Editorial Slate" + IBM Plex.
   No framework, no reset library, no third-party anything.
   Hierarchy comes from size / weight / whitespace / register-switch
   (serif -> sans -> mono), not colour or decorative rules.
   ============================================================================= */

/* ---- Design tokens (Visual-System brief, verbatim) ------------------------ */
:root {
  /* Palette A "Editorial Slate" — LIGHT (default) */
  --color-bg: #fbfaf8;
  --color-surface: #f3f1ec;
  --color-text: #1a1a1a; /* 16.7:1 on bg — AAA */
  --color-muted: #5a5a5a; /* 6.6:1 — AA */
  --color-accent: #9a3412; /* 7.0:1 — AA text + UI */
  --color-border: #e2ded7;
  --color-focus: var(--color-accent);

  /* Type families (all self-hosted, SIL OFL 1.1) */
  --font-serif:
    "IBM Plex Serif", "Plex Serif Fallback", Georgia, "Times New Roman", serif;
  --font-sans:
    "IBM Plex Sans", "Plex Sans Fallback", system-ui, -apple-system, "Segoe UI",
    sans-serif;
  --font-mono:
    "IBM Plex Mono", ui-monospace, SFMono-Regular, "Cascadia Mono", monospace;

  /* Modular type scale (1.25, 18px base) */
  --step--1: 0.833rem;
  --step-0: 1.125rem; /* body */
  --step-1: 1.5rem; /* h3 */
  --step-2: 1.75rem; /* h2 */
  --step-3: clamp(2.25rem, 1.6rem + 2.6vw, 3rem); /* h1 / name */
  --quote: clamp(1.75rem, 1.3rem + 1.6vw, 2.25rem);
  --measure: 66ch;
  --leading-body: 1.6;
  --leading-head: 1.2;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Motion */
  --dur-micro: 120ms;
  --dur-base: 180ms;
  --dur-max: 240ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* Dark tokens: applied when the OS prefers dark (unless the user forced light),
   and always when the JS toggle sets data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #14161a;
    --color-surface: #1e2127;
    --color-text: #e8e6e1; /* 14.5:1 — AAA */
    --color-muted: #9ba1a8; /* 7.0:1 — AA */
    --color-accent: #e2935f; /* 7.4:1 — AA text + UI */
    --color-border: #2a2e36;
  }
}
:root[data-theme="dark"] {
  --color-bg: #14161a;
  --color-surface: #1e2127;
  --color-text: #e8e6e1;
  --color-muted: #9ba1a8;
  --color-accent: #e2935f;
  --color-border: #2a2e36;
}

/* ---- Fonts ---------------------------------------------------------------- */
/* Real faces (subset WOFF2, Latin + the German glyphs and typographic marks the
   copy uses). font-display: swap so text is never invisible. */
@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/plex-serif-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/plex-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/plex-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/plex-mono-400.woff2") format("woff2");
}

/* Metric-matched fallbacks so the swap causes ~0 CLS. Derived from the real Plex
   metrics (upm 1000, ascent 1025, descent -275, x-height 516) against the
   fallback's x-height: size-adjust aligns x-height, the *-override values then
   reproduce Plex's line box on top of the adjusted em. */
@font-face {
  font-family: "Plex Serif Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 107.3%; /* 0.516 / Georgia 0.481 */
  ascent-override: 95.5%; /* 102.5% / 1.073 */
  descent-override: 25.6%; /* 27.5% / 1.073 */
  line-gap-override: 0%;
}
@font-face {
  font-family: "Plex Sans Fallback";
  src: local("Arial"), local("Helvetica Neue");
  size-adjust: 99.5%; /* 0.516 / Arial 0.519 */
  ascent-override: 103%; /* 102.5% / 0.995 */
  descent-override: 27.6%; /* 27.5% / 0.995 */
  line-gap-override: 0%;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-feature-settings:
    "kern" 1,
    "liga" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  /* Let long tokens (URLs, long German compounds) break rather than overflow at
     narrow widths — inherited, so it protects every text block including headings. */
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--font-sans);
  line-height: var(--leading-head);
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color var(--dur-micro) var(--ease);
}
a:hover {
  text-decoration-thickness: 2px;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

strong,
b {
  font-family: var(--font-sans);
  font-weight: 600;
}

/* Visible focus ring — >=2px, accent, never removed (WCAG 2.4.7 / 1.4.11). */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Skip link ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 10;
  background: var(--color-bg);
  color: var(--color-accent);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--color-accent);
  border-radius: 4px;
  text-decoration: none;
  transition: top var(--dur-base) var(--ease);
}
.skip-link:focus {
  top: var(--space-4);
}

/* ---- Layout frame --------------------------------------------------------- */
.site-header,
main > section,
.site-footer {
  width: 100%;
  max-width: 44rem; /* outer frame; text is further constrained to --measure */
  margin-inline: auto;
  padding-inline: var(--space-6);
}

main > section {
  padding-block: var(--space-12);
}

/* Constrain running text to a comfortable measure. */
.measure {
  max-width: var(--measure);
}

/* ---- Header --------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-6);
  min-height: 4.5rem;
}

.wordmark {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--step-1);
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}
.wordmark:hover {
  color: var(--color-accent);
}

/* Reserve the toggle's footprint so JS injection causes no layout shift. */
.theme-toggle-slot {
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.theme-toggle {
  inline-size: 2.75rem; /* 44px target */
  block-size: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition:
    color var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}
.theme-toggle:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.theme-toggle svg {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Hero ----------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-8);
  align-items: start;
  padding-top: var(--space-8);
}
.hero__portrait {
  inline-size: 120px;
  block-size: 150px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--color-surface);
  filter: grayscale(1);
}
.hero__intro {
  max-width: var(--measure);
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--step-3);
  letter-spacing: -0.015em;
  margin-bottom: var(--space-2);
}
.hero__lead {
  font-family: var(--font-serif);
  font-size: var(--quote);
  line-height: 1.25;
  margin-bottom: var(--space-6);
  text-wrap: balance;
}
.hero__subhead {
  color: var(--color-text);
  margin-bottom: var(--space-6);
}
.hero__cta {
  font-family: var(--font-sans);
  font-weight: 600;
}
.hero__cta a {
  text-decoration: none;
}
.hero__cta a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.hero__cta a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.arrow {
  inline-size: 1.1em;
  block-size: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur-base) var(--ease);
}
.hero__cta a:hover .arrow {
  transform: translateX(2px);
}

@media (max-width: 34rem) {
  .hero {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

/* ---- Credibility strip ---------------------------------------------------- */
.credibility {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--color-muted);
  border-block: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  justify-content: space-between;
}
.credibility p {
  margin: 0;
}
.cred__label {
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  margin-right: var(--space-2);
}

/* ---- Thesis pull-quote (the visual climax; most whitespace) --------------- */
.thesis {
  padding-block: var(--space-24);
}
.thesis figure {
  margin: 0;
  max-width: 40ch;
  margin-inline: auto;
  text-align: center;
}
.thesis blockquote {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--quote);
  line-height: 1.3;
  text-wrap: balance;
}
.thesis figcaption {
  margin-top: var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--color-muted);
}

/* ---- Section heading pattern ---------------------------------------------- */
.section-title {
  font-size: var(--step-2);
  margin-bottom: var(--space-8);
}
.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

/* ---- "The kind of work I do best" ----------------------------------------- */
.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-8);
  max-width: var(--measure);
}
.work-list h3 {
  font-size: var(--step-1);
  margin-bottom: var(--space-2);
}
.work-list p {
  margin: 0;
}

/* ---- Selected work -------------------------------------------------------- */
.selected {
  display: grid;
  gap: var(--space-16);
  max-width: var(--measure);
}
.piece h3 {
  font-size: var(--step-1);
  margin-bottom: var(--space-4);
}
.piece p {
  margin-bottom: var(--space-4);
}
.piece p:last-child {
  margin-bottom: 0;
}
.piece__link {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  word-break: break-word;
}

/* ---- About / Availability prose ------------------------------------------- */
.prose {
  max-width: var(--measure);
  display: grid;
  gap: var(--space-4);
}

/* ---- Contact -------------------------------------------------------------- */
.contact__grid {
  max-width: var(--measure);
  display: grid;
  gap: var(--space-6);
}
.contact address {
  font-style: normal;
  font-family: var(--font-sans);
  line-height: 1.6;
}
.contact address strong {
  font-weight: 600;
}
.contact__methods {
  display: grid;
  gap: var(--space-2);
  font-family: var(--font-sans);
}
/* Email + phone controls are >=44px tall touch targets. */
.email,
.contact__phone a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-size: var(--step-1);
  font-weight: 600;
  text-decoration: none;
}
.email:hover,
.contact__phone a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.contact__phone a {
  font-weight: 400;
  font-size: var(--step-0);
  color: var(--color-text);
}
.contact noscript {
  font-family: var(--font-mono);
  font-size: var(--step-0);
}

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-12);
  margin-top: var(--space-16);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--color-muted);
}
.footer-nav ul {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
}
.footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
}
.footer-legal {
  margin: 0 0 var(--space-3);
  max-width: var(--measure);
}
.footer-legal:last-child {
  margin-bottom: 0;
}

/* ---- Legal / long-form markdown pages ------------------------------------- */
main.legal {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--space-6);
  padding-block: var(--space-16);
  /* Long German compounds (Datenschutzerklärung, Verbraucherstreitbeilegung)
     hyphenate cleanly here; overflow-wrap is the last-resort backstop. */
  hyphens: auto;
  -webkit-hyphens: auto;
}
.legal h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.5rem);
  margin-bottom: var(--space-8);
}
.legal h2 {
  font-size: var(--step-1);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}
.legal h3 {
  font-size: var(--step-0);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}
.legal p,
.legal li {
  margin-bottom: var(--space-3);
}
.legal ul {
  padding-left: var(--space-6);
}
.legal em {
  color: var(--color-muted);
}
.legal a {
  word-break: break-word;
}

/* ---- Motion kill-switch (Visual-System brief, verbatim) ------------------- */
@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;
  }
}
