/* ===== Токены темы ===== */
:root {
  --nav-h: 70px;
  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-soft: #efeff0;
  --text: #15161a;
  --text-muted: #5d6170;
  --border: #e3e3e7;
  --accent: #4f5bd5;
  --accent-soft: rgba(79, 91, 213, 0.1);
  --accent-text: #ffffff;
  --success: #1f9d55;
  --shadow: 0 1px 2px rgba(16, 18, 27, 0.04), 0 8px 24px rgba(16, 18, 27, 0.06);
  --grid-line: rgba(21, 22, 26, 0.05);

  --radius: 18px;
  --radius-sm: 10px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0e12;
  --bg-elev: #15171d;
  --bg-soft: #1b1d25;
  --text: #ecedf1;
  --text-muted: #9a9fb0;
  --border: #262935;
  --accent: #8b95ff;
  --accent-soft: rgba(139, 149, 255, 0.12);
  --accent-text: #0d0e12;
  --success: #3ccf7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --grid-line: rgba(236, 237, 241, 0.04);
  color-scheme: dark;
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

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

/* ===== Навигация ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: center;
  padding: 16px 16px 0;
  pointer-events: none;
}
.nav__bar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  backdrop-filter: saturate(170%) blur(16px);
  -webkit-backdrop-filter: saturate(170%) blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 18, 27, 0.04);
  transition: box-shadow .3s ease, background-color .3s ease;
  max-width: 100%;
}
.nav.is-scrolled .nav__bar { box-shadow: var(--shadow); background: color-mix(in srgb, var(--bg-elev) 85%, transparent); }
.nav__links { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav__links::-webkit-scrollbar { display: none; }
.nav__links a {
  padding: 9px 16px; border-radius: 999px; white-space: nowrap;
  font-size: 15px; font-weight: 600; color: var(--text-muted);
  transition: color .2s, background-color .2s;
}
.nav__links a:hover { color: var(--text); }
.nav__links a.is-active { color: var(--accent-text); background: var(--accent); }
.nav__divider { width: 1px; height: 22px; background: var(--border); margin: 0 2px; flex-shrink: 0; }

.theme-toggle {
  display: grid; place-items: center; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 999px;
  border: 0; background: transparent; color: var(--text);
  cursor: pointer; transition: transform .3s ease, background-color .2s;
}
.theme-toggle:hover { background: var(--bg-soft); }
.theme-toggle:active { transform: rotate(30deg) scale(.95); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ===== Hero ===== */
.hero {
  position: relative;
  margin-top: calc(-1 * var(--nav-h));
  padding: calc(64px + var(--nav-h)) 0 40px;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 200px;
  background: linear-gradient(transparent, var(--bg)); pointer-events: none;
}
.hero > .container { position: relative; z-index: 1; }
.hero__grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 56px; align-items: center; }


.hero__title { font-size: clamp(48px, 8vw, 92px); font-weight: 800; letter-spacing: -0.04em; margin-bottom: 20px; }
.hero__role { font-size: 19px; font-weight: 600; color: var(--accent); margin-bottom: 20px; }
.hero__lead { font-size: 19px; color: var(--text-muted); max-width: 560px; margin-bottom: 36px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-radius: 999px;
  font-weight: 600; font-size: 16px;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn--primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 20px var(--accent-soft); }
.btn--primary:hover { box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn--ghost { border: 1px solid var(--border); background: var(--bg-elev); }
.btn--ghost:hover { border-color: var(--accent); }

.hero__photo { position: relative; justify-self: center; max-width: 380px; width: 100%; }
.photo-frame {
  position: relative; border-radius: 28px; overflow: hidden;
  aspect-ratio: 4 / 5; background: var(--bg-soft);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.photo-frame::before {
  content: ""; position: absolute; inset: -40% -40% auto auto; width: 80%; height: 80%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  z-index: -1;
}

.stats {
  list-style: none; padding: 0; margin: 72px 0 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.stat {
  padding: 22px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.stat__value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat__label { font-size: 14px; color: var(--text-muted); line-height: 1.4; }

/* ===== Секции ===== */
.section { padding: 96px 0; }
.section__head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 40px; }
.section__head h2, .contact h2 { font-size: clamp(32px, 4.5vw, 48px); font-weight: 800; }
.section__index { font-size: 14px; color: var(--accent); font-weight: 500; }

.about { display: grid; grid-template-columns: 1fr 2fr; gap: 48px; }
.about .section__head { align-self: start; margin-bottom: 0; }
.about__body { color: var(--text-muted); font-size: 18px; }
.about__big { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.4; color: var(--text); font-weight: 600; letter-spacing: -0.01em; margin-bottom: 1.2em; }

/* ===== Карточки навыков ===== */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card--wide { grid-column: span 2; }
.card, .project {
  padding: 28px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--border);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card:hover, .project:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.card__icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 18px;
}
.card h3, .project h3 { font-size: 21px; font-weight: 700; margin-bottom: 14px; }
.card p, .project p { color: var(--text-muted); font-size: 16px; }

.tags { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  padding: 5px 12px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px;
}
.project .tags { margin: 16px 0 0; }

/* ===== Проекты ===== */
.project__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; font-size: 14px; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--bg-soft); border: 1px solid var(--border); }
.pill--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.project--featured {
  padding: 0; margin-bottom: 20px; position: relative; overflow: hidden;
}
.project__media { position: relative; background: #a9a9ab; aspect-ratio: 1250 / 480; overflow: hidden; }
.project__media img { width: 100%; height: 100%; object-fit: cover; object-position: center 55%; transition: transform .8s ease; }
.project__media::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 30%;
  background: linear-gradient(transparent, rgba(0, 0, 0, .12)); pointer-events: none;
}
.project--featured:hover .project__media img { transform: scale(1.04); }
.project__content { padding: 36px 40px 40px; position: relative; display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px 48px; align-items: start; }
.project__content .project__meta, .project__content h3 { grid-column: 1; }
.project__content > p { grid-column: 1; }
.project__content .pipeline { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; }
.project--featured::before {
  content: ""; position: absolute; right: -120px; bottom: -160px; width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%); pointer-events: none;
}
.project--featured h3 { font-size: clamp(24px, 2.6vw, 30px); }
.project--featured .project__content > p { font-size: 17px; }

.pipeline {
  list-style: none; padding: 0; margin: 24px 0 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.pipeline li {
  position: relative; padding: 16px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600; line-height: 1.35;
  display: flex; flex-direction: column; gap: 6px;
}
.pipeline li span { color: var(--accent); font-size: 12px; font-weight: 500; }

.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.project--link { background: var(--accent-soft); border-color: transparent; grid-column: span 2; }
.link-arrow { display: inline-flex; gap: 6px; margin-top: 16px; font-weight: 600; color: var(--accent); font-size: 15px; }
.link-arrow span { transition: transform .2s; }
.link-arrow:hover span { transform: translateX(4px); }

/* ===== Места работы и учёбы ===== */
.places { display: grid; grid-template-columns: 1fr 1.5fr; gap: 20px; margin-bottom: 64px; }
.place {
  position: relative; overflow: hidden; border-radius: var(--radius);
  min-height: 300px; border: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: space-between;
}
.place--orion {
  background:
    radial-gradient(420px circle at 85% 0%, rgba(85, 221, 129, 0.16), transparent 60%),
    linear-gradient(160deg, #0f1a33, #0a0f1d);
  color: #e8f1fb; border-color: #1c2742;
}
/* Ромбическая сетка на фоне карточки */
.place--orion::before {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background-image:
    linear-gradient(45deg, rgba(232, 241, 251, .06) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(232, 241, 251, .06) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
}
.place__brand { position: relative; padding: 36px 32px 0; }
.place__logo { width: 150px; height: auto; }
.place__caption { position: relative; padding: 28px 32px 30px; }
.place__caption span { font-size: 13px; opacity: .7; }
.place__caption h3 { font-size: 24px; margin: 6px 0 4px; }
.place__caption p { margin: 0; opacity: .8; font-size: 15px; }
.place--photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; transition: transform .8s ease; }
.place--photo:hover img, .place--orion:hover .place__logo { transform: scale(1.04); }
.place__logo { transition: transform .6s ease; }
.place__caption--overlay {
  margin-top: auto; color: #fff;
  background: linear-gradient(transparent, rgba(5, 8, 16, .78));
  padding-top: 80px;
}

/* ===== Таймлайн ===== */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 200px; top: 8px; bottom: 8px; width: 1px; background: var(--border); }
.timeline__item { display: grid; grid-template-columns: 200px 1fr; gap: 40px; padding-bottom: 44px; position: relative; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: ""; position: absolute; left: 195px; top: 8px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline__date { font-size: 14px; color: var(--text-muted); padding-top: 2px; }
.timeline__body h3 { font-size: 21px; margin-bottom: 6px; }
.timeline__body p { color: var(--text-muted); font-size: 16px; margin-bottom: 6px; }
.timeline__body p:not(.muted) { color: var(--text); opacity: .85; }
.timeline__list { margin: 10px 0 0; padding-left: 20px; color: var(--text); opacity: .85; font-size: 16px; }
.timeline__list li { margin-bottom: 4px; }
.timeline__list li::marker { color: var(--accent); }

/* ===== Контакты ===== */
.contact {
  text-align: center; padding: 72px 32px; border-radius: 28px;
  background: var(--bg-elev); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.contact::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px circle at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.contact > * { position: relative; }
.contact .section__index { display: block; margin-bottom: 12px; }
.contact__lead { color: var(--text-muted); font-size: 18px; max-width: 520px; margin: 16px auto 32px; }
.contact__links { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.contact__item {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
  transition: border-color .2s, transform .2s;
}
.contact__item:hover { border-color: var(--accent); transform: translateY(-2px); }
.contact__item svg { color: var(--accent); }

/* ===== Подвал ===== */
.footer {
  margin-top: 40px; padding: 64px 0 32px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 15px;
}
.footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
.footer__name { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 16px; }
.footer__mail { font-weight: 600; color: var(--accent); border-bottom: 1px solid transparent; transition: border-color .2s; }
.footer__mail:hover { border-bottom-color: var(--accent); }
.footer__col { display: flex; flex-direction: column; gap: 10px; }
.footer__col a { color: var(--text-muted); width: fit-content; transition: color .2s; }
.footer__col a:hover { color: var(--text); }
.footer__title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; opacity: .8; }
.footer__bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px;
}
.footer__top {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text); font-weight: 600; transition: border-color .2s, transform .2s;
}
.footer__top:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ===== Анимация появления ===== */
/* Скрываем только если JS запущен, иначе контент виден сразу */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ===== Адаптив ===== */
@media (max-width: 400px) {
  .nav__links a:first-child { display: none; }
}

@media (max-width: 960px) {
  .hero { padding-top: calc(40px + var(--nav-h)); }
  .skills { grid-template-columns: repeat(2, 1fr); }
  .project__content { grid-template-columns: 1fr; }
  .project__content .pipeline { grid-column: 1; grid-row: auto; margin-top: 16px; }
  .project__media { aspect-ratio: 1250 / 560; }
  .places { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .footer__brand { grid-column: 1 / -1; }
  .hero__grid { grid-template-columns: 1fr; gap: 48px; }
  .hero__photo { max-width: 320px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .about { grid-template-columns: 1fr; gap: 0; }
  .pipeline { grid-template-columns: repeat(3, 1fr); }
  .projects { grid-template-columns: repeat(2, 1fr); }
  .project--link { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { padding: 0 16px; }
  .section { padding: 64px 0; }
  .skills, .projects { grid-template-columns: 1fr; }
  .card--wide, .project--link { grid-column: auto; }
  .nav { padding: 10px 8px 0; }
  :root { --nav-h: 62px; }
  .nav__links a { padding: 8px 9px; font-size: 13.5px; }
  .nav__divider { display: none; }
  .project__content { padding: 24px; }
  .place { min-height: 240px; }
  .footer { padding-top: 48px; }
  .footer__bottom { flex-direction: column; align-items: flex-start; }
  .stats { gap: 10px; }
  .stat { padding: 16px; }
  .stat__value { font-size: 22px; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .timeline::before { left: 5px; }
  .timeline__item { grid-template-columns: 1fr; gap: 6px; padding-left: 32px; }
  .timeline__item::before { left: 0; }
  .contact { padding: 48px 20px; }
}
