:root {
  --night: #0b1230;
  --night-2: #151e45;
  --paper: #f7f3e9;
  --ink: #17181d;
  --text: #f1f1f6;
  --muted: #a7afcc;
  --red: #ff5440;
  --green: #43dc6c;
  --blue: #5c8dff;
  --yellow: #ffca3a;
  --gap: 16px;
  --edge: 24px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ui: 'Rubik', system-ui, sans-serif;
  --serif: 'STIX Two Text', 'Times New Roman', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font: 400 16px/1.5 var(--ui);
  overflow-x: hidden;
}
h1, p, figure { margin: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

.head {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 20px var(--edge) 20px;
  text-align: center;
}
.atom { width: 52px; height: 52px; }
.head h1 {
  font-size: clamp(36px, 5.4vw, 76px);
  font-weight: 600;
  line-height: 1.04;
  text-wrap: balance;
}
.lead { font: 400 clamp(18px, 2vw, 26px)/1.35 var(--serif); text-wrap: balance; }
.hint { color: var(--muted); font-size: 14px; }
.hint-touch { display: none; }
@media (hover: none) {
  .hint-mouse { display: none; }
  .hint-touch { display: inline; }
}

.collage {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--edge);
}

/* ---- карточка ---- */
.card {
  --laser: var(--yellow);
  position: relative;
  container-type: inline-size;
  min-width: 0;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .32s var(--ease);
}
.l-red { --laser: var(--red); }
.l-green { --laser: var(--green); }
.l-blue { --laser: var(--blue); }
.l-yellow { --laser: var(--yellow); }
.r-v { --r: .75; }
.r-h { --r: 1.3333; }
.r-t { --r: 1.5; }
.shot {
  position: relative;
  aspect-ratio: var(--r);
  overflow: hidden;
  background: var(--night-2);
  border: 5px solid var(--paper);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgb(0 0 0 / .45);
}
.shot > .bg, .shot > .fg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  transition: transform .7s var(--ease);
}
.shot > .fg { transform-origin: 50% 100%; }
.hit { position: absolute; inset: 0; z-index: 3; width: 100%; border: 0; background: none; }
.hit:focus-visible { outline: 3px solid var(--laser); outline-offset: -6px; }

.is-speed { --tilt: -1.2deg; }
.is-wake { --tilt: .6deg; }
.is-results { --tilt: 1.3deg; }
.is-vlasov { --tilt: -1.6deg; }
.is-grants { --tilt: 1.1deg; }
.is-papers { --tilt: 1.5deg; }
.is-shelf { --tilt: -1.3deg; }
.is-routine { --tilt: -.8deg; }
.is-birthday { --tilt: 1deg; }
.is-defense { --tilt: .9deg; }

.card.is-on { --tilt: 0deg; z-index: 6; }
.card.is-on .shot > .bg { transform: scale(1.12); }
.card.is-on .shot > .fg { transform: scale(1.035); }
.card.is-shelf.is-on .shot > .bg { transform: scale(1.04); }

/* ---- раскладка: ряды равной высоты, общее фото в центре ---- */
.row { display: flex; gap: var(--gap); }
.row .card { flex: var(--r) 1 0; }
.core { display: grid; grid-template-columns: 1fr 4fr 1fr; gap: var(--gap); }
.side { display: flex; flex-direction: column; gap: var(--gap); justify-content: space-between; }
.core > .is-team { display: flex; flex-direction: column; }
.core > .is-team .shot { flex: 1; }

/* ---- лист с законом ---- */
.law {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  padding: clamp(10px, 4cqw, 20px);
  background: var(--paper);
  color: var(--ink);
  border-top: 4px solid var(--laser);
  border-radius: 2px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .4);
  text-align: center;
  font-family: var(--serif);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .32s var(--ease), visibility 0s .22s;
}
.card.is-on .law {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .22s var(--ease), transform .32s var(--ease);
}
.quote { font-size: clamp(16px, 6.4cqw, 32px); font-weight: 600; line-height: 1.12; text-wrap: balance; }
.name { margin-top: 6px; font: 500 clamp(11px, 3.4cqw, 15px)/1.3 var(--ui); text-wrap: balance; }
.formula { margin-top: 6px; font-size: clamp(14px, 5cqw, 24px); line-height: 1.4; }
.formula sub, .formula sup, .zoom-text sub, .zoom-text sup { line-height: 0; }
.note { margin-top: 4px; font-size: clamp(11px, 3.8cqw, 16px); line-height: 1.35; text-wrap: balance; }
.wave { display: none; }
.more { display: none; }

.is-team .law { left: auto; width: min(380px, 44%); }
.is-team .quote { font-size: clamp(16px, 2.6cqw, 28px); }
.is-team .name { font-size: clamp(12px, 1.5cqw, 15px); }
.is-team .formula { font-size: clamp(15px, 2.2cqw, 24px); }
.is-team .note { font-size: clamp(12px, 1.7cqw, 16px); }
.is-team .law { padding: 16px; }

/* боковые снимки маленькие: при наведении выезжают крупно, к центру */
@media (min-width: 1100px) {
  .side .card.is-on { transform: scale(1.5); }
  .side-left .card:first-child { transform-origin: 0 0; }
  .side-left .card:last-child { transform-origin: 0 100%; }
  .side-right .card:first-child { transform-origin: 100% 0; }
  .side-right .card:last-child { transform-origin: 100% 100%; }
  .side .law { left: 6px; right: 6px; bottom: 6px; padding: 8px; }
  .side .quote { font-size: 15px; }
  .side .name { font-size: 10px; margin-top: 4px; }
  .side .formula { font-size: 13px; margin-top: 3px; }
  .side .note { font-size: 10.5px; margin-top: 2px; }
}

/* ---- эффекты ---- */
.fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .25s var(--ease); }
.fx-front { z-index: 2; }
.card.is-on .fx { opacity: 1; }
.fx svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx i { position: absolute; display: block; }

.draw { fill: none; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.card.is-on .draw { animation: draw .7s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.streak { left: 50%; top: 22%; width: 34%; height: 4px; transform-origin: 0 50%; background: var(--text); opacity: 0; }
.card.is-on .streak { animation: streak .62s linear infinite; }
@keyframes streak {
  0% { transform: rotate(var(--a)) translateX(10%) scaleX(.1); opacity: 0; }
  40% { opacity: .9; }
  100% { transform: rotate(var(--a)) translateX(230%) scaleX(1); opacity: 0; }
}

.ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom; opacity: .34; }
.card.is-on .ghost { animation: ghost 1.8s var(--ease) infinite alternate; }
@keyframes ghost { from { transform: translateX(0); } to { transform: translateX(var(--dx)); } }

.meter { left: 6%; right: 6%; top: 5%; padding: 8px 10px; background: var(--paper); color: var(--ink); border-radius: 2px; font: 500 clamp(11px, 3.6cqw, 14px)/1.2 var(--ui); font-style: normal; font-variant-numeric: tabular-nums; }
.meter b { display: block; height: 6px; margin-top: 6px; background: var(--night-2); transform-origin: 0 50%; transform: scaleX(0); }

.sheet { top: -16%; width: 13%; aspect-ratio: .72; background: var(--paper); box-shadow: 0 2px 8px rgb(0 0 0 / .3); opacity: 0; }
.card.is-on .sheet { animation: fall 2.6s linear infinite; animation-delay: var(--d); }
.bit { top: -4%; width: 2.2%; aspect-ratio: .45; opacity: 0; }
.card.is-on .bit { animation: fall 2.2s linear infinite; animation-delay: var(--d); }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), 150cqw) rotate(var(--a)); opacity: 1; }
}

.ring { left: 38%; top: 15%; width: 30%; aspect-ratio: 1; margin: -15% 0 0 -15%; border: 3px solid var(--paper); border-radius: 50%; opacity: 0; }
.card.is-on .ring { animation: ring 2.1s var(--ease) infinite; animation-delay: var(--d); }
@keyframes ring {
  from { transform: scale(.1); opacity: .9; }
  to { transform: scale(4.2); opacity: 0; }
}

/* ---- подвал ---- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px var(--edge) 40px;
  color: var(--muted);
  font-size: 14px;
}

/* ---- крупный вид ---- */
.zoom {
  width: min(1200px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.zoom::backdrop { background: rgb(5 9 24 / .88); }
.zoom.is-v { width: min(980px, calc(100vw - 32px)); }
.close { position: sticky; top: 8px; z-index: 5; float: right; margin: 8px 8px 0 0; padding: 8px 14px; background: var(--ink); color: var(--paper); border: 0; border-radius: 4px; font-size: 14px; }
.zoom-body { display: grid; clear: both; padding: 8px; gap: 8px; }
.zoom.is-v .zoom-body { grid-template-columns: auto 1fr; align-items: center; }
.zoom-scroll { overflow: auto; overscroll-behavior: contain; border-radius: 2px; }
.zoom-stack { position: relative; aspect-ratio: var(--r); margin: 0 auto; width: min(100%, calc((100dvh - 290px) * var(--r))); }
.zoom.is-v .zoom-stack { width: calc((100dvh - 110px) * var(--r)); }
.zoom-stack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.zoom-text { padding: 8px 16px 16px; text-align: center; font-family: var(--serif); }
.zoom-text .quote { font-size: 28px; }
.zoom-text .name { font-size: 15px; }
.zoom-text .formula { font-size: 22px; }
.zoom-text .note { font-size: 17px; }
.zoom-text .wave { display: block; margin-top: 12px; padding-top: 8px; border-top: 3px solid var(--laser, var(--ink)); font: 400 13px var(--ui); }
.zoom-text .more { display: none; }
.zoom .pan { display: none; }

/* ---- планшет ---- */
@media (max-width: 1099px) {
  .row, .core, .side { display: contents; }
  .collage { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .card { grid-column: span 1; }
  .card.r-h { grid-column: 1 / -1; }
  .is-team { grid-column: 1 / -1; order: -2; }
  .is-wake { order: -1; }
  .is-birthday { order: 3; grid-column: 1 / -1; width: min(100%, 520px); justify-self: center; }
  .is-routine, .is-defense { order: 2; }
  .core > .is-team .shot { flex: none; }
  .is-team .law { left: 12px; width: auto; }
}

/* ---- телефон и всё без мыши: лист открывается под снимком, лица не закрывает ---- */
@media (max-width: 759px), (hover: none) {
  .law {
    position: static;
    display: none;
    margin-top: 0;
    padding: 16px;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: none;
  }
  .card.is-on .law { display: block; animation: rise .28s var(--ease); }
  .side .card.is-on { transform: none; }
  .card .quote { font-size: 22px; }
  .card .name { font-size: 13px; }
  .card .formula { font-size: 20px; }
  .card .note { font-size: 15px; }
  .card .more { display: inline-block; font-family: var(--ui); margin-top: 12px; padding: 10px 18px; background: var(--ink); color: var(--paper); border: 0; border-radius: 4px; font-size: 14px; }
  .is-team .law { width: auto; }
}
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 759px) {
  :root { --edge: 16px; --gap: 20px; }
  .head { padding-top: 20px; padding-bottom: 20px; }
  .collage { grid-template-columns: 1fr; }
  .card { --tilt: 0deg; }
  .card.r-h, .is-team, .is-birthday { grid-column: 1; }
  .shot { border-width: 4px; }
  .zoom-body, .zoom.is-v .zoom-body { grid-template-columns: 1fr; }
  .zoom-stack, .zoom.is-v .zoom-stack { width: 100%; }
  .zoom.is-team .zoom-stack { width: 250%; }
  .zoom.is-team .pan { display: block; padding: 4px 8px 0; font: 400 13px var(--ui); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card.is-on .shot > .bg, .card.is-on .shot > .fg { transform: none; }
  .draw { stroke-dashoffset: 0; }
  .streak, .sheet, .bit, .ring { display: none !important; }
}
