/* =========================================================================
   PsyGrow24 — дизайн-система
   Палитра «шалфей и крем»: приглушённый зелёный, кремовая бумага, песочный акцент.
   Здесь токены, базовая типографика и переиспользуемые компоненты.
   Разделы берут стили отсюда; своё — в site.css, materials.css, questions.css.
   ========================================================================= */

:root {
    /* Цвет */
    --ink:            #17241d;   /* основной текст */
    --ink-soft:       #45564c;   /* вторичный текст */
    --ink-muted:      #5c6e64;   /* подписи, метки */
    --paper:          #fbf9f4;   /* фон страницы */
    --surface:        #ffffff;   /* карточки */
    --surface-alt:    #f3f0e8;   /* мягкие блоки */
    --surface-sunken: #eee9de;
    --line:           #e3ddd0;   /* границы */
    --line-strong:    #cfc7b6;

    --brand:          #2f6b4f;   /* шалфей */
    --brand-strong:   #21503b;
    --brand-bright:   #3f8a66;
    --brand-soft:     #e6efe9;
    --brand-tint:     #f1f7f3;

    --accent:         #b98c46;   /* песочное золото */
    --accent-strong:  #84601f;
    --accent-soft:    #f7efdf;

    --danger:         #a8372f;
    --danger-soft:    #fbeeec;
    --success:        #2f6b4f;
    --success-soft:   #e6efe9;
    --warning:        #8a6100;
    --warning-soft:   #fdf3dd;

    --focus:          #3f8a66;

    /* Типографика */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Lora', Georgia, 'Times New Roman', serif;

    --text-xs:   0.8125rem;
    --text-sm:   0.9375rem;
    --text-base: 1.0625rem;
    --text-lg:   1.1875rem;
    --text-xl:   clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
    --text-2xl:  clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --text-3xl:  clamp(1.875rem, 1.5rem + 1.8vw, 2.75rem);
    --text-4xl:  clamp(2.25rem, 1.6rem + 3vw, 3.75rem);

    /* Ритм */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;

    --container: 1180px;
    --container-narrow: 760px;

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(23, 36, 29, .06), 0 2px 8px rgba(23, 36, 29, .04);
    --shadow:    0 2px 6px rgba(23, 36, 29, .06), 0 12px 28px rgba(23, 36, 29, .07);
    --shadow-lg: 0 8px 20px rgba(23, 36, 29, .1), 0 32px 60px rgba(23, 36, 29, .14);

    --header-height: 72px;
    --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------------------------------------------------------------- Сброс */

*, *::before, *::after { box-sizing: border-box; }

/* атрибут hidden должен побеждать display у компонентов (кнопки, карточки) */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 16px);
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg, video, audio { max-width: 100%; }
img, svg, video { height: auto; display: block; }

h1, h2, h3, h4, h5 {
    margin: 0 0 var(--space-4);
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -.01em;
    color: var(--ink);
    text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

a {
    color: var(--brand-strong);
    text-decoration-color: color-mix(in srgb, var(--brand-strong) 35%, transparent);
    text-underline-offset: 3px;
    transition: color .15s var(--ease), text-decoration-color .15s var(--ease);
}

a:hover { color: var(--brand-bright); text-decoration-color: currentColor; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

hr {
    height: 1px;
    border: 0;
    margin: var(--space-6) 0;
    background: var(--line);
}

small { font-size: var(--text-sm); }

::selection { background: var(--brand-soft); color: var(--brand-strong); }

/* ------------------------------------------------------------- Раскладка */

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--space-5);
}

.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: clamp(var(--space-7), 6vw, var(--space-9)); }
.section--tight { padding-block: var(--space-7); }
.section--alt { background: var(--surface-alt); }
.section--brand { background: var(--brand-tint); }

.section__head {
    max-width: 720px;
    margin-bottom: var(--space-6);
}

.section__head--center {
    margin-inline: auto;
    text-align: center;
}

.section__eyebrow {
    display: inline-block;
    margin-bottom: var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.section__title { margin-bottom: var(--space-3); }

.section__lead {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--ink-soft);
    text-wrap: pretty;
}

.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

.text-center { text-align: center; }
.muted { color: var(--ink-muted); }
.lead { font-size: var(--text-lg); color: var(--ink-soft); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -100px;
    z-index: 200;
    padding: var(--space-3) var(--space-5);
    background: var(--brand-strong);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: top .2s var(--ease);
}

.skip-link:focus { top: var(--space-4); color: #fff; }

/* --------------------------------------------------------------- Кнопки */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 13px 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: none;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .18s var(--ease), border-color .18s var(--ease),
                color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .6; pointer-events: none; }

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 6px 16px rgba(47, 107, 79, .22);
}

.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

.btn--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #241a05;
    box-shadow: 0 6px 16px rgba(185, 140, 70, .26);
}

.btn--accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

.btn--outline {
    border-color: var(--line-strong);
    color: var(--ink);
    background: var(--surface);
}

.btn--outline:hover { border-color: var(--brand); color: var(--brand-strong); }

.btn--ghost { color: var(--ink-soft); padding-inline: var(--space-4); }
.btn--ghost:hover { color: var(--brand-strong); background: var(--brand-soft); }

.btn--light {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .5);
    color: #fff;
    backdrop-filter: blur(4px);
}

.btn--light:hover { background: #fff; color: var(--brand-strong); border-color: #fff; }

.btn--lg { padding: 16px 34px; font-size: var(--text-base); }
.btn--sm { padding: 9px 18px; font-size: var(--text-xs); }
.btn--block { display: flex; width: 100%; }

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    text-decoration: none;
}

.link-arrow::after { content: '\2192'; transition: transform .18s var(--ease); }
.link-arrow:hover::after { transform: translateX(3px); }

/* -------------------------------------------------------------- Карточки */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-5);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}

.card--link:hover, .card--link:focus-within {
    border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.card__title { margin-bottom: var(--space-2); font-size: var(--text-lg); }
.card__text { margin: 0; color: var(--ink-soft); font-size: var(--text-sm); }
.card__foot { margin-top: auto; padding-top: var(--space-4); }

/* ссылка, растянутая на карточку: кликается вся карточка, текст остаётся выделяемым */
.stretched-link::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

/* ----------------------------------------------------------------- Метки */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: var(--radius-pill);
    background: var(--surface-alt);
    color: var(--ink-soft);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge--brand   { background: var(--brand-soft); color: var(--brand-strong); }
.badge--accent  { background: var(--accent-soft); color: var(--accent-strong); }
.badge--locked  { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--outline { background: none; border: 1px solid var(--line-strong); }

/* ----------------------------------------------------------------- Формы */

.field { margin-bottom: var(--space-4); }

.field__label {
    display: block;
    margin-bottom: 6px;
    font-size: var(--text-sm);
    font-weight: 600;
}

.field__hint { margin-top: 6px; font-size: var(--text-xs); color: var(--ink-muted); }

.input, .textarea, .select {
    display: block;
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: var(--text-sm);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }

.input:focus, .textarea:focus, .select:focus {
    outline: 0;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }

.checkbox {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--ink-soft);
    cursor: pointer;
}

.checkbox input { margin: 4px 0 0; flex-shrink: 0; }

/* -------------------------------------------------------------- Сообщения */

.alert {
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: var(--text-sm);
    margin-bottom: var(--space-5);
}

.alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); color: var(--brand-strong); }
.alert--error   { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 25%, transparent);  color: var(--danger); }
.alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); color: var(--warning); }

/* --------------------------------------------------------- Хлебные крошки */

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: var(--space-4) 0 0;
    margin: 0;
    list-style: none;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

.breadcrumbs li { display: flex; align-items: center; gap: 6px; }
.breadcrumbs li + li::before { content: '/'; color: var(--line-strong); }
.breadcrumbs a { color: var(--ink-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand-strong); }

/* ------------------------------------------------------------- Пагинация */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-6);
    padding: 0;
    list-style: none;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding-inline: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: var(--text-sm);
    text-decoration: none;
}

.pagination a:hover { border-color: var(--brand); color: var(--brand-strong); }
.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ------------------------------------------------- Длинный текст (prose) */

.prose { max-width: 72ch; font-size: var(--text-lg); line-height: 1.75; color: var(--ink-soft); }
.prose > *:first-child { margin-top: 0; }
.prose h2 { margin: 1.8em 0 .5em; font-size: var(--text-2xl); color: var(--ink); }
.prose h3 { margin: 1.6em 0 .4em; font-size: var(--text-xl); color: var(--ink); }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { color: var(--brand); }
.prose strong { color: var(--ink); }
.prose img { border-radius: var(--radius); margin: 1.4em 0; }

.prose blockquote {
    margin: 1.6em 0;
    padding: var(--space-4) var(--space-5);
    border-left: 3px solid var(--brand);
    background: var(--brand-tint);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-style: italic;
    color: var(--ink);
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: var(--text-sm);
}

.prose th, .prose td { padding: 10px 14px; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--surface-alt); color: var(--ink); font-weight: 600; }

.prose code {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--surface-alt);
    font-size: .92em;
}

.table-scroll { overflow-x: auto; }

/* -------------------------------------------------------------- Аккордеон */

.faq { display: grid; gap: var(--space-3); }

.faq__item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.faq__item[open] { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

.faq__q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.faq__q::-webkit-details-marker { display: none; }

.faq__q::after {
    content: '+';
    flex-shrink: 0;
    font-family: var(--font-sans);
    font-size: 1.4em;
    line-height: 1;
    color: var(--brand);
    transition: transform .2s var(--ease);
}

.faq__item[open] .faq__q::after { transform: rotate(45deg); }

.faq__a {
    padding: 0 var(--space-5) var(--space-5);
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

/* --------------------------------------------------------- Модальные окна */

.modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    padding: var(--space-5);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 28, 21, .55);
    backdrop-filter: blur(3px);
    animation: psyFade .2s var(--ease);
}

.modal__window {
    position: relative;
    margin: auto;
    width: 100%;
    max-width: 460px;
    padding: var(--space-6);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: psyPop .22s var(--ease);
}

.modal__close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--ink-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal__close:hover { background: var(--surface-alt); color: var(--ink); }

body.is-locked { overflow: hidden; }

@keyframes psyFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes psyPop  { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
    .modal { padding: var(--space-3); }
    .modal__window { padding: var(--space-5) var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
