/* ===== Переменные ===== */
:root {
  --color-primary: #212121;
  --color-secondary: #181818;
  --color-accent: #00ff00;
  --color-hover: #303030;
  --logo-bg: #000;
  --text-main: #fff;
  --text-muted: rgba(255, 255, 255, 0.4);
  --navbar-width: 50px;
  color-scheme: dark;
}

/* Светлая тема: меняются только переменные, остальные стили берут цвета из них */
html[data-theme="light"] {
  --color-primary: #e4efe8;
  --color-secondary: #d3e4d9;
  --color-accent: #008a39;
  --color-hover: #bfd8c7;
  --logo-bg: #c4dccb;
  --text-main: #12241a;
  --text-muted: rgba(18, 36, 26, 0.55);
  color-scheme: light;
}


/* ===== Сброс стилей ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  box-sizing: border-box;
}

/* Скрываем скроллбары */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

* {
  scrollbar-width: none;
}



/* ===== Базовые стили ===== */
html,
body {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 20px;
  color: var(--text-main);
  background: var(--color-primary);
}

body.lock {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

li {
  list-style: none;
}

svg {
  fill: var(--text-main);
}



/* ===== Бургер-меню (показывается только на планшетах и телефонах) ===== */
.burger {
  display: none;
  width: 40px;
  height: 30px;
  position: fixed;
  top: 20px;
  left: 20px;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  z-index: 11;
  transition: left 0.3s;
}

.burger-item {
  width: 100%;
  height: 4px;
  background: var(--text-main);
  border-radius: 5px;
  transition: transform 0.3s, opacity 0.3s;
}

.burger.active .burger-item:nth-child(1) {
  transform: rotate(45deg) translate(9px, 9px);
}

.burger.active .burger-item:nth-child(2) {
  opacity: 0;
}

.burger.active .burger-item:nth-child(3) {
  transform: rotate(-45deg) translate(9px, -9px);
}



/* ===== Навигационная панель ===== */
.navbar {
  width: var(--navbar-width);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-secondary);
}

.nav-logo-link {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--logo-bg);
  transition: background 0.2s;
}

.nav-logo-link img {
  height: 100%;
}

html[data-theme="light"] .nav-logo-link img {
  filter: brightness(0.55) saturate(1.4);
}

/* Меню по центру свободного места, контакты прижаты к низу */
.navbar-menu {
  margin: auto 0;
}

.navbar-contact {
  margin-top: auto;
}

.navbar ul {
  background: var(--color-hover);
}

.navbar li {
  position: relative;
  margin: 1px 0;
  background: var(--color-secondary);
}

.navbar li a,
.navbar li button {
  width: var(--navbar-width);
  height: 50px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

/* Кнопка темы в навбаре: без браузерного оформления */
.navbar li button {
  color: inherit;
  font: inherit;
  background: transparent;
  cursor: pointer;
}

/* Блок кнопки темы сразу под логотипом, свой фон вместо auto-центрирования меню */
.navbar-tools {
  margin-top: 1px;
}

/* В темной теме показываем солнце (переключит на светлую), в светлой — луну */
html[data-theme="dark"] .navbar-tools .icon-moon,
html[data-theme="light"] .navbar-tools .icon-sun {
  display: none;
}

.navbar-menu svg,
.navbar-contact svg,
.navbar-tools svg {
  width: 20px;
  height: 20px;
  display: block;
}

.navbar-link.active {
  background: var(--color-hover);
}

.navbar-link.active svg {
  fill: var(--color-accent);
}

/* Подпись при наведении (на телефонах подпись показывается всегда, см. медиа-запросы) */
.navbar-hover {
  position: absolute;
  left: 60px;
  top: 50%;
  translate: 0 -50%;
  padding: 5px 10px;
  font-size: 14px;
  white-space: nowrap;
  background: var(--color-secondary);
  border-radius: 5px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}

@media (hover: hover) {
  .navbar li a:hover svg,
  .navbar li button:hover svg {
    fill: var(--color-accent);
  }

  .navbar li:hover .navbar-hover {
    opacity: 1;
    visibility: visible;
  }
}



/* ===== Обертка и секции ===== */
.wrapper {
  margin-left: var(--navbar-width);
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.wrapper::before,
.wrapper::after {
  position: absolute;
  left: 60px;
  color: var(--text-muted);
}

.wrapper::before {
  content: "<body>";
  top: 60px;
}

.wrapper::after {
  content: "</body>";
  bottom: 60px;
}

/* Все секции лежат друг на друге, видна только активная */
section {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

/* Новая секция появляется только после того, как предыдущая полностью исчезла */
section.visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.3s;
}



/* ===== Главная секция ===== */
#home {
  display: flex;
}

.home-left,
.home-right {
  flex: 1 1 0;
  min-width: 0;
}

.home-left {
  padding: 100px 50px 50px clamp(50px, 14vw, 200px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-title {
  font-size: clamp(32px, 3.4vw, 48px);
  font-weight: bold;
  margin-bottom: 20px;
}

.home-subtitle {
  font-size: 24px;
  margin-bottom: 55px;
  color: var(--text-muted);
}

.home-button {
  display: inline-block;
  padding: 15px 30px;
  color: var(--color-accent);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid var(--color-accent);
  transition: border-radius 0.1s;
}

@media (hover: hover) {
  .home-button:hover {
    border-radius: 30px;
  }
}

.home-right {
  position: relative;
}

/* Кольца вращаются через transform, поэтому центрируем их свойством translate, а не transform */
/* Кольца симметрично относительно середины .home-right, перекрываются на четверть диаметра */
.home-circle {
  --ring: min(400px, 28vw);
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  width: var(--ring);
  aspect-ratio: 1;
  border-radius: 50%;
  animation: homeCircle 10s linear infinite;
}

.home-circle.left {
  left: calc(50% - var(--ring) * 0.75);
  border-inline: 3px solid var(--color-hover);
}

.home-circle.right {
  left: calc(50% - var(--ring) * 0.25);
  border-block: 3px solid var(--color-hover);
  animation-timing-function: ease;
}

@keyframes homeCircle {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Линии: ширина и позиция задаются переменными, а анимация одна на всех */
.home-line {
  position: absolute;
  left: 50%;
  height: 3px;
  width: var(--w-start);
  translate: -50% -50%;
  background: var(--text-main);
  animation: homeLine 10s linear infinite;
}

.home-line:nth-child(3) {
  top: 40%;
  --w-start: 500px;
  --w-mid: 300px;
}

.home-line:nth-child(4) {
  top: 45%;
  --w-start: 400px;
  --w-mid: 200px;
}

.home-line:nth-child(5) {
  top: 50%;
  --w-start: 300px;
  --w-mid: 500px;
}

.home-line:nth-child(6) {
  top: 55%;
  --w-start: 400px;
  --w-mid: 200px;
}

.home-line:nth-child(7) {
  top: 60%;
  --w-start: 500px;
  --w-mid: 300px;
}

@keyframes homeLine {
  0%,
  100% {
    width: var(--w-start);
  }
  50% {
    width: var(--w-mid);
  }
}

/* Кнопка-стрелка вниз */
.home-int {
  position: absolute;
  left: 50%;
  bottom: 20px;
  translate: -50% 0;
  width: 30px;
  height: 60px;
  background: var(--color-hover);
  border-radius: 50px;
}

.home-int_el {
  position: absolute;
  left: 50%;
  top: 20%;
  translate: -50% 0;
  width: 15px;
  height: 15px;
  background: var(--color-accent);
  border-radius: 50%;
  animation: homeIntAnim 3s infinite;
}

@keyframes homeIntAnim {
  0%,
  100% {
    top: 20%;
  }
  50% {
    top: 60%;
  }
}



/* ===== Секция «Обо мне» ===== */
#about {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  padding: clamp(80px, 14vh, 200px) clamp(40px, 20vw, 300px);
}

.about-title {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 36px;
}

.about-container {
  grid-column: 1;
  grid-row: 2 / 4;
  display: flex;
  justify-content: center;
  align-items: center;
}

.about-teq {
  grid-column: 2;
  grid-row: 1 / 5;
  display: flex;
  align-items: center;
}

.about-teq_list {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.about-teq_item {
  flex: none;
  width: 110px;
  height: 110px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: default;
  background: var(--color-hover);
  border: 8px solid var(--color-secondary);
  box-shadow: 5px 5px 5px var(--color-secondary);
  border-radius: 1.5rem;
  transition: all 0.2s;
}

.about-teq_item img {
  flex: none;
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 0.5rem;
  user-select: none;
  -webkit-user-drag: none;
}

@media (hover: hover) {
  .about-teq_item:hover {
    border-color: var(--color-accent);
    transform: scale(1.2) rotate(90deg);
  }
}

/* Нажатие: вместо JS-класса «clicked» */
.about-teq_item:active {
  border-radius: 50%;
  transform: scale(0.9) rotate(0deg);
}

.about-teq_item:active img {
  width: 70px;
  height: 70px;
}



/* ===== Секция проектов ===== */
#projects {
  padding: clamp(80px, 14vh, 200px) clamp(40px, 20vw, 300px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
}

.projects-title {
  font-size: 36px;
  text-align: center;
  margin-bottom: 20px;
}

/* Плашка: проекты демонстрационные */
.projects-note {
  max-width: 720px;
  margin: 0 auto 30px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-main);
  background: var(--color-secondary);
  border: 1px solid var(--color-hover);
  border-left: 4px solid var(--color-accent);
  border-radius: 10px;
}

.projects-note_badge {
  flex: none;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--color-accent);
  border-radius: 50px;
}

.projects-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px 20px;
  padding: 25px;
}

.projects-item {
  background: var(--color-hover);
  box-shadow: 5px 5px 10px var(--color-secondary);
  overflow: hidden;
  border-radius: 15px;
  transition: transform 0.2s;
}

@media (hover: hover) {
  .projects-item:hover {
    transform: scale(1.05);
  }
}

.projects-link {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Превью одной пропорции: карточки в сетке одинаковой высоты */
.projects-link img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: top;
  user-select: none;
  -webkit-user-drag: none;
}

.projects-name {
  font-size: 23px;
  font-weight: bold;
  margin: 10px 0;
  padding: 0 15px;
}

.projects-category {
  font-size: 20px;
  color: var(--text-muted);
  padding: 0 15px;
}

.projects-text {
  font-size: 17px;
  margin: 10px 0;
  padding: 0 15px;
}



/* Точки карусели проектов (видны только на телефонах) */
.projects-dots {
  display: none;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.projects-dot {
  width: 10px;
  height: 10px;
  background: var(--color-hover);
  border-radius: 50%;
  transition: background 0.2s;
}

.projects-dot.active {
  background: var(--color-accent);
}



/* ===== Адаптивность ===== */

/* Планшеты и телефоны: бургер-меню, секции в колонку */
@media (max-width: 1100px) {
  .wrapper::before,
  .wrapper::after {
    display: none;
  }

  #home {
    flex-direction: column;
  }

  /* Высота по содержимому, а не в долях экрана: текст не упирается в бургер и не обрезается */
  #home {
    justify-content: center;
  }

  .home-left,
  .home-right {
    flex: none;
    width: 100%;
  }

  /* Нижний отступ больше верхнего: текст поднимается выше центра, над стрелкой */
  .home-left {
    padding: 100px 24px 60px;
    text-align: center;
    justify-content: center;
  }

  .home-title {
    font-size: clamp(28px, 8vw, 40px);
  }

  .home-subtitle {
    font-size: 18px;
    margin-bottom: 35px;
  }

  .home-button {
    font-size: 16px;
  }

  /* Декоративные кольца и линии на телефонах не нужны, текст остается по центру */
  .home-right {
    display: none;
  }

  /* Кольца становятся обычными flex-элементами, поэтому translate и top не нужны */
  .home-circle {
    position: static;
    translate: none;
    width: min(350px, 40vw);
  }

  .home-line {
    left: 50%;
  }

  .home-line:nth-child(3) {
    --w-start: 90%;
    --w-mid: 60%;
  }

  .home-line:nth-child(4) {
    --w-start: 60%;
    --w-mid: 40%;
  }

  .home-line:nth-child(5) {
    --w-start: 60%;
    --w-mid: 90%;
  }

  .home-line:nth-child(6) {
    --w-start: 60%;
    --w-mid: 40%;
  }

  .home-line:nth-child(7) {
    --w-start: 90%;
    --w-mid: 60%;
  }

  /* safe center: при переполнении блок прижимается к верху, а не уходит за край экрана */
  #about {
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-content: safe center;
    gap: 10px;
    padding: 100px 40px 80px;
  }

  .about-title,
  .about-container,
  .about-teq {
    grid-column: 1;
    grid-row: auto;
  }

  #projects {
    padding: 80px 40px;
  }

  .projects-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .burger {
    display: flex;
  }

  .burger.active {
    left: calc(50% + 25px);
  }

  /* Панель выезжает слева, поверх затемненной области */
  /* Выше оверлея (9), ниже бургера (11) */
  .navbar {
    width: 50%;
    z-index: 10;
    translate: -100% 0;
    transition: translate 0.3s;
  }

  .navbar.active {
    translate: 0 0;
  }

  /* Иконка слева, подпись справа от нее */
  .navbar li a,
  .navbar li button {
    width: 100%;
    justify-content: flex-start;
  }

  .navbar.active .navbar-hover {
    opacity: 1;
    visibility: visible;
    left: 60px;
    padding: 0;
    font-size: 16px;
    background: transparent;
  }

  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }

  .overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .wrapper {
    margin-left: 0;
  }
}

/* Телефоны: проекты в горизонтальной карусели со снапом на карточку */
@media (max-width: 768px) {
  .projects-list {
    display: flex;
    gap: 20px;
    padding: 25px 10%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .projects-item {
    flex: 0 0 80%;
    scroll-snap-align: center;
  }

  .projects-dots {
    display: flex;
  }
}

/* На телефонах с достаточной высотой экрана показываем кольца и линии */
@media (max-width: 1100px) and (min-height: 720px) {
  /* Блок ограничен по ширине: линии (в %) не растягиваются на весь экран */
  .home-right {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(100%, 440px);
    height: 200px;
    margin-inline: auto;
  }

  /* Кольца вписываются в высоту блока и не налезают на текст */
  .home-right .home-circle {
    width: auto;
    height: min(100%, 44vw);
  }
}

@media (max-width: 425px) {
  .home-circle {
    width: min(200px, 45vw);
  }

  .home-line {
    animation-duration: 5s;
  }

  /* Верхний отступ оставляет место под бургер */
  #about,
  #projects {
    padding: 100px 16px 80px;
  }

  .about-container {
    font-size: 17px;
    padding: 0;
  }

  .about-teq_list {
    gap: 12px;
  }

  .about-teq_item {
    width: 68px;
    height: 68px;
    border-width: 5px;
    border-radius: 18px;
  }

  .about-teq_item img {
    width: 44px;
    height: 44px;
  }
}


/* Стартовая секция из хэша: без переходов, чтобы не было промежуточного кадра с «Главной» */
html[data-start] section {
    transition: none !important;
}

html[data-start="projects"] #home {
    opacity: 0;
    visibility: hidden;
}

html[data-start="projects"] #projects {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 425px) {
  .projects-note {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
  }
}
