:root {
  --ink: #14100f;
  --paper: #f7f1ea;
  --accent: #e8b4b8;
  --accent-deep: #c97b86;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --pad-top: env(safe-area-inset-top, 0px);
  --pad-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* атрибут hidden должен побеждать любые display ниже */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.show { overflow: hidden; }

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

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.kicker {
  font-size: 12px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 20px;
}

.btn {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper);
  border-radius: 999px;
  padding: 14px 34px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform .3s cubic-bezier(.2,.7,.2,1), background .3s, color .3s;
}
.btn:hover { transform: translateY(-2px); }
.btn--big { padding: 18px 52px; font-size: 15px; }
.btn--ghost { background: none; color: var(--paper); border-color: rgba(247,241,234,.35); }
.btn--ghost:hover { border-color: var(--paper); }

/* ---------- обложка и финал ---------- */

.intro, .finale {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--pad-top) + 32px) 20px calc(var(--pad-bottom) + 32px);
  background:
    radial-gradient(120% 90% at 50% 40%, #2a201e 0%, #14100f 70%);
  animation: fadeIn 1.4s ease both;
}

.intro.is-gone, .finale.is-gone { animation: fadeOut .9s ease both; pointer-events: none; }

.intro__inner { max-width: 640px; }

.intro__name {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(60px, 20vw, 150px);
  line-height: .9;
  margin: 0;
  letter-spacing: -.01em;
}

.intro__sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(19px, 4.6vw, 25px);
  color: rgba(247,241,234,.72);
  margin: 20px auto 0;
  max-width: 32ch;
}

.intro__count {
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(247,241,234,.45);
  margin: 14px 0 0;
}

.intro .btn { margin-top: 42px; }

.intro__hint {
  font-size: 12px;
  letter-spacing: .1em;
  color: rgba(247,241,234,.4);
  margin: 18px 0 0;
}

.finale__actions {
  margin-top: 40px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- вопрос на входе ---------- */

.gate {
  margin: 38px auto 0;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gate__q {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: rgba(247,241,234,.72);
}

.gate__input {
  width: 100%;
  font-family: var(--sans);
  font-size: 17px;
  text-align: center;
  color: var(--paper);
  background: rgba(247,241,234,.06);
  border: 1px solid rgba(247,241,234,.25);
  border-radius: 999px;
  padding: 13px 20px;
  outline: none;
  transition: border-color .25s, background .25s;
}
.gate__input:focus { border-color: var(--accent); background: rgba(247,241,234,.1); }
.gate__input::placeholder { color: rgba(247,241,234,.35); }

.gate__error {
  margin: 0;
  font-size: 13px;
  color: var(--accent);
}

/* ---------- сцена ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  background: var(--ink);
}

.stage__bg {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: center;
  filter: blur(26px) saturate(115%);
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 2.4s ease;
  will-change: opacity, transform;
}
.stage__bg.is-on { opacity: .62; animation: drift 18s ease-out forwards; }

.stage__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(100% 75% at 50% 45%, rgba(20,16,15,.08) 0%, rgba(20,16,15,.72) 100%);
}

.stage__cards { position: absolute; inset: 0; }

.card {
  position: absolute;
  margin: 0;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  transform: translate(-50%, -50%) rotate(var(--r)) scale(.86);
  opacity: 0;
  padding: 10px 10px 34px;
  background: #fbf7f2;
  border-radius: 2px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.95), 0 2px 8px rgba(0,0,0,.35);
  animation: cardIn 1.3s cubic-bezier(.16,.84,.26,1) forwards;
  will-change: transform, opacity;
  transition: filter .9s ease;
}

/* пока говорит строка — фотографии уходят на второй план */
.stage.is-telling .card { filter: brightness(.45) saturate(.8); }

.card img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: cover;
  background: #e6ddd4;
  opacity: 0;
  transition: opacity .5s ease;
}

.card img.is-ready { opacity: 1; }

.card.is-out { animation: cardOut 1.6s ease forwards; }

/* ---------- всплывающие реплики ---------- */

.moment {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad-bottom) + 15vh);
  transform: translateX(-50%);
  width: min(720px, 88vw);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  animation: momentIn 1.2s ease forwards;
  text-shadow: 0 2px 22px rgba(0,0,0,.85);
}

.moment::before {
  content: "";
  position: absolute;
  inset: -130px -22vw;
  z-index: -1;
  background: radial-gradient(50% 50% at 50% 50%, rgba(12,9,8,.86) 0%, rgba(12,9,8,.5) 52%, rgba(12,9,8,0) 100%);
}
.moment.is-out { animation: momentOut 1.2s ease forwards; }

.moment__label {
  display: block;
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.moment__text {
  font-family: var(--serif);
  font-size: clamp(24px, 5.4vw, 40px);
  line-height: 1.3;
  margin: 0;
}

/* ---------- панель управления ---------- */

.bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(20,16,15,.72);
  border: 1px solid rgba(247,241,234,.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  max-width: calc(100vw - 24px);
  transition: opacity .5s ease, transform .5s ease;
}
.bar.is-hidden { opacity: 0; transform: translateX(-50%) translateY(14px); pointer-events: none; }

.bar__btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--paper);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: .8;
  transition: opacity .2s, background .2s;
}
.bar__btn:hover { opacity: 1; background: rgba(247,241,234,.12); }

.bar__track {
  min-width: 0;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.bar__title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__artist {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(247,241,234,.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__progress {
  width: 92px;
  height: 2px;
  background: rgba(247,241,234,.2);
  border-radius: 2px;
  overflow: hidden;
  flex: none;
}
.bar__progress i { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- страница галереи ---------- */

body.page { overflow-y: auto; background: var(--ink); }

.page__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(var(--pad-top) + 32px) 16px 24px;
}

.page__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(30px, 7vw, 52px);
  margin: 0;
}

.page__note {
  font-family: var(--serif);
  font-style: italic;
  color: rgba(247,241,234,.6);
  font-size: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  padding-bottom: calc(var(--pad-bottom) + 48px);
}

.tile {
  position: relative;
  padding: 0;
  border: 0;
  background: #241c1a;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: transform .6s cubic-bezier(.2,.7,.2,1), opacity .6s ease;
}
.tile img.is-loaded { opacity: .92; }
.tile:hover img { transform: scale(1.05); opacity: 1; }

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0807;
  padding: calc(var(--pad-top) + 16px) 16px calc(var(--pad-bottom) + 16px);
}

.lb__figure {
  margin: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lb__figure img { max-height: 82svh; width: auto; object-fit: contain; }

.lb__figure figcaption { color: rgba(247,241,234,.6); font-size: 13px; text-align: center; }

.lb__close, .lb__nav {
  position: absolute;
  background: none;
  border: 0;
  color: var(--paper);
  cursor: pointer;
  opacity: .6;
  line-height: 1;
  transition: opacity .2s;
}
.lb__close:hover, .lb__nav:hover { opacity: 1; }

.lb__close { top: calc(var(--pad-top) + 10px); right: 16px; font-size: 38px; }

.lb__nav { top: 50%; transform: translateY(-50%); font-size: 52px; padding: 8px 14px; }
.lb__nav--prev { left: 2px; }
.lb__nav--next { right: 2px; }

/* ---------- анимации ---------- */

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }

@keyframes cardIn {
  0%   { opacity: 0; transform: translate(-50%, calc(-50% + 46px)) rotate(var(--r)) scale(.86); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)) scale(1); }
}

@keyframes cardOut {
  0%   { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)) scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 54px)) rotate(var(--r)) scale(1.04); }
}

@keyframes momentIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(24px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes momentOut {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-22px); }
}

@keyframes drift {
  from { transform: scale(1.06); }
  to   { transform: scale(1.18); }
}

@media (max-width: 640px) {
  body { font-size: 16px; }

  .card { padding: 7px 7px 26px; }
  .card img { max-height: 62vh; }

  /* реплика садится над панелью, а не поверх неё */
  .moment { bottom: calc(var(--pad-bottom) + 104px); width: 92vw; }
  .moment::before { inset: -70px -10vw; }
  .moment__text { font-size: clamp(22px, 6vw, 30px); }
  .moment__label { font-size: 10px; letter-spacing: .26em; }

  /* по кнопкам надо попадать пальцем */
  .bar { bottom: calc(var(--pad-bottom) + 12px); gap: 2px; padding: 6px 8px; }
  .bar__btn { width: 46px; height: 46px; font-size: 17px; }
  .bar__track { display: none; }
  .bar__progress { width: 56px; }

  .intro, .finale { padding-left: 18px; padding-right: 18px; }
  .intro .btn { margin-top: 32px; }
  .gate { margin-top: 30px; gap: 12px; }
  .finale__actions { gap: 10px; }

  .grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .page__head { padding-top: calc(var(--pad-top) + 22px); padding-bottom: 18px; }

  .lb__nav { font-size: 40px; padding: 12px 10px; }
  .lb__close { font-size: 34px; }
}

/* телефон боком: по высоте места почти нет */
@media (max-height: 520px) and (orientation: landscape) {
  .card img { max-height: 60vh; }
  .moment { bottom: calc(var(--pad-bottom) + 70px); }
  .moment::before { inset: -46px -12vw; }
  .moment__text { font-size: 19px; }
  .moment__label { margin-bottom: 4px; }
  .intro__name { font-size: clamp(44px, 12vh, 78px); }
  .intro .btn { margin-top: 20px; }
  .intro__count, .intro__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation-duration: .6s; }
  .stage__bg.is-on { animation: none; }
  .btn:hover { transform: none; }
}
