@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  --bg: #0a0e0c;
  --bg-alt: #0d1310;
  --fg: #d7f5e4;
  --fg-dim: #6b8a79;
  --accent: #22c55e;
  --accent2: #86efac;
  --accent-rgb: 34, 197, 94;
  --error: #f87171;
  --panel: #101713;
  --border: #1e2b23;
  --font: "JetBrains Mono", "Consolas", monospace;
  --maxw: 880px;
  --glow: 0 0 10px rgba(var(--accent-rgb), 0.5);
}

html[data-theme="amber"] {
  --bg: #120c05;
  --bg-alt: #160f06;
  --fg: #f6e2bd;
  --fg-dim: #8a6a3a;
  --accent: #f59e0b;
  --accent2: #fde68a;
  --accent-rgb: 245, 158, 11;
  --panel: #170f06;
  --border: #2b1e0c;
}

html[data-theme="matrix"] {
  --bg: #000000;
  --bg-alt: #030603;
  --fg: #cdf7d8;
  --fg-dim: #4c7a5b;
  --accent: #22c55e;
  --accent2: #4ade80;
  --accent-rgb: 34, 197, 94;
  --panel: rgba(4, 10, 6, 0.78);
  --border: #103319;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font);
  color: var(--fg);
}

a {
  color: var(--accent2);
}

.hidden {
  display: none !important;
}

/* ---------- Матрица-фон ---------- */

#matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: none;
  pointer-events: none;
}

/* Затемняющая подложка над "дождём" — чтобы текст поверх было легко читать */
#matrix-dim {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: none;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.55);
}

/* ---------- CRT-эффекты: скан-линии и шум старого монитора ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15) 1px, transparent 1px, transparent 2px);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 49;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: noiseShift 0.4s steps(4) infinite;
}

@keyframes noiseShift {
  0% {
    background-position: 0 0;
  }
  25% {
    background-position: -10% 5%;
  }
  50% {
    background-position: 8% -8%;
  }
  75% {
    background-position: -6% 10%;
  }
  100% {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .noise {
    animation: none;
  }
}

/* ---------- Page ---------- */

#page {
  position: relative;
  z-index: 1;
}

/* ---------- Navbar ---------- */

#navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(10, 14, 12, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(var(--accent-rgb), 0.15), 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow-x: auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--fg-dim);
  font-size: 12px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red {
  background: #ef4444;
}
.dot.yellow {
  background: #f59e0b;
}
.dot.green {
  background: #22c55e;
}

.nav-title {
  margin-left: 8px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.nav-links button {
  background: none;
  border: 1px solid transparent;
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-links button:hover,
.nav-links button.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--panel);
}

.nav-actions {
  display: flex;
  gap: 6px;
}

.nav-actions button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--accent2);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Hero ---------- */

#hero {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 10px;
}

.avatar-wrap {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
}

.avatar-wrap--hero #avatar,
.avatar-wrap--hero .avatar-fallback {
  width: 96px;
  height: 96px;
  font-size: 26px;
}

.avatar-wrap {
  position: relative;
}

#avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: var(--glow);
  position: relative;
  z-index: 1;
  /* Ч/б в покое, плавно проявляется цвет при наведении — простой и надёжный transition,
     без анимаций-костылей. */
  filter: grayscale(100%) contrast(1.1);
  transition: filter 0.4s ease;
}

.avatar-wrap:hover #avatar {
  filter: none;
}

.avatar-fallback {
  display: none;
  border-radius: 50%;
  border: 1px dashed var(--fg-dim);
  color: var(--fg-dim);
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

/* Тот же самый глитч, что у имени (RGB-расслоение + дрожание), просто применённый к фото.
   На <img> нельзя использовать content: attr() как у текста, поэтому дублируем картинку
   через background-image на псевдоэлементах — эффект тот же самый, техника адаптирована. */
.avatar-wrap.glitching {
  animation: glitchShake 0.3s ease;
}

.avatar-wrap.glitching::before,
.avatar-wrap.glitching::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: url("assets/avatar.jpg") center / cover no-repeat;
  mix-blend-mode: screen;
  pointer-events: none;
}

.avatar-wrap.glitching::before {
  filter: brightness(1.4) sepia(1) hue-rotate(-50deg) saturate(6);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  animation: glitchColor 0.3s ease;
}

.avatar-wrap.glitching::after {
  filter: brightness(1.4) sepia(1) hue-rotate(150deg) saturate(6);
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  animation: glitchColor 0.3s ease reverse;
}

@media (prefers-reduced-motion: reduce) {
  #avatar {
    transition: none;
  }
  .avatar-wrap.glitching,
  .avatar-wrap.glitching::before,
  .avatar-wrap.glitching::after {
    animation: none;
  }
}

#hero-name {
  font-size: clamp(28px, 6vw, 48px);
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  text-shadow: var(--glow);
  position: relative;
  display: inline-block;
}

#hero-name .cursor {
  display: inline-block;
  width: 0.5em;
  background: var(--accent);
  margin-left: 4px;
  animation: blink 1s step-end infinite;
}

/* Глитч RGB-расслоение на имени при наведении курсора */
.glitch-text.glitching {
  animation: glitchShake 0.3s ease;
}

@keyframes glitchShake {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(0);
  }
}

.glitch-text.glitching::before,
.glitch-text.glitching::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch-text.glitching::before {
  color: #ff2d55;
  animation: glitchColor 0.3s ease;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch-text.glitching::after {
  color: #22d3ee;
  animation: glitchColor 0.3s ease reverse;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitchColor {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(3px, 0);
  }
  40% {
    transform: translate(-3px, 0);
  }
  60% {
    transform: translate(3px, 0);
  }
  80% {
    transform: translate(-3px, 0);
  }
  100% {
    transform: translate(0);
  }
}

#hero-title {
  font-size: clamp(15px, 2.6vw, 20px);
  margin: 0;
  color: var(--accent2);
  font-weight: 500;
}

.dim {
  color: var(--fg-dim);
  font-size: 13px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 14px;
}

.btn {
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: inline-block;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn--accent {
  background: var(--accent);
  color: #04150a;
  border-color: var(--accent);
  font-weight: 700;
}

.btn--ghost {
  background: transparent;
}

.scroll-hint {
  margin-top: 26px;
  background: none;
  border: none;
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  animation: bounce 2s ease-in-out infinite;
}

/* ---------- Sections ---------- */

.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 70px 20px;
}

.section-title {
  color: var(--accent);
  font-size: 15px;
  margin: 0 0 26px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.section-title .prompt {
  color: var(--accent2);
  font-weight: 700;
}

.section-title .cmd::after {
  content: "▌";
  color: var(--accent);
  margin-left: 6px;
  animation: blink 1s step-end infinite;
}

/* Reveal-on-scroll: элементы внутри секции с классом reveal-item */

.reveal-item {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal-item.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- About ---------- */

.about-text p {
  margin: 0 0 4px;
  line-height: 1.7;
}

/* ---------- Skills ---------- */

.skills-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skill-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: start;
  gap: 6px 14px;
}

.skill-label {
  color: var(--accent2);
  font-weight: 700;
  font-size: 13px;
  padding-top: 5px;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 5px;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.skill-tag:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 12px var(--accent);
  transform: translateY(-1px);
}

/* ---------- Timeline / Experience ---------- */

.timeline {
  position: relative;
  padding-left: 22px;
  border-left: 2px solid var(--border);
}

.job {
  margin-bottom: 34px;
  position: relative;
}

.job::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}

.job-company {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
}

.job-role {
  color: var(--fg-dim);
  font-style: italic;
  font-size: 13.5px;
}

.job-meta {
  color: var(--fg-dim);
  font-size: 12px;
  margin-bottom: 10px;
}

.job-block-title {
  color: var(--accent2);
  font-size: 13.5px;
  font-style: italic;
  margin: 12px 0 6px;
}

.job ul {
  margin: 0;
  padding-left: 20px;
}

.job li {
  margin-bottom: 5px;
  line-height: 1.6;
  font-size: 14px;
}

/* ---------- Projects ---------- */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  gap: 16px;
}

.project-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-card.no-details {
  cursor: default;
}

.project-card.no-details:hover {
  border-color: var(--border);
}

.project-name {
  color: var(--accent);
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 4px;
}

.project-period {
  color: var(--fg-dim);
  font-size: 11.5px;
  margin-bottom: 8px;
}

.project-summary {
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 8px;
}

.project-stack {
  font-size: 11.5px;
  color: var(--accent2);
  margin-bottom: 8px;
  font-style: italic;
}

.project-stack::before {
  content: "// ";
  color: var(--fg-dim);
  font-style: normal;
}

.project-toggle {
  font-size: 11.5px;
  color: var(--fg-dim);
  text-decoration: underline;
}

.project-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.project-card.open .project-details {
  max-height: 500px;
}

.project-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.project-details li {
  font-size: 13px;
  margin-bottom: 5px;
  line-height: 1.5;
}

/* ---------- Education ---------- */

.education-item {
  margin-bottom: 20px;
}

.education-school {
  color: var(--accent);
  font-weight: 700;
  font-size: 14.5px;
}

.education-meta {
  color: var(--fg-dim);
  font-size: 12.5px;
}

/* ---------- Contact ---------- */

.contact-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.contact-row:hover {
  background: rgba(var(--accent-rgb), 0.06);
  transform: translateX(4px);
}

.contact-row::before {
  content: "-rwxr-xr-x";
  color: var(--fg-dim);
  font-size: 11px;
  opacity: 0.7;
}

.contact-label {
  color: var(--accent2);
  font-weight: 700;
}

.contact-label::after {
  content: ".sh";
  opacity: 0.6;
  font-weight: 400;
}

.contact-arrow {
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-left: 4px;
}

.contact-row:hover .contact-arrow {
  opacity: 1;
}

/* ---------- Footer / Easter eggs ---------- */

#footer {
  text-align: center;
  padding: 50px 20px 70px;
}

.easter-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.footer-note {
  color: var(--fg-dim);
  font-size: 11.5px;
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-item {
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 6px;
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.3s forwards;
}

/* ---------- Modal ---------- */

#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 24px;
  max-width: 640px;
  max-height: 80vh;
  overflow: auto;
}

#modal-content {
  color: var(--accent2);
  font-size: 13px;
  white-space: pre-wrap;
  margin: 0;
}

#modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 20px;
  cursor: pointer;
}

/* ---------- Confetti ---------- */

.confetti-piece {
  position: fixed;
  top: -20px;
  z-index: 80;
  font-size: 20px;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

/* ---------- Keyframes ---------- */

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes confettiFall {
  to {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0.2;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  #navbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav-brand {
    order: 1;
  }
  .nav-actions {
    order: 2;
  }
  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .skill-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .section {
    padding: 50px 16px;
  }
  .contact-row::before {
    display: none;
  }
}
