/* ПОДКЛЮЧЕНИЕ ФИРМЕННЫХ ШРИФТОВ STEM */
@font-face {
    font-family: 'Stem';
    src: url('https://raw.githubusercontent.com/ivan-ska/ecards-premium/main/fonts/stem_regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Stem';
    src: url('https://raw.githubusercontent.com/ivan-ska/ecards-premium/main/fonts/stem_medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
}

/* CSS ПЕРЕМЕННЫЕ */
:root {
    --bg-color: #FAFAFF;
    --white: #FFFFFF;
    --dark: #1E1E1E;
    --dark-grey: #636363;
    --light-grey: #AFAFAF;
    --violet: #748BFF;
    --violet-hover: #5D43FF;
    --light-violet: #F1F3FF;
    --light-violet-hover: #E3E8FF;
    --surface-20: #E3E8FF;
    --border-color: #E3E8FF;
    --danger-color: #FF4E62;
    --success-color: #00BD87;
    --warning-color: #FFB800;
    --font-family: 'Stem', sans-serif;
    --shadow: 0 10px 30px rgba(30, 30, 30, 0.1);
}

/* БАЗОВЫЕ СТИЛИ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--dark);
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
strong,
b,
th {
    font-weight: 500;
}

a {
    color: var(--violet);
    text-decoration: none;
    transition: 0.2s;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

ul,
ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

li {
    margin-bottom: 8px;
}

p {
    margin-bottom: 12px;
}

p:last-child {
    margin-bottom: 0;
}

/* ОФОРМЛЕНИЕ ТЕКСТА */
.highlight {
    background-color: var(--surface-20);
    color: var(--violet);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.seq {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    background: #FFFFFF;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.95em;
}

.seq-arrow {
    color: var(--violet);
    font-weight: 500;
}

.important-note {
    background: #FFF0F1;
    border-left: 4px solid var(--danger-color);
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.95em;
}

blockquote {
    background: var(--light-violet);
    border-left: 4px solid var(--violet);
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    font-style: normal;
    font-weight: 500;
    color: var(--violet);
}

.code-inline {
    background: var(--light-violet);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--violet);
}

/* ТАБЛИЦЫ */
.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #FFFFFF;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--light-violet);
    color: var(--dark);
}

tr:last-child td {
    border-bottom: none;
}

/* HEADER */
header {
    background: var(--white);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logo img {
    height: 32px;
    display: block;
}

.main-link {
    display: flex;
    padding: 12px 20px;
    padding-right: 16px;
    height: 44px;
    box-sizing: border-box;
    gap: 8px;
    align-items: center;
    background: var(--violet);
    color: #FFFFFF;
    border-radius: 16px;
    font-size: 14px;
    line-height: auto;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.main-link:hover {
    background: var(--violet-hover);
    color: #FFFFFF;
    text-decoration: none;
}

/* ======== ПОИСК ======== */
.back-search-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 600px;
    flex: 1;
    height: 100%
}

.search-wrapper {
    flex: 1;
    position: relative;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0px 16px;
    gap: 8px;
    height: 44px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrap:focus-within {
    border-color: var(--violet);
    box-shadow: 0 0 0 3px var(--light-violet);
    background: #FFFFFF;
}

.search-icon {
    color: var(--light-grey);
    display: flex;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0px;
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--dark);
    outline: none;
}

.search-input::placeholder {
    color: var(--light-grey);
}

.search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--light-grey);
    padding: 4px;
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.search-clear:hover {
    color: var(--dark);
    background: var(--light-violet);
}

.search-clear.visible {
    display: flex;
}

/* Дропдаун результатов поиска */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow);
    max-height: 480px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-dropdown.open {
    display: block;
}

.search-dropdown-header {
    padding: 10px 16px 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--dark-grey);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--light-violet);
}

.search-result-breadcrumb {
    font-size: 11px;
    color: var(--dark-grey);
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-result-breadcrumb .badge {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 12px;
    background: var(--surface-20);
    color: var(--violet);
}

.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.search-result-title mark {
    background: var(--surface-20);
    color: var(--violet);
    border-radius: 2px;
    padding: 0 1px;
    font-weight: 500;
}

.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--dark-grey);
    font-size: 14px;
}

/* MAIN CONTAINER */
.container {
    display: flex;
    flex-direction: column;
    flex: 1;
    max-width: 1200px;
    margin: 80px auto;
    padding: 0 20px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* HOME PAGE */
.hero {
    text-align: center;
    margin-bottom: 60px;
}

.hero-icon-mobile {
    display: none;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    padding-bottom: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 42px;
    font-weight: 500;
    line-height: normal;
}

.hero p {
    color: var(--dark-grey);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    max-width: 600px;
    margin: 0 auto;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 120px;
    gap: 20px;
}

.nav-card {
    height: 300px;
    border-radius: 24px;
    padding: 40px;
    padding-right: 100px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: none;
    text-decoration: none;
    display: block;
    color: inherit;
    border: none;
}

.nav-card--faq {
    background: linear-gradient(120deg, #642DFF, #7AAFFF);
}

.nav-card--terms {
    background: linear-gradient(120deg, #4C3FE7, #FF8DE6);
}

.nav-card--faq:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px #7AAFFF;
    ;
    text-decoration: none;
    color: inherit;
}

.nav-card--terms:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px #FF8DE6;
    ;
    text-decoration: none;
    color: inherit;
}

.nav-card h2 {
    font-size: 42px;
    font-weight: 500;
    line-height: normal;
    margin-bottom: 10px;
    color: #FFFFFF;
}

.nav-card p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
}

/* ИНФО БЛОК: КОНТАКТЫ И ПОДДЕРЖКА */
.support-wrap {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto 60px;
    padding: 0 20px;
}

.support-wrap .support-block {
    margin-top: 0;
}

.support-block {
    margin-top: auto;
    width: calc(100% - 40px);
    /* Делаем отступы по краям для мобилок */
    max-width: 1160px;
    /* Ограничиваем максимальную ширину как у контейнера */
    margin-left: auto;
    /* Центрируем по горизонтали */
    margin-right: auto;
    /* Центрируем по горизонтали */
    margin-bottom: 60px;
    /* Делаем отступ снизу, чтобы не прилипал к краю */
    box-sizing: border-box;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    text-align: center;
}

/* Отменяем двойные отступы, если блок уже лежит внутри контейнера */
.container .support-block,
.support-wrap .support-block {
    width: 100%;
    margin-bottom: 0;
}

/* footer-header стиль */

.support-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.support-item {
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    box-shadow: none;
}

/* footer-header стиль */
.support-item strong {
    color: var(--dark);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
}

/* footer-text стиль */
.support-item a {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--dark-grey);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    padding-bottom: 4px;
    transition: border-color 0.2s, color 0.2s;
    border-bottom: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: fit-content;
}

.support-item a:hover {
    border-bottom: 1px solid var(--dark-grey);
    text-decoration: none;
}

/* footer-text стиль */

.support-footer-text-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    text-align: left;
}

.support-footer-text {
    color: var(--light-grey);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    margin: 0;
}

/* INNER PAGES */
.page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

/* h1-d стиль */
.page-header h1 {
    font-size: 42px;
    font-weight: 500;
    line-height: normal;
}

.back-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--violet);
    padding: 10px 12px;
    height: 44px;
    box-sizing: border-box;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 500;
    transition: 0.2s;
    text-decoration: none;
}

.back-btn:hover {
    background: var(--light-violet-hover);
    text-decoration: none;
    color: var(--violet);
}

/* THEMES */
.theme-section {
    margin-bottom: 50px;
    scroll-margin-top: 100px;
}

/* h2 стиль */
.theme-title {
    font-size: 24px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.section-intro {
    margin-bottom: 16px;
    padding: 0 10px;
    color: var(--dark-grey);
}

.copy-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--violet);
    opacity: 0;
    transition: 0.2s;
    padding: 6px;
    border-radius: 6px;
    display: flex;
}

.copy-link-btn:hover {
    background: var(--surface-20);
}

.theme-title:hover .copy-link-btn,
.accordion-header:hover .copy-link-btn,
.entry-header:hover .copy-link-btn {
    opacity: 1;
}

/* ACCORDION */
.accordion {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    scroll-margin-top: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.accordion-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    background: var(--light-violet);
}

.accordion-header:hover {
    background: var(--light-violet-hover);
}

.accordion-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

.accordion h3 {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: var(--dark);
}

.chevron {
    transition: transform 0.3s;
    color: var(--violet);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #FFFFFF;
}

.accordion-content {
    padding: 20px;
    color: var(--dark);
}

.accordion.active {
    border-color: var(--violet);
    box-shadow: var(--shadow);
}

.accordion.active .chevron {
    transform: rotate(180deg);
}

.accordion.active .accordion-header {
    border-bottom: 1px solid var(--border-color);
    background: var(--light-violet-hover);
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark);
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ======== LAYOUT С САЙДБАРОМ ======== */
.page-layout {
    display: flex;
    align-items: flex-start;
    flex: 1;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    gap: 40px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* САЙДБАР */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-group {
    margin-bottom: 4px;
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.sidebar-group-header:hover {
    background: var(--light-violet);
}

.sidebar-group-header:hover .sidebar-group-link,
.sidebar-group-header:hover .sidebar-toggle-btn {
    color: var(--violet);
}

/* sidebar стиль */
.sidebar-group-link {
    flex: 1;
    display: block;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--dark-grey);
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 8px 0 0 8px;
    user-select: none;
}

.sidebar-group-link.active {
    color: var(--violet);
    border-left-color: var(--violet);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--dark-grey);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 0 8px 8px 0;
}

.sidebar-chevron {
    display: block;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group.open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-items {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group.open .sidebar-items {
    max-height: 800px;
}

/* sidebar стиль */
.sidebar-item-link {
    display: block;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--light-grey);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.sidebar-item-link:hover,
.sidebar-item-link.active {
    color: var(--violet);
    background: var(--light-violet);
    border-left-color: var(--violet);
    text-decoration: none;
}

/* ОСНОВНОЙ КОНТЕНТ РЯДОМ С САЙДБАРОМ */
.page-content {
    flex: 1;
    min-width: 0;
}

/* ======== ENTRY ======== */
.entry {
    margin-bottom: 32px;
    scroll-margin-top: 90px;
}

.entry-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* h3 стиль */
.entry-header h3 {
    font-size: 17px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--dark);
    margin: 0;
}

.entry-body {
    padding: 0 4px;
    color: var(--dark);
}

/* Тема-секция */
.theme-section {
    margin-bottom: 48px;
    scroll-margin-top: 90px;
}

.section-intro {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--light-violet);
    border-radius: 10px;
    color: var(--dark-grey);
    font-size: 14px;
}

/* ======== БУРГЕР ======== */
.sidebar-burger {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 20px;
    z-index: 500;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--violet);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-direction: column;
    gap: 5px;
    padding: 0;
}

.sidebar-burger:hover {
    background: var(--violet-hover);
    transform: scale(1.05);
}

.sidebar-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
    transform-origin: center;
}

.sidebar-burger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.sidebar-burger.open span:nth-child(2) {
    opacity: 0;
}

.sidebar-burger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Оверлей */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 30, 30, 0.35);
    z-index: 399;
}

.sidebar-overlay.open {
    display: block;
}

/* ======== АДАПТИВНОСТЬ ======== */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    /* h1-m стиль */
    .hero h1 {
        font-size: 32px;
    }

    .hero-icon-desktop {
        display: none;
    }

    .hero-icon-mobile {
        display: block;
    }

    .page-header h1 {
        font-size: 32px;
    }

    /* card-m стиль */
    .nav-card h2 {
        font-size: 32px;
    }

    .copy-link-btn {
        opacity: 1;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-container>.search-wrapper,
    /* Для внутренних страниц */
    .back-search-wrapper {
        max-width: 100%;
        order: 3;
        flex-basis: 100%;
    }

    .back-search-wrapper {
        display: flex;
        width: 100%;
    }

    /* Отменяем перенос строки для самого поиска внутри обертки */
    .back-search-wrapper .search-wrapper {
        order: unset;
        flex-basis: auto;
    }

    .header-container {
        flex-wrap: wrap;
    }

    .page-layout {
        display: block;
        padding: 0 16px;
        margin: 24px auto;
    }

    .support-block {
        padding: 20px;
    }

    .support-grid {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    .support-footer-text-wrapper {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: start;
        text-align: left;
    }

    .nav-card {
        padding: 20px;
        padding-right: 60px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-height: 100vh;
        background: #fff;
        border-right: 1px solid var(--border-color);
        box-shadow: var(--shadow);
        z-index: 400;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 60px 16px 24px;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-burger {
        display: flex;
    }
}