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

:root {
    --bg-page: #f5f0e8;
    --bg-surface: #ede8dc;
    --text-primary: #2a2520;
    --text-secondary: #5a5248;
    --text-muted: #8a8278;
    --accent: #5e7d6a;
    --accent-subtle: #dbe8e0;
    --accent-dark: #3e5c4a;
    --border: #d4cec2;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Lora', Georgia, serif;
    font-size: 17px;
    line-height: 1.75;
    min-height: 100vh;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Counter ─────────────────────────── */
.counter-strip {
    background: var(--accent-subtle);
    border-bottom: 1px solid #c2d6c9;
    padding: 18px 0;
    text-align: center;
}

.counter-strip p {
    font-family: 'Spectral', serif;
    font-size: 14px;
    font-weight: 300;
    color: var(--accent-dark);
    letter-spacing: 0.04em;
}

.counter-strip strong {
    font-size: 22px;
    font-weight: 600;
    font-family: 'Spectral', serif;
    margin-right: 6px;
}

/* ── Header ──────────────────────────── */
header {
    border-bottom: 1px solid var(--border);
    padding: 56px 0 40px;
    text-align: center;
}

.header-eyebrow {
    font-family: 'Spectral', serif;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 18px;
}

header h1 {
    font-family: 'Spectral', serif;
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 300;
    line-height: 1.22;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

header h1 em {
    font-style: italic;
    color: var(--accent-dark);
}

.header-rule {
    width: 48px;
    height: 2px;
    background: var(--accent);
    margin: 28px auto 0;
    border: none;
}

/* ── Sections ────────────────────────── */
section {
    padding: 64px 0;
    border-bottom: 1px solid var(--border);
}

section:last-of-type {
    border-bottom: none;
}

.section-label {
    font-family: 'Spectral', serif;
    font-size: 10.5px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

h2 {
    font-family: 'Spectral', serif;
    font-size: clamp(20px, 3vw, 27px);
    font-weight: 300;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

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

/* ── Law card ────────────────────────── */
.ordinance-card {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    border-radius: 2px;
    padding: 22px 26px;
    margin-top: 28px;
}

.ordinance-card .label {
    font-family: 'Spectral', serif;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.ordinance-card blockquote {
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.7;
}

.ordinance-card .source {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ── Form ────────────────────────────── */
.builder-grid {
    display: grid;
    gap: 20px;
    margin-top: 36px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-group.half {
    max-width: 260px;
}

label {
    font-family: 'Spectral', serif;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 400;
}

label .req {
    font-size: 10px;
    opacity: .55;
    letter-spacing: 0;
}

.field-hint {
    font-family: 'Spectral', serif;
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    min-height: 1px;
}

.field-hint.error {
    color: #a4503f;
}

input[type="text"],
input[type="date"],
textarea {
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 13px 16px;
    font-family: 'Lora', Georgia, serif;
    font-size: 15.5px;
    color: var(--text-primary);
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 125, 106, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: #b8b2a8;
}

textarea {
    resize: vertical;
    min-height: 84px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── Pills ───────────────────────────── */
.pill-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pill-option {
    position: relative;
    cursor: pointer;
}

.pill-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pill-option span {
    display: block;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 30px;
    font-family: 'Spectral', serif;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.15s;
    background: white;
}

.pill-option input:checked+span {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.pill-option:hover span {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.pill-option input:checked+span:hover {
    color: white;
}

.ask-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ask-group .pill-option span {
    border-radius: 4px;
}

/* ── Document output ─────────────────── */
.doc-output {
    margin-top: 32px;
    display: none;
}

.doc-output.visible {
    display: block;
}

.doc-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.doc-note {
    font-family: 'Spectral', serif;
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 16px 0 14px;
    line-height: 1.6;
}

.doc-scroll {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
}

.doc-stage {
    position: relative;
    overflow: hidden;
}

/* A4 sheet, 20 mm margins — matches the .docx page setup */
.doc-sheet {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
    font-family: Helvetica, Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
}

.doc-sheet p {
    color: #000;
    margin: 0;
    font-size: 11pt;
    line-height: 1.5;
}

/* header block: indented 80 mm from the left margin, as in the original form */
.doc-sheet .dp-head {
    margin-left: 80mm;
    text-align: justify;
}

.doc-sheet .dp-cap {
    margin-left: 80mm;
    text-align: center;
    font-size: 8pt;
    line-height: 1.35;
}

.doc-sheet .dp-title {
    text-align: center;
}

.doc-sheet .dp-body {
    text-indent: 10mm;
    text-align: justify;
}

.doc-sheet .dp-blank {
    height: 1.5em;
}

.doc-sheet .dp-sign {
    display: flex;
    gap: 8mm;
}

.doc-sheet .dp-sign .dp-sign-right {
    margin-left: auto;
}

.doc-sheet .dp-signcap {
    text-align: right;
    font-size: 8pt;
    line-height: 1.35;
}

/* ── Buttons ─────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 26px;
    border-radius: 3px;
    font-family: 'Spectral', serif;
    font-size: 13.5px;
    letter-spacing: 0.04em;
    cursor: pointer;
    border: none;
    transition: all 0.18s;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: white;
    margin-top: 28px;
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 16px;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 13px;
    padding: 10px 18px;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.btn-mailto {
    background: var(--accent);
    color: white;
    font-size: 13px;
    padding: 10px 18px;
}

/* «Сразу к форме» — над рассказом о законе, для тех, кто уже всё знает */
.btn-jump {
    background: var(--accent-subtle);
    color: var(--accent-dark);
    border: 1px solid #c2d6c9;
    font-size: 13px;
    padding: 11px 20px;
    margin-bottom: 34px;
}

.btn-jump:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-mailto:hover {
    background: var(--accent-dark);
}

.copy-feedback {
    font-family: 'Spectral', serif;
    font-size: 12px;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-feedback.show {
    opacity: 1;
}

/* ── Q&A ─────────────────────────────── */
.qa-item {
    border-bottom: 1px solid var(--border);
}

.qa-question {
    width: 100%;
    background: none;
    border: none;
    padding: 22px 0;
    font-family: 'Lora', Georgia, serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    line-height: 1.4;
}

.qa-question:hover {
    color: var(--accent-dark);
}

.qa-chevron {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    color: var(--accent);
    transition: transform 0.25s;
}

.qa-item.open .qa-chevron {
    transform: rotate(180deg);
}

.qa-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.qa-item.open .qa-answer {
    max-height: 900px;
}

.qa-answer-inner {
    padding-bottom: 24px;
    font-size: 15.5px;
    line-height: 1.78;
}

.qa-answer-inner p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.qa-answer-inner p:last-child {
    margin-bottom: 0;
}

.qa-answer-inner a {
    color: var(--accent-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Footer ──────────────────────────── */
footer {
    padding: 40px 0 56px;
    text-align: center;
}

footer p {
    font-family: 'Spectral', serif;
    font-size: 13px;
    color: var(--text-muted);
}

footer a {
    color: var(--accent-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* дисклеймер про непричастность НГУ — читается раньше остального подвала */
.footer-disclaimer {
    color: var(--text-secondary);
    max-width: 54ch;
    margin: 0 auto 22px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.footer-disclaimer strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Animations ──────────────────────── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-up {
    animation: fadeUp 0.55s ease both;
}

.d1 {
    animation-delay: 0.05s;
}

.d2 {
    animation-delay: 0.15s;
}

.d3 {
    animation-delay: 0.25s;
}

.d4 {
    animation-delay: 0.35s;
}

@media (max-width: 540px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    header {
        padding: 40px 0 32px;
    }

    .doc-scroll {
        padding: 12px;
    }
}

/* ── Print: only the sheet, at true A4 size ── */
@page {
    size: A4;
    margin: 20mm;
}

@media print {

    html,
    body {
        background: #fff !important;
        background-image: none !important;
    }

    .fade-up {
        animation: none !important;
    }

    /* всё, кроме листа, убирается из потока — иначе перед документом
       напечатались бы пустые страницы */
    .counter-strip,
    .container>header,
    .container>footer,
    .container>section:not(.doc-print-host),
    .doc-print-host>*:not(.doc-output),
    .doc-output>*:not(.doc-scroll) {
        display: none !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
    }

    .doc-print-host {
        padding: 0 !important;
        border: none !important;
    }

    .doc-scroll,
    .doc-stage {
        overflow: visible !important;
        border: none !important;
        background: none !important;
        padding: 0 !important;
        height: auto !important;
    }

    /* поля страницы задаёт @page, поэтому у листа их нет */
    .doc-sheet {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }
}
