/* ═══════════════════════════════════════════════════════════════════════════
   Экран 7 («А теперь переходим к подаркам», вариант «Монолит») — изолированные
   стили для основного лендинга sec2/d1.html со светлой бумажной палитрой,
   чернильным центром #16202F и залипающей лесенкой как в psycholog-demo.
   ═══════════════════════════════════════════════════════════════════════════ */

.gifts-chapter {
  --gch-paper-deep: #ecebe8;
  --gch-paper: #f4f3f0;
  --gch-sheet: #f7f6f3;
  --gch-navy: #192236;
  --gch-navy-panel: #16202f;
  --gch-navy-glow: #3a526d;
  --gch-steel: #355075;
  --gch-ivory: #f5f3ea;
  --gch-dark-body: #e4e9ea;
  --gch-dark-muted: #c2ced7;
  --gch-ink: #141821;
  --gch-body: #2a2d33;
  --gch-muted: #484b52;
  --gch-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gch-pad: clamp(1.25rem, 5vw, 5.5rem);
  --gch-maxw: 83.5rem;

  position: relative;
  background-color: var(--gch-paper-deep);
  background-image:
    radial-gradient(ellipse 56% 52% at 10% 8%, rgb(247 246 243 / 0.92) 0%, transparent 72%),
    radial-gradient(ellipse 42% 48% at 88% 92%, rgb(244 243 240 / 0.72) 0%, transparent 72%);
  color: var(--gch-ink);
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  scroll-margin-top: 0;
}

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

.gifts-chapter h2,
.gifts-chapter h3,
.gifts-chapter p {
  margin: 0;
}

.gifts-chapter svg {
  display: block;
}

.gifts-chapter ::selection {
  background: var(--gch-navy);
  color: var(--gch-ivory);
}

.gifts-chapter :focus-visible {
  outline: 2px solid var(--gch-navy);
  outline-offset: 0.25rem;
  border-radius: 0.25rem;
}

.gifts-chapter .gch-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(3.5rem, 5.4vw, 5.25rem) clamp(4.75rem, 7.2vw, 7rem);
  padding-inline: var(--gch-pad);
}

.gifts-chapter .gch-dots {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  inset-block-start: 0;
  inset-inline-end: 0;
  inline-size: min(44%, 36.25rem);
  block-size: clamp(12.5rem, 26vw, 21.25rem);
  background: radial-gradient(circle, var(--gch-navy-glow) 1.15px, transparent 1.55px) top right / 0.875rem 0.875rem;
  opacity: 0.2;
  mask-image: radial-gradient(ellipse at 100% 6%, #141821 10%, rgb(20 24 33 / 0.55) 40%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse at 100% 6%, #141821 10%, rgb(20 24 33 / 0.55) 40%, transparent 74%);
}

.gifts-chapter .gch-meter {
  position: absolute;
  inset-inline-end: clamp(0.875rem, 2.4vw, 2.375rem);
  inset-block-start: 50%;
  transform: translateY(-50%);
  inline-size: 2px;
  block-size: clamp(4.5rem, 11svh, 7.375rem);
  border-radius: 999px;
  background: rgb(25 34 54 / 0.12);
  overflow: clip;
  pointer-events: none;
  opacity: 0;
}

.gifts-chapter .gch-meter i {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  background: var(--gch-navy);
  transform-origin: top;
  transform: scaleY(0.1);
}

.gifts-chapter .gch-bound {
  position: relative;
  z-index: 1;
  inline-size: min(100%, var(--gch-maxw));
  margin-inline: auto;
}

.gifts-chapter .gch-num {
  font-variant-numeric: tabular-nums;
}

/* ── Шапка блока ── */
.gifts-chapter .gch-head {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
  column-gap: clamp(1.75rem, 4.5vw, 4.5rem);
  row-gap: 0.875rem;
  align-items: end;
  margin-block-end: clamp(1.75rem, 3vw, 2.625rem);
}

.gifts-chapter .gch-title {
  font-weight: 500;
  color: var(--gch-navy);
  font-size: clamp(2.125rem, 4vw, 3.75rem);
  line-height: 1.06;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

.gifts-chapter .gch-lead {
  max-inline-size: 34ch;
  justify-self: end;
  font-size: clamp(1.125rem, 1.45vw, 1.5rem);
  font-weight: 430;
  line-height: 1.38;
  letter-spacing: -0.015em;
  color: var(--gch-muted);
  text-wrap: balance;
}

/* ── Сетка 3 монолитов на subgrid ── */
.gifts-chapter .gch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto 1fr auto;
  column-gap: clamp(1rem, 1.8vw, 1.5rem);
  row-gap: 0;
  align-items: stretch;
}

.gifts-chapter .gch-card {
  position: relative;
  grid-row: span 4;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-rows: subgrid;
  align-items: start;
  min-inline-size: 0;
  padding: clamp(1.625rem, 2.5vw, 2.25rem);
  border-radius: 1.25rem;
  background-color: var(--gch-sheet);
  box-shadow:
    inset 0 1px 0 rgb(247 246 243 / 0.95),
    0 1.125rem 2.5rem -1.75rem rgb(20 24 33 / 0.22);
  overflow: clip;
  transition:
    transform 0.55s var(--gch-ease),
    opacity 0.45s var(--gch-ease),
    box-shadow 0.55s var(--gch-ease);
}

.gifts-chapter .gch-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    21.25rem circle at var(--mx, 50%) var(--my, 24%),
    rgb(38 53 84 / 0.065) 0%,
    transparent 68%
  );
  opacity: 0;
  transition: opacity 0.5s var(--gch-ease);
}

.gifts-chapter .gch-card > * {
  position: relative;
  z-index: 1;
}

.gifts-chapter .gch-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: clamp(1.5rem, 2.6vw, 2.25rem);
}

.gifts-chapter .gch-denom {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.gifts-chapter .gch-denom__prefix {
  font-size: 0.875rem;
  font-weight: 450;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--gch-muted);
}

.gifts-chapter .gch-denom__fig {
  display: inline-block;
  font-size: clamp(2.5rem, 4.1vw, 3.75rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--gch-navy);
  white-space: nowrap;
}

.gifts-chapter .gch-strike-wrap {
  position: relative;
  display: inline-block;
  inline-size: fit-content;
}

.gifts-chapter .gch-denom__text {
  display: inline-block;
  opacity: 0.44;
  transition: opacity 0.72s var(--gch-ease) var(--strike-d, 0.28s);
}

.gifts-chapter .gch-strike {
  position: absolute;
  inset-inline: -3%;
  inset-block-start: 50%;
  inline-size: 106%;
  block-size: 0.62em;
  transform: translateY(-50%);
  pointer-events: none;
  overflow: visible;
  color: var(--gch-steel);
}

.gifts-chapter .gch-strike path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.gifts-chapter .gch-index {
  padding-block-start: 0.25rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--gch-muted);
}

.gifts-chapter .gch-name {
  font-weight: 500;
  font-size: clamp(1.25rem, 1.55vw, 1.5rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--gch-navy);
  text-wrap: balance;
  margin-block-end: 0.75rem;
}

.gifts-chapter .gch-desc {
  font-size: clamp(1rem, 1.1vw, 1.125rem);
  line-height: 1.54;
  color: var(--gch-body);
  text-wrap: pretty;
  margin-block-end: clamp(1.5rem, 2.6vw, 2.125rem);
}

.gifts-chapter .gch-card > footer {
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gifts-chapter .gch-rule {
  display: block;
  inline-size: 2.25rem;
  block-size: 2px;
  border-radius: 999px;
  background: var(--gch-navy);
  transform-origin: left;
  transition: transform 0.55s var(--gch-ease), background-color 0.45s var(--gch-ease);
}

.gifts-chapter .gch-status {
  font-size: clamp(1.125rem, 1.35vw, 1.25rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--gch-navy);
}

/* Центральный чернильный монолит (5 000 ₽) */
.gifts-chapter .gch-card--dark {
  background-color: var(--gch-navy-panel);
  background-image:
    radial-gradient(76% 58% at 96% 8%, rgb(169 198 218 / 0.17) 0%, transparent 72%),
    radial-gradient(54% 48% at 10% 94%, rgb(58 82 109 / 0.24) 0%, transparent 72%),
    linear-gradient(164deg, #24334e 0%, #16202f 52%, #121929 100%);
  color: var(--gch-ivory);
  box-shadow:
    inset 0 1px 0 rgb(245 243 234 / 0.16),
    inset 0 -2px 0 rgb(18 25 41 / 0.55),
    0 1.625rem 3.25rem -1.625rem rgb(18 25 41 / 0.62);
}

.gifts-chapter .gch-card--dark::before {
  inset: 0 auto 0 0;
  inline-size: 46%;
  z-index: 2;
  background: linear-gradient(
    104deg,
    transparent 12%,
    rgb(245 243 234 / 0.08) 36%,
    rgb(245 243 234 / 0.22) 50%,
    rgb(245 243 234 / 0.08) 66%,
    transparent 90%
  );
  transform: translateX(-145%) skewX(-20deg);
  opacity: 0;
  transition: none;
}

.gifts-chapter .gch-card--dark.is-sheening::before {
  animation: gch-card-sheen 0.85s var(--gch-ease) both;
}

.gifts-chapter .gch-card--dark .gch-denom__prefix,
.gifts-chapter .gch-card--dark .gch-index {
  color: var(--gch-dark-muted);
}

.gifts-chapter .gch-card--dark .gch-denom__fig,
.gifts-chapter .gch-card--dark .gch-name,
.gifts-chapter .gch-card--dark .gch-status {
  color: var(--gch-ivory);
}

.gifts-chapter .gch-card--dark .gch-desc {
  color: var(--gch-dark-body);
}

.gifts-chapter .gch-card--dark .gch-strike {
  color: #a9c6da;
}

.gifts-chapter .gch-card--dark .gch-rule {
  background: #a9c6da;
}

/* Мобильный/не-sticky вход при прокрутке */
@media screen and (prefers-reduced-motion: no-preference) {
  .gifts-chapter.gch-js-ready [data-gifts-reveal] {
    opacity: 0;
    translate: 0 1.25rem;
    transition:
      opacity 0.72s var(--gch-ease) var(--d, 0s),
      translate 0.82s var(--gch-ease) var(--d, 0s),
      transform 0.55s var(--gch-ease),
      box-shadow 0.55s var(--gch-ease);
  }

  .gifts-chapter.gch-js-ready [data-gifts-reveal].is-in {
    opacity: 1;
    translate: 0 0;
  }

  .gifts-chapter.gch-js-ready [data-gifts-reveal] .gch-denom__text {
    opacity: 1;
  }

  .gifts-chapter.gch-js-ready [data-gifts-reveal].is-in .gch-denom__text {
    opacity: 0.44;
  }

  .gifts-chapter.gch-js-ready [data-gifts-reveal] .gch-strike {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.72s var(--gch-ease) var(--strike-d, 0.28s);
  }

  .gifts-chapter.gch-js-ready [data-gifts-reveal].is-in .gch-strike {
    clip-path: inset(0 0 0 0);
  }
}

/* ── Залипающая хореография «лесенкой» на десктопе (как в psycholog-demo) ── */
@media screen and (prefers-reduced-motion: no-preference) and (min-width: 960px) and (min-height: 680px) {
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    .gifts-chapter:not(.gch-static) {
      block-size: 230svh;
      view-timeline: --gch-stair block;
    }

    .gifts-chapter:not(.gch-static) .gch-stage {
      position: sticky;
      inset-block-start: 0;
      block-size: 100svh;
      min-block-size: 40rem;
      padding-block: clamp(1.75rem, 3.6svh, 3.25rem) clamp(4.5rem, 7svh, 6rem);
      clip-path: inset(-15svh 0 0 0);
    }

    .gifts-chapter.gch-js-ready:not(.gch-static) [data-gifts-reveal] {
      opacity: 1;
      translate: none;
      transition:
        transform 0.55s var(--gch-ease),
        opacity 0.45s var(--gch-ease),
        box-shadow 0.55s var(--gch-ease);
    }

    .gifts-chapter.gch-js-ready:not(.gch-static) .gch-denom__text,
    .gifts-chapter.gch-js-ready:not(.gch-static) .gch-strike {
      transition: none;
    }

    .gifts-chapter:not(.gch-static) .gch-meter {
      opacity: 1;
    }

    .gifts-chapter:not(.gch-static) .gch-meter i {
      animation: gch-meter-fill linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 82%;
    }

    .gifts-chapter:not(.gch-static) .gch-head {
      will-change: translate;
      animation: gch-head-lift linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card {
      will-change: translate;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="0"] {
      animation: gch-rise-1 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="1"] {
      animation: gch-rise-2 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="2"] {
      animation: gch-rise-3 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="0"] .gch-strike {
      animation: gch-strike-1 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="1"] .gch-strike {
      animation: gch-strike-2 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="2"] .gch-strike {
      animation: gch-strike-3 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="0"] .gch-denom__text {
      animation: gch-dim-1 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="1"] .gch-denom__text {
      animation: gch-dim-2 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }

    .gifts-chapter:not(.gch-static) .gch-card[data-gch-step="2"] .gch-denom__text {
      animation: gch-dim-3 linear both;
      animation-timeline: --gch-stair;
      animation-range: contain 0% contain 100%;
    }
  }
}

@keyframes gch-meter-fill {
  from { transform: scaleY(0.1); }
  to { transform: scaleY(1); }
}

@keyframes gch-head-lift {
  0% {
    translate: 0 5.5svh;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }
  44%, 100% {
    translate: 0 0;
  }
}

@keyframes gch-rise-1 {
  0% {
    translate: 0 14svh;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }
  42%, 100% {
    translate: 0 0;
  }
}

@keyframes gch-rise-2 {
  0%, 13% {
    translate: 0 32svh;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }
  56%, 100% {
    translate: 0 0;
  }
}

@keyframes gch-rise-3 {
  0%, 26% {
    translate: 0 50svh;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }
  70%, 100% {
    translate: 0 0;
  }
}

@keyframes gch-strike-1 {
  0%, 24% { clip-path: inset(0 100% 0 0); }
  44%, 100% { clip-path: inset(0 0 0 0); }
}

@keyframes gch-strike-2 {
  0%, 40% { clip-path: inset(0 100% 0 0); }
  60%, 100% { clip-path: inset(0 0 0 0); }
}

@keyframes gch-strike-3 {
  0%, 56% { clip-path: inset(0 100% 0 0); }
  76%, 100% { clip-path: inset(0 0 0 0); }
}

@keyframes gch-dim-1 {
  0%, 24% { opacity: 1; }
  44%, 100% { opacity: 0.44; }
}

@keyframes gch-dim-2 {
  0%, 40% { opacity: 1; }
  60%, 100% { opacity: 0.44; }
}

@keyframes gch-dim-3 {
  0%, 56% { opacity: 1; }
  76%, 100% { opacity: 0.44; }
}

@keyframes gch-card-sheen {
  0% {
    transform: translateX(-145%) skewX(-20deg);
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  84% {
    opacity: 1;
  }
  100% {
    transform: translateX(315%) skewX(-20deg);
    opacity: 0;
  }
}

/* Резервный JS-фолбэк для браузеров без CSS Scroll-Driven Animations */
@media screen and (prefers-reduced-motion: no-preference) and (min-width: 960px) and (min-height: 680px) {
  .gifts-chapter.is-js-fallback {
    block-size: 230svh;
  }

  .gifts-chapter.is-js-fallback .gch-stage {
    position: sticky;
    inset-block-start: 0;
    block-size: 100svh;
    min-block-size: 40rem;
    padding-block: clamp(1.75rem, 3.6svh, 3.25rem) clamp(4.5rem, 7svh, 6rem);
    clip-path: inset(-15svh 0 0 0);
  }

  .gifts-chapter.is-js-fallback .gch-meter {
    opacity: 1;
  }

  .gifts-chapter.is-js-fallback .gch-meter i {
    transform: scaleY(var(--p-meter, 0.1));
  }

  .gifts-chapter.is-js-fallback .gch-head {
    translate: 0 calc((1 - var(--p-head, 0)) * 5.5svh);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="0"] {
    translate: 0 calc((1 - var(--p-c1, 0)) * 14svh);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="1"] {
    translate: 0 calc((1 - var(--p-c2, 0)) * 32svh);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="2"] {
    translate: 0 calc((1 - var(--p-c3, 0)) * 50svh);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="0"] .gch-strike {
    clip-path: inset(0 calc((1 - var(--p-s1, 0)) * 100%) 0 0);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="1"] .gch-strike {
    clip-path: inset(0 calc((1 - var(--p-s2, 0)) * 100%) 0 0);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="2"] .gch-strike {
    clip-path: inset(0 calc((1 - var(--p-s3, 0)) * 100%) 0 0);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="0"] .gch-denom__text {
    opacity: calc(1 - var(--p-s1, 0) * 0.56);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="1"] .gch-denom__text {
    opacity: calc(1 - var(--p-s2, 0) * 0.56);
  }

  .gifts-chapter.is-js-fallback .gch-card[data-gch-step="2"] .gch-denom__text {
    opacity: calc(1 - var(--p-s3, 0) * 0.56);
  }
}

/* ── Интерактивный ховер (независим от scroll-driven translate) ── */
@media (min-width: 861px) and (hover: hover) and (pointer: fine) {
  .gifts-chapter .gch-grid:has(.gch-card:hover) .gch-card:not(:hover) {
    opacity: 0.72;
    transform: scale(0.992);
  }

  .gifts-chapter .gch-card:hover {
    transform: translate3d(0, -0.375rem, 0);
  }

  .gifts-chapter .gch-card:not(.gch-card--dark):hover {
    box-shadow:
      inset 0 1px 0 rgb(247 246 243 / 0.98),
      0 1.75rem 3.375rem -1.625rem rgb(20 24 33 / 0.3);
  }

  .gifts-chapter .gch-card:not(.gch-card--dark):hover::before {
    opacity: 1;
  }

  .gifts-chapter .gch-card--dark:hover {
    box-shadow:
      inset 0 1px 0 rgb(245 243 234 / 0.24),
      0 2.125rem 4rem -1.625rem rgb(18 25 41 / 0.78);
  }

  .gifts-chapter .gch-card:hover .gch-rule {
    transform: scaleX(1.65);
  }
}

@media (max-width: 959px) {
  .gifts-chapter .gch-head {
    grid-template-columns: minmax(0, 1fr);
    margin-block-end: 24px;
  }

  .gifts-chapter .gch-lead {
    justify-self: start;
  }

  .gifts-chapter .gch-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: 16px;
  }

  .gifts-chapter .gch-card {
    grid-row: auto;
    grid-template-rows: auto auto auto auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gifts-chapter .gch-denom__text,
  .gifts-chapter .gch-card,
  .gifts-chapter .gch-card::before,
  .gifts-chapter .gch-rule {
    transition: none;
  }

  .gifts-chapter .gch-card--dark.is-sheening::before {
    animation: none;
  }
}
