/* ============================================================
   Цифровые сервисы Минприроды России
   Размеры шрифта, отступы и иконки берутся из токенов ниже.
   ============================================================ */

/* ---------- Шрифт ---------- */

@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-line: #d8e2ef;

    /* Тени */
    --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 16px 32px -16px 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);

    /* Размеры шрифта */
    --text-12: 0.75rem;
    --text-14: 0.875rem;
    --text-16: 1rem;
    --text-20: 1.25rem;
    --text-24: 1.5rem;
    --text-32: 2rem;
    --text-40: 2.5rem;

    /* Межстрочные интервалы */
    --lh-body: 1.5;
    --lh-title: 1.2;
    --lh-display: 1.1;
    --lh-control: 1;

    /* Текстовые стили */
    --type-display: var(--text-40);
    --type-title-lg: var(--text-32);
    --type-title: var(--text-24);
    --type-lead: var(--text-20);
    --type-body: var(--text-16);
    --type-caption: var(--text-14);
    --type-label: var(--text-12);

    /* Отступы */
    --space-4: 4px;
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-24: 24px;
    --space-32: 32px;
    --space-48: 48px;
    --space-64: 64px;

    /* Иконки */
    --icon-sm: 16px;
    --icon-md: 24px;

    /* Элементы управления */
    --control-h: 44px;
    --tile-sm: 40px;
    --tile-md: 48px;

    /* Скругления */
    --r-container: 16px;
    --r-small: 12px;
    --r-focus: 4px;
    --r-pill: 999px;

    /* Сетка */
    --gap: var(--space-24);
    --page-max: 1200px;
    --pad-x: var(--space-48);

    /* Фокус */
    --focus-ring: 2px solid var(--accent);
    --focus-offset: 3px;

    /* Анимация */
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --dur: 220ms;

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

@media (max-width: 900px) {
    :root {
        --pad-x: var(--space-24);
    }
}

@media (max-width: 560px) {
    :root {
        --type-display: var(--text-32);
        --type-title-lg: var(--text-24);
        --type-lead: var(--text-16);
        --pad-x: var(--space-16);
        --gap: var(--space-16);
    }
}

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

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

* {
    margin: 0;
    padding: 0;
}

html {
    /* Чтобы страница не сдвигалась при открытии модалки */
    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: var(--type-body);
    line-height: var(--lh-body);
    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 {
    color: var(--ink-900);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: var(--lh-title);
    text-wrap: balance;
}

h1 {
    font-size: var(--type-display);
    letter-spacing: -0.032em;
    line-height: var(--lh-display);
}

h2 {
    font-size: var(--type-title);
}

p {
    text-wrap: pretty;
}

.lead {
    font-size: var(--type-lead);
    color: var(--ink-500);
    max-width: 52ch;
}

/* Размер иконки задается через --ico у родителя */
.ico {
    width: var(--ico, var(--icon-sm));
    height: var(--ico, var(--icon-sm));
    flex: none;
}

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

.skip-link {
    position: absolute;
    left: 50%;
    top: var(--space-12);
    z-index: 200;
    transform: translate(-50%, -160%);
    display: inline-flex;
    align-items: center;
    min-height: var(--control-h);
    background: var(--accent);
    color: #fff;
    font-size: var(--type-body);
    font-weight: 600;
    padding: 0 var(--space-24);
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: transform var(--dur) var(--ease);
}

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

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
    border-radius: var(--r-focus);
}

.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: var(--space-64);
}

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

.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 {
    min-height: 72px;
    padding-block: var(--space-12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-24);
}

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

.brand__crest {
    height: var(--tile-md);
    width: var(--tile-md);
    flex: none;
}

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

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

.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-block: var(--space-64);
}

.hero__copy {
    max-width: 34rem;
}

.hero h1 {
    margin-bottom: var(--space-16);
}

/* ---------- Сервисы ---------- */

.services {
    margin-top: var(--space-48);
}

.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: var(--space-32);
    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-500);
}

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

/* Бейдж на отдельной странице сервиса */
.page .service__badge {
    display: flex;
    width: fit-content;
    margin-bottom: var(--space-24);
}

/* Главная карточка на всю ширину */
.service--primary {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    gap: var(--space-48);
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(66, 93, 132, 0.10), transparent 62%),
        var(--accent-tint);
    border-color: var(--accent-line);
}

.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 {
    --ico: var(--icon-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-md);
    height: var(--tile-md);
    border-radius: var(--r-small);
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--accent);
    margin-bottom: var(--space-24);
}

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

.service__title {
    margin-bottom: var(--space-8);
}

.service--primary .service__title {
    font-size: var(--type-title-lg);
}

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

.service--primary .service__summary {
    max-width: 40ch;
}

.service__facts {
    margin-top: var(--space-24);
    display: grid;
    gap: var(--space-12);
}

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

.service__facts dt {
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: var(--space-4);
}

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

/* Кнопки прижаты к низу карточки */
.service__actions {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    margin-top: auto;
    padding-top: var(--space-24);
}

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

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

.btn:focus-visible {
    border-radius: var(--r-pill);
}

.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);
}

/* Заглушка для сервиса в разработке */
.btn--disabled,
.btn--disabled:hover,
.btn--disabled:active {
    background: var(--surface-2);
    color: var(--ink-500);
    cursor: default;
    transform: none;
}

/* Круглая кнопка справки */
.btn--icon {
    --ico: var(--icon-md);
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    flex: none;
}

/* ---------- Ссылка для сотрудников ---------- */
.staff-link {
    max-width: 420px;
    margin-top: var(--space-32);
}

.staff-link__row {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    padding: var(--space-12) var(--space-16);
    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:focus-visible {
    border-radius: var(--r-container);
}

.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: var(--tile-sm);
    height: var(--tile-sm);
    flex: none;
    border-radius: var(--r-small);
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-500);
}

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

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

.staff-link__meta {
    display: block;
    font-size: var(--type-caption);
    color: var(--ink-500);
}

.staff-link__arrow {
    flex: none;
    color: var(--ink-500);
    transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

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

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

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

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-16) var(--space-32);
    font-size: var(--type-caption);
    color: var(--ink-500);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8) var(--space-24);
    list-style: none;
}

.footer-links a {
    color: var(--ink-500);
    text-decoration: none;
    border-radius: var(--r-focus);
    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: var(--space-16);
    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: var(--space-32);
    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 {
    --ico: var(--icon-md);
    position: absolute;
    top: var(--space-16);
    right: var(--space-16);
    width: var(--control-h);
    height: var(--control-h);
    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);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.modal__close:focus-visible {
    border-radius: var(--r-pill);
}

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

.modal__icon {
    --ico: var(--icon-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-md);
    height: var(--tile-md);
    border-radius: var(--r-small);
    background: var(--accent);
    color: #fff;
    margin-bottom: var(--space-16);
}

.modal__title {
    margin-bottom: var(--space-12);
    padding-right: calc(var(--control-h) + var(--space-8));
}

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

.modal__body + .modal__body {
    margin-top: var(--space-12);
}

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-12);
    margin-top: var(--space-24);
}

.panel[hidden] {
    display: none;
}

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

.page {
    padding-top: var(--space-64);
    max-width: 62ch;
}

.page__back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
    min-height: var(--control-h);
    font-weight: 500;
    color: var(--ink-500);
    text-decoration: none;
    margin-bottom: var(--space-16);
    border-radius: var(--r-focus);
    transition: color var(--dur) var(--ease);
}

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

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

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

.page h1 {
    margin-bottom: var(--space-16);
}

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

.page p + p {
    margin-top: var(--space-12);
}

.page__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-12);
    margin-top: var(--space-32);
}

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

.reveal {
    opacity: 0;
    transform: translateY(16px);
    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) {
    .services__grid {
        grid-template-columns: 1fr;
    }

    .service--primary {
        flex-direction: column;
        gap: var(--space-32);
    }

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

@media (max-width: 560px) {
    .site-header__inner {
        min-height: 64px;
        padding-block: var(--space-8);
    }

    .brand__crest {
        height: var(--tile-sm);
        width: var(--tile-sm);
    }

    .brand__name {
        max-width: none;
    }

    .hero__inner {
        padding-block: var(--space-48);
    }

    .services {
        margin-top: var(--space-32);
    }

    .service,
    .modal__dialog {
        padding: var(--space-24);
    }

    .service__actions {
        flex-wrap: wrap;
    }

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

    .site-main {
        padding-bottom: var(--space-48);
    }

    .page {
        padding-top: var(--space-48);
    }

    .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;
    }
}
