/* ==========================================================================
   Igor Pariy — personal site
   Palette: cold steel neutrals + temper colours (цвета побежалости)
   used only on the diffractogram line.
   ========================================================================== */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/onest-cyrillic-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/onest-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/onest-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f2f4f5;
  --surface: #ffffff;
  --ink: #18212b;
  --muted: #5a6672;
  --rule: #d3dae0;
  --accent: #2e55a0;
  --accent-ink: #ffffff;
  --accent-hover: #1f3f80;
  --ok: #2f7a4f;
  --error: #a3342b;

  /* temper colours: straw → bronze → purple → blue → pale blue */
  --t1: #c8a54e;
  --t2: #b07a3e;
  --t3: #7a4e8e;
  --t4: #2e55a0;
  --t5: #5c8fc9;

  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 6px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11161b;
    --surface: #182028;
    --ink: #e3e8ec;
    --muted: #96a2ad;
    --rule: #2a343e;
    --accent: #8eaee6;
    --accent-ink: #0f1620;
    --accent-hover: #b3c9ef;
    --ok: #7cc79b;
    --error: #ee8f86;
    --t4: #6d8fd6;
    --t5: #9cc0ea;
  }
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "tnum" 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

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

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

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0; padding: 0; list-style: none; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
}
.skip-link:focus { top: 12px; color: var(--paper); }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
}

.brand {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }

.nav { display: flex; gap: 22px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.nav a:hover { color: var(--ink); }

.lang {
  display: flex;
  gap: 2px;
  font-size: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2px;
}
.lang a,
.lang span {
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
  line-height: 1.5;
}
.lang a { color: var(--muted); }
.lang a:hover { color: var(--ink); }
.lang [aria-current] {
  background: var(--ink);
  color: var(--paper);
}

@media (max-width: 760px) {
  .nav { display: none; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost {
  border-color: var(--rule);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- hero ---------- */

.hero { padding: clamp(40px, 7vw, 88px) 0 0; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(200px, 26vw, 300px);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}

.status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}
.status::before {
  content: "";
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent);
  transform: translateY(-1px);
}

.hero h1 {
  font-size: clamp(2.6rem, 6.4vw, 4.6rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}
.hero h1 .role {
  display: block;
  margin-top: 18px;
  max-width: 26ch;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
}

.hero-lede {
  max-width: 58ch;
  margin: 22px 0 30px;
  color: var(--muted);
  font-size: 18px;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.portrait {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rule);
}
.portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait .initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  color: var(--muted);
}
.portrait.no-photo img { display: none; }

@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait {
    order: -1;
    width: 120px;
    aspect-ratio: 1;
    border-radius: 50%;
  }
  .portrait .initials { font-size: 2.4rem; }
}

/* ---------- diffractogram ---------- */

.xrd {
  margin: clamp(44px, 7vw, 76px) 0 0;
}

.xrd-plot {
  position: relative;
  height: clamp(110px, 16vw, 180px);
  border-bottom: 1px solid var(--ink);
}

.xrd-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.xrd-line {
  fill: none;
  stroke: url(#temper);
  stroke-width: 1.6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.js .xrd-line {
  stroke-dashoffset: 1;
  animation: draw 2.2s cubic-bezier(.45, .05, .2, 1) .25s forwards;
}

.hkl {
  position: absolute;
  transform: translate(-50%, calc(-100% - 6px));
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1;
}
.js .hkl {
  opacity: 0;
  animation: fade .6s ease forwards;
}
.hkl-110 { left: 16.30%; top: 7%; }
.hkl-200 { left: 38.91%; top: 74%; }
.hkl-211 { left: 58.14%; top: 61%; }
.hkl-220 { left: 76.60%; top: 82.5%; }
.hkl-310 { left: 95.98%; top: 77.6%; }
/* each index appears as the line reaches its peak */
.js .hkl-110 { animation-delay: .85s; }
.js .hkl-200 { animation-delay: 1.06s; }
.js .hkl-211 { animation-delay: 1.22s; }
.js .hkl-220 { animation-delay: 1.45s; }
.js .hkl-310 { animation-delay: 1.93s; }

.xrd figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}
.xrd .axis { white-space: nowrap; font-style: italic; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }

@media (max-width: 760px) {
  .hkl { font-size: 11px; }
  .hkl-310 { transform: translate(-85%, calc(-100% - 6px)); }
}

/* ---------- facts ---------- */

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin: 36px 0 0;
  padding: 0;
}
.facts div { border-left: 1px solid var(--rule); padding-left: 16px; }
.facts dt {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.facts dd {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

@media (max-width: 760px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- sections ---------- */

.section {
  padding: clamp(64px, 10vw, 120px) 0 0;
}

.section-head {
  max-width: 44rem;
  margin-bottom: clamp(32px, 5vw, 52px);
}
.section-head h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
}
.section-head p {
  margin-top: 14px;
  color: var(--muted);
}

/* about */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
}
.about-text { max-width: 60ch; }

.skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 32px;
  align-content: start;
}
.skills h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.skills li {
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.75;
}

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
}

/* experience — a real sequence, so it gets a timeline */

.timeline { position: relative; }

.job {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 32px;
  position: relative;
}

.job-dates {
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
  position: relative;
}

.job-body {
  position: relative;
  padding: 0 0 48px 32px;
  border-left: 1px solid var(--rule);
  max-width: 68ch;
}
.job:last-child .job-body { padding-bottom: 4px; }
.job-body::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 9px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--muted);
}
.job.current .job-body::before {
  background: var(--accent);
  border-color: var(--accent);
}

.job h3 { font-size: 1.3rem; }
.job .org {
  margin: 4px 0 14px;
  color: var(--muted);
}
.job .org a { color: inherit; }
.job ul li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 8px;
}
.job ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .78em;
  width: 7px;
  height: 1px;
  background: var(--muted);
}

@media (max-width: 760px) {
  .job { grid-template-columns: 1fr; gap: 0; }
  .job-dates {
    padding: 0 0 6px 24px;
    border-left: 1px solid var(--rule);
  }
  .job-dates::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 9px;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--paper);
    border: 1.5px solid var(--muted);
  }
  .job.current .job-dates::before { background: var(--accent); border-color: var(--accent); }
  .job-body { padding: 0 0 36px 24px; }
  .job-body::before { display: none; }
}

/* projects */

.projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(32px, 5vw, 64px);
}
.project {
  padding: 28px 0 32px;
  border-top: 1px solid var(--rule);
}
.project.lead {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: clamp(24px, 5vw, 64px);
  border-top-color: var(--ink);
}
.project h3 { font-size: 1.2rem; margin-bottom: 10px; }
.project.lead h3 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); }
.project p { color: var(--muted); max-width: 62ch; }
.project .stack {
  margin-top: 12px;
  font-size: 14.5px;
  color: var(--ink);
}

@media (max-width: 760px) {
  .projects { grid-template-columns: 1fr; }
  .project.lead { grid-template-columns: 1fr; gap: 0; }
}

/* education */

.edu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
}
.edu h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  margin-bottom: 10px;
}
.edu p { margin: 0; }
.edu .meta { color: var(--muted); font-size: 15px; margin-top: 4px; }
.edu li { line-height: 1.8; }
.edu li span { color: var(--muted); }

@media (max-width: 760px) {
  .edu { grid-template-columns: 1fr; gap: 28px; }
}

/* ---------- contact ---------- */

.contact {
  margin-top: clamp(64px, 10vw, 120px);
  padding: clamp(56px, 8vw, 96px) 0;
  background: var(--surface);
  border-top: 1px solid var(--rule);
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(36px, 6vw, 88px);
}

.contact h2 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.contact-intro { margin: 18px 0 32px; color: var(--muted); max-width: 52ch; }

.channels li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  align-items: baseline;
}
.channels li:last-child { border-bottom: 1px solid var(--rule); }
.channels .k { color: var(--muted); font-size: 15px; }
.channels a {
  font-size: 18px;
  font-weight: 500;
  word-break: break-word;
}
.channels .note { display: block; color: var(--muted); font-size: 14px; }

/* form */

.form h3 { font-size: 1.3rem; margin-bottom: 6px; }
.form > p { color: var(--muted); margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}
.field input,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color .15s ease;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:hover,
.field textarea:hover { border-color: var(--muted); }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 4px 0 20px;
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.45;
}
.consent input {
  flex: none;
  width: 18px; height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.form-status {
  min-height: 1.5em;
  margin: 14px 0 0;
  font-size: 15px;
}
.form-status.ok { color: var(--ok); }
.form-status.error { color: var(--error); }

.privacy {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}
.privacy summary { cursor: pointer; }
.privacy p { margin-top: 8px; max-width: 60ch; }

@media (max-width: 860px) {
  .contact-grid { grid-template-columns: 1fr; }
}

/* ---------- footer ---------- */

.site-footer {
  padding: 28px 0 40px;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  border-top: 1px solid var(--rule);
  padding-top: 24px;
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 70vh;
  display: grid;
  align-content: center;
  gap: 18px;
}
.notfound h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.notfound p { color: var(--muted); max-width: 48ch; }

/* ---------- motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .xrd-line { animation: none; stroke-dashoffset: 0; }
  .js .hkl { animation: none; opacity: 1; }
  .btn { transition: none; }
}

@media print {
  .site-header, .actions, .form, .xrd, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .section, .contact { padding-top: 24pt; margin-top: 0; }
  .contact { background: none; border: 0; }
  a { color: #000; }
}

/* gradient stops (CSS variables don't work in SVG attributes) */
.t1 { stop-color: var(--t1); }
.t2 { stop-color: var(--t2); }
.t3 { stop-color: var(--t3); }
.t4 { stop-color: var(--t4); }
.t5 { stop-color: var(--t5); }
