/* Светлая и воздушная тема: тёплый фон, не белый; текст тёмно-серый,
   не чёрный; один приглушённый акцент. Воздух делаем отступами. */

:root {
  --bg: #faf8f5;
  --ink: #2e2c29;
  --muted: rgba(46, 44, 41, 0.55);
  --accent: #c9a99a;
  --hairline: rgba(46, 44, 41, 0.12);

  --gap: 14px;
  --page: min(1320px, 100% - 2 * var(--edge));
  --edge: 20px;

  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --motion: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 700px) {
  :root {
    --gap: 20px;
    --edge: 40px;
  }
}

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

/* Правило браузера [hidden] { display: none } слабее любого класса
   с display, так что скрытый флексом элемент остаётся на виду.
   Возвращаем атрибуту силу. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 14px var(--edge);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.topbar__brand {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 20px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

.topbar__nav {
  display: flex;
  gap: 20px;
}

.topbar__link {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0 0 2px;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: color var(--motion), border-color var(--motion);
}

.topbar__link:hover,
.topbar__link.is-current {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

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

.hero {
  width: var(--page);
  margin: clamp(28px, 5vw, 64px) auto 0;
}

.hero__frame {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
  border: 1px solid var(--hairline);
}

/* На телефоне горизонтальный кадр в полную ширину превращается в полоску,
   поэтому подрезаем его до более вертикального. */
@media (max-width: 640px) {
  .hero__frame {
    aspect-ratio: 4 / 5;
  }
}

.hero__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 500ms ease;
}

.hero__image.is-loaded {
  opacity: 1;
}

.hero__titles {
  text-align: center;
  padding: clamp(24px, 4vw, 44px) 0 0;
}

.hero__names {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 1.1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero__date {
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro {
  width: min(620px, 100% - 2 * var(--edge));
  margin: clamp(36px, 6vw, 72px) auto;
  text-align: center;
}

.intro__text {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2.4vw, 25px);
  font-weight: 300;
  line-height: 1.65;
  color: color-mix(in srgb, var(--ink) 85%, transparent);
}

/* ---------- секции ---------- */

.section {
  width: var(--page);
  margin: 0 auto clamp(48px, 8vw, 96px);
}

.section__title {
  margin: 0 0 clamp(20px, 3vw, 32px);
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}

.section__title::after {
  content: "";
  display: block;
  width: 40px;
  height: 1px;
  margin: 16px auto 0;
  background: var(--accent);
}

/* Избранное — горизонтальная лента, чтобы не спорить с общей сеткой.
   Высота у всех кадров одна, ширину задают пропорции: лента получается
   ровной полосой, но вертикальные кадры не режутся под горизонтальные. */
.strip {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 10px;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

.strip .tile {
  flex: 0 0 auto;
  height: clamp(300px, 38vw, 460px);
  scroll-snap-align: start;
}

/* ---------- фильтры по тегам ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 clamp(22px, 3vw, 34px);
}

.chip {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 15px;
  cursor: pointer;
  transition: color var(--motion), border-color var(--motion),
    background var(--motion);
}

.chip:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.chip.is-active {
  color: var(--ink);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.chip__count {
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- сетка ---------- */

/* Раскладку по колонкам считает JS: кадр уходит в самую короткую колонку,
   поэтому низ сетки получается ровным, а не рваным, как у CSS-колонок. */
.masonry {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}

.masonry__column {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1 1 0;
  min-width: 0;
}

.tile {
  position: relative;
  margin: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: color-mix(in srgb, var(--ink) 5%, var(--bg));
  /* На светлом фоне фото «плывут» — держим их волосяной рамкой */
  border: 1px solid var(--hairline);
  transition: transform var(--motion), box-shadow var(--motion);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 350ms ease;
}

.tile img.is-loaded {
  opacity: 1;
}

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(46, 44, 41, 0.12);
  }
}

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

/* Скелетон вместо спиннера: мягкая волна по месту будущего кадра */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 80%
  );
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.tile.is-ready::before {
  display: none;
}

@keyframes shimmer {
  from {
    background-position: 140% 0;
  }
  to {
    background-position: -40% 0;
  }
}

/* Значок с числом лайков на плитке. Показываем, только если лайки есть:
   пустые сердечки на каждом кадре превратили бы сетку в интерфейс. */
.tile__likes {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(250, 248, 245, 0.82);
  backdrop-filter: blur(6px);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  pointer-events: none;
}

.tile__likes svg {
  fill: var(--accent);
}

/* Значок ролика: сразу видно, что это видео и насколько длинное. */
.tile__play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(46, 44, 41, 0.6);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.tile__play::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.sentinel {
  height: 1px;
}

.grid-end {
  margin: 40px 0 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- лайтбокс ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  /* третья строка — комментарии, пока свёрнуты, она нулевая */
  grid-template-rows: 1fr auto auto;
  background: color-mix(in srgb, var(--bg) 97%, #000);
  animation: fade var(--motion);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* Именно flex, а не grid: в grid процентная max-height у картинки
   считается от трека, который сам меряется по содержимому, — получается
   круг, и кадр вылезает за экран. */
.lightbox__stage {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: clamp(48px, 6vh, 72px) clamp(16px, 6vw, 96px) 8px;
  touch-action: pan-y pinch-zoom;
}

.lightbox__image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 180ms ease;
}

.lightbox__image.is-loaded {
  opacity: 1;
}

/* Ролику отдаём всю сцену: в отличие от фотографии его не жалко
   растянуть, а object-fit не даст исказить пропорции. */
.lightbox__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Встраиваем YouTube только по нажатию: до этого лежит обложка, и ни
   одного запроса на сторону не уходит. */
.lightbox__embed {
  position: relative;
  width: min(100%, 1280px);
  aspect-ratio: 16 / 9;
  max-height: 100%;
  background: #000;
}

.lightbox__embed iframe,
.lightbox__embed img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.lightbox__embed button {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: pointer;
}

.lightbox__embed button::after {
  content: "";
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background: rgba(46, 44, 41, 0.75);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.lightbox__embed button::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 0;
  height: 0;
  border-left: 18px solid #fff;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  margin-left: 5px;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(6px);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--motion), transform var(--motion);
}

.lightbox__close {
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  font-size: 26px;
  line-height: 1;
  padding-bottom: 4px;
}

.lightbox__nav--prev {
  left: 12px;
}

.lightbox__nav--next {
  right: 12px;
}

.lightbox__nav[disabled] {
  opacity: 0.25;
  cursor: default;
}

@media (hover: hover) {
  .lightbox__close:hover,
  .lightbox__nav:not([disabled]):hover {
    background: var(--bg);
    border-color: var(--accent);
  }
}

/* На телефоне стрелки не нужны — там свайп */
@media (max-width: 640px) {
  .lightbox__nav {
    display: none;
  }
}

.lightbox__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px var(--edge) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
}

.lightbox__caption {
  margin: 0;
  flex: 1 1 240px;
  font-family: var(--serif);
  font-size: 19px;
  color: color-mix(in srgb, var(--ink) 85%, transparent);
}

.lightbox__caption:empty::before {
  content: "";
}

.lightbox__actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.lightbox__counter {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Лайк. Счётчик виден до голосования, цифра меняется сразу по нажатию,
   запрос уходит фоном — ждать сети незачем. */
.like {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 2px;
  font: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
}

.like__heart {
  display: grid;
  place-items: center;
}

.like__heart svg {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  transition: fill 160ms ease, stroke 160ms ease;
}

.like[aria-pressed="true"] .like__heart svg {
  fill: var(--accent);
  stroke: var(--accent);
}

/* Пружинка: сердце перелетает через единицу и возвращается */
.like.is-popping .like__heart {
  animation: like-pop 420ms cubic-bezier(0.18, 1.5, 0.4, 1);
}

@keyframes like-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.lightbox__action {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--accent);
  padding: 2px 0;
  cursor: pointer;
  text-decoration: none;
}

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

/* Просьба убрать кадр. Кнопка нарочно тише остальных: нужна редко,
   но найтись должна сразу (SPEC §13). */
.lightbox__quiet {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  cursor: pointer;
  transition: color var(--motion), border-color var(--motion);
}

.lightbox__quiet:hover {
  color: var(--ink);
  border-bottom-color: var(--hairline);
}

.lightbox__quiet[disabled] {
  cursor: default;
  color: var(--muted);
  opacity: 0.7;
}

.report {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(680px, 100%);
  margin: 0 auto;
  padding: 0 var(--edge) 16px;
}

.report__label {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.report__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.report__buttons {
  display: flex;
  gap: 10px;
}

/* Заглушка на месте убранного кадра */
.gone {
  width: var(--page);
  margin: 24px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* ---------- комментарии и гостевая книга ---------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(46vh, 420px);
  padding: 16px var(--edge) calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.thread__list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(680px, 100%);
  margin: 0 auto;
}

.thread__foot {
  width: min(680px, 100%);
  margin: 0 auto;
}

.note-line {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.comment {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Ответ сдвигаем и подпираем волосяной линией — вложенность на один
   уровень, глубже ветки в такой книге не нужны. */
.comment--reply {
  margin-left: 18px;
  padding-left: 14px;
  border-left: 1px solid var(--hairline);
}

.comment__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.comment__author {
  font-size: 14px;
  font-weight: 500;
}

.comment--mine .comment__author {
  color: var(--accent);
}

.comment__when {
  font-size: 12px;
  color: var(--muted);
}

.comment__body {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment__reply {
  align-self: flex-start;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
}

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

/* ---------- форма сообщения ---------- */

.writer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.writer__to {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.writer__cancel {
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.writer__area {
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
  min-height: 76px;
}

.writer__area:focus {
  outline: none;
  border-color: var(--accent);
}

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

.writer__left {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.writer__left.is-over {
  color: #a4453a;
}

.pill-button {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: opacity var(--motion);
}

.pill-button:hover {
  opacity: 0.85;
}

.pill-button[disabled] {
  opacity: 0.4;
  cursor: default;
}

.pill-button--ghost {
  background: none;
  color: var(--ink);
  border-color: var(--hairline);
}

.pill-button--ghost:hover {
  border-color: var(--accent);
}

/* ---------- страница гостевой книги ---------- */

.book {
  width: min(680px, 100% - 2 * var(--edge));
  margin: clamp(32px, 6vw, 72px) auto clamp(48px, 8vw, 96px);
}

.book__intro {
  margin: 0 0 clamp(24px, 4vw, 40px);
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(18px, 2.2vw, 23px);
  font-weight: 300;
  color: color-mix(in srgb, var(--ink) 85%, transparent);
}

.book__list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: clamp(28px, 4vw, 44px);
}

.book__empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- загрузка фотографий гостем ---------- */

.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: clamp(24px, 5vw, 44px) var(--edge);
  border: 1px dashed var(--hairline);
  border-radius: 8px;
  text-align: center;
  transition: border-color var(--motion), background var(--motion);
}

.upload.is-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.upload__gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.queue {
  list-style: none;
  width: min(520px, 100%);
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
  text-align: left;
}

.queue__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue__status {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

.queue__item.is-done .queue__status {
  color: var(--accent);
}

.queue__item.is-failed .queue__status {
  color: #a4453a;
}

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

.footer {
  border-top: 1px solid var(--hairline);
  padding: 32px var(--edge) calc(40px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

/* ---------- меньше движения ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .tile::before {
    display: none;
  }
}

/* Переход миниатюра → полный экран через View Transitions */
::view-transition-old(media),
::view-transition-new(media) {
  animation-duration: 220ms;
}
