/* ═══════════════ LEGAL DOCUMENTS (scoped) ═══════════════ */
/* /legal/ і /legal/{doc}/ — див. templates/legal/*. Усе під .fs-legal. */

.fs-legal {
    --page: #ffffff;
    --soft: #f4f5f6;
    --line: #ebeef2;
    --line-strong: #c9cdd3;
    --text: #1a1d21;
    --text-body: #33383f;
    --muted: #88909f;
    --muted-dark: #606977;
    --accent: #e34d1e;
    --accent-hover: #ca4219;
    --accent-soft: #fef5ee;
    --radius-lg: 20px;
    --radius-md: 12px;
    /* Відступ липких елементів і якорів: у залогінених зверху фіксована шапка. */
    --sticky-top: 0px;
    --anchor-gap: 24px;

    /* body має глобальний padding-left: 25px — розтягуємо сторінку на всю ширину. */
    margin-left: -25px;
    width: calc(100% + 25px);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--page);
    -webkit-text-size-adjust: 100%;
}

/* Типографіка й ресети — лише для вмісту сторінки: футер сайту (footer-garage.php)
   теж лежить усередині .fs-legal і має виглядати так само, як на інших сторінках. */
.fs-legal .legal-topbar,
.fs-legal .legal-shell {
    color: var(--text);
    font-family: "Manrope", -apple-system, Roboto, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

.header ~ .fs-legal {
    --sticky-top: 73px;
    padding-top: 73px;
}

.fs-legal :where(.legal-topbar, .legal-shell),
.fs-legal :where(.legal-topbar, .legal-shell) *,
.fs-legal :where(.legal-topbar, .legal-shell) *::before,
.fs-legal :where(.legal-topbar, .legal-shell) *::after {
    box-sizing: border-box;
}

.fs-legal :where(.legal-topbar, .legal-shell) a {
    color: inherit;
}

.fs-legal :where(.legal-topbar, .legal-shell) svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: currentColor;
}

.fs-legal .footer-wrapper {
    margin-top: auto;
}

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

.fs-legal .legal-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s ease;
}

.fs-legal .legal-button:hover {
    background: var(--accent-hover);
}

.fs-legal .legal-button span {
    font-weight: 500;
    opacity: .8;
}

.fs-legal .legal-button.is-ghost {
    background: transparent;
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.fs-legal .legal-button.is-ghost:hover {
    background: var(--soft);
}

.fs-legal .legal-button.is-small {
    min-height: 36px;
    padding: 0 16px;
    font-size: 14px;
}

/* ─────────── Смуга для гостей ─────────── */

.fs-legal .legal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0;
}

.fs-legal .legal-topbar-logo img {
    display: block;
    width: 112px;
    height: auto;
}

.fs-legal .legal-topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.fs-legal .legal-topbar-link {
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.fs-legal .legal-topbar-link:hover {
    color: var(--accent);
}

/* ─────────── Каркас ─────────── */

.fs-legal .legal-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0 96px;
}

.fs-legal .legal-shell.is-narrow {
    width: min(760px, calc(100% - 32px));
}

/* ─────────── Шапка документа ─────────── */

.fs-legal .legal-hero {
    position: relative;
    padding-bottom: 32px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--line);
}

.fs-legal .legal-hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.fs-legal .legal-crumbs a {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted-dark);
    text-decoration: none;
}

.fs-legal .legal-crumbs a::before {
    content: "←";
    margin-right: 8px;
}

.fs-legal .legal-crumbs a:hover {
    color: var(--accent);
}

.fs-legal .legal-lang {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--soft);
}

.fs-legal .legal-lang-item {
    min-width: 44px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: .04em;
    text-align: center;
    text-decoration: none;
    color: var(--muted-dark);
    transition: color .15s ease, background-color .15s ease;
}

.fs-legal .legal-lang-item:hover {
    color: var(--text);
}

.fs-legal .legal-lang-item.is-active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(26, 29, 33, .1);
}

.fs-legal .legal-title {
    margin: 0;
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.fs-legal .legal-lead {
    margin: 12px 0 0;
    color: var(--muted-dark);
}

.fs-legal .legal-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 28px;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}

.fs-legal .legal-meta li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
}

.fs-legal .legal-meta-label {
    color: var(--muted);
}

.fs-legal .legal-meta-value {
    font-weight: 600;
}

.fs-legal .legal-meta-value.is-muted {
    font-weight: 500;
    color: var(--muted-dark);
}

.fs-legal .legal-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: .02em;
}

.fs-legal .legal-badge.is-preview {
    background: #fff3c4;
    color: #7a5b00;
}

.fs-legal .legal-badge.is-archive {
    background: var(--soft);
    color: var(--muted-dark);
}

.fs-legal .legal-notice {
    margin: 20px 0 0;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--soft);
    color: var(--muted-dark);
    font-size: 14px;
    line-height: 1.5;
}

.fs-legal .legal-notice.is-archive {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    background: var(--accent-soft);
    color: var(--text);
}

.fs-legal .legal-notice p {
    margin: 0;
}

.fs-legal .legal-notice a {
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.fs-legal .legal-meta .legal-meta-pdf {
    margin-left: auto;
}

.fs-legal .legal-pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted-dark);
    text-decoration: none;
}

.fs-legal .legal-pdf-link:hover {
    color: var(--accent);
}

/* ─────────── Зміст + текст ─────────── */

.fs-legal .legal-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 720px);
    justify-content: space-between;
    gap: 64px;
}

.fs-legal .legal-toc-toggle {
    display: none;
}

.fs-legal .legal-toc {
    position: sticky;
    top: calc(var(--sticky-top) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--sticky-top) - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.fs-legal .legal-toc-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.fs-legal .legal-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.fs-legal .legal-toc-list a {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--muted-dark);
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease;
}

.fs-legal .legal-toc-list a:hover {
    color: var(--text);
    background: var(--soft);
}

.fs-legal .legal-toc-list a.is-active {
    color: var(--text);
    font-weight: 600;
    background: var(--soft);
}

.fs-legal .legal-toc-list a.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: var(--accent);
}

.fs-legal .legal-toc-num {
    flex: none;
    min-width: 20px;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.fs-legal .legal-toc-list a.is-active .legal-toc-num {
    color: var(--accent);
}

.fs-legal .legal-toc-extra {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.fs-legal .legal-toc-extra a {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted-dark);
    text-decoration: none;
}

.fs-legal .legal-toc-extra a:hover,
.fs-legal .legal-toc-extra a.is-active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ─────────── Текст документа ─────────── */

.fs-legal .legal-body {
    min-width: 0;
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-body);
}

.fs-legal .legal-section {
    scroll-margin-top: calc(var(--sticky-top) + var(--anchor-gap));
}

.fs-legal .legal-section + .legal-section {
    margin-top: 56px;
}

.fs-legal .legal-section-title {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin: 0 0 20px;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.fs-legal .legal-section-num {
    flex: none;
    min-width: 44px;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    text-decoration: none;
}

.fs-legal .legal-clause {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: baseline;
    gap: 14px;
    margin: 0 -14px;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    scroll-margin-top: calc(var(--sticky-top) + var(--anchor-gap));
    transition: background-color .6s ease;
}

.fs-legal .legal-clause + .legal-clause {
    margin-top: 10px;
}

.fs-legal .legal-clause-text {
    min-width: 0;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* Текст пункту приходить із редактора адмінки: абзаци, списки, посилання. */
.fs-legal .legal-clause-text > :first-child {
    margin-top: 0;
}

.fs-legal .legal-clause-text > :last-child {
    margin-bottom: 0;
}

.fs-legal .legal-clause-text p,
.fs-legal .legal-clause-text ul,
.fs-legal .legal-clause-text ol {
    margin: .6em 0;
}

.fs-legal .legal-clause-text ul,
.fs-legal .legal-clause-text ol {
    padding-left: 1.3em;
}

.fs-legal .legal-clause-text li + li {
    margin-top: .3em;
}

.fs-legal .legal-clause-text a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fs-legal .legal-clause-num {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    transition: color .15s ease;
}

.fs-legal .legal-clause-num:hover,
.fs-legal .legal-clause:target .legal-clause-num {
    color: var(--accent);
}

.fs-legal .legal-clause:target,
.fs-legal .legal-clause.is-flash {
    background: var(--accent-soft);
}

.fs-legal .legal-placeholder {
    padding: 0 4px;
    border-radius: 4px;
    background: #fff3c4;
    color: inherit;
    font-weight: 600;
}

.fs-legal .legal-to-top {
    display: inline-block;
    margin-top: 40px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted-dark);
    text-decoration: none;
}

.fs-legal .legal-to-top:hover {
    color: var(--accent);
}

/* ─────────── PDF ─────────── */

.fs-legal .legal-card {
    border-radius: var(--radius-lg);
    background: var(--soft);
}

.fs-legal .legal-download {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 16px 20px;
    margin-top: 72px;
    padding: 28px;
    scroll-margin-top: calc(var(--sticky-top) + var(--anchor-gap));
}

.fs-legal .legal-download-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    color: var(--accent);
}

.fs-legal .legal-download-icon svg {
    width: 26px;
    height: 26px;
}

.fs-legal .legal-download-text h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--text);
}

.fs-legal .legal-download-text p {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted-dark);
}

.fs-legal .legal-download-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ─────────── Попередні редакції ─────────── */

.fs-legal .legal-archive {
    margin-top: 56px;
    scroll-margin-top: calc(var(--sticky-top) + var(--anchor-gap));
}

.fs-legal .legal-archive-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.fs-legal .legal-archive-empty {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--muted-dark);
}

.fs-legal .legal-archive-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
}

.fs-legal .legal-archive-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.fs-legal .legal-archive-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 14px;
}

.fs-legal .legal-archive-version {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.fs-legal .legal-archive-dates {
    font-size: 14px;
    color: var(--muted-dark);
}

.fs-legal .legal-archive-actions {
    display: flex;
    gap: 16px;
}

.fs-legal .legal-archive-actions a {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.fs-legal .legal-archive-actions a:hover {
    text-decoration: underline;
}

/* ─────────── /legal/ ─────────── */

.fs-legal .legal-doc-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fs-legal .legal-doc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 16px;
    padding: 22px 24px;
    text-decoration: none;
    transition: background-color .15s ease;
}

.fs-legal .legal-doc:hover {
    background: var(--accent-soft);
}

.fs-legal .legal-doc-title {
    font-size: 18px;
    font-weight: 700;
}

.fs-legal .legal-doc-meta {
    grid-column: 1;
    font-size: 14px;
    color: var(--muted-dark);
}

.fs-legal .legal-doc svg {
    grid-column: 2;
    grid-row: 1 / span 2;
    color: var(--muted);
}

/* ─────────── Тост «Посилання скопійовано» ─────────── */

.legal-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1000;
    padding: 10px 18px;
    border-radius: 999px;
    background: #1a1d21;
    color: #fff;
    font: 600 14px/20px "Manrope", sans-serif;
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.legal-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ─────────── Футер сайту на вузьких екранах ─────────── */

@media (max-width: 760px) {
    .fs-legal .footer-wrapper {
        height: auto;
        padding: 28px 16px;
    }

    .fs-legal .footer-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .fs-legal .footer-nav ul {
        flex-wrap: wrap;
        gap: 10px 20px;
    }
}

/* ─────────── Планшет і телефон ─────────── */

@media (max-width: 1000px) {
    .fs-legal {
        --anchor-gap: 76px; /* + липка смуга змісту */
    }

    .fs-legal .legal-shell {
        padding-top: 24px;
    }

    .fs-legal .legal-layout {
        display: block;
    }

    .fs-legal .legal-toc-toggle {
        position: sticky;
        top: var(--sticky-top);
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 10px;
        width: calc(100% + 32px);
        margin: 0 -16px 24px;
        padding: 14px 16px;
        border: 0;
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        background: rgba(255, 255, 255, .94);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        font: inherit;
        font-size: 14px;
        text-align: left;
        color: var(--text);
        cursor: pointer;
    }

    .fs-legal .legal-toc-toggle-label {
        flex: none;
        font-weight: 700;
    }

    .fs-legal .legal-toc-toggle-current {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: var(--muted-dark);
    }

    .fs-legal .legal-toc-toggle-current:not(:empty)::before {
        content: "· ";
    }

    .fs-legal .legal-toc-toggle svg {
        transition: transform .2s ease;
    }

    .fs-legal .legal-toc-toggle[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }

    /* Зміст на телефоні — аркуш під смугою, а не колонка. */
    .fs-legal .legal-toc {
        position: fixed;
        top: calc(var(--sticky-top) + 52px);
        left: 0;
        right: 0;
        z-index: 19;
        max-height: min(70vh, calc(100vh - var(--sticky-top) - 52px));
        padding: 12px 8px 20px;
        border-bottom: 1px solid var(--line);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        background: #fff;
        box-shadow: 0 24px 48px rgba(26, 29, 33, .14);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
    }

    .fs-legal .legal-toc.is-open {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: opacity .2s ease, transform .2s ease;
    }

    .fs-legal .legal-toc-title {
        display: none;
    }

    .fs-legal .legal-toc-list a {
        padding: 10px 12px;
        font-size: 15px;
    }

    .fs-legal .legal-meta .legal-meta-pdf {
        flex-basis: 100%;
        margin-left: 0;
    }

    .fs-legal .legal-hero {
        margin-bottom: 0;
        padding-bottom: 24px;
        border-bottom: 0;
    }
}

@media (max-width: 600px) {
    .fs-legal .legal-shell {
        padding-bottom: 64px;
    }

    .fs-legal .legal-topbar {
        padding: 14px 0;
    }

    .fs-legal .legal-topbar-actions {
        gap: 14px;
    }

    .fs-legal .legal-body {
        font-size: 16px;
    }

    .fs-legal .legal-section + .legal-section {
        margin-top: 44px;
    }

    .fs-legal .legal-section-title {
        gap: 10px;
        font-size: 20px;
    }

    .fs-legal .legal-section-num {
        min-width: 0;
    }

    /* Номер пункту — над текстом, щоб текст займав усю ширину екрана. */
    .fs-legal .legal-clause {
        display: block;
        margin: 0 -10px;
        padding: 8px 10px;
    }

    .fs-legal .legal-clause-num {
        display: inline-block;
        margin-bottom: 2px;
        font-size: 13px;
        line-height: 20px;
    }


    .fs-legal .legal-download {
        grid-template-columns: minmax(0, 1fr);
        padding: 22px;
    }

    .fs-legal .legal-download-actions {
        grid-column: 1;
    }

    .fs-legal .legal-download-actions .legal-button {
        flex: 1 1 100%;
    }

    .fs-legal .legal-archive-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fs-legal :where(.legal-topbar, .legal-shell) *,
    .legal-toast {
        transition: none !important;
    }
}
