/* Общие страницы каталога и прежние шаблоны открываются через разные точки входа. */
@media screen {
  /* В части готовых HTML старая шапка сохранена за верхней границей экрана. */
  #root header.sticky.top-0 {
    transform: none !important;
  }
  main.flex-grow section.text-white:has(h1) {
    background: linear-gradient(115deg, #175cf0, #183ec4);
  }

  main.flex-grow section.text-white:has(h1) :is(.text-gray-300, .text-gray-400, .text-gray-500) {
    color: #dce8ff;
  }

  main.flex-grow h1 {
    font-size: clamp(1.8rem, 3.3vw, 2.75rem);
    line-height: 1.14;
    letter-spacing: -.025em;
    text-wrap: balance;
    overflow-wrap: anywhere;
  }

  /* Короткая закладка повторяет акцент каталога на обложках услуг, стран и статей. */
  main.flex-grow :is(section.text-white, article.py-12) h1::before {
    display: block;
    content: "";
    width: 34px;
    height: 5px;
    margin-block-end: 14px;
    background: #facc15;
    clip-path: polygon(0 0, 88% 0, 100% 100%, 0 100%);
    transform-origin: left;
  }

  main.flex-grow article.py-12:has(.prose) > div > h1 + div {
    flex-wrap: wrap;
    row-gap: .55rem;
  }

  main.flex-grow :is(section, article) h2 {
    letter-spacing: -.018em;
    overflow-wrap: anywhere;
  }

  main.flex-grow details > summary {
    min-block-size: 44px;
    align-content: center;
  }

  main.flex-grow :is(a, button, summary):focus-visible {
    outline: 3px solid #175cf0;
    outline-offset: 2px;
  }
  main.flex-grow .text-white :is(a, button, summary):focus-visible {
    outline-color: #facc15;
  }
}

@media screen and (max-width: 700px) {
  main.flex-grow section.text-white:has(h1) {
    padding-block: 1.65rem 2rem;
  }

  /* Значок документа больше не отнимает отдельную колонку у всей карточки. */
  main.flex-grow section.overflow-hidden:has(h1) .items-start:has(> .flex-1 h1) {
    display: block;
  }
  main.flex-grow section.overflow-hidden:has(h1) .items-start > .w-20 {
    display: none;
  }
  main.flex-grow section.overflow-hidden:has(h1) > .absolute.inset-0 {
    display: none;
  }
  main.flex-grow section.overflow-hidden:has(h1) h1 + p {
    font-size: 1rem;
    line-height: 1.55;
    margin-block-end: 1rem;
  }
  main.flex-grow section.overflow-hidden:has(h1) .flex-1 > .grid.backdrop-blur-sm {
    padding: 14px 16px;
    gap: 8px;
    backdrop-filter: none;
  }
  main.flex-grow section.overflow-hidden:has(h1) .grid.backdrop-blur-sm > div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 12px;
  }
  main.flex-grow section.overflow-hidden:has(h1) .grid.backdrop-blur-sm .font-bold {
    font-size: 1.125rem;
    line-height: 1.4;
  }
  main.flex-grow :is(.grid > *, .flex-1) {
    min-inline-size: 0;
  }
  main.flex-grow article .prose {
    overflow-wrap: anywhere;
  }
}

@keyframes mp-page-arrive {
  from { opacity: .76; translate: 0 var(--mp-entry-distance, 9px); }
  to { opacity: 1; translate: 0 0; }
}
@keyframes mp-tab-unfold {
  from { transform: scaleX(.22); }
  to { transform: scaleX(1); }
}

@media screen and (prefers-reduced-motion: no-preference) {
  :is(main.flex-grow, .cn-hero, .cp-intro, .pp-hero, .sp-intro) h1 {
    animation: mp-page-arrive 380ms cubic-bezier(.2,.75,.2,1);
  }
  main.flex-grow h1::before {
    animation: mp-tab-unfold 420ms cubic-bezier(.2,.75,.2,1);
  }
  :is(.cn-hero-copy > p, .cp-write, .pp-jumps) {
    animation: mp-page-arrive 420ms 50ms cubic-bezier(.2,.75,.2,1) backwards;
  }
  main.flex-grow details[open] > :not(summary, details) {
    --mp-entry-distance: -3px;
    animation: mp-page-arrive 170ms ease-out;
  }

  /* Браузер ведёт эффект по положению заголовка. Без поддержки текст сразу виден. */
  @supports (animation-timeline: view()) {
    :is(main.flex-grow section h2, main.flex-grow .prose h2,
        .catalog-search-heading h2, .catalog-bottom h2, .bp-results-heading h2,
        .rf-heading h2, .cn-results h2, .dn-heading h2, .pp-heading h2,
        .cp-section-heading h2, .cn-help h2, .bp-reference h2, .rf-help h2) {
      animation: mp-page-arrive linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 100%;
    }
  }
}

@media screen and (max-width: 700px) and (prefers-reduced-motion: no-preference) {
  main { --mp-entry-distance: 4px; }
  :is(main.flex-grow, .cn-hero, .cp-intro, .pp-hero, .sp-intro) h1,
  :is(.cn-hero-copy > p, .cp-write, .pp-jumps) {
    animation-duration: 240ms;
    animation-delay: 0ms;
  }
}

@media screen and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  :is(.dn-theme, .cn-card, .rf-topics > a, main.flex-grow a.rounded-xl:has(h3)) {
    transition: translate 180ms ease, border-color 180ms ease;
  }
  :is(.dn-theme, .cn-card, .rf-topics > a, main.flex-grow a.rounded-xl:has(h3)):hover {
    translate: 0 -2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  main.flex-grow :is(.absolute[style*="infinite"], .absolute.inset-0 *) {
    animation: none !important;
  }
}
