/* ===== Переменные: все цвета и шрифты в одном месте ===== */
:root {
  --bg: #0b1110;       /* фон */
  --text: #e6ece9;     /* основной текст */
  --muted: #98a6a0;    /* второстепенный текст */
  --accent: #3fcfa9;   /* бирюзовый акцент */
  --surface: #141b18;  /* фон шторки */
  --border: #27322d;   /* тонкие линии-разделители */

  /* Шрифты описаны в fonts/fonts.css. После своего шрифта — запасные,
     ими браузер пишет, пока свой грузится или если не загрузился. */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;      /* текст */
  --font-head: "Unbounded", system-ui, sans-serif;                                  /* главный заголовок */
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; /* акценты */
}

/* ===== Сброс: размеры считаются одинаково во всех браузерах ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ===== Каркас страницы: шапка / содержимое / подвал на всю высоту экрана ===== */
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* Одна колонка ровно в ширину экрана. Без этого колонка подстраивается под самое
     широкое содержимое: длинная строка раздвинула бы всю страницу вбок */
  grid-template-columns: minmax(0, 1fr);
  font: 16px/1.6 var(--font);
  color: var(--text);
  background: var(--bg);
}

/* Открыт раздел: страница ровно в экран и сама не прокручивается — прокручивается панель */
body.has-panel {
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

/* ===== Фон: сетка точек и два мягких круга-свечения. Только CSS, без картинок =====
   Слои перечисляются сверху вниз: первый лежит поверх остальных. */
body::before {
  content: "";
  position: fixed;   /* фон стоит на месте, даже если страница прокручивается */
  inset: 0;
  z-index: -1;       /* под всем содержимым */
  background:
    /* бирюзовый круг справа сверху */
    radial-gradient(60vmax 40vmax at 85% 8%, rgb(63 207 169 / 0.22), transparent 65%),
    /* тёплый жёлтый круг слева снизу */
    radial-gradient(50vmax 35vmax at 5% 95%, rgb(255 196 61 / 0.14), transparent 60%),
    /* сетка точек: по одной точке в клетке 26×26 */
    radial-gradient(rgb(255 255 255 / 0.07) 1px, transparent 1.5px) 0 0 / 26px 26px,
    var(--bg);
}

/* ===== Шапка: кнопка «Меню» и логотип в одну строку ===== */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font: 700 15px/1 var(--font);
  cursor: pointer;
}

.menu-btn:hover {
  filter: brightness(1.1);
}

.logo {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;  /* имя и фамилия не переносятся на вторую строку */
  /* Если всё же не влезает (самые узкие экраны) — обрезаем с многоточием, а не вылезаем */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Узкий телефон (320–360 точек): чуть плотнее, чтобы имя влезло целиком */
@media (max-width: 360px) {
  .header {
    gap: 12px;
  }

  .logo {
    font-size: 15px;
  }
}

/* ===== Сцена: визитка и панель раздела ===== */
/* На главной — одна визитка по центру экрана */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding: 24px 20px;
  align-self: center;
}

/* Открыт раздел: визитка слева, панель справа на всю высоту сцены.
   Колонка визитки — до 460px, как сама визитка: так она в разделе того же размера,
   что и на главной. Если на экране есть лишнее место, обе колонки стоят по центру */
.has-panel .stage {
  grid-template-columns: minmax(0, 460px) minmax(0, 660px);
  justify-content: center;
  gap: 48px;
  max-width: 1280px;
  height: 100%;
  min-height: 0;
  padding: 8px 24px 16px;
  align-self: stretch;
}

/* Визитка одной ширины на главной и в разделах: выглядит одинаково везде,
   имя всегда в две строки */
.hero {
  align-self: center;
  justify-self: center;
  width: min(100%, 460px);
}

/* ===== Панель раздела ===== */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgb(11 17 16 / 0.88);  /* фон сайта, чуть прозрачный — сквозь него видны точки */
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.45);
}

/* Прокручивается только содержимое панели. overscroll-behavior: докрутив до конца,
   страница под панелью не поедет */
.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 28px 32px;
}

/* Заголовок раздела чуть меньше и не залезает под крестик */
.panel__body > h1 {
  margin-right: 44px;
  font-size: clamp(28px, 3.4vw, 40px);
}

/* Крестик «закрыть» — ссылка на главную, стоит в углу панели и не прокручивается */
.panel__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  text-decoration: none;
}

.panel__close:hover {
  background: var(--border);
  color: var(--text);
}

/* Узкий экран: места на визитку и панель рядом нет — панель на всю ширину, визитка прячется */
@media (max-width: 1099px) {
  .has-panel .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    max-width: 760px;
    padding: 4px 10px 10px;
  }

  .has-panel .hero {
    display: none;
  }
}

@media (max-width: 480px) {
  .panel {
    border-radius: 16px;
  }

  .panel__body {
    padding: 22px 18px 26px;
  }
}

/* Аватарка: круглая, с бирюзовым кольцом и мягкой тенью.
   object-fit: cover обрезает фото по кругу, не сплющивая его */
.avatar {
  display: block;
  width: 112px;
  height: 112px;
  margin-bottom: 22px;
  border: 3px solid var(--bg);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--accent), 0 10px 30px rgb(0 0 0 / 0.45);
}

@media (max-width: 480px) {
  .avatar {
    width: 88px;
    height: 88px;
  }
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

/* Unbounded широкий — размер меньше, чем был у системного шрифта, иначе фамилия
   не помещается на узком телефоне. .hero__name — имя в визитке: в разделах это
   не h1, а абзац, но выглядеть должно так же */
h1,
.hero__name {
  margin: 0 0 14px;
  font-family: var(--font-head);
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 20px);
}

/* ===== Разделы страниц «Контакты» и «Обо мне» ===== */
.contact-group,
.about-section {
  margin-top: 32px;
}

/* Заголовок раздела: мелкий моноширинный, заглавными буквами */
.contact-group h2,
.about-section h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Сетка карточек: две колонки, если хватает места, на телефоне — одна */
.contacts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Карточка: плашка с иконкой слева, подпись и значение справа */
.contact {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

/* При наведении рамка становится цвета бренда */
.contact:hover {
  border-color: var(--brand, var(--accent));
}

.contact__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand, var(--accent));
}

.contact__text {
  display: flex;
  flex-direction: column;
  min-width: 0;  /* без этого длинная почта распирает карточку */
}

.contact__label {
  color: var(--muted);
  font-size: 13px;
}

.contact__value {
  font-weight: 600;
  overflow-wrap: anywhere;  /* длинное значение переносится, а не вылезает за край */
}

/* ===== Фирменные цвета брендов =====
   Переменная --brand красит плашку под иконкой и рамку при наведении */
.contact--telegram  { --brand: #26a5e4; }
.contact--whatsapp  { --brand: #25d366; }
.contact--viber     { --brand: #7360f2; }
.contact--upwork    { --brand: #14a800; }
.contact--linkedin  { --brand: #0a66c2; }
.contact--github    { --brand: #24292f; }
.contact--instagram { --brand: #e1306c; }
.contact--facebook  { --brand: #0866ff; }
.contact--x         { --brand: #000000; }

/* Телефон и почта — не бренды, берём тёмный вариант нашего акцента */
.contact--phone,
.contact--mail      { --brand: #0e7c66; }

/* У Instagram фирменная плашка — градиент, как на значке приложения */
.contact--instagram .contact__icon {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}

/* Чёрные плашки GitHub и X сливаются с тёмной карточкой — даём им тонкую светлую обводку */
.contact--github .contact__icon,
.contact--x .contact__icon {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
}

/* ===== Обо мне: карточки «Чем занимаюсь» ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 12px;
}

.card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

/* ===== Обо мне: опыт по годам =====
   Слева период моноширинным шрифтом, справа должность и описание.
   Тонкая линия слева с точками связывает пункты в ленту */
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 2px solid var(--border);
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 0 0 20px 20px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

/* Точка на линии напротив каждого пункта */
.timeline li::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -7px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
}

.timeline__when {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
}

.timeline h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

/* Ссылка на компанию — цвет текста, а подчёркивание бирюзовое, чтобы было видно, что кликается */
.timeline a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.timeline a:hover {
  color: var(--accent);
}

.timeline p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

/* На телефоне период стоит над текстом, а не слева */
@media (max-width: 480px) {
  .timeline li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ===== Плашки: инструменты, языки ===== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
}

/* ===== Проекты: карточка со скриншотом сверху ===== */
.project {
  margin-top: 28px;
  overflow: hidden;  /* скриншот обрезается по скруглённым углам карточки */
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.project__cover {
  display: block;
  width: 100%;
  height: auto;
  border-bottom: 1px solid var(--border);
}

.project__body {
  padding: 18px 20px 20px;
}

.project h2 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}

.project p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

/* Плашки стека внутри карточки — на тёмном фоне, иначе сливаются с ней */
.project .tags li {
  background: var(--bg);
}

.project__link {
  display: inline-block;
  margin-top: 14px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.project__link:hover {
  text-decoration: underline;
}

/* «Ещё скриншоты»: <details> раскрывается по клику на <summary> */
.project__more {
  margin-top: 14px;
}

.project__more summary {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* Галерея: превью одной высоты, обрезаны сверху; клик открывает скриншот целиком */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.shots figure {
  margin: 0;
}

.shots img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.shots a:hover img {
  border-color: var(--accent);
}

.shots figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Кнопка-ссылка ===== */
.btn {
  display: inline-block;
  margin-top: 14px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.1);
}

/* Кнопка-<button> по умолчанию рисуется системным видом: возвращаем шрифт и убираем рамку */
button.btn {
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ===== Форма входа ===== */
.form {
  display: grid;
  gap: 16px;
  max-width: 360px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Сообщение об ошибке; без текста абзац пустой и не занимает места */
.form__error {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgb(255 107 107 / 0.4);
  border-radius: 12px;
  background: rgb(255 107 107 / 0.08);
  color: #ff9a9a;
  font-size: 15px;
}

.form__error:empty {
  display: none;
}

.form .btn {
  justify-self: start;
  margin-top: 0;
}

/* ===== Подвал ===== */
.footer {
  padding: 12px 20px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
}

/* ===== Шторка меню ===== */
.drawer {
  /* браузер ставит popover по центру — прижимаем к левому краю на всю высоту */
  inset: 0 auto 0 0;
  width: min(300px, 85vw);
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* Открытая шторка — колонка: пункты сверху, кнопка «Вход» прижата к низу.
   display задаём только открытой: у закрытой браузер сам ставит display: none */
.drawer:popover-open {
  display: flex;
  flex-direction: column;
}

.drawer__account {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.drawer__account .btn {
  display: block;
  margin-top: 0;
  text-align: center;
}

/* Затемнение страницы позади открытой шторки */
.drawer::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.drawer__close:hover {
  background: var(--border);
  color: var(--text);
}

.drawer__list {
  margin: 0;
  padding: 12px;
  list-style: none;
}

.drawer__list a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.drawer__list a:hover {
  background: var(--border);
}

/* Текущая страница подсвечена */
.drawer__list a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

/* Старый браузер без popover (до 2024 года) не умеет прятать шторку —
   тогда убираем и кнопку, и шторку, чтобы не ломали вёрстку */
@supports not selector(:popover-open) {
  .drawer,
  .menu-btn {
    display: none;
  }
}

/* Рамка вокруг ссылки или кнопки при переходе клавишей Tab — для тех, кто без мыши.
   Скругление браузер берёт у самого элемента, свой border-radius не нужен. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ===== Просмотр скриншота поверх страницы (окно <dialog> из app.js) ===== */
/* Браузер по умолчанию рисует <dialog> небольшим окошком с рамкой —
   растягиваем на весь экран и делаем прозрачным, картинка стоит по центру */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Затемнение страницы под открытым окном */
.lightbox::backdrop {
  background: rgb(5 10 9 / 0.9);
}

.lightbox__img {
  max-width: 100%;
  max-height: calc(100dvh - 110px);  /* место под подпись и отступы */
  border-radius: 10px;
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.6);
  object-fit: contain;
}

.lightbox__caption {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.lightbox__close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.lightbox__close:hover {
  background: var(--border);
}
