/* Слева — логотип, заголовок и контакты; справа — поле с эмблемой, срезанное под углом полосок из логотипа.
   Тема одна, светлая: логотип тёмно-синий и на тёмном фоне не читается. */
:root {
    --navy: #00163b;
    --blue: #0763b4;
    --sky: #028aff;
    --red: #fc0203;
    --green: #029b1d;
    --text: #3d4d68;
    --line: #d5e0ee;
    --field: #e6f0fb;
    --ground: #fff;
    --slant: 9vw;
    color-scheme: light;
}

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42vw;
    background: var(--ground);
    color: var(--text);
    font: 500 1rem/1.6 'Montserrat', 'Segoe UI', Arial, sans-serif;
    overflow-x: hidden;
}

.page {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding: clamp(20px, 3.2vw, 48px);
    padding-left: clamp(16px, 6vw, 112px);
}

/* ── Шапка ── */
.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 32px; }

/* assets/site/logo.svg — public/logo.svg без полей: знак стоит по левому краю текста */
.logo { display: block; width: clamp(230px, 22vw, 22.5rem); height: auto; }

.langs { display: flex; gap: 4px; margin-inline: -10px; }
.langs a { padding: 10px; color: var(--text); font-size: .9375rem; font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; }
.langs a:hover { color: var(--blue); }
.langs a[aria-current] { color: var(--navy); border-bottom-color: var(--blue); }

/* ── Основное ── */
.main { margin-block: auto; display: flex; flex-direction: column; align-items: flex-start; }

.bars { display: flex; gap: 5px; width: min(300px, 70%); margin: 0 0 28px 4px; }
.bars i { position: relative; flex: 1; height: 8px; transform: skewX(-40deg); overflow: hidden; background: var(--sky); }
.bars i:nth-child(2) { background: var(--red); }
.bars i:nth-child(3) { background: var(--green); }
.bars i::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
    transform: translateX(-100%);
    animation: sheen 4.2s ease-in-out infinite;
}
.bars i:nth-child(2)::after { animation-delay: .35s; }
.bars i:nth-child(3)::after { animation-delay: .7s; }

@keyframes sheen {
    0% { transform: translateX(-100%); }
    22%, 100% { transform: translateX(100%); }
}

h1 {
    margin: 0;
    max-width: 17ch;
    color: var(--navy);
    font-size: clamp(2.125rem, 4.4vw, 4.25rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -.02em;
    text-wrap: balance;
}

/* Слово выезжает из-под края строки; запас снизу — для хвостов у «y», «q», «қ» */
.word { display: inline-block; overflow: hidden; vertical-align: bottom; padding: 0 .06em .16em; margin: 0 -.06em -.16em; }
.word > span { display: inline-block; }

.lead { margin: 20px 0 0; max-width: 44ch; font-size: clamp(1rem, 1.25vw, 1.1875rem); }

.contacts {
    width: 100%;
    max-width: 37.5rem;
    margin: 40px 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 32px;
    padding-top: 32px;
    position: relative;
}
.contacts::before { content: ""; position: absolute; inset: 0 0 auto; height: 1px; background: var(--line); transform-origin: left; }
.contacts > div { min-width: 0; }
.contacts .wide { grid-column: 1 / -1; }
.contacts dt { margin-bottom: 2px; font-size: .875rem; }
.contacts dd { margin: 0; color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.contacts address span { white-space: nowrap; }
.contacts address { font-style: normal; max-width: 46ch; text-wrap: pretty; }
/* При наведении черта под ссылкой заливается синим слева направо */
.contacts a {
    padding-bottom: 3px;
    color: inherit;
    text-decoration: none;
    background: linear-gradient(var(--sky), var(--sky)) 0 100% / 0 2px no-repeat, linear-gradient(var(--line), var(--line)) 0 100% / 100% 2px no-repeat;
    transition: background-size .35s ease, color .2s;
}
.contacts a:hover, .contacts a:focus-visible { color: var(--blue); background-size: 100% 2px, 100% 2px; }
.phones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; font-size: clamp(1.125rem, 1.5vw, 1.375rem); font-variant-numeric: tabular-nums; }
.phones a { justify-self: start; white-space: nowrap; }

a:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 2px; }

.foot { font-size: .875rem; }

/* ── Поле с эмблемой ── */
.field { position: relative; overflow: hidden; background: var(--field); clip-path: polygon(var(--slant) 0, 100% 0, 100% 100%, 0 100%); }
.emblem, .rosette { position: absolute; top: 50%; left: calc(19% + 24vw); }
.emblem { width: 48vw; translate: -50% -50%; transform: translate(calc(var(--px, 0) * 14px), calc(var(--py, 0) * 14px)); }
.emblem svg { display: block; width: 100%; height: auto; overflow: visible; }
.rosette { width: 78vw; height: 78vw; translate: -50% -50%; transform: translate(calc(var(--px, 0) * -22px), calc(var(--py, 0) * -22px)); stroke: var(--blue); stroke-width: 1.1; stroke-opacity: .16; }

/* ── Страницы ошибок ── */
.code { margin: 0 0 8px; color: var(--navy); font-size: clamp(5.5rem, 15vw, 13rem); font-weight: 800; line-height: .86; letter-spacing: -.05em; font-variant-numeric: lining-nums; }
.error h1 { max-width: 20ch; font-size: clamp(1.625rem, 2.6vw, 2.5rem); line-height: 1.15; }
.error .code + .bars { margin: 20px 0 24px 4px; }
.error .lead { margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: 2px solid var(--blue);
    background: transparent;
    color: var(--blue);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.btn:hover { background: var(--field); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { border-color: var(--navy); background: var(--navy); }
.btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.langs button { padding: 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; }
.langs button:hover { color: var(--blue); }
.langs button[aria-pressed="true"] { color: var(--navy); border-bottom-color: var(--blue); }
.help { margin: 32px 0 0; }
.help a { color: var(--navy); font-weight: 600; text-underline-offset: 4px; text-decoration-color: var(--line); text-decoration-thickness: 2px; white-space: nowrap; }
.help a:hover { color: var(--blue); text-decoration-color: currentColor; }

/* ── Большие мониторы: всё растёт вместе с экраном ── */
@media (min-width: 1800px) {
    html { font-size: calc(16px + (100vw - 1800px) * .0065); }
    .page { padding-left: 7vw; }
}

/* ── Низкие экраны ноутбуков: ужимаем отступы, чтобы контакты были видны без прокрутки ── */
@media (min-width: 901px) and (max-height: 800px) {
    .page { gap: 24px; padding-block: 24px; }
    .logo { width: 15.5rem; }
    h1 { font-size: clamp(2.125rem, min(4.4vw, 7.4vh), 4.25rem); }
    .bars { margin-bottom: 20px; }
    .lead { margin-top: 14px; }
    .contacts { margin-top: 24px; padding-top: 24px; gap: 16px 32px; }
}

/* ── Узкие экраны в две колонки: телефон на боку, планшет ── */
@media (max-width: 1100px) {
    .contacts, .phones { grid-template-columns: 1fr; gap: 14px; }
    .phones { gap: 6px; }
}

/* ── Телефон и планшет вертикально: логотип, эмблема (анимация видна сразу), заголовок, контакты ── */
@media (max-width: 640px), (max-width: 900px) and (orientation: portrait) {
    :root { --pad: max(20px, 5vw); }
    body { display: flex; flex-direction: column; }
    .page { display: contents; }
    .top { order: 1; padding: max(20px, env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) 12px max(var(--pad), env(safe-area-inset-left)); }
    .field { order: 2; flex: none; height: clamp(190px, 56vw, 420px); --slant: 7vw; clip-path: polygon(0 var(--slant), 100% 0, 100% calc(100% - var(--slant)), 0 100%); }
    .main { order: 3; margin: 0; padding: 20px max(var(--pad), env(safe-area-inset-right)) 0 max(var(--pad), env(safe-area-inset-left)); align-items: stretch; }
    .foot { order: 4; margin-top: auto; padding: 28px max(var(--pad), env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left)); }

    .logo { width: clamp(200px, 56vw, 320px); }
    .emblem, .rosette { left: 50%; top: 50%; }
    .emblem { width: clamp(138px, 41vw, 310px); }
    .rosette { width: 125vw; height: 125vw; stroke-width: 1.6; }

    h1 { max-width: none; font-size: clamp(1.875rem, 8.6vw, 3.5rem); }
    .bars { width: min(240px, 62%); margin-bottom: 20px; }
    .lead { margin-top: 14px; max-width: 56ch; }
}

/* Планшет вертикально: места хватает на две колонки контактов и языки рядом с логотипом */
@media (min-width: 641px) and (max-width: 900px) and (orientation: portrait) {
    .contacts { grid-template-columns: 1fr 1fr; gap: 28px 32px; max-width: none; }
    .phones { grid-template-columns: 1fr 1fr; gap: 8px 32px; font-size: 1.375rem; }
}

/* Телефон: языки — ровным рядом на всю ширину, контакты — крупные строки под палец */
@media (max-width: 640px) {
    .langs { width: 100%; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-bottom: 1px solid var(--line); }
    .langs a { min-height: 44px; display: grid; place-items: center; padding: 0; margin-bottom: -1px; }

    .langs button { min-height: 44px; padding: 0; margin-bottom: -1px; }
    .actions { flex-direction: column; margin-top: 24px; }

    .contacts { margin-top: 24px; padding-top: 0; gap: 0; }
    .contacts > div { padding: 14px 0; border-bottom: 1px solid var(--line); }
    .contacts > div:last-child { border-bottom: 0; }
    .contacts dd > a { display: flex; align-items: center; min-height: 44px; background: none; padding: 0; }
    .contacts a:active { color: var(--blue); }
    .phones { gap: 0; font-size: clamp(1.25rem, 6vw, 1.5rem); }
    .phones a { justify-self: stretch; }
    .contacts dd:has(> address) { padding-top: 6px; }
}

/* Телефон на боку */
@media (min-width: 641px) and (max-height: 500px) {
    body { grid-template-columns: minmax(0, 1fr) 36vw; }
    .page { gap: 20px; padding-block: 20px; padding-left: max(24px, env(safe-area-inset-left)); }
    .logo { width: 190px; }
    h1 { font-size: 1.875rem; }
    .field { min-height: 100dvh; }
    .emblem { width: 28vw; left: 58%; top: 50vh; }
    .rosette { left: 58%; top: 50vh; }
    .contacts { margin-top: 20px; padding-top: 20px; }
}

/* Сенсорный экран любого размера: ссылки не мельче 44 px */
@media (pointer: coarse) {
    .contacts dd > a, .help a { display: inline-flex; align-items: center; min-height: 44px; }
    .langs a, .langs button { min-height: 44px; min-width: 44px; display: inline-grid; place-items: center; }
}

/* ── Анимации ──
   Порядок при загрузке: полоски и заголовок → контакты; справа — узор, эмблема по частям. Потом эмблема остаётся живой. */
@keyframes rise { from { transform: translateY(110%); } }
@keyframes appear { from { opacity: 0; transform: translateY(14px); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-bar { from { transform: skewX(-40deg) scaleX(0); } }
@keyframes ray-in { from { transform: scale(.35); opacity: 0; } }
@keyframes ray-glow { 0%, 30%, 100% { fill: #dca33a; } 12% { fill: #ffd978; } }
@keyframes halo { from { opacity: .35; transform: scale(.9); } to { opacity: 1; transform: scale(1.08); } }
@keyframes unfurl { from { clip-path: circle(0% at 50% 85%); } to { clip-path: circle(110% at 50% 85%); } }
@keyframes flag-in { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% -2% -10% 0); } }
@keyframes flag-wave { from { transform: rotate(-.5deg) translateY(-1.2px); } to { transform: rotate(.5deg) translateY(1.6px); } }
@keyframes moon-in { from { opacity: 0; transform: rotate(-70deg) scale(.6); } }
@keyframes star-in { from { opacity: 0; transform: rotate(-180deg) scale(0); } }
@keyframes twinkle { 0%, 70%, 100% { transform: none; } 82% { transform: scale(1.22) rotate(18deg); } }
@keyframes float { from { transform: translateY(-5px); } to { transform: translateY(7px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
    .logo { animation: fade .7s ease both; }
    .langs { animation: fade .7s .15s ease both; }
    .bars i { transform-origin: left; animation: grow-bar .55s cubic-bezier(.2, .7, .2, 1) both; }
    .bars i:nth-child(2) { animation-delay: .12s; }
    .bars i:nth-child(3) { animation-delay: .24s; }
    .word > span { animation: rise .75s cubic-bezier(.2, .75, .2, 1) both; animation-delay: calc(.15s + var(--i) * .09s); }
    .code { animation: appear .6s .1s ease both; }
    .lead { animation: appear .6s .45s ease both; }
    .contacts::before { animation: grow-x .8s .55s cubic-bezier(.2, .7, .2, 1) both; }
    .contacts > div { animation: appear .6s .65s ease both; }
    .contacts > div:nth-child(2) { animation-delay: .74s; }
    .contacts > div:nth-child(3) { animation-delay: .8s; }
    .contacts > div:nth-child(4) { animation-delay: .9s; }
    .foot { animation: fade .6s 1s ease both; }

    .rosette { animation: fade 1.6s ease both; }
    .rosette g { transform-origin: 500px 500px; animation: spin 180s linear infinite; }
    .rosette .rosette-inner { animation-duration: 120s; animation-direction: reverse; }

    .emblem svg { animation: float 6.5s 1.8s ease-in-out infinite alternate; }
    .emblem :is(path, circle) { transform-box: fill-box; transform-origin: center; }
    .e-eagle { animation: unfurl 1.3s .2s cubic-bezier(.3, .6, .2, 1) both; }
    .emblem .e-rays path {
        transform-box: view-box;
        transform-origin: calc(305.5px - 134px) calc(185px - 31px);
        animation: ray-in .6s calc(.75s + var(--i) * .06s) cubic-bezier(.2, 1.3, .4, 1) both, ray-glow 5s calc(2.2s + var(--i) * .13s) ease-in-out infinite;
    }
    .e-halo { animation: fade 1s 1s both, halo 3.6s 2s ease-in-out infinite alternate both; }
    .e-crescent { animation: moon-in .9s .9s cubic-bezier(.2, .8, .2, 1) both; }
    .e-star { animation: star-in .8s 1.35s cubic-bezier(.2, 1.4, .4, 1) both, twinkle 4.5s 3s ease-in-out infinite; }
    .e-flag { animation: flag-in 1s .7s cubic-bezier(.4, .1, .2, 1) both, flag-wave 3.4s 1.7s ease-in-out infinite alternate; }
    .e-flag-red { animation-delay: .8s, 1.8s; }
    .e-flag-green { animation-delay: .95s, 2s; }
}

@media (prefers-reduced-motion: reduce) {
    .bars i::after { animation: none; }
}
