/* ========================================================================
   Ágil Fiscal — Documentos Legais
   Estética: "Editorial Fiscal" — Fraunces + Lora + JetBrains Mono
   ======================================================================== */

:root {
    --paper:        #F7F3EB;
    --paper-deep:   #EFE8D7;
    --ink:          #0F1B1F;
    --ink-soft:     #2C3438;
    --muted:        #6B6258;
    --hairline:     #D9D2C2;
    --brand:        #05585D;
    --brand-deep:   #033E42;
    --brand-light:  #0A7A7F;
    --warning:      #B7611F;
    --warning-bg:   #F2E6D4;
    --warning-ink:  #6B3A0F;
    --max-content:  680px;
    --max-shell:    1280px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 4rem;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Lora', 'Iowan Old Style', Georgia, serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.75;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Paper grain — sutil, em multiply, fixo */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.55;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.05  0 0 0 0 0.05  0 0 0 0.07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Decorativo: arco de gradiente atrás do header */
body::after {
    content: '';
    position: fixed;
    top: -30vh;
    right: -25vw;
    width: 70vw;
    height: 70vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(5,88,93,0.10), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* === Reading progress bar === */
.legal-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--brand-light), var(--brand), var(--brand-deep));
    z-index: 100;
    transition: width 0.12s ease-out;
}

/* === Document shell === */
.legal-doc {
    position: relative;
    z-index: 2;
    max-width: var(--max-shell);
    margin: 0 auto;
    padding: 0 2.5rem;
}

/* === Header === */
.legal-doc__header {
    position: relative;
    padding: 5rem 0 3rem;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 4.5rem;
}

.legal-doc__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
    text-decoration: none;
    padding: 0.3rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    margin-bottom: 3.5rem;
}
.legal-doc__back:hover {
    color: var(--brand);
    border-bottom-color: var(--brand);
    transform: translateX(-2px);
}
.legal-doc__back-arrow {
    font-family: 'Fraunces', serif;
    font-size: 1rem;
    line-height: 1;
    transform: translateY(-1px);
}

.legal-doc__brand {
    display: block;
    height: 38px;
    width: auto;
    margin-bottom: 2rem;
    user-select: none;
}

.legal-doc__eyebrow {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--brand);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.legal-doc__eyebrow::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--brand), transparent);
    max-width: 220px;
}

.legal-doc__title {
    font-family: 'Fraunces', 'Bodoni Moda', Georgia, serif;
    font-weight: 400;
    font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 0;
    font-size: clamp(2.6rem, 7vw, 5.2rem);
    line-height: 0.96;
    letter-spacing: -0.03em;
    color: var(--ink);
    margin-bottom: 1.25rem;
    max-width: 920px;
}
.legal-doc__title em {
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
    color: var(--brand);
    font-weight: 400;
}

.legal-doc__subtitle {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1.05rem, 1.4vw, 1.2rem);
    line-height: 1.55;
    color: var(--ink-soft);
    max-width: 620px;
    margin-bottom: 2.5rem;
    font-style: italic;
}

.legal-doc__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2.5rem;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.legal-doc__meta-item label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    opacity: 0.7;
}
.legal-doc__meta-item span {
    color: var(--ink);
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
}

/* === Layout em duas colunas === */
.legal-doc__layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 5rem;
    padding-bottom: 6rem;
    align-items: start;
}

/* === TOC === */
.legal-toc {
    position: sticky;
    top: 3rem;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.legal-toc__title {
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.5rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--hairline);
}
.legal-toc__list {
    list-style: none;
    padding: 0;
    max-height: calc(100vh - 9rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
    padding-right: 0.5rem;
}
.legal-toc__list::-webkit-scrollbar { width: 4px; }
.legal-toc__list::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 2px; }

.legal-toc__item { margin-bottom: 0.1rem; }
.legal-toc__link {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    margin-left: -0.85rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.82rem;
    line-height: 1.35;
    border-left: 2px solid transparent;
    transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.legal-toc__link:hover {
    color: var(--ink);
    background: rgba(15, 27, 31, 0.025);
}
.legal-toc__link.is-active {
    color: var(--brand);
    border-left-color: var(--brand);
    font-weight: 600;
}
.legal-toc__num {
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-size: 0.95rem;
    font-weight: 500;
    font-feature-settings: "tnum" 1;
    min-width: 1.6em;
    text-align: right;
    color: inherit;
    opacity: 0.85;
}

/* === Artigo === */
.legal-article {
    max-width: var(--max-content);
}

.legal-intro {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.18rem;
    line-height: 1.65;
    color: var(--ink-soft);
    margin-bottom: 5rem;
}
.legal-intro::first-letter {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
    font-weight: 400;
    font-style: italic;
    font-size: 5rem;
    float: left;
    line-height: 0.85;
    padding: 0.35rem 0.95rem 0 0;
    color: var(--brand);
}

/* === Seção === */
.legal-section {
    margin-bottom: 5rem;
    scroll-margin-top: 3rem;
    position: relative;
}

.legal-section__head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.75rem;
    align-items: baseline;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--hairline);
}

.legal-section__num {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 1;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(2.8rem, 4.5vw, 4.2rem);
    line-height: 0.88;
    color: var(--brand);
    font-feature-settings: "tnum" 1, "lnum" 1;
    letter-spacing: -0.035em;
    opacity: 0.95;
}

.legal-section__title {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 36, "SOFT" 0;
    font-weight: 500;
    font-size: clamp(1.35rem, 2.4vw, 1.8rem);
    line-height: 1.18;
    letter-spacing: -0.015em;
    color: var(--ink);
}

/* Subsection */
.legal-subsection {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 24, "SOFT" 0;
    font-weight: 500;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--ink);
    margin: 2.25rem 0 0.85rem;
    letter-spacing: -0.005em;
}

/* Content */
.legal-article p {
    margin-bottom: 1.15rem;
    color: var(--ink-soft);
}

.legal-article ul {
    margin: 1rem 0 1.5rem 0;
    padding: 0;
    list-style: none;
}
.legal-article li {
    position: relative;
    padding-left: 1.65rem;
    margin-bottom: 0.45rem;
    color: var(--ink-soft);
}
.legal-article li::before {
    content: '—';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--brand);
    font-family: 'Fraunces', serif;
    font-weight: 500;
}

.legal-article strong {
    color: var(--ink);
    font-weight: 600;
}

.legal-article a {
    color: var(--brand);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.legal-article a:hover {
    color: var(--brand-deep);
}

/* === Callouts === */
.legal-callout {
    position: relative;
    padding: 1.5rem 1.75rem 1.5rem 2rem;
    margin: 1.75rem 0;
    background: var(--paper-deep);
    border-left: 3px solid var(--brand);
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    color: var(--ink);
    font-style: italic;
}
.legal-callout strong { font-style: normal; }

.legal-warning {
    position: relative;
    padding: 1.5rem 1.75rem 1.5rem 2rem;
    margin: 1.75rem 0;
    background: var(--warning-bg);
    border-left: 3px solid var(--warning);
    color: var(--warning-ink);
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    font-style: italic;
}
.legal-warning strong { font-style: normal; color: var(--warning-ink); }

/* === Definitions === */
.legal-definitions {
    margin: 1.5rem 0 2rem;
    padding: 2rem 0;
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}
.legal-definitions dt {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 24;
    font-style: italic;
    font-weight: 500;
    color: var(--brand);
    font-size: 1.1rem;
    margin-top: 1.35rem;
    letter-spacing: -0.005em;
}
.legal-definitions dt:first-child { margin-top: 0; }
.legal-definitions dd {
    margin: 0.4rem 0 0;
    color: var(--ink-soft);
    font-size: 0.97rem;
    line-height: 1.65;
}

/* === Contact (dark inversion) === */
.legal-contact {
    margin-top: 1.5rem;
    padding: 2.25rem 2.25rem 2rem;
    background: var(--ink);
    color: var(--paper);
    position: relative;
    overflow: hidden;
}
.legal-contact::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 70%;
    height: 200%;
    background: radial-gradient(circle, rgba(10, 122, 127, 0.32), transparent 65%);
    pointer-events: none;
}
.legal-contact > * { position: relative; z-index: 1; }
.legal-contact-name {
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 72, "SOFT" 30;
    font-style: italic;
    font-weight: 500;
    font-size: 1.6rem;
    margin-bottom: 1.25rem;
    color: var(--paper);
    display: block;
}
.legal-contact p {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.78rem;
    margin-bottom: 0.55rem;
    color: rgba(247, 243, 235, 0.72);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.legal-contact a {
    color: var(--paper);
    border-bottom-color: rgba(247, 243, 235, 0.35);
    text-transform: none;
    letter-spacing: 0.02em;
}
.legal-contact a:hover {
    color: var(--brand-light);
    border-bottom-color: var(--brand-light);
}

/* === Article footer === */
.legal-article__footer {
    margin-top: 5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--hairline);
    text-align: center;
    font-family: 'Fraunces', serif;
    font-variation-settings: "opsz" 24, "SOFT" 0;
    font-style: italic;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

/* === Page footer === */
.legal-pagefoot {
    position: relative;
    z-index: 2;
    border-top: 1px solid var(--hairline);
    padding: 2.5rem 2.5rem 3rem;
    margin: 0 auto;
    max-width: var(--max-shell);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
}
.legal-pagefoot a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.legal-pagefoot a:hover {
    color: var(--brand);
    border-bottom-color: var(--brand);
}
.legal-pagefoot__links { display: flex; gap: 1.5rem; }

/* === Responsive === */
@media (max-width: 980px) {
    .legal-doc { padding: 0 1.5rem; }
    .legal-doc__header { padding-top: 3.5rem; padding-bottom: 2.5rem; margin-bottom: 3rem; }
    .legal-doc__back { margin-bottom: 2.5rem; }
    .legal-doc__layout {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    .legal-toc {
        position: relative;
        top: 0;
        padding-bottom: 2rem;
        border-bottom: 1px solid var(--hairline);
    }
    .legal-toc__list {
        max-height: 280px;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 0.15rem;
        padding-right: 0;
    }
    .legal-toc__link {
        padding: 0.5rem 0.75rem;
        margin: 0;
        border-left: none;
        border-bottom: 2px solid transparent;
    }
    .legal-toc__link.is-active {
        border-left: none;
        border-bottom-color: var(--brand);
        background: rgba(5, 88, 93, 0.04);
    }
    .legal-section { margin-bottom: 3.5rem; }
    .legal-section__head { gap: 1rem; }
    .legal-pagefoot { padding: 2rem 1.5rem 2.5rem; flex-direction: column; text-align: center; }
}

@media (max-width: 640px) {
    body { font-size: 16px; }
    .legal-doc { padding: 0 1.25rem; }
    .legal-intro { font-size: 1.05rem; margin-bottom: 3rem; }
    .legal-intro::first-letter { font-size: 4rem; }
    .legal-section__head { grid-template-columns: 1fr; gap: 0.5rem; }
    .legal-section__num { font-size: 2.5rem; }
    .legal-contact { padding: 1.75rem 1.5rem; }
    .legal-contact-name { font-size: 1.35rem; }
}

/* === Print === */
@media print {
    body { background: #fff; color: #000; font-size: 11pt; }
    body::before, body::after, .legal-progress, .legal-toc, .legal-doc__back { display: none !important; }
    .legal-doc__layout { grid-template-columns: 1fr; gap: 0; }
    .legal-doc { padding: 0; max-width: 100%; }
    .legal-section { page-break-inside: avoid; margin-bottom: 2rem; }
    .legal-section__num { color: #000; }
    .legal-contact { background: #f5f5f5; color: #000; }
    .legal-contact-name, .legal-contact p, .legal-contact a { color: #000; }
    .legal-pagefoot { padding: 1rem 0; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* === Entry animation === */
@keyframes legalFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
.legal-doc__header > * {
    animation: legalFadeUp 0.65s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
.legal-doc__header > *:nth-child(1) { animation-delay: 0s; }
.legal-doc__header > *:nth-child(2) { animation-delay: 0.06s; }
.legal-doc__header > *:nth-child(3) { animation-delay: 0.12s; }
.legal-doc__header > *:nth-child(4) { animation-delay: 0.18s; }
.legal-doc__header > *:nth-child(5) { animation-delay: 0.24s; }
.legal-doc__header > *:nth-child(6) { animation-delay: 0.30s; }
.legal-toc { animation: legalFadeUp 0.6s ease-out both; animation-delay: 0.3s; }
.legal-article { animation: legalFadeUp 0.6s ease-out both; animation-delay: 0.35s; }
