/* ==========================================================================
   Переменные
   ========================================================================== */

:root {
  color-scheme: light;

  --ink: #101410;
  --muted: #747a76;
  --paper: #fff;
  --line: #c9cdca;
  --glow: rgba(145, 255, 131, .52);

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, Arial, Helvetica, sans-serif;
}

/* ==========================================================================
   База
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #fff;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid #1735a0;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  background: #111;
  transform: translateY(-160%);
  transition: transform .2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ==========================================================================
   Бегущая строка с ключевыми словами
   ========================================================================== */

.keyword-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 42px;
  overflow: hidden;
  padding: 6px 0;
}

.keyword-track {
  display: flex;
  width: max-content;
  gap: 6px;
  animation: keyword-marquee 48s linear infinite;
}

.keyword-track span {
  flex: 0 0 auto;
  padding: 7px 14px 6px;
  border-radius: 999px;
  color: #3b403c;
  background: #FFF8D233;
  box-shadow: inset 0 0 0 1px rgba(90, 109, 98, .05);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.keyword-bar:hover .keyword-track {
  animation-play-state: paused;
}

@keyframes keyword-marquee {
  to {
    transform: translateX(-50%);
  }
}

/* ==========================================================================
   Главная: обложка и категории
   ========================================================================== */

.hero {
  position: relative;
  height: 100svh;
  min-height: 680px;
  overflow: hidden;
  --card-h: 230px;
  --credits-h: 172px;
  --intro-y: max(98px, 13.2%);
  --grid-pref: 47.7%;
  --credits-pref: 74.9%;
  --credits-y: min(var(--credits-pref), calc(100% - var(--credits-h) - 26px));
  --grid-y: max(212px, min(var(--grid-pref), calc(var(--credits-y) - var(--card-h) - 16px)));
  background-color: #a9c1c0;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, .02), rgba(16, 35, 20, .08)),
    url("/assets/background/hero.webp");
  background-position: center center;
  background-size: cover;
}

.hero-intro,
.category-grid,
.credits {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.hero-intro {
  top: var(--intro-y);
  width: min(760px, calc(100% - 40px));
  text-align: center;
  text-shadow: 0 1px 18px rgba(255, 255, 255, .48);
}

.hero-intro h1,
.collection-intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 4vw, 58px);
  font-style: italic;
  line-height: 1;
  font-weight: 500;
  letter-spacing: -.03em;
}

.hero-intro p {
  margin: 14px 0 0;
  font-size: clamp(14px, 1.25vw, 18px);
}

.category-grid {
  top: var(--grid-y);
  width: 860px;
  display: grid;
  grid-template-columns: repeat(4, 200px);
  gap: 20px;
}

.category-card {
  width: 200px;
  height: 230px;
  min-width: 0;
  padding: 15px 15px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(103, 124, 103, .18);
  border-radius: 24px;
  color: #252925;
  background: rgba(255, 255, 255, .96);
  box-shadow:
    inset 0 -4px 15px 0 rgba(128, 191, 108, .9),
    0 16px 30px rgba(13, 38, 17, .08);
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  transition: transform .2s ease, box-shadow .5s ease;
}

.category-card:hover {
  box-shadow:
    inset 0 -4px 69px 0 rgba(128, 191, 108, .9),
    0 20px 34px rgba(13, 38, 17, .15);
}

.category-art {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: transparent;
}

.category-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.category-art--ice img {
  transform: scale(1.1);
}

.category-art--azure img {
  transform: scale(.9);
}

/* ==========================================================================
   Главная: блок авторства
   ========================================================================== */

.credits {
  top: var(--credits-y);
  width: 420px;
  min-height: 172px;
  padding: 24px 30px 20px;
  border: 1px solid rgba(103, 124, 103, .16);
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  box-shadow:
    inset 0 0 18px 1px var(--glow),
    0 16px 30px rgba(13, 38, 17, .08);
  text-align: center;
}

.credits-action,
.credits > p {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-style: italic;
  font-weight: 500;
}

.credits-action {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.credits-action:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.credits .credits-link {
  margin-top: 10px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.credits dl {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
  color: #797d79;
  font-size: 13px;
}

.credits dl div {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.credits dd {
  margin: 0;
}

.social {
  position: relative;
}

.social-trigger {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.social-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  z-index: 5;
  min-width: 150px;
  margin: 0;
  padding: 8px;
  list-style: none;
  border: 1px solid rgba(103, 124, 103, .16);
  border-radius: 16px;
  background: #fff;
  box-shadow:
    inset 0 0 12px 1px var(--glow),
    0 12px 24px rgba(13, 38, 17, .12);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.social-popup::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(103, 124, 103, .16);
  border-bottom: 1px solid rgba(103, 124, 103, .16);
  border-bottom-right-radius: 3px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(45deg);
}

.social-popup::after {
  content: "";
  position: absolute;
  inset: 100% 0 -12px;
}

.social.is-open .social-popup {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (hover: hover) {
  .social:hover .social-popup {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }
}

.social-popup a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  color: #252925;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.social-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: #6f8f66;
}

.social-popup a:hover,
.social-popup a:focus-visible {
  background: rgba(128, 191, 108, .18);
}

/* ==========================================================================
   Диалог «Условия использования»
   ========================================================================== */

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

.terms-dialog {
  width: min(610px, calc(100% - 8px));
  max-height: none;
  padding: 20px;
  overflow: visible;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.terms-dialog::backdrop {
  background: rgba(9, 13, 10, .78);
  backdrop-filter: blur(3px);
}

.terms-dialog__panel {
  position: relative;
  max-height: calc(100svh - 40px);
  padding: 32px;
  overflow: auto;
  border: 1px solid rgba(103, 124, 103, .16);
  border-radius: 26px;
  background: #fff;
  box-shadow: inset 0 0 30px 4px rgba(145, 255, 131, .62);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.55;
}

.terms-dialog__panel p {
  margin: 0 0 16px;
}

.terms-dialog__panel p:last-child {
  margin-bottom: 0;
}

.terms-heading {
  position: relative;
  margin: 0 0 8px;
  padding-left: 28px;
  font-size: 15px;
  font-weight: 300;
}

.terms-heading::before {
  position: absolute;
  left: 0;
}

.terms-heading--allowed::before {
  content: "✅";
}

.terms-heading--forbidden::before {
  content: "❌";
}

.terms-list {
  margin: 0 0 16px;
  padding-left: 28px;
  font-size: 15px;
  list-style: disc;
}

.terms-note {
  color: #8b8f8b;
  font-size: 15px;
}

.terms-dialog__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #737873;
  background: #f0f2f0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.donate-panel {
  text-align: center;
}

.donate-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  font-weight: 500;
}

.donate-qr {
  display: block;
  width: min(240px, 100%);
  height: auto;
  margin: 8px auto 16px;
  image-rendering: pixelated;
}

.donate-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  margin: 0 auto 16px;
  padding: 6px 6px 6px 14px;
  border: 1px solid rgba(103, 124, 103, .16);
  border-radius: 14px;
  background: #f6f8f6;
}

.donate-card__number {
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
}

.donate-card__copy {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: #2f3a30;
  cursor: pointer;
  transition: background .2s;
}

.donate-card__copy:hover {
  background: #445245;
}

.donate-card__copy.is-copied {
  background: #3f8f4a;
}

.donate-card__icon {
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .2s, transform .2s;
}

.donate-card__icon--check,
.is-copied .donate-card__icon--copy {
  opacity: 0;
  transform: scale(.6);
}

.is-copied .donate-card__icon--check {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Страница коллекции
   ========================================================================== */

.collection-page {
  min-height: 100dvh;
  background: #fff;
}

.collection-main {
  position: relative;
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 34px 30px 80px;
}

.collection-home {
  position: absolute;
  top: 34px;
  right: 30px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  color: #000;
  background: #eef0ee;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 300;
}

.collection-home svg path {
  fill: currentColor;
}

.collection-home:hover {
  color: #000;
  background: #e2e5e2;
}

.collection-home-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.collection-intro {
  max-width: 980px;
  margin: 30px auto 47px;
  text-align: center;
}

.collection-intro h1 {
  font-size: 48px;
}

.collection-intro p {
  margin: 16px auto 0;
  max-width: 930px;
  color: #777d79;
  font-size: 17px;
  line-height: 1.45;
}

.collection-note {
  margin-top: 18px;
  color: #6e5722;
  font-size: 14px;
}

/* ==========================================================================
   Сетка орнаментов
   ========================================================================== */

.ornament-grid {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 38px 34px;
  list-style: none;
}

.ornament-item {
  min-width: 0;
  display: grid;
  gap: 13px;
}

.ornament-card {
  height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
}

.ornament-preview {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
  text-decoration: none;
}

.ornament-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .25s ease;
}

.ornament-preview:hover img {
  transform: scale(1.035);
}

.download-button {
  width: min(145px, 74%);
  justify-self: start;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #232423;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  transition: background .2s ease, transform .2s ease;
}

.download-button:hover {
  background: #050505;
  transform: translateY(-2px);
}

.download-button[aria-disabled="true"] {
  color: #777;
  background: #e6e8e6;
  cursor: not-allowed;
}

.preview-dialog {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 64px 88px 32px;
  border: 0;
  background: transparent;
}

.preview-dialog[open] {
  display: grid;
  place-items: center;
  animation: preview-in .22s ease;
}

.preview-dialog::backdrop {
  background: rgba(9, 13, 10, .86);
  backdrop-filter: blur(4px);
}

html:has(.preview-dialog[open]) {
  overflow: hidden;
}

.preview-dialog__frame {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 20px;
}

.preview-dialog__image {
  width: min(860px, calc(100vw - 176px), calc(100svh - 160px));
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

.preview-dialog .preview-dialog__download {
  justify-self: center;
  color: var(--ink);
  background: #fff;
}

.preview-dialog__download:hover {
  background: #e9ece9;
}

.preview-dialog__close,
.preview-dialog__nav {
  position: absolute;
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease;
  z-index: 1;
}

.preview-dialog__close:hover,
.preview-dialog__nav:hover {
  background: rgba(255, 255, 255, .24);
}

.preview-dialog__close {
  top: 16px;
  right: 16px;
}

.preview-dialog__nav {
  top: 50%;
  translate: 0 -50%;
  font-size: 38px;
  padding-bottom: 4px;
}

.preview-dialog__nav--prev {
  left: 20px;
}

.preview-dialog__nav--next {
  right: 20px;
}

@keyframes preview-in {
  from {
    opacity: 0;
    transform: scale(.97);
  }
}

.collection-footer {
  margin-top: 72px;
  color: #777d79;
  text-align: center;
  font-size: 13px;
}

.collection-error {
  margin: 40px auto;
  color: #8b2727;
  text-align: center;
}

/* ==========================================================================
   Переходы между страницами и появление карточек
   ========================================================================== */

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: lift-out .18s ease both;
}

::view-transition-new(root) {
  animation: lift-in .3s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes lift-out {
  to {
    opacity: 0;
  }
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
}

.collection-intro {
  animation: rise .55s cubic-bezier(.2, .7, .3, 1) both;
}

.ornament-item {
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(120ms + var(--i, 0) * 32ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(26px) scale(.97);
  }
}

/* ==========================================================================
   Адаптив
   ========================================================================== */

@media (max-width: 1499px) {
  .ornament-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1300px) and (min-width: 901px) {
  .hero {
    --card-h: 190px;
    --credits-h: 145px;
    --intro-y: max(88px, 15.2%);
    --grid-pref: 42.8%;
    --credits-pref: 76%;
  }

  .category-grid {
    width: 620px;
    grid-template-columns: repeat(4, 140px);
    gap: 20px;
  }

  .category-card {
    width: 140px;
    height: 190px;
    padding: 10px;
    gap: 10px;
    border-radius: 20px;
    font-size: 12px;
  }

  .category-art {
    flex: 0 0 120px;
    border-radius: 16px;
  }

  .credits {
    width: 316px;
    min-height: 145px;
    padding: 18px 24px 16px;
    border-radius: 22px;
  }

  .credits-action,
  .credits > p {
    font-size: 17px;
  }

  .credits .credits-link {
    margin-top: 8px;
  }

  .credits dl {
    margin-top: 11px;
    gap: 7px;
    font-size: 11px;
  }
}

@media (max-width: 1100px) {
  .ornament-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) and (min-width: 761px) {
  .hero {
    height: 1024px;
    min-height: 100svh;
    background-position: 51% center;
  }

  .hero-intro {
    top: 130px;
  }

  .category-grid {
    top: 480px;
    width: 596px;
    grid-template-columns: repeat(4, 140px);
    gap: 12px;
  }

  .category-card {
    width: 140px;
    height: 190px;
    padding: 10px;
    gap: 10px;
    border-radius: 20px;
    font-size: 12px;
  }

  .category-art {
    flex: 0 0 120px;
    border-radius: 16px;
  }

  .credits {
    top: 748px;
    width: 316px;
    min-height: 145px;
    padding: 18px 24px 16px;
    border-radius: 22px;
  }

  .credits-action,
  .credits > p {
    font-size: 17px;
  }

  .credits .credits-link {
    margin-top: 8px;
  }

  .credits dl {
    margin-top: 11px;
    gap: 7px;
    font-size: 11px;
  }
}

@media (max-width: 760px) {
  .preview-dialog {
    padding: 64px 12px 24px;
  }

  .preview-dialog__image {
    width: min(calc(100vw - 24px), calc(100svh - 160px));
    border-radius: 18px;
  }

  .preview-dialog__nav {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, .45);
    font-size: 32px;
  }

  .preview-dialog__nav--prev {
    left: 18px;
  }

  .preview-dialog__nav--next {
    right: 18px;
  }

  .keyword-bar {
    height: 39px;
  }

  .keyword-track span {
    padding: 6px 12px;
    font-size: 12px;
  }

  .hero {
    height: 800px;
    min-height: 100svh;
    background-position: 52% center;
  }

  .hero-intro {
    top: 105px;
    width: min(360px, calc(100% - 40px));
  }

  .hero-intro h1 {
    font-size: clamp(38px, 10.2vw, 42px);
    line-height: .98;
  }

  .hero-intro p {
    max-width: 270px;
    margin: 12px auto 0;
    line-height: 1.35;
  }

  .category-grid {
    top: 398px;
    left: 0;
    width: 100%;
    padding: 10px 28px 18px;
    overflow-x: auto;
    transform: none;
    grid-template-columns: repeat(4, 140px);
    gap: 10px;
    scroll-padding-inline: 28px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .category-grid::-webkit-scrollbar {
    display: none;
  }

  .category-card {
    width: 140px;
    height: 190px;
    padding: 10px;
    gap: 10px;
    border-radius: 20px;
    scroll-snap-align: start;
    font-size: 12px;
  }

  .category-art {
    flex: 0 0 120px;
    border-radius: 16px;
  }

  .credits {
    top: 650px;
    width: min(342px, calc(100% - 32px));
    min-height: 145px;
    padding: 18px 24px 16px;
    border-radius: 22px;
  }

  .credits-action,
  .credits > p {
    font-size: 17px;
  }

  .credits .credits-link {
    margin-top: 8px;
  }

  .credits dl {
    margin-top: 11px;
    gap: 7px;
    font-size: 11px;
  }

  .terms-dialog__panel {
    padding: 40px 24px 30px;
    font-size: 15px;
  }

  .terms-heading,
  .terms-list,
  .terms-note {
    font-size: 14px;
  }

  .terms-list {
    padding-left: 34px;
  }

  .collection-main {
    padding: 22px 20px 60px;
  }

  .collection-home {
    top: 22px;
    right: 20px;
  }

  .collection-intro {
    margin: 56px auto 44px;
  }

  .collection-intro h1 {
    font-size: 40px;
  }

  .collection-intro p {
    font-size: 15px;
  }

  .ornament-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px 18px;
  }

  .ornament-card {
    height: 270px;
    border-radius: 18px;
  }

    .download-button {
    justify-self: start;
  }
}

@media (max-width: 470px) {
  .hero {
    background-position: 54% center;
  }

  .ornament-grid {
    grid-template-columns: 1fr;
  }

  .ornament-card {
    height: 340px;
  }
}

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

  .keyword-track {
    animation: none;
  }

  .category-card,
  .ornament-preview img,
  .download-button {
    transition: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  .collection-intro,
  .ornament-item,
  .preview-dialog[open] {
    animation: none;
  }
}
