/* ============================================================
   Цифровые сервисы Минприроды России
   Дизайн-система: один акцент #425d84, холодная нейтральная шкала,
   единая шкала скруглений, тени тонированы в цвет акцента.
   ============================================================ */

/* ---------- Шрифт: Golos Text, самохостинг, вариативный ---------- */

@font-face {
    font-family: 'Golos Text';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/golos-text-cyrillic.024646dc00da.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Golos Text';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/golos-text-latin.3ba0fde64bcf.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Токены ---------- */

:root {
    /* Нейтральная шкала, подтонированная в холодный оттенок акцента */
    --ink-900: #14181f;
    --ink-700: #2e3644;
    --ink-500: #5a6474;
    --ink-400: #667080;

    --paper: #ffffff;
    --surface: #f4f6f9;
    --surface-2: #eaeef4;
    --line: #e1e6ee;
    --line-strong: #cdd5e1;

    /* Единственный акцент на весь сайт */
    --accent: #425d84;
    --accent-hover: #35496b;
    --accent-active: #2b3c58;
    --accent-tint: #e9eef6;
    --accent-ring: rgba(66, 93, 132, 0.38);

    /* Тени тонированы в оттенок акцента, без чистого черного */
    --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.04),
                 0 2px 8px -4px rgba(45, 62, 90, 0.10);
    --shadow-md: 0 2px 4px rgba(20, 24, 31, 0.04),
                 0 18px 36px -20px rgba(45, 62, 90, 0.26);
    --shadow-lg: 0 4px 8px rgba(20, 24, 31, 0.05),
                 0 32px 64px -28px rgba(45, 62, 90, 0.34);

    /* Скругления: контейнеры 16, мелкие элементы 10, управление - капсула */
    --r-container: 16px;
    --r-small: 10px;
    --r-pill: 999px;

    /* Ритм */
    --gap: 24px;
    --page-max: 1200px;
    --pad-x: clamp(20px, 5vw, 48px);

    /* Движение: одна кривая на весь проект */
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --dur: 220ms;

    /* Слои */
    --z-raised: 1;
    --z-header: 10;
    --z-modal: 50;
    --z-grain: 100;
}

/* ---------- Сброс ---------- */

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

* {
    margin: 0;
    padding: 0;
}

html {
    /* Место под полосу прокрутки резервируется всегда, иначе при открытии
       модалки (overflow: hidden) страница сдвигается вбок */
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--ink-700);
    font-family: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    font-feature-settings: 'ss01' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Зерно: разбивает цифровую плоскость фона, не перехватывает клики */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-grain);
    pointer-events: none;
    opacity: 0.038;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Типографика ---------- */

h1,
h2,
h3 {
    color: var(--ink-900);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
    text-wrap: balance;
}

h1 {
    font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.85rem);
    letter-spacing: -0.032em;
    line-height: 1.06;
}

h2 {
    font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem);
}

h3 {
    font-size: 1.125rem;
    letter-spacing: -0.014em;
}

p {
    text-wrap: pretty;
}

.lead {
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
    color: var(--ink-500);
    max-width: 52ch;
}

.ico {
    width: 1em;
    height: 1em;
    flex: none;
}

/* ---------- Доступность ---------- */

.skip-link {
    position: absolute;
    left: 50%;
    top: 12px;
    z-index: 200;
    transform: translate(-50%, -160%);
    background: var(--accent);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
    transform: translate(-50%, 0);
}

:focus-visible {
    outline: 3px solid var(--accent-ring);
    outline-offset: 3px;
    border-radius: 4px;
}

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

/* ---------- Каркас страницы ---------- */

.shell {
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: var(--pad-x);
}

.site-main {
    flex: 1;
    padding-bottom: clamp(56px, 8vw, 96px);
}

/* ---------- Шапка ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    border-radius: var(--r-small);
}

.brand__crest {
    height: 48px;
    width: 48px;
    flex: none;
}

.brand__name {
    max-width: 21rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.005em;
    color: var(--ink-900);
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-700);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    padding: 9px 16px;
    border-radius: var(--r-pill);
    white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.header-link .ico {
    font-size: 1.125rem;
    color: var(--accent);
    transition: color var(--dur) var(--ease);
}

.header-link:hover {
    background: var(--accent-tint);
    color: var(--accent);
}

/* ---------- Первый экран ---------- */

.hero {
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.hero__inner {
    position: relative;
    z-index: var(--z-raised);
    padding-top: clamp(40px, 5vw, 62px);
    padding-bottom: clamp(40px, 5vw, 62px);
}

/* Ширина в rem, а не в ch: иначе заголовок ломается на четыре строки */
.hero__copy {
    max-width: 34rem;
}

.hero h1 {
    margin-bottom: 18px;
}

/* ---------- Сервисы: несимметричная сетка ---------- */

.services {
    margin-top: clamp(28px, 4vw, 44px);
}

.services__grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(3, 1fr);
}

.service {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-container);
    padding: clamp(22px, 2.6vw, 32px);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease),
                transform var(--dur) var(--ease);
}

.service:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Сервис в разработке: та же карточка, но приглушенная, без лишних надежд -
   пунктирная рамка и выцветшая поверхность читаются как "еще не готово" */
.service--soon {
    background: var(--surface-2);
    border-style: dashed;
    border-color: var(--line-strong);
}

.service--soon:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.service--soon .service__icon {
    background: var(--paper);
    color: var(--ink-400);
}

.service__badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-500);
    background: var(--paper);
    border: 1px solid var(--line-strong);
    padding: 4px 10px;
    border-radius: var(--r-pill);
    margin-bottom: 16px;
}

/* Вне карточки (.service - флекс-колонка) бейдж не блокируется автоматически -
   без этого он встал бы в один ряд со ссылкой "Все сервисы" */
.page .service__badge {
    display: flex;
    width: fit-content;
    margin-bottom: 20px;
}

/* Крупная ячейка на всю ширину: своя поверхность, чтобы сетка
   не была четырьмя одинаковыми белыми карточками */
.service--primary {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    gap: clamp(32px, 4vw, 56px);
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(66, 93, 132, 0.10), transparent 62%),
        var(--accent-tint);
    border-color: #d8e2ef;
}

.service--primary .service__main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

/* Ширина под содержимое, а не резиновая - иначе часть перечня остается пустой,
   когда фактов меньше, чем помещается по высоте колонки с описанием */
.service--primary .service__facts {
    flex: 0 0 clamp(260px, 30vw, 360px);
    margin-top: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.service__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: var(--r-small);
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--accent);
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.service--primary .service__icon {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.service__title {
    margin-bottom: 8px;
}

.service--primary .service__title {
    font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.75rem);
}

.service__summary {
    color: var(--ink-500);
    font-size: 0.9375rem;
    max-width: 44ch;
}

.service--primary .service__summary {
    font-size: 1rem;
    max-width: 40ch;
}

/* Перечень в крупной ячейке: разделители только между пунктами */
.service__facts {
    margin-top: 26px;
    display: grid;
    gap: 14px;
}

.service__facts .fact + .fact {
    border-top: 1px solid rgba(66, 93, 132, 0.14);
    padding-top: 14px;
}

.service__facts dt {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: 2px;
}

.service__facts dd {
    font-size: 0.875rem;
    color: var(--ink-500);
    max-width: 42ch;
}

/* Кнопки прижаты ко дну: у всех карточек ряда действия на одной линии */
.service__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 26px;
}

/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    padding: 12px 22px;
    cursor: pointer;
    transition: background var(--dur) var(--ease),
                border-color var(--dur) var(--ease),
                color var(--dur) var(--ease),
                transform 120ms var(--ease);
}

.btn .ico {
    font-size: 1.05rem;
}

.btn:active {
    transform: scale(0.975);
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-hover);
}

.btn--primary:active {
    background: var(--accent-active);
}

.btn--quiet {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--ink-700);
}

.btn--quiet:hover {
    background: var(--paper);
    border-color: var(--accent);
    color: var(--accent);
}

.service--primary .btn--quiet {
    border-color: #c4d2e4;
    background: rgba(255, 255, 255, 0.55);
}

.service--primary .btn--quiet:hover {
    background: var(--paper);
}

/* Заглушка вместо кнопки для сервиса в разработке - без href, чтобы не вести
   в никуда, но на вид остается частью того же набора кнопок */
.btn--disabled,
.btn--disabled:hover,
.btn--disabled:active {
    background: var(--surface-2);
    color: var(--ink-400);
    cursor: default;
    transform: none;
}

/* Круглая кнопка справки: подпись скрыта визуально, но есть для скринридера */
.btn--icon {
    width: 44px;
    height: 44px;
    padding: 0;
    flex: none;
    font-size: 1.125rem;
}

/* ---------- Внутренняя ссылка для сотрудников ---------- */
/* Нарочно не карточка из сетки сервисов: по размеру и цвету - тихая строка,
   не конкурирует взглядом с публичными сервисами выше. Без акцентного синего. */
.staff-link {
    max-width: 420px;
    margin-top: clamp(28px, 4vw, 40px);
}

.staff-link__row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-container);
    background: var(--surface-2);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.staff-link__row:hover {
    border-color: var(--line-strong);
    background: var(--paper);
}

.staff-link__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: var(--r-small);
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-400);
    font-size: 1.1rem;
}

.staff-link__text {
    min-width: 0;
    flex: 1;
}

.staff-link__title {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-700);
}

.staff-link__meta {
    display: block;
    font-size: 0.8125rem;
    color: var(--ink-400);
    margin-top: 2px;
}

.staff-link__arrow {
    flex: none;
    color: var(--ink-400);
    font-size: 1.05rem;
    transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.staff-link__row:hover .staff-link__arrow {
    color: var(--ink-700);
    transform: translateX(3px);
}

@media (max-width: 560px) {
    .staff-link {
        max-width: none;
    }
}

/* ---------- Подвал ---------- */

.site-footer {
    background: var(--paper);
    border-top: 1px solid var(--line);
    padding-block: 32px;
}

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
}

.site-footer p {
    font-size: 0.875rem;
    color: var(--ink-500);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    list-style: none;
}

.footer-links a {
    font-size: 0.875rem;
    color: var(--ink-500);
    text-decoration: none;
    border-radius: 4px;
    transition: color var(--dur) var(--ease);
}

.footer-links a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- Модальное окно справки ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(20, 24, 31, 0.42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}

.modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* display: grid из правила выше перебивает атрибут hidden, возвращаем ему силу */
.modal[hidden] {
    display: none;
}

.modal__dialog {
    position: relative;
    width: min(100%, 560px);
    max-height: min(80dvh, 720px);
    overflow-y: auto;
    background: var(--paper);
    border-radius: var(--r-container);
    padding: clamp(26px, 4vw, 38px);
    box-shadow: var(--shadow-lg);
    transform: translateY(12px) scale(0.98);
    transition: transform var(--dur) var(--ease);
}

.modal.is-open .modal__dialog {
    transform: none;
}

.modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--ink-500);
    font-size: 1.125rem;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.modal__close:hover {
    background: var(--surface-2);
    color: var(--ink-900);
}

.modal__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--r-small);
    background: var(--accent);
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 18px;
}

.modal__title {
    margin-bottom: 12px;
    padding-right: 44px;
}

.modal__body {
    color: var(--ink-500);
    font-size: 0.9375rem;
    max-width: 58ch;
}

.modal__body + .modal__body {
    margin-top: 12px;
}

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.panel[hidden] {
    display: none;
}

/* ---------- Внутренние страницы сервисов и 404 ---------- */

.page {
    padding-top: clamp(40px, 6vw, 64px);
    max-width: 62ch;
}

.page__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--ink-500);
    text-decoration: none;
    margin-bottom: 24px;
    border-radius: 4px;
    transition: color var(--dur) var(--ease);
}

.page__back .ico {
    font-size: 1rem;
    transform: rotate(180deg);
    transition: transform var(--dur) var(--ease);
}

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

.page__back:hover .ico {
    transform: rotate(180deg) translateX(3px);
}

.page h1 {
    margin-bottom: 16px;
}

.page p {
    color: var(--ink-500);
}

.page p + p {
    margin-top: 14px;
}

.page__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 30px;
}

/* ---------- Появление контента ---------- */

.reveal {
    opacity: 0;
    transform: translateY(14px);
    animation: reveal 520ms var(--ease) forwards;
}

.reveal:nth-child(2) { animation-delay: 70ms; }
.reveal:nth-child(3) { animation-delay: 140ms; }
.reveal:nth-child(4) { animation-delay: 210ms; }

@keyframes reveal {
    to {
        opacity: 1;
        transform: none;
    }
}

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

@media (max-width: 900px) {
    /* 2 колонки оставили бы 3 маленькие карточки как 2+1 с пустым местом в углу -
       сразу переходим на одну колонку */
    .services__grid {
        grid-template-columns: 1fr;
    }

    /* Двум колонкам внутри большой карточки не хватает ширины - обратно в столбик */
    .service--primary {
        flex-direction: column;
    }

    .service--primary .service__facts {
        flex: none;
    }
}

@media (max-width: 560px) {
    .site-header__inner {
        height: 60px;
    }

    .brand__crest {
        height: 40px;
        width: 40px;
    }

    .brand__name {
        font-size: 0.75rem;
        max-width: 13rem;
    }

    .header-link span {
        display: none;
    }

    .header-link {
        padding: 10px;
    }

    .hero__inner {
        max-width: none;
    }

    .service__actions {
        flex-wrap: wrap;
    }

    .service__actions .btn--primary {
        flex: 1;
    }

    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------- Уменьшенное движение ---------- */

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}
