/* ===== Базовые переменные ===== */
:root {
  --bg: #F7F8FA;
  --dot: #D5D9E2;
  --surface: #FFFFFF;
  --border: #E3E6EC;
  --row-border: #F1F3F6;
  --text: #1B2233;
  --text-muted: #4F5668;
  --text-soft: #6B7280;
  --accent: #4F46E5;
  --accent-soft: #EEF0FF;
  --line: #A5B4FC;
  --chip-border: #C7D2FE;
  --c-contact: #0EA5E9;
  --c-project: #10B981;
  --c-focus: #F59E0B;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gap: 24px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.mono { font-family: var(--mono); }

/* ===== Главная: ER-схема ===== */
.er {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 16px;
}

/* --- Сущность (общий вид карточки) --- */
.entity {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(27, 34, 51, .04);
  display: flex;
  flex-direction: column;
}

.entity__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #EEF0F4;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
}

.entity__type {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entity__type::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent));
}

.entity--contact { --dot-color: var(--c-contact); }
.entity--project { --dot-color: var(--c-project); }
.entity--focus { --dot-color: var(--c-focus); }

.entity__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.entity__rows > li + li { border-top: 1px solid var(--row-border); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 18px;
}

.row__label { flex: 1; font-weight: 600; }

.row__value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-soft);
  overflow-wrap: anywhere;
  text-align: right;
}

a.row:hover { background: #F8F9FC; }
a.row:hover .row__value { color: var(--accent); }

/* --- Главная сущность --- */
.entity--main {
  width: 100%;
  max-width: 620px;
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(27, 34, 51, .05), 0 16px 40px rgba(27, 34, 51, .07);
}

.pk {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.profile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
  padding: 28px 28px 30px;
}

.profile__photo {
  display: block;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  background: #ABBFD7;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border);
}

.profile__text {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile__name {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.02em;
}

.profile__role {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}

.profile__tagline {
  margin: 0;
  font-size: 16px;
  color: var(--text-muted);
}

/* --- Связи между сущностями (десктоп) --- */
.links {
  position: relative;
  width: 100%;
  max-width: 1080px;
  height: 112px;
  --c1: calc((100% - 2 * var(--gap)) / 6);
}

.links span {
  position: absolute;
  display: block;
}

.links__trunk { left: 50%; top: 0; bottom: 0; border-left: 1.5px solid var(--line); }
.links__one { left: calc(50% - 7px); top: 8px; width: 14px; border-top: 1.5px solid var(--line); }
.links__bus { left: var(--c1); right: var(--c1); top: 44px; border-top: 1.5px solid var(--line); }
.links__drop-l { left: var(--c1); top: 44px; bottom: 0; border-left: 1.5px solid var(--line); }
.links__drop-r { right: var(--c1); top: 44px; bottom: 0; border-right: 1.5px solid var(--line); }

/* «Воронья лапка» рисуется псевдоэлементом самой линии,
   поэтому всегда стоит ровно по её центру */
.links__trunk::after,
.links__drop-l::after,
.links__drop-r::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 16px;
  height: 12px;
  transform: translateX(-50%);
  background: no-repeat center / 16px 12px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12' fill='none' stroke='%23A5B4FC' stroke-width='1.5'%3E%3Cpath d='M8 0 1 12M8 0v12M8 0l7 12'/%3E%3C/svg%3E");
}
/* Линия слева рисуется border-left, справа — border-right; сдвиг на полтолщины линии */
.links__trunk::after,
.links__drop-l::after { left: -0.75px; }
.links__drop-r::after { left: 0.75px; }

.rel {
  top: 62px;
  background: var(--surface);
  border: 1px solid var(--chip-border);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.links .rel--l { left: var(--c1); transform: translateX(-50%); }
.links .rel--c { left: 50%; transform: translateX(-50%); }
.links .rel--r { right: var(--c1); transform: translateX(50%); }

/* --- Нижний ряд сущностей --- */
.children {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.child-rel { display: none; }

.project {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
}

.project__name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
}

.project__text { font-size: 14px; color: var(--text-soft); }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  color: #8A4B00;
  background: #FCEFD9;
}

.entity__foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--row-border);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}

.entity__note {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--row-border);
  font-size: 14px;
  color: var(--text-soft);
}

/* ===== Мобильная версия: сущности в столбик ===== */
@media (max-width: 860px) {
  .er { justify-content: flex-start; padding-top: 32px; }

  .links { display: none; }

  .children {
    grid-template-columns: minmax(0, 1fr);
    max-width: 620px;
    gap: 0;
  }

  /* Вертикальная связь над каждой нижней сущностью */
  .child-rel {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    height: 72px;
  }

  .child-rel::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    border-left: 1.5px solid var(--line);
  }

  .child-rel .rel {
    position: relative;
    top: 0;
    margin-top: 23px;
  }
}

@media (max-width: 520px) {
  .profile { flex-direction: column; text-align: center; padding: 24px 20px 26px; gap: 20px; }
  .profile__text { flex-basis: auto; align-items: center; }
  .profile__name { font-size: 28px; }
  .row__value { font-size: 12px; }
}

/* ===== Страница проектов ===== */
.page {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 28px 0;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
}

.topbar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.page__head { padding: 32px 0 36px; }

.page__title {
  margin: 0 0 10px;
  font-size: 48px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.02em;
}

.page__lead {
  margin: 0;
  font-size: 18px;
  color: var(--text-muted);
}

.projects {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.projects .project {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* Обложка проекта: цветная плашка с буквой.
   Чтобы поставить скриншот, замените <div class="project__cover">…</div>
   на <img class="project__cover" src="assets/projects/имя.png" alt=""> */
.project__cover {
  flex: 0 0 220px;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 800;
  object-fit: cover;
}

.project__body {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.projects .project__name { margin: 0; font-size: 24px; font-weight: 800; }
.projects .project__text { margin: 0; font-size: 16px; color: var(--text-muted); }

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.badge--live { color: #1F6B3A; background: #E3F2E8; }
.badge--dev { color: #8A4B00; background: #FCEFD9; }
.badge--archive { color: #4F5668; background: #EEF0F3; }

.footer {
  padding: 40px 0 0;
  font-size: 13px;
  color: var(--text-soft);
}

@media (max-width: 520px) {
  .page__title { font-size: 36px; }
  .project__cover { flex-basis: 100%; }
}

/* Нижние сущности на десктопе: каждая своей высоты, выровнены по верху */
.children { align-items: start; }

/* Строка навыка: название сверху, инструменты под ним */
.row--stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-top: 11px;
  padding-bottom: 11px;
}
.row--stack .row__value { text-align: left; }
