/*
 * SibData — витрина проектов.
 * Шрифты системные, внешних подключений нет: страница открывается мгновенно
 * и ничего не сообщает о посетителе третьим сторонам.
 */

:root {
  /* Цвета фирменного знака SD: синий → фиолетовый → красный. */
  --brand-navy: #002e93;
  --brand-violet: #6b2782;
  --brand-red: #ec091b;
  --accent: #1d3aa6;
  --grad-text: linear-gradient(100deg, var(--brand-navy), var(--brand-violet) 50%, var(--brand-red));

  --bg: #f6f9fc;
  --surface: #ffffff;
  --surface-2: #f1f6fb;
  --text: #0e1a26;
  --muted: #5b6b7a;
  --line: #dfe8f0;
  --shadow: 0 1px 2px rgba(14, 26, 38, .04), 0 8px 24px rgba(14, 26, 38, .06);
  --shadow-hover: 0 2px 4px rgba(14, 26, 38, .05), 0 18px 44px rgba(0, 46, 147, .14);
  --glow: .10;
  --tile-l: 52%;        /* светлота акцента плитки */
  --tile-text-l: 38%;
  --grid-line: rgba(0, 46, 147, .06);

  --radius: 20px;
  --wrap: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

/* Тёмная тема: системная, если пользователь не выбрал светлую явно… */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070d14;
    --surface: #0e1822;
    --surface-2: #132130;
    --text: #e8f0f7;
    --muted: #8ea0b1;
    --line: #1c2c3b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 50px rgba(0, 0, 0, .5);
    --glow: .16;
    --tile-l: 62%;
    --tile-text-l: 74%;
    --grid-line: rgba(142, 162, 255, .06);
    --accent: #8ea2ff;
    --grad-text: linear-gradient(100deg, #6f8bff, #b45ab0 50%, #ff4757);
    color-scheme: dark;
  }
}
/* …и она же, если выбрана вручную. */
:root[data-theme="dark"] {
  --bg: #070d14;
  --surface: #0e1822;
  --surface-2: #132130;
  --text: #e8f0f7;
  --muted: #8ea0b1;
  --line: #1c2c3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 50px rgba(0, 0, 0, .5);
  --glow: .16;
  --tile-l: 62%;
  --tile-text-l: 74%;
  --grid-line: rgba(142, 162, 255, .06);
  --accent: #8ea2ff;
  --grad-text: linear-gradient(100deg, #6f8bff, #b45ab0 50%, #ff4757);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

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

/* ---------- фон ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 12% -8%, color-mix(in srgb, var(--brand-navy) 16%, transparent), transparent 70%),
    radial-gradient(700px 420px at 92% 4%, color-mix(in srgb, var(--brand-red) 9%, transparent), transparent 70%);
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, #000 0, transparent 620px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, transparent 620px);
}

/* ---------- шапка ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.top__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
}
.brand__dim { color: var(--muted); font-weight: 500; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.icon-btn:active { transform: scale(.95); }

.i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

/* ---------- первый экран ---------- */

.hero { padding: 72px 0 40px; max-width: 820px; }

.eyebrow {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.02;
  letter-spacing: -.035em;
  font-weight: 800;
}
.grad {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  margin: 22px 0 0;
  max-width: 640px;
  font-size: clamp(17px, 2vw, 19px);
  color: var(--muted);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  margin: 36px 0 0;
}
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd {
  margin: 0;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

/* ---------- фильтры ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 24px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.chip[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-violet));
  border-color: transparent;
}
.chip__n { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 300px;
  min-width: 220px;
  padding: 0 14px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.search input::placeholder { color: var(--muted); }

/* ---------- плитки ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
  padding-bottom: 80px;
}

.tile {
  --c: hsl(var(--h) 80% var(--tile-l));
  --c2: hsl(calc(var(--h) + 38) 85% var(--tile-l));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s, border-color .25s;
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}
/* Свечение под курсором: координаты приходят из app.js. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), hsl(var(--h) 90% 60% / var(--glow)), transparent 60%);
  opacity: 0;
  transition: opacity .3s;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--c) 45%, var(--line));
}
.tile:hover::before, .tile:focus-visible::before { opacity: 1; }
.tile:focus-visible { outline-offset: 2px; border-radius: var(--radius); }

/* Обложка-скриншот: во всю ширину плитки, поверх неё — значок проекта. */
.tile__cover {
  display: block;
  margin: -24px -24px 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tile__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.tile:hover .tile__cover img { transform: scale(1.03); }
.tile--cover .tile__head { margin-top: -40px; }
.tile--cover .badge { outline: 4px solid var(--surface); }

.tile__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--c), var(--c2));
  box-shadow: 0 8px 20px hsl(var(--h) 80% 50% / .28), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.badge svg { width: 26px; height: 26px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
}
.status[data-s="prod"] { --dot: #2fbf62; }
.status[data-s="prod"]::before { box-shadow: 0 0 0 3px rgba(47, 191, 98, .2); }
.status[data-s="dev"] { --dot: #f2a93b; }
.status[data-s="prototype"] { --dot: #a77bff; }
.status[data-s="concept"] { --dot: #ff6f91; }
.status[data-s="done"] { --dot: #7f93a6; }

.tile__name {
  margin: 4px 0 0;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.015em;
}
.tile__tag {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 550;
  color: hsl(var(--h) 70% var(--tile-text-l));
}
.tile__sum { margin: 0; font-size: 15px; color: var(--muted); }

.tile__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 6px;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tags li {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}
.tile__go {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-2);
  transition: color .2s, background .2s, transform .25s;
}
.tile:hover .tile__go, .tile:focus-visible .tile__go {
  color: #fff;
  background: linear-gradient(135deg, var(--c), var(--c2));
  transform: translateX(3px);
}

.empty { padding: 40px 0 120px; text-align: center; color: var(--muted); }
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- подвал ---------- */

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot__row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 24px; padding-bottom: 24px; }
.foot__dim { opacity: .8; }

/* ---------- карточка проекта ---------- */

.sheet {
  --c: hsl(var(--h, 210) 80% var(--tile-l));
  --c2: hsl(calc(var(--h, 210) + 38) 85% var(--tile-l));
  width: min(920px, calc(100vw - 32px));
  max-width: none;
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, .45);
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(.98);
  transition: opacity .22s, transform .28s cubic-bezier(.2, .7, .2, 1), overlay .28s allow-discrete, display .28s allow-discrete;
}
.sheet[open] { display: flex; opacity: 1; transform: none; }
@starting-style {
  .sheet[open] { opacity: 0; transform: translateY(18px) scale(.98); }
}
.sheet::backdrop {
  background: rgba(4, 10, 16, 0);
  backdrop-filter: blur(0);
  transition: background .25s, backdrop-filter .25s, overlay .25s allow-discrete, display .25s allow-discrete;
}
.sheet[open]::backdrop { background: rgba(4, 10, 16, .6); backdrop-filter: blur(6px); }
@starting-style {
  .sheet[open]::backdrop { background: rgba(4, 10, 16, 0); backdrop-filter: blur(0); }
}

.sheet__body { flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain; }

.sheet__hero {
  position: relative;
  padding: 32px 36px 28px;
  background:
    radial-gradient(600px 260px at 0% 0%, hsl(var(--h) 90% 60% / .22), transparent 70%),
    radial-gradient(500px 240px at 100% 0%, hsl(calc(var(--h) + 38) 90% 60% / .16), transparent 70%),
    var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.sheet__bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  height: 0;
  padding: 0 16px;
  transform: translateY(16px);
}
.sheet__bar .icon-btn { background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

.sheet__id { display: flex; align-items: center; gap: 18px; padding-right: 140px; }
.sheet__id .badge { width: 64px; height: 64px; border-radius: 18px; }
.sheet__id .badge svg { width: 32px; height: 32px; }
.sheet__title { margin: 0; font-size: clamp(24px, 4vw, 32px); line-height: 1.15; letter-spacing: -.025em; font-weight: 800; }
.sheet__tag { margin: 4px 0 0; font-size: 16px; color: hsl(var(--h) 70% var(--tile-text-l)); font-weight: 550; }
.sheet__meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.sheet__meta .status { background: var(--surface); border: 1px solid var(--line); }
.pill { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 550; }

.sheet__cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 40px;
  padding: 32px 36px 36px;
}
.sheet h3 {
  margin: 28px 0 10px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet h3:first-child { margin-top: 0; }
.sheet p { margin: 0 0 12px; }
.sheet__lead { font-size: 17px; }

.feat { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.feat li { position: relative; padding-left: 28px; }
.feat li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .3em;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5.2 9.3 2.5 2.5 5.1-5.4'/%3E%3C/svg%3E") center / contain no-repeat,
    linear-gradient(135deg, var(--c), var(--c2));
}

.shots { display: grid; gap: 14px; }
.shot {
  display: block;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
  background: var(--surface-2);
}
.shot img { display: block; width: 100%; height: auto; }
.shot span { display: block; padding: 8px 12px; }
.shot span:empty { display: none; }
.shot:hover { border-color: var(--c); }

.sheet aside .tags li { font-size: 12.5px; padding: 4px 10px; }
.links { display: grid; gap: 8px; }
.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--c); background: var(--surface-2); }
.btn small { display: block; font-weight: 450; color: var(--muted); font-size: 12px; }
.btn svg { flex: none; color: var(--muted); }
.btn--primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--c), var(--c2)); }
.btn--primary:hover { background: linear-gradient(135deg, var(--c), var(--c2)); filter: brightness(1.08); }
.btn--primary small, .btn--primary svg { color: rgba(255, 255, 255, .85); }
.facts { margin: 0; display: grid; gap: 6px; font-size: 14.5px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

/* ---------- узкие экраны ---------- */

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 44px 0 28px; }
  .stats { gap: 12px 28px; }
  .stats dd { font-size: 26px; }
  /* nowrap обязателен: в многострочной колонке ширину строки задаёт самый
     широкий элемент, и лента чипов распирает поиск за край экрана. */
  .controls { flex-flow: column-reverse nowrap; align-items: stretch; }
  .search { flex: none; min-width: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .grid { grid-template-columns: 1fr; gap: 14px; padding-bottom: 56px; }
  .tile { padding: 20px; }
  .tile__cover { margin: -20px -20px 0; }

  /* Карточка выезжает снизу на всю ширину. */
  .sheet {
    width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
    border-width: 1px 0 0;
    transform: translateY(40px);
  }
  @starting-style { .sheet[open] { transform: translateY(40px); } }
  .sheet__hero { padding: 24px 20px 22px; }
  .sheet__id { flex-direction: column; align-items: flex-start; gap: 14px; padding-right: 0; padding-top: 36px; }
  .sheet__cols { grid-template-columns: 1fr; gap: 28px; padding: 24px 20px 32px; }
}
