/* ============================================================
   Klasa w chmurze: base: reset, typography roles, links, focus, a11y
   ============================================================ */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--surface-paper);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--accent);
  color: var(--surface-paper);
}

/* ---- Typography roles ---- */

.t-display-xl {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 0.9rem + 6.2vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  max-width: 14ch;
  font-variant-numeric: lining-nums tabular-nums;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.t-display-l {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 0.95rem + 4.6vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.015em;
  max-width: 18ch;
  font-variant-numeric: lining-nums tabular-nums;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.t-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.625rem, 1.25rem + 1.6vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  max-width: 26ch;
  text-wrap: balance;
}

.t-subheading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.25;
  max-width: 34ch;
}

.t-lead {
  font-size: clamp(1.1875rem, 1.1rem + 0.4vw, 1.3125rem);
  line-height: 1.55;
  max-width: 60ch;
  color: var(--text-secondary);
}

.t-body,
p {
  max-width: var(--measure);
}

.t-spec {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.8125rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.t-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.6875rem;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.t-label-s {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.625rem;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--accent-hover);
}

a:active {
  color: var(--accent-active);
}

/* ---- Focus ---- */

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

/* ---- Skip link ---- */

.u-skip {
  position: absolute;
  left: var(--space-16);
  top: var(--space-16);
  z-index: var(--z-skip);
  padding: var(--space-8) var(--space-16);
  background: var(--surface-graphite);
  color: var(--text-inverse);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-decoration: none;
  transform: translateY(-200%);
}

.u-skip:focus-visible {
  transform: none;
  color: var(--text-inverse);
}

/* ---- Code ---- */

code,
kbd,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--surface-technical);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-1);
}

pre {
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}

hr {
  border: 0;
  border-top: var(--stroke-hair) solid var(--line-subtle);
  margin-block: var(--space-48);
}

/* ---- Helpers ---- */

.u-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.u-accent {
  color: var(--accent);
}

/* ---- Reveal (fail-safe: base state is visible; the animation
        starts only once .is-inview lands, so content can never
        be stuck hidden if JS or IntersectionObserver fails) ---- */

@media (prefers-reduced-motion: no-preference) {
  .js .u-reveal.is-inview {
    animation: u-reveal-in var(--dur-slow) var(--ease) backwards;
  }

  /* Long-form pages keep text and panels stable while scrolling.
     Case-study diagrams retain their dedicated draw-in animation. */
  .js .page-home .u-reveal.is-inview,
  .js .page-case-studies .u-reveal.is-inview,
  .js .page-personal .u-reveal.is-inview {
    animation: none;
  }

  @keyframes u-reveal-in {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
  }
}
