/* =========================================================
   Michał Zaniewicz — editorial portfolio
   Pure CSS · light/dark · warm paper + ink + electric accent
   ========================================================= */

:root {
  --paper:      #f3efe6;
  --paper-2:    #ece7db;
  --ink:        #16140f;
  --ink-soft:   #4a463d;
  --ink-mute:   #8a8474;
  --line:       rgba(22, 20, 15, 0.14);
  --line-soft:  rgba(22, 20, 15, 0.08);
  --accent:     #2440ff;
  --accent-ink: #1b2fcf;
  --card:       #f8f5ee;
  --shadow:     rgba(22, 20, 15, 0.10);

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-sans:    "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --maxw: 1280px;
  --pad: clamp(20px, 5vw, 80px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --paper:      #0e0d0b;
  --paper-2:    #151310;
  --ink:        #f3efe6;
  --ink-soft:   #c3bdaf;
  --ink-mute:   #7b7567;
  --line:       rgba(243, 239, 230, 0.16);
  --line-soft:  rgba(243, 239, 230, 0.08);
  --accent:     #6f82ff;
  --accent-ink: #8a99ff;
  --card:       #16140f;
  --shadow:     rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

@media (max-width: 600px) { body { font-size: 16px; } }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
em { font-style: italic; }

/* Better line breaking */
h1, h2, h3, .hero__title, .section__title, .contact__title,
.about__lead, .card__title, .job__role, .stat__label { text-wrap: balance; }
p, .hero__tagline, .about__body p, .card__text, .contact__sub { text-wrap: pretty; }

::selection { background: var(--accent); color: #fff; }

/* ---------- Grain ---------- */
.grain {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  opacity: 0.04; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: 0.05; }

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 9999;
  background: transparent; pointer-events: none;
}
.scroll-progress span {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* ---------- Custom cursor ---------- */
.cursor {
  position: fixed; top: 0; left: 0; z-index: 9997;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); pointer-events: none;
  transform: translate(-50%, -50%);
  transition: width 0.25s var(--ease), height 0.25s var(--ease),
              background 0.25s var(--ease), opacity 0.25s var(--ease);
  mix-blend-mode: difference; opacity: 0;
}
.cursor.is-hover { width: 46px; height: 46px; background: #fff; }
.cursor.is-active { opacity: 1; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* =========================================================
   NAV
   ========================================================= */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  padding: 18px var(--pad);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.4s var(--ease), padding 0.4s var(--ease),
              background 0.4s var(--ease);
}
.nav.is-scrolled { border-color: var(--line-soft); padding-top: 12px; padding-bottom: 12px; }

.nav__brand { display: flex; align-items: center; gap: 12px; }
.nav__mono {
  font-family: var(--font-mono); font-weight: 500; font-size: 13px;
  border: 1px solid var(--line); border-radius: 7px;
  width: 30px; height: 30px; display: grid; place-items: center;
  letter-spacing: 0.04em;
}
.nav__name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

.nav__links { display: flex; gap: 28px; }
.nav__link {
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.02em;
  color: var(--ink-soft); position: relative; padding: 4px 0;
  transition: color 0.25s var(--ease);
}
.nav__link span { color: var(--ink-mute); margin-right: 5px; font-size: 10.5px; }
.nav__link::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -1px; height: 1px;
  background: var(--accent); transition: right 0.35s var(--ease);
}
.nav__link:hover { color: var(--ink); }
.nav__link:hover::after { right: 0; }

.nav__meta { display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--ink); cursor: pointer; transition: border-color 0.25s, color 0.25s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: block; }

@media (max-width: 860px) {
  .nav__links { display: none; }
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
  position: relative; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 140px var(--pad) 80px;
  overflow: hidden;
}
.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero__inner { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; width: 100%; }

.hero__status {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.02em;
  color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 7px 16px 7px 13px; margin-bottom: 38px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  70% { box-shadow: 0 0 0 9px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(54px, 12.5vw, 184px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  margin-bottom: 30px;
}
.hero__title .line { display: block; overflow: hidden; }
.hero__title .line:last-child { color: var(--ink-mute); font-weight: 500; }
.reveal-text {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1s var(--ease);
}
.loaded .reveal-text { transform: translateY(0); }
.loaded .line:last-child .reveal-text { transition-delay: 0.12s; }

.hero__role {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px;
  font-family: var(--font-mono); font-size: clamp(14px, 2.2vw, 19px);
  letter-spacing: 0.01em; margin-bottom: 28px;
}
.hero__role-main { color: var(--ink); font-weight: 500; }
.hero__role-sep { color: var(--accent); }
.hero__role-co {
  color: var(--ink-soft); position: relative; transition: color 0.25s var(--ease);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size 0.35s var(--ease), color 0.25s var(--ease);
}
.hero__role-co:hover { color: var(--ink); background-size: 100% 1px; }

/* Inline link */
.link {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat;
  padding-bottom: 1px; transition: background-size 0.3s var(--ease), color 0.25s var(--ease);
}
.link:hover { color: var(--accent); background-size: 100% 2px; }

.hero__tagline {
  max-width: 620px; font-size: clamp(17px, 2.1vw, 21px);
  line-height: 1.55; color: var(--ink-soft); margin-bottom: 44px;
}
.hero__tagline em { color: var(--ink); font-style: normal; font-family: var(--font-display); font-weight: 600; }

.hero__cta { display: flex; flex-wrap: wrap; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 500; letter-spacing: 0.01em;
  padding: 14px 26px; border-radius: 100px;
  border: 1px solid var(--line);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease),
              color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.btn svg { transition: transform 0.3s var(--ease); }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: translateY(-2px); }
.btn--primary:hover svg { transform: translateX(4px); }
.btn--ghost:hover { border-color: var(--ink); transform: translateY(-2px); }

.hero__scroll {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-mute);
}
.hero__scroll svg { animation: bob 2s var(--ease) infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@media (max-width: 600px) { .hero__scroll { display: none; } }

/* =========================================================
   MARQUEE
   ========================================================= */
.marquee {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 20px 0; overflow: hidden; background: var(--paper-2);
  white-space: nowrap;
}
.marquee__track {
  display: inline-flex; align-items: center; gap: 30px;
  animation: marquee 38s linear infinite; will-change: transform;
}
.marquee__track span {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(18px, 2.7vw, 30px); color: var(--ink-soft);
  letter-spacing: -0.02em;
}
.marquee__track .sep { color: var(--accent); font-size: 14px; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.marquee:hover .marquee__track { animation-play-state: paused; }

/* =========================================================
   SECTIONS
   ========================================================= */
.section {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(80px, 12vw, 160px) var(--pad);
}
.section__head { margin-bottom: 56px; }
.kicker {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-mute);
}
.kicker__num { color: var(--accent); }
.section__title {
  font-family: var(--font-display); font-weight: 360;
  font-size: clamp(34px, 6vw, 72px); line-height: 1.0;
  letter-spacing: -0.03em; margin-top: 18px;
}

/* ---------- About ---------- */
.about__grid {
  display: grid; grid-template-columns: 0.85fr 1.15fr; gap: clamp(40px, 6vw, 90px);
  align-items: start;
}
.about__portrait {
  position: relative; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: 0 30px 70px -40px var(--shadow);
}
.about__portrait img {
  width: 100%; height: auto; aspect-ratio: 4/5; object-fit: cover;
  filter: grayscale(1) contrast(1.04);
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
}
.about__portrait:hover img { transform: scale(1.04); }
.about__portrait-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between;
  padding: 14px 16px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  color: #f3efe6;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
}
.about__lead {
  font-family: var(--font-display); font-weight: 380;
  font-size: clamp(24px, 3.6vw, 40px); line-height: 1.18;
  letter-spacing: -0.02em; margin-bottom: 34px;
}
.about__body p { color: var(--ink-soft); margin-bottom: 18px; max-width: 56ch; }
.about__body strong { color: var(--ink); font-weight: 600; }

@media (max-width: 820px) {
  .about__grid { grid-template-columns: 1fr; }
  .about__portrait { max-width: 360px; }
}

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 30px; margin-top: clamp(56px, 8vw, 96px);
  border-top: 1px solid var(--line); padding-top: 50px;
}
.stat { display: flex; flex-direction: column; gap: 10px; }
.stat__num {
  font-family: var(--font-display); font-weight: 340;
  font-size: clamp(48px, 8vw, 92px); line-height: 1;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
}
.stat__label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.03em;
  color: var(--ink-mute); max-width: 22ch;
}
@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr; gap: 36px; }
}

/* ---------- Cards / Focus ---------- */
.cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden;
}
.card {
  background: var(--card); padding: clamp(28px, 4vw, 48px);
  position: relative; transition: background 0.4s var(--ease);
  min-height: 240px; display: flex; flex-direction: column;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; width: 0; height: 2px;
  background: var(--accent); transition: width 0.5s var(--ease);
}
.card:hover { background: var(--paper-2); }
.card:hover::before { width: 100%; }
.card__num {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  letter-spacing: 0.05em; margin-bottom: auto;
}
.card__title {
  font-family: var(--font-display); font-weight: 420;
  font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -0.02em;
  margin: 30px 0 14px;
}
.card__text { color: var(--ink-soft); font-size: 15.5px; line-height: 1.6; }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.contact__inner { max-width: 900px; }
.contact__title {
  font-family: var(--font-display); font-weight: 360;
  font-size: clamp(38px, 7vw, 92px); line-height: 1.02;
  letter-spacing: -0.035em;
}
.contact__title em { color: var(--accent); font-style: normal; }
.contact__sub { margin-top: 26px; font-size: clamp(16px, 2vw, 20px); color: var(--ink-soft); max-width: 52ch; text-wrap: balance; }
.nowrap { white-space: nowrap; }
.contact__links {
  margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}
.contact__link {
  background: var(--card); padding: 28px 30px;
  display: flex; flex-direction: column; gap: 8px;
  transition: background 0.35s var(--ease);
}
.contact__link:hover { background: var(--paper-2); }
.contact__link-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-mute);
}
.contact__link-val { font-size: clamp(15px, 2vw, 19px); font-weight: 500; word-break: break-word; }
@media (max-width: 620px) { .contact__links { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 36px var(--pad) 48px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.footer__mono {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.03em;
  color: var(--ink-mute);
}
.footer__center { color: var(--ink-soft); }
@media (max-width: 600px) { .footer { justify-content: flex-start; gap: 6px; flex-direction: column; } }

/* =========================================================
   Reveal on scroll
   ========================================================= */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* No-JS / fallback: never hide content */
html:not(.js) .reveal,
html:not(.js) .reveal-text { opacity: 1 !important; transform: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .reveal, .reveal-text { opacity: 1 !important; transform: none !important; }
}
