/* ------------------------------------------------------------------
   Rafał Wilkowski — portfolio
   Plain CSS, no framework. Tokens first, then layout, then components.
   ------------------------------------------------------------------ */

:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-display: var(--font-sans);
  --display-weight: 800;
  --display-tracking: -0.035em;
  --border-w: 1px;
  --card-shadow: none;

  --bg: #0a0d12;
  --bg-2: #0e1219;
  --surface: #12171f;
  --surface-2: #171d27;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8edf2;
  --text-2: #a6b1bd;
  --text-3: #8592a1;
  --focus: var(--accent);
  --accent: #7cf29a;
  --accent-2: #5ee6d0;
  --accent-ink: #062a14;
  --accent-soft: rgba(124, 242, 154, 0.12);
  --glow: rgba(124, 242, 154, 0.18);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);

  --radius: 18px;
  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-2: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #5b6675;
  --accent: #15803d;
  --accent-2: #0d9488;
  --accent-ink: #ffffff;
  --accent-soft: rgba(21, 128, 61, 0.1);
  --glow: rgba(21, 128, 61, 0.14);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  padding: 10px 14px; background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 16px; }

.noscript { padding: 16px var(--gutter); text-align: center; color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px;
  border: var(--border-w) solid var(--border-strong);
  background: var(--surface);
  font-weight: 600; font-size: 15px; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), background .2s, border-color .2s, color .2s;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
@media (prefers-reduced-motion: no-preference) { .btn:hover { transform: translateY(-1px); } .icon-btn:hover { transform: translateY(-1px); } .card:hover { transform: translateY(-2px); } }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { color: var(--accent-ink); filter: brightness(1.05); }
.btn--sm { padding: 9px 14px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }

.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  border-radius: 999px; border: var(--border-w) solid var(--border-strong); background: var(--surface);
  cursor: pointer; transition: border-color .2s, transform .2s var(--ease);
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.nav__brand { font-family: var(--font-mono); font-weight: 500; font-size: 18px; letter-spacing: 0.02em; }
.nav__dot { color: var(--accent); }
.nav__links { display: flex; gap: 4px; margin-inline: auto; }
.nav__links a {
  padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-2);
  transition: color .2s, background .2s;
}
.nav__links a:hover, .nav__links a.is-active { color: var(--text); background: var(--surface-2); }
.nav__actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
@media (max-width: 860px) {
  .nav__inner { flex-wrap: wrap; height: auto; padding: 10px 0 0; row-gap: 6px; }
  .nav__links { order: 3; width: calc(100% + 2 * var(--gutter)); margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav__links::-webkit-scrollbar { display: none; }
  .nav__links a { white-space: nowrap; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(48px, 8vw, 96px) 0 clamp(32px, 5vw, 64px); overflow: hidden; }
.hero__bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 80% 10%, var(--glow), transparent 70%),
    radial-gradient(40% 40% at 10% 90%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%);
}
.hero__bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 30%, #000 30%, transparent 100%);
  mask-image: radial-gradient(70% 70% at 50% 30%, #000 30%, transparent 100%);
  opacity: .5;
}
.hero__grid {
  position: relative;
  display: grid; grid-template-columns: 1.25fr .85fr; gap: clamp(32px, 6vw, 80px); align-items: center;
}
.hero__text { max-width: 640px; }

.status {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  margin-bottom: 24px;
}
.status__dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s infinite;
}
.status__sep, .status__mode { color: var(--text-2); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .status__dot { animation: none; } }

.hero__name { font-size: clamp(40px, 6.5vw, 76px); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1; }
.hero__headline { margin-top: 18px; font-size: clamp(20px, 2.6vw, 28px); font-weight: 600; letter-spacing: -0.015em; }
.hero__headline .hl { color: var(--accent); }
.hero__tagline { margin-top: 10px; font-size: 17px; color: var(--text-2); max-width: 54ch; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero__where { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-family: var(--font-mono); font-size: 13.5px; color: var(--text-2); }
.hero__now { margin-top: 16px; font-size: 14.5px; color: var(--text-3); }

.hero__photo { margin: 0; position: relative; justify-self: end; width: min(100%, 380px); }
.hero__photo-frame {
  position: relative; border-radius: 28px; overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
  background: var(--surface);
}
.hero__photo-frame::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 70%, transparent), transparent 45%, color-mix(in srgb, var(--accent-2) 50%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  z-index: 1; pointer-events: none;
}
.hero__photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: clamp(40px, 6vw, 72px);
}
.stat {
  padding: 20px 22px; border-radius: var(--radius); background: var(--surface); border: var(--border-w) solid var(--border); box-shadow: var(--card-shadow);
}
.stat__value { font-size: clamp(28px, 3.4vw, 38px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat__value small { font-size: .5em; font-weight: 600; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }
.stat__label { margin-top: 8px; font-size: 14px; color: var(--text-2); }

@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__photo { justify-self: start; width: 132px; order: -1; margin-bottom: 8px; }
  .hero__photo-frame { border-radius: 50%; aspect-ratio: 1; box-shadow: none; }
  .stat { padding: 16px 14px; }
  .stat__value { font-size: 26px; }
  .stat__label { font-size: 13px; }
}

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 8vw, 112px) 0; border-top: 1px solid var(--border); }
.section--muted { background: var(--bg-2); }
.section__grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.section__head { position: sticky; top: 88px; }
.section__head--wide { position: static; max-width: 720px; margin-bottom: clamp(28px, 4vw, 44px); }
.section__head h2 { font-size: clamp(26px, 3.2vw, 38px); letter-spacing: -0.025em; }
.section__note { margin-top: 14px; color: var(--text-2); font-size: 15px; max-width: 46ch; }
.eyebrow { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
@media (max-width: 860px) {
  .section__grid { grid-template-columns: 1fr; }
  .section__head { position: static; }
}

.prose p + p { margin-top: 1em; }
.prose { font-size: 18px; color: var(--text-2); }
.prose p:first-child { color: var(--text); font-size: 20px; }
.prose strong { color: var(--text); }

/* ---------- Bento (highlights) ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.card {
  position: relative; padding: 26px; border-radius: var(--radius);
  background: var(--surface); border: var(--border-w) solid var(--border); box-shadow: var(--card-shadow);
  transition: border-color .25s, transform .25s var(--ease), background .25s;
  overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: -40% auto auto -20%; width: 60%; height: 80%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.card:hover { border-color: var(--border-strong); }
.card:hover::after { opacity: 1; }
.bento .card { grid-column: span 2; }
.bento .card:nth-child(1), .bento .card:nth-child(2) { grid-column: span 3; }
.bento .card:nth-child(6) { grid-column: span 6; display: grid; grid-template-columns: auto 1fr; column-gap: 22px; align-items: start; }
.bento .card:nth-child(6) .card__icon { margin: 0; grid-row: 1 / 3; }
.bento .card:nth-child(6) p { grid-column: 2; max-width: 80ch; }
.card__icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 18px;
}
.card__icon svg { width: 20px; height: 20px; }
.card h3 { font-size: 19px; margin-bottom: 8px; }
.card p { color: var(--text-2); font-size: 15.5px; }
@media (max-width: 960px) { .bento .card { grid-column: span 3; } .bento .card:nth-child(6) { grid-column: span 6; } }
@media (max-width: 620px) { .bento .card, .bento .card:nth-child(-n+2), .bento .card:nth-child(6) { grid-column: span 6; } .bento .card:nth-child(6) { display: block; } .bento .card:nth-child(6) .card__icon { margin-bottom: 18px; } }

/* ---------- Timeline ---------- */
.timeline { display: grid; gap: 14px; position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 14px; width: 2px; background: var(--border-strong); border-radius: 2px; }
.job { position: relative; }
.job::before { content: ""; position: absolute; left: -24px; top: 32px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 4px var(--bg); }
.job--current::before { background: var(--accent); }
@media (max-width: 480px) { .timeline { padding-left: 0; } .timeline::before, .job::before { display: none; } }
.job { padding: 26px 28px; border-radius: var(--radius); background: var(--surface); border: var(--border-w) solid var(--border); box-shadow: var(--card-shadow); }
.job__top { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; justify-content: space-between; }
.job__role { font-size: 20px; }
.job__company { color: var(--text-2); font-weight: 500; }
.job__company a:hover { color: var(--accent); }
.job__period { font-family: var(--font-mono); font-size: 13px; color: var(--accent); white-space: nowrap; }
.job__meta { font-weight: 400; color: var(--text-3); }
.job--edu { padding: 18px 28px; }
.job--edu .job__role { font-size: 17px; }
.job__intro { margin-top: 14px; color: var(--text-2); }
.products { margin-top: 14px; display: grid; gap: 6px; }
.product { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 2px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; }
.product__name { font-weight: 600; }
.product__note { color: var(--text-3); font-family: var(--font-mono); font-size: 12.5px; }
.product__links { grid-column: 2; grid-row: 1 / 3; display: inline-flex; gap: 12px; }
@media (max-width: 480px) { .product { grid-template-columns: 1fr; } .product__links { grid-column: 1; grid-row: auto; } }
.product__links a { color: var(--accent); font-weight: 600; font-size: 13.5px; }
.job__bullets { margin-top: 16px; display: grid; gap: 10px; }
.job__bullets li { position: relative; padding-left: 20px; color: var(--text-2); font-size: 15.5px; }
.job__bullets li::before { content: ""; position: absolute; left: 0; top: .62em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); opacity: .8; }
.job--current { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

/* ---------- Skills ---------- */
.skills { display: grid; gap: 22px; }
.skill-group h3 { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 500; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--surface); border: var(--border-w) solid var(--border); box-shadow: var(--card-shadow);
  transition: border-color .2s, color .2s;
}
.chip:hover { border-color: var(--accent); }

/* ---------- Archive (earlier projects) ---------- */
.archive { display: grid; border-top: 1px solid var(--border-strong); }
.archive__row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 64px; gap: 4px 20px; align-items: baseline; padding: 11px 0 12px; border-bottom: 1px solid var(--border); }
.archive__main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.archive__title { font-weight: 600; }
.archive__meta { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-3); }
.archive__role { font-size: 14px; color: var(--text-2); }
.archive__links { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-self: end; }
.archive__links a { font-size: 13.5px; font-weight: 600; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.archive__links a svg { width: 13px; height: 13px; }
@media (max-width: 760px) { .archive__row { grid-template-columns: 1fr; gap: 4px; } .archive__links { justify-self: start; } }

/* ---------- Contact ---------- */
.contact-card {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center;
  padding: clamp(28px, 5vw, 56px); border-radius: 28px;
  background:
    radial-gradient(70% 120% at 100% 0%, var(--glow), transparent 60%),
    var(--surface);
  border: var(--border-w) solid var(--border-strong);
}
:root[data-theme="light"] .contact-card { background: var(--surface-2); }
.contact-card h2 { font-size: clamp(26px, 3.4vw, 40px); letter-spacing: -0.025em; }
.contact-card__text { margin-top: 14px; color: var(--text-2); max-width: 52ch; }
.contact-card__actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.contact-card__actions .btn { justify-content: center; }
.contact-card__email { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); text-align: center; word-break: break-all; }
@media (max-width: 760px) { .contact-card { grid-template-columns: 1fr; } }

@media (pointer: coarse) { .btn--sm { padding: 12px 16px; } .nav__links a { padding: 10px 12px; } }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 28px 0 40px; font-size: 13.5px; color: var(--text-3); }
.footer__inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer a { color: var(--text-2); }
.footer a:hover { color: var(--accent); }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(6px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Print (fallback: printing the portfolio itself) ---------- */
@media print {
  :root { --bg: #fff; --bg-2: #fff; --surface: #fff; --surface-2: #fff; --text: #111; --text-2: #333; --text-3: #555; --border: #ddd; --border-strong: #bbb; --accent: #15803d; --glow: transparent; --shadow: none; }
  .nav, .hero__bg, .skip-link, .footer, .icon-btn, .hero__cta, .section--muted { display: none !important; }
  .section { padding: 18px 0; break-inside: avoid; }
  .section__head { position: static; }
  .reveal { opacity: 1; transform: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}
