/* michalkomar.com — design tokens, layout, and components. No framework. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 400 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ── tokens ─────────────────────────────────────────────────────────── */
:root {
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Newsreader", Georgia, "Times New Roman", serif;

  --ground: #f4f5f7;
  --ground-2: #ffffff;
  --line: #d3d7de;
  --line-soft: #e3e6eb;
  --ink: #111318;
  --ink-body: #2a2f37;
  --ink-2: #5b6370;
  --ink-3: #8a919c;
  --accent: #111318;
  --accent-ink: #f4f5f7;
  --accent-soft: rgba(17, 19, 24, 0.07);
  --selection: rgba(17, 19, 24, 0.16);
  --panel: rgba(244, 245, 247, 0.86);
  --scene-dot: 58, 65, 75;
  --scene-node: 17, 19, 24;
  --scene-blend: normal;

  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --measure: 62ch;
  --radius: 0.375rem;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --ground: #121417;
  --ground-2: #1b1e23;
  --line: #2e333b;
  --line-soft: #23272e;
  --ink: #e8eaed;
  --ink-body: #c9cdd3;
  --ink-2: #a0a7b1;
  --ink-3: #6f7680;
  --accent: #e8eaed;
  --accent-ink: #121417;
  --accent-soft: rgba(232, 234, 237, 0.08);
  --selection: rgba(232, 234, 237, 0.22);
  --panel: rgba(18, 20, 23, 0.82);
  --scene-dot: 201, 205, 211;
  --scene-node: 255, 255, 255;
  --scene-blend: additive;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121417;
    --ground-2: #1b1e23;
    --line: #2e333b;
    --line-soft: #23272e;
    --ink: #e8eaed;
    --ink-body: #c9cdd3;
    --ink-2: #a0a7b1;
    --ink-3: #6f7680;
    --accent: #e8eaed;
    --accent-ink: #121417;
    --accent-soft: rgba(232, 234, 237, 0.08);
    --selection: rgba(232, 234, 237, 0.22);
    --panel: rgba(18, 20, 23, 0.82);
    --scene-dot: 201, 205, 211;
    --scene-node: 255, 255, 255;
    --scene-blend: additive;
    color-scheme: dark;
  }
}

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

html {
  background: var(--ground);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ground);
  color: var(--ink-body);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection { background: var(--selection); }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-optical-sizing: auto;
  margin: 0;
  color: var(--ink);
}

p { margin: 0; }
strong { font-weight: 600; }

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

.skip {
  position: absolute;
  left: var(--gutter);
  top: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--display);
  font-weight: 600;
  border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip:focus-visible { transform: none; }

/* ── scene (fixed behind the story) ─────────────────────────────────── */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--ground) 26%, transparent 64%);
  opacity: 0.88;
}
@media (max-width: 900px) {
  .scene::before {
    background: linear-gradient(to bottom, var(--ground) 0%, var(--ground) 11%, transparent 24%, transparent 84%, var(--ground) 100%);
    opacity: 0.96;
  }
}

.top, main, .foot { position: relative; z-index: 1; }

/* ── header ─────────────────────────────────────────────────────────── */
.top {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 1.25rem var(--gutter);
  font-family: var(--display);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.mark svg { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.35rem;
  margin-left: auto;
}
.nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.98rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
}
.nav a:hover { border-bottom-color: var(--accent); }

.theme {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.theme-label { color: var(--ink-2); }
.theme-value { font-weight: 600; }
.theme:hover { border-color: var(--accent); }

@media (max-width: 720px) {
  .nav { order: 3; flex-basis: 100%; margin-left: 0; gap: 1.1rem; overflow-x: auto; scrollbar-width: none; }
  .theme { margin-left: auto; }
}

/* ── hero ───────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 7.5rem var(--gutter) 2rem;
}

.hero-inner {
  align-self: end;
  max-width: 46rem;
}

.hero-title { display: grid; gap: 1rem; }

.hero-name {
  display: block;
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

.hero-claim {
  display: block;
  font-size: clamp(2.5rem, 7.4vw, 6.75rem);
  font-weight: 700;
  font-stretch: 90%;
  line-height: 0.96;
  letter-spacing: -0.035em;
  margin-left: -0.03em;
  text-wrap: balance;
}
.line-wrap { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.line { display: inline-block; }

.hero-lead {
  max-width: 36rem;
  margin-top: 1.75rem;
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem);
  line-height: 1.45;
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.9rem;
  padding: 0.55rem 1.15rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.button:hover { background: var(--accent-soft); }
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.button-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

.hero-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.definition {
  max-width: 38rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
}
.definition-term {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
  margin-right: 0.35em;
}

.pause {
  flex: none;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-family: var(--display);
  font-size: 0.85rem;
  cursor: pointer;
}
.pause:hover { color: var(--ink); border-color: var(--accent); }

@media (max-width: 720px) {
  .hero { padding-top: 8.5rem; }
  .hero-foot { flex-direction: column; align-items: flex-start; gap: 1rem; }
}

/* One orchestrated entrance. Only when motion is welcome. */
@media (prefers-reduced-motion: no-preference) {
  .hero .line { transform: translateY(110%); animation: line-up 720ms var(--ease-out) forwards; }
  .hero-name .line { animation-delay: 60ms; }
  .hero-claim .line-wrap:nth-child(1) .line { animation-delay: 160ms; }
  .hero-claim .line-wrap:nth-child(2) .line { animation-delay: 250ms; }
  .hero-claim .line-wrap:nth-child(3) .line { animation-delay: 340ms; }
  .hero-lead, .hero-actions, .hero-foot { opacity: 0; animation: fade-up 640ms var(--ease-out) forwards; }
  .hero-lead { animation-delay: 560ms; }
  .hero-actions { animation-delay: 660ms; }
  .hero-foot { animation-delay: 820ms; }
}
@keyframes line-up { to { transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(0.75rem); } to { opacity: 1; transform: none; } }

/* ── proof: the scrollytelling chapters ─────────────────────────────── */
.proof {
  padding: 4rem var(--gutter) 6rem;
}

.proof-title {
  min-height: 56svh;
  display: grid;
  align-content: center;
  max-width: 14ch;
  font-size: clamp(2.4rem, 1.4rem + 4.4vw, 5.75rem);
  font-weight: 700;
  font-stretch: 92%;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
  text-shadow: 0 0 20px var(--ground), 0 0 8px var(--ground);
}

.chapter {
  min-height: 86svh;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "copy figure";
  align-items: center;
  gap: 2rem var(--gutter);
  padding: 2rem 0;
}
.chapter-copy { grid-area: copy; max-width: 34rem; }
.figure { grid-area: figure; justify-self: end; text-align: right; display: grid; gap: 0.5rem; margin: 0; }

.figure-number {
  font-family: var(--display);
  font-size: clamp(4.5rem, 2rem + 9vw, 11rem);
  font-weight: 800;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--accent);
  text-shadow: 0 0 18px var(--ground), 0 0 6px var(--ground);
}
.figure-word {
  font-family: var(--display);
  font-size: clamp(3rem, 1.4rem + 6vw, 7.5rem);
  font-weight: 800;
  font-stretch: 78%;
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-shadow: 0 0 18px var(--ground), 0 0 6px var(--ground);
}
.figure-label {
  text-shadow: 0 0 14px var(--ground), 0 0 5px var(--ground), 0 0 2px var(--ground);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-2);
  max-width: 18rem;
  justify-self: end;
}

.chapter h3 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 1rem;
  text-wrap: balance;
}
.chapter p { text-wrap: pretty; }

.sources {
  max-width: 40rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .chapter {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "figure" "copy";
    gap: 1.25rem;
    padding: 3rem 0;
  }
  .figure { justify-self: start; text-align: left; }
  .figure-label { justify-self: start; }
  .chapter-copy {
    padding: 1.25rem 1.25rem 1.25rem 1.1rem;
    border-left: 2px solid var(--accent);
    background: var(--panel);
  }
}

/* Scroll-driven reveals, native and off the main thread. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .chapter-copy, .figure, .proof-title, .sources {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 8% entry 42%;
    }
  }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(2rem); }
  to { opacity: 1; transform: none; }
}

/* ── quiet sections after the story ─────────────────────────────────── */
.section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem var(--gutter);
  padding: clamp(3rem, 7vw, 6rem) var(--gutter);
  border-top: 1px solid var(--line-soft);
  background: var(--ground);
}
@media (min-width: 900px) {
  .section { grid-template-columns: minmax(0, 5fr) minmax(0, 8fr); }
  .section-head { position: sticky; top: 2rem; align-self: start; }
}

.section h2 {
  font-size: clamp(2rem, 1.5rem + 2.2vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  text-wrap: balance;
}
.section-note {
  max-width: 26rem;
  margin-top: 0.9rem;
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.section-body { max-width: var(--measure); }
.prose { text-wrap: pretty; }
.prose p + p { margin-top: 1.1em; }

/* services */
.services { margin: 0; display: grid; }
.service {
  display: grid;
  gap: 0.35rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line-soft);
}
.service:last-child { border-bottom: 1px solid var(--line-soft); }
.service dt {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.service dd { margin: 0; text-wrap: pretty; }

/* approach */
.creed {
  margin: 0;
  padding: 0;
  font-style: italic;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.creed p::before { content: "\201C"; margin-left: -0.45em; }
.creed p::after { content: "\201D"; }

.principles {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.9rem;
}
.principles li {
  padding-left: 1.25rem;
  border-left: 2px solid var(--accent);
  text-wrap: pretty;
}
.principles strong { font-family: var(--display); font-weight: 600; }
.principles + .prose { margin-top: 2rem; color: var(--ink-2); }

/* path timeline */
.path { margin: 0; padding: 0; list-style: none; display: grid; }
.path li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line-soft);
}
.path li:last-child { border-bottom: 1px solid var(--line-soft); }
.path-when {
  font-family: var(--display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.path-what { text-wrap: pretty; }
@media (max-width: 480px) {
  .path li { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* projects */
.projects { margin: 0; padding: 0; list-style: none; display: grid; }
.project {
  display: grid;
  gap: 0.5rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--line-soft);
}
.project:last-child { border-bottom: 1px solid var(--line-soft); }
.project h3 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.015em; }
.project p { text-wrap: pretty; }
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-family: var(--display);
  font-size: 0.98rem;
}

/* faq */
.faq { display: grid; }
.faq details { border-top: 1px solid var(--line-soft); }
.faq details:last-child { border-bottom: 1px solid var(--line-soft); }
.faq summary {
  cursor: pointer;
  padding: 1rem 2.25rem 1rem 0;
  position: relative;
  list-style: none;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute;
  right: 0.35rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 160ms ease;
}
.faq details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq summary:hover { color: var(--accent); }
.faq details p { padding: 0 0 1.25rem; max-width: var(--measure); text-wrap: pretty; }

/* contact */
.contact-lead {
  font-family: var(--display);
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}
.contact .prose { margin-top: 1.25rem; color: var(--ink-2); }
.contact-links {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.contact-links a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 2.9rem;
  padding: 0.55rem 1.15rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 600;
  text-decoration: none;
}
.contact-links a:hover { background: var(--accent-soft); border-color: var(--accent); }
.contact-hint { font-weight: 400; font-size: 0.85rem; color: var(--ink-2); }

/* footer */
.foot {
  padding: 2.5rem var(--gutter) 3rem;
  display: grid;
  gap: 0.5rem;
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--ground);
  border-top: 1px solid var(--line-soft);
}
.foot p { max-width: var(--measure); text-wrap: pretty; }

/* ── motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── print ──────────────────────────────────────────────────────────── */
@media print {
  .top, .scene, .pause, .hero-actions, .skip { display: none !important; }
  .hero, .chapter { min-height: auto; }
  .hero { padding-top: 1rem; }
  body { color: #000; background: #fff; }
  a { color: #000; }
  .section-head { position: static; }
  .figure-number, .figure-word { color: #000; }
}
