/* ============================================================
   Marcin Grudzień — portfolio
   Direction: "Dark instrument" — deep ink, luminous contours,
   monospace readouts. Accent toggles amber <-> teal via
   <html data-accent="amber|teal"> (persisted in JS).
   ============================================================ */

:root {
  --ink-0:    #0b121a;   /* page base */
  --surface-1:#121d29;   /* header / chips */
  --surface-2:#152230;   /* raised cards */
  --line:     #233040;   /* hairline border */
  --line-2:   #2f3f50;   /* stronger border */

  --text-1:   #f2eee3;   /* primary */
  --text-2:   #c7cdd2;   /* secondary */
  --text-3:   #94a0aa;   /* muted */
  --readout:  #86c0b8;   /* mono labels (teal) */

  --accent:        #e8a33d;  /* amber (graphic) */
  --accent-strong: #f0b454;  /* amber text/links on dark */
  --accent-ink:    #23170a;  /* text on amber fill */
  --accent-tint:   rgba(232,163,61,.14);

  --maxw: 1080px;
  --pad: clamp(1.1rem, 4vw, 3rem);

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(.22,.61,.36,1);
}

html[data-accent="teal"] {
  --accent:        #3fb6a8;
  --accent-strong: #67d0c3;
  --accent-ink:    #04201c;
  --accent-tint:   rgba(63,182,168,.16);
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text-2);
  background: var(--ink-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.06; font-weight: 600; color: var(--text-1); }
a { color: var(--accent-strong); text-underline-offset: 3px; }
strong { color: var(--text-1); font-weight: 600; }

.coord {
  font-family: var(--font-mono);
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--readout);
}
.muted { color: var(--text-3); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

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

/* ---------- Cartographic background ---------- */
.topo { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--ink-0); }
.topo::before {
  content: ""; position: absolute; inset: 0;
  background-image: url('/assets/img/hero-dark.webp');
  background-size: cover; background-position: center; background-repeat: no-repeat;
  opacity: .7;
}
.topo::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, transparent 55%, rgba(7,11,16,.55) 100%),
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(255,255,255,.025) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(255,255,255,.025) 47px 48px);
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--ink-0) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav { max-width: var(--maxw); margin: 0 auto; padding: .7rem var(--pad); display: flex; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text-1); font-family: var(--font-display); font-weight: 700; }
.brand__pin { color: var(--accent); }
.nav__links { list-style: none; display: flex; gap: clamp(.6rem, 2vw, 1.4rem); margin: 0 0 0 auto; padding: 0; }
.nav__links a {
  text-decoration: none; color: var(--text-3); font-size: .92rem;
  padding: .3rem 0; border-bottom: 2px solid transparent; transition: color .15s;
}
.nav__links a:hover, .nav__links a.active { color: var(--text-1); border-color: var(--accent); }

.accent-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-1); color: var(--text-2);
  border: 1px solid var(--line-2); border-radius: 999px; padding: .3rem .6rem; cursor: pointer;
}
.accent-toggle__dot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.nav__toggle { display: none; }

/* ---------- Layout primitives ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) var(--pad); }
.section__head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 2.4rem; }
.section__index { font-family: var(--font-mono); color: var(--accent-strong); font-size: .85rem; letter-spacing: .1em; }
.section__head h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin: 0; letter-spacing: -.01em; }
.section__head::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; }

.btn {
  display: inline-block; text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: .72rem 1.2rem; border-radius: 8px; transition: transform .15s var(--ease), background .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn--ghost { border: 1px solid var(--line-2); color: var(--text-1); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-strong); transform: translateY(-2px); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; max-width: var(--maxw); margin: 0 auto; padding: clamp(3rem, 10vw, 7rem) var(--pad) clamp(2rem,6vw,4rem); }
.hero__inner { position: relative; z-index: 1; }
.hero__route { position: absolute; top: 5%; right: -4%; width: min(56%, 540px); height: auto; z-index: 0; opacity: .85; pointer-events: none; }
.hero__route .route-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hero__route .wpt { fill: var(--ink-0); stroke: var(--accent); stroke-width: 2; }
.hero__route .end { fill: var(--accent); }

.hero__title {
  font-size: clamp(3rem, 11vw, 6.5rem); font-weight: 700; margin: .5rem 0 1.2rem;
  letter-spacing: -.025em; color: var(--text-1);
}
.hero__headline { font-size: clamp(1.15rem, 2.6vw, 1.6rem); max-width: 44ch; margin: 0 0 1rem; color: var(--text-1); font-weight: 400; }
.hero__sub { color: var(--text-2); max-width: 60ch; margin: 0 0 1.8rem; }
.hero__cta { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 2.6rem; }
.hero__stats {
  list-style: none; padding: 1.5rem 0 0; margin: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  border-top: 1px solid var(--line);
}
.hero__stats li { display: flex; flex-direction: column; gap: .2rem; }
.stat__num { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.4rem, 3vw, 2rem); color: var(--accent-strong); }
.stat__lbl { font-size: .8rem; color: var(--text-3); }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 260px 1fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.about__photo { position: relative; }
.about__photo img {
  width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--surface-2); display: block; margin-bottom: .6rem;
}
.about__text p { margin: 0 0 1rem; max-width: 64ch; color: var(--text-2); }

/* ---------- Experience timeline ---------- */
.timeline { position: relative; display: grid; gap: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--accent), var(--line)); opacity: .6; }
.role { position: relative; padding: 1.1rem 1.3rem 1.1rem 2.3rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.role::before { content: ""; position: absolute; left: -1px; top: 1.4rem; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-0); border: 3px solid var(--accent); }
.role--current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
.role__period { margin: 0 0 .3rem; }
.role__title { font-size: 1.15rem; margin: 0 0 .15rem; color: var(--text-1); }
.role__org { color: var(--text-2); font-size: .92rem; margin: 0 0 .6rem; }
.role__points { margin: 0 0 .6rem; padding-left: 1.1rem; color: var(--text-2); }
.role__points li { margin-bottom: .3rem; }
.role__points li::marker { color: var(--accent); }
.role__skills { font-family: var(--font-mono); font-size: .74rem; color: var(--readout); margin: 0; letter-spacing: .04em; }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.6rem; }
.skillgroup h3 { font-size: 1rem; margin: 0 0 .8rem; color: var(--text-1); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; }
.chips li {
  font-size: .85rem; padding: .35rem .7rem; border-radius: 999px;
  background: var(--surface-1); border: 1px solid var(--line); color: var(--text-2);
  transition: transform .15s var(--ease), border-color .15s, color .15s;
}
.chips li:hover { border-color: var(--accent); color: var(--accent-strong); transform: translateY(-2px); }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; }
.project {
  padding: 1.6rem; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); border-left: 4px solid var(--accent);
  transition: transform .2s var(--ease), border-color .2s;
}
.project:hover { transform: translateY(-3px); border-left-color: var(--accent-strong); }
.project h3 { font-size: 1.2rem; margin: .4rem 0 .7rem; color: var(--text-1); }
.project p { margin: 0; color: var(--text-2); }

/* ---------- Credentials ---------- */
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.8rem; }
.cred h3 { font-size: 1.05rem; margin: 1.4rem 0 .7rem; color: var(--text-1); }
.cred h3:first-child { margin-top: 0; }
.stack { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.stack--tight { gap: .4rem; font-size: .92rem; }
.stack li { color: var(--text-2); }
.more { margin-top: .6rem; }
.more summary { cursor: pointer; color: var(--accent-strong); font-size: .85rem; font-family: var(--font-mono); }
.more[open] summary { margin-bottom: .5rem; }

.more--projects { margin-top: 1.4rem; }
.more--projects[open] summary { margin-bottom: 1.2rem; }
.projects--all { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.project--compact { padding: 1.2rem 1.3rem; }
.project--compact h3 { font-size: 1.02rem; margin: .35rem 0 .5rem; }
.project--compact p:not(.coord) { font-size: .92rem; }

/* ---------- Contact ---------- */
.section--contact .contact__lead { font-size: clamp(1.1rem, 2.4vw, 1.4rem); max-width: 50ch; margin: 0 0 1.4rem; color: var(--text-1); }
.contact__list { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.contact__list li { display: grid; grid-template-columns: 7rem 1fr; align-items: baseline; gap: 1rem; }
.contact__list a { font-size: 1.1rem; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--maxw); margin: 0 auto; padding: 2rem var(--pad) 3rem;
  border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  font-size: .85rem; color: var(--text-3); align-items: center;
}
.footer__meta p { margin: .2rem 0; }
.scalebar { width: 150px; height: auto; flex: 0 0 auto; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in-view { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Hero entrance stagger ---------- */
.hero__inner .reveal:nth-child(1) { transition-delay: .04s; }
.hero__inner .reveal:nth-child(2) { transition-delay: .12s; }
.hero__inner .reveal:nth-child(3) { transition-delay: .20s; }
.hero__inner .reveal:nth-child(4) { transition-delay: .28s; }
.hero__inner .reveal:nth-child(5) { transition-delay: .36s; }
.hero__inner .reveal:nth-child(6) { transition-delay: .44s; }

@media (prefers-reduced-motion: no-preference) {
  /* Hero route draws itself + pulsing destination */
  .hero__route .route-line { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: routeDraw 2.6s var(--ease) .35s forwards; }
  .hero__route .wpt { opacity: 0; animation: wptIn .45s ease forwards; }
  .hero__route .wpt:nth-of-type(1) { animation-delay: .8s; }
  .hero__route .wpt:nth-of-type(2) { animation-delay: 1.5s; }
  .hero__route .wpt:nth-of-type(3) { animation-delay: 2.2s; }
  .hero__route .end { transform-box: fill-box; transform-origin: center; animation: endPulse 2.4s ease-in-out 3s infinite; }
  @keyframes routeDraw { to { stroke-dashoffset: 0; } }
  @keyframes wptIn { to { opacity: 1; } }
  @keyframes endPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.7); opacity: .55; } }

  /* Timeline line draws down, roles rise in sequence */
  .js .timeline::before { transform: scaleY(0); transform-origin: top; }
  .js .timeline.is-drawn::before { transform: scaleY(1); transition: transform 1.1s var(--ease); }
  .js .timeline .role { opacity: 0; transform: translateY(20px); }
  .js .timeline.is-drawn .role { opacity: 1; transform: none; transition: opacity .55s var(--ease), transform .55s var(--ease); }
  .js .timeline.is-drawn .role:nth-child(1) { transition-delay: .15s; }
  .js .timeline.is-drawn .role:nth-child(2) { transition-delay: .25s; }
  .js .timeline.is-drawn .role:nth-child(3) { transition-delay: .35s; }
  .js .timeline.is-drawn .role:nth-child(4) { transition-delay: .45s; }
  .js .timeline.is-drawn .role:nth-child(5) { transition-delay: .55s; }
  .js .timeline.is-drawn .role:nth-child(6) { transition-delay: .65s; }
  .js .timeline.is-drawn .role:nth-child(n+7) { transition-delay: .75s; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav__links {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column;
    background: var(--surface-1); border-bottom: 1px solid var(--line);
    padding: .8rem var(--pad); margin: 0; gap: .2rem; display: none;
  }
  .nav__links.open { display: flex; }
  .nav__links a { display: block; padding: .8rem 0; }
  .nav__toggle {
    display: inline-flex; flex-direction: column; gap: 4px; margin-left: auto;
    align-items: center; justify-content: center; min-width: 44px; min-height: 44px;
    background: none; border: 0; cursor: pointer; padding: .4rem;
  }
  .nav__toggle span { width: 22px; height: 2px; background: var(--text-1); display: block; }
  .accent-toggle { order: 3; min-height: 40px; padding: .5rem .7rem; }
  .about { grid-template-columns: 1fr; }
  .about__photo { max-width: 220px; }
  .hero__stats { grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
  .contact__list li { grid-template-columns: 1fr; gap: .1rem; }
  .hero__route { display: none; }
  .topo::before { background-image: url('/assets/img/hero-dark-mobile.webp'); }
}

/* ---------- Premium instrument details ---------- */
::selection { background: var(--accent); color: var(--accent-ink); }

html { scrollbar-width: thin; scrollbar-color: var(--line-2) var(--ink-0); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ink-0); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; border: 2px solid var(--ink-0); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Scroll progress hairline — the route travelled */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 40; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 8px var(--accent-tint); }

/* Sparing luminous glow (dark-instrument: minimal, purposeful) */
.stat__num { text-shadow: 0 0 18px var(--accent-tint); }
.hero__route { filter: drop-shadow(0 0 6px var(--accent-tint)); }

/* Machined card edges: hairline top highlight */
.role, .project { box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }

/* Cartographic plate corner ticks on the hero */
.hero::before, .hero::after { content: ""; position: absolute; width: 26px; height: 26px; pointer-events: none; opacity: .55; }
.hero::before { top: 26px; left: var(--pad); border-top: 1px solid var(--readout); border-left: 1px solid var(--readout); }
.hero::after { bottom: 20px; right: var(--pad); border-bottom: 1px solid var(--readout); border-right: 1px solid var(--readout); }

/* Anchors land clear of the sticky header */
section[id] { scroll-margin-top: 70px; }

/* ---------- Print: clean ink-on-white CV ---------- */
@media print {
  .topo, .site-header, .hero__cta, .hero__route, .progress { display: none !important; }
  .hero::before, .hero::after { display: none; }
  .stat__num { text-shadow: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  h1, h2, h3, strong, .role__title, .hero__title, .hero__headline, .contact__lead, .skillgroup h3, .cred h3 { color: #000 !important; }
  .text-2, .role__org, .role__points, .about__text p, .project p, .stack li { color: #1a1a1a !important; }
  a { color: #000; text-decoration: none; }
  .section, .hero { padding: .6rem 0; max-width: none; }
  .section__head::after { display: none; }
  .role, .project, .chips li { border-color: #999; background: #fff; break-inside: avoid; }
  .timeline::before, .role::before { display: none; }
  .hero__stats { border-color: #999; }
  .stat__num, .section__index, .role__skills, .coord, a, .accent-strong { color: #000 !important; }
}
