/* =========================================================
   Свадебная фотогалерея — Максим и Анастасия
   ========================================================= */

:root {
  --ink: #2b2622;
  --ink-soft: #6b6157;
  --muted: #9a8f84;
  --line: #e7e1d8;
  --cream: #faf7f2;
  --paper: #ffffff;
  --gold: #b8935a;
  --gold-soft: #d8c3a0;
  --accent: #8a6d3b;
  --shadow-sm: 0 2px 8px rgba(43, 38, 34, 0.06);
  --shadow-md: 0 8px 30px rgba(43, 38, 34, 0.12);
  --shadow-lg: 0 20px 60px rgba(43, 38, 34, 0.22);
  --radius: 6px;
  --serif: 'Cormorant Garamond', 'Cormorant', Georgia, 'Times New Roman', serif;
  --sans:
    'Jost', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Header / Hero ---------- */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  color: #fff;
  background: #1a1714;
}

.hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* фото по центру и немного отдалено, чтобы влезало целиком */
  object-position: center center;
  transform: translateY(1.02);
  animation: heroZoom 18s var(--ease) infinite alternate;
}

@keyframes heroZoom {
  from {
    transform: scale(1.02);
  }
  to {
    transform: scale(1.05);
  }
}

.hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(26, 23, 20, 0.35) 0%,
    rgba(26, 23, 20, 0.45) 50%,
    rgba(26, 23, 20, 0.7) 100%
  );
}

.hero__inner {
  position: relative;
  z-index: 2;
  padding: 2rem 1.5rem;
  max-width: 820px;
  animation: fadeUp 1.4s var(--ease) both;
}

.hero__pre {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.92;
  margin-bottom: 1.8rem;
}

.hero__pre .dot {
  display: inline-block;
  margin: 0 0.8em;
  opacity: 0.7;
}

.hero__names {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(3.2rem, 11vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.hero__amp {
  font-style: italic;
  font-weight: 400;
  color: var(--gold-soft);
  display: inline-block;
  margin: 0 0.1em;
  transform: translateY(-0.06em);
}

.hero__date {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  letter-spacing: 0.05em;
  opacity: 0.95;
  margin-top: 1.6rem;
}

.hero__scroll {
  position: absolute;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.8;
  cursor: pointer;
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease);
}

.hero__scroll:hover {
  opacity: 1;
  transform: translateX(-50%) translateY(3px);
}

.hero__scroll::after {
  content: '';
  width: 1px;
  height: 42px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
  animation: scrollLine 2s ease-in-out infinite;
}

@keyframes scrollLine {
  0%,
  100% {
    transform: scaleY(0.4);
    transform-origin: top;
    opacity: 0.4;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* ---------- Gallery toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(250, 247, 242, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.toolbar__brand {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}

.toolbar__brand .amp {
  color: var(--gold);
  font-style: italic;
  transition:
    color 0.3s var(--ease),
    transform 0.3s var(--ease);
  display: inline-block;
}

.toolbar__brand:hover .amp {
  color: var(--accent);
  transform: scale(1.15);
}

.toolbar__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition:
    transform 0.28s var(--ease),
    background 0.28s var(--ease),
    color 0.28s var(--ease),
    border-color 0.28s var(--ease),
    box-shadow 0.28s var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

/* блик, пробегающий по кнопке при наведении */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}

.btn:hover::after {
  animation: btnShine 0.7s var(--ease);
}

@keyframes btnShine {
  to {
    left: 130%;
  }
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.28s var(--ease);
}

.btn--gold {
  background: var(--ink);
  color: #fff;
}

.btn--gold:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn--gold:active {
  transform: translateY(0);
}

.btn--ghost {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.btn--ghost:hover {
  border-color: var(--gold-soft);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn--ghost:active {
  transform: translateY(0);
}

.btn--block {
  width: 100%;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none !important;
  box-shadow: none !important;
}

.btn:disabled::after {
  display: none;
}

/* ---------- Gallery section ---------- */
.gallery-section {
  padding: 3.5rem 1.5rem 5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-head {
  text-align: center;
  margin-bottom: 2.5rem;
}

.gallery-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.gallery-head .ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0.8rem 0 0.4rem;
  color: var(--gold);
  animation: ornamentPulse 3.5s var(--ease) infinite;
}

@keyframes ornamentPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.gallery-head .ornament::before,
.gallery-head .ornament::after {
  content: '';
  width: 50px;
  height: 1px;
  background: var(--gold-soft);
}

.gallery-head p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.gallery-head .count {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Masonry grid ---------- */
/* Число колонок задаём через CSS-переменную, чтобы JS мог её прочитать
   и распределить фото по колонкам слева направо (round-robin). */
.grid {
  --cols: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  align-items: start;
  gap: 1rem;
}

@media (max-width: 900px) {
  .grid {
    --cols: 2;
  }
}

@media (max-width: 560px) {
  .grid {
    --cols: 1;
  }
}

/* Каждая колонка — вертикальный стопчик плиток с натуральной высотой.
   min-width:0 не даёт flex-детям раздувать колонку. */
.masonry-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.tile {
  /* <button> defaults to inline-block; force block so it fills the column */
  display: block;
  width: 100%;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition:
    transform 0.45s var(--ease),
    box-shadow 0.45s var(--ease),
    outline-color 0.3s var(--ease);
  opacity: 0;
  transform: translateY(18px);
  animation: tileIn 0.6s var(--ease) forwards;
  /* тонкая золотая рамка, проявляется при наведении */
  outline: 1px solid transparent;
  outline-offset: 0;
}

@keyframes tileIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tile::after {
  /* блик-свечение, пробегающий по плитке при наведении */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.28) 45%,
    rgba(255, 255, 255, 0.05) 55%,
    transparent 70%
  );
  transform: translateX(-120%);
  pointer-events: none;
  z-index: 3;
}

.tile:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  outline-color: var(--gold-soft);
}

.tile:hover::after {
  animation: tileShine 0.9s var(--ease);
}

@keyframes tileShine {
  to {
    transform: translateX(120%);
  }
}

.tile__img {
  width: 100%;
  height: auto;
  display: block;
  transition:
    transform 0.7s var(--ease),
    filter 0.45s var(--ease);
}

.tile:hover .tile__img {
  transform: scale(1.06);
}

.tile__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.7rem 0.8rem;
  background: linear-gradient(
    to top,
    rgba(26, 23, 20, 0.6) 0%,
    rgba(26, 23, 20, 0.08) 35%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  z-index: 2;
  pointer-events: none;
}

.tile:hover .tile__overlay,
.tile:focus-visible .tile__overlay {
  opacity: 1;
}

.tile__num {
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
  transform: translateY(6px);
  opacity: 0;
  transition:
    transform 0.4s var(--ease),
    opacity 0.4s var(--ease);
}

.tile:hover .tile__num,
.tile:focus-visible .tile__num {
  transform: translateY(0);
  opacity: 1;
}

.tile__dl {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  opacity: 0;
  transform: translateY(-6px) scale(0.85);
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease),
    background 0.25s var(--ease),
    color 0.25s var(--ease);
  box-shadow: var(--shadow-sm);
  z-index: 4;
}

.tile__dl svg {
  width: 17px;
  height: 17px;
}

.tile:hover .tile__dl {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tile__dl:hover {
  background: var(--gold);
  color: #fff;
  transform: scale(1.1) !important;
}

.tile__dl:hover svg {
  animation: dlBob 0.6s var(--ease);
}

@keyframes dlBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(2px);
  }
}

/* ---------- Loading / empty states ---------- */
.state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--ink-soft);
}

.state__spinner {
  width: 34px;
  height: 34px;
  border: 2.5px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 17, 14, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lightbox.is-open {
  display: flex;
  animation: lbFade 0.3s var(--ease);
}

@keyframes lbFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox__stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem 6rem;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  animation: lbImg 0.4s var(--ease);
}

@keyframes lbImg {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Lightbox controls */
.lb-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: 50%;
  transition:
    background 0.3s var(--ease),
    transform 0.3s var(--ease),
    color 0.3s var(--ease);
  z-index: 2;
}

.lb-btn svg {
  width: 26px;
  height: 26px;
  transition: transform 0.3s var(--ease);
}

.lb-close {
  top: 1.2rem;
  right: 1.2rem;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.12);
}

.lb-close:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg) scale(1.05);
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lb-nav:hover {
  background: rgba(255, 255, 255, 0.26);
}

.lb-nav:hover svg {
  transform: scale(1.15);
}

.lb-prev {
  left: 1rem;
}

.lb-next {
  right: 1rem;
}

.lb-nav:hover.lb-prev {
  transform: translateY(-50%) translateX(-4px);
}

.lb-nav:hover.lb-next {
  transform: translateY(-50%) translateX(4px);
}

/* Lightbox bottom bar */
.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.5rem;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
}

.lb-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.lb-caption {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-counter {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.lb-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

.lb-actions .btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.lb-actions .btn:hover {
  background: rgba(216, 195, 160, 0.35);
  border-color: var(--gold-soft);
}

.lb-actions .btn:hover svg {
  transform: translateY(2px);
}

@media (max-width: 600px) {
  .lb-nav {
    width: 44px;
    height: 44px;
  }
  .lb-nav svg {
    width: 20px;
    height: 20px;
  }
  .lb-caption {
    font-size: 1rem;
  }
  .lb-bar {
    flex-wrap: wrap;
    padding: 0.9rem 1rem 1.4rem;
  }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 3rem 1.5rem 3.5rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.footer__names {
  font-family: var(--serif);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
}

.footer__names .amp {
  color: var(--gold);
  font-style: italic;
}

.footer__date {
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.footer__credit {
  margin-top: 1.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.footer__credit a {
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: color 0.2s;
}

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

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastIn 0.3s var(--ease);
}

.toast.is-out {
  animation: toastOut 0.3s var(--ease) forwards;
}

.toast svg {
  width: 16px;
  height: 16px;
  color: var(--gold-soft);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ---------- Progress overlay (download-all) ---------- */
.progress {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 17, 14, 0.85);
  backdrop-filter: blur(4px);
}

.progress.is-open {
  display: flex;
}

.progress__card {
  background: var(--paper);
  border-radius: 12px;
  padding: 2rem 2.2rem;
  width: min(360px, 88vw);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.progress__title {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.progress__sub {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 1.3rem;
}

.progress__bar {
  height: 7px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  border-radius: 999px;
  transition: width 0.25s var(--ease);
}

.progress__pct {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
