html,
body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

body.legal-page,
body.status-page {
    background:
        linear-gradient(rgba(3, 12, 14, 0.82), rgba(3, 12, 14, 0.96)),
        url("/assets/images/backgrounds/patterns/dark-ornament.svg") center top / 520px auto repeat,
        #071012;
}

.legal-main {
    width: min(100% - 36px, 1040px);
    margin: 0 auto;
    padding: calc(var(--header-height) + clamp(60px, 8vw, 120px)) 0 90px;
}

.legal-hero {
    position: relative;
    display: grid;
    place-items: center;
    min-height: clamp(260px, 36vw, 410px);
    text-align: center;
}

.legal-emblem,
.status-emblems {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(220px, 31vw, 410px);
    aspect-ratio: 1;
    opacity: 0.32;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.legal-emblem img,
.status-emblems img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: document-emblem 46s linear infinite;
}

.legal-emblem img + img,
.status-emblems img + img {
    animation-direction: reverse;
    animation-duration: 34s;
}

.legal-hero > div:last-child {
    position: relative;
    z-index: 1;
}

.legal-hero > div > p:first-child {
    margin: 0 0 18px;
    color: var(--gold);
    font-size: 0.7rem;
    letter-spacing: 0.34em;
}

.legal-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 5.6vw, 4.6rem);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.11em;
}

.legal-hero .legal-lead {
    max-width: 680px;
    margin: 25px auto 0;
    color: rgba(243, 238, 226, 0.67);
    font-size: clamp(0.8rem, 1.3vw, 0.95rem);
    line-height: 2;
    letter-spacing: 0.08em;
}

.legal-document {
    position: relative;
    padding: clamp(30px, 6vw, 70px);
    border: 1px solid rgba(213, 189, 130, 0.38);
    background: rgba(5, 17, 20, 0.9);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.legal-tabs {
    position: sticky;
    z-index: 20;
    top: calc(var(--header-height) + 12px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 18px;
    padding: 8px;
    background: rgba(2, 8, 10, 0.92);
    border: 1px solid rgba(213, 189, 130, 0.22);
    backdrop-filter: blur(12px);
}

.legal-tab {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 74px;
    padding: 11px 14px;
    overflow: hidden;
    border: 1px solid rgba(213, 189, 130, 0.22);
    color: rgba(243, 238, 226, 0.55);
    background: rgba(6, 20, 23, 0.62);
    text-align: center;
    text-decoration: none;
    transition: color 0.45s ease, border-color 0.45s ease, background 0.45s ease, transform 0.45s ease;
}

.legal-tab::after {
    content: "";
    position: absolute;
    right: 17%;
    bottom: 0;
    left: 17%;
    height: 1px;
    background: var(--gold);
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 0.45s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-tab small {
    display: block;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
}

.legal-tab span {
    display: block;
    margin-top: 5px;
    font-size: clamp(0.72rem, 1.25vw, 0.88rem);
    letter-spacing: 0.08em;
}

.legal-tab:hover,
.legal-tab:focus-visible,
.legal-tab.is-active {
    color: var(--ivory);
    border-color: rgba(213, 189, 130, 0.65);
    background: rgba(19, 44, 47, 0.9);
    outline: none;
}

.legal-tab.is-active::after {
    opacity: 1;
    transform: scaleX(1);
}

.legal-panel[hidden] {
    display: none;
}

.legal-panel.is-active {
    animation: legal-panel-reveal 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.legal-panel-heading {
    margin: 0 0 32px;
    padding: 0 0 30px;
    border-bottom: 1px solid rgba(213, 189, 130, 0.18);
    text-align: center;
}

.legal-panel-heading > p:first-child {
    margin: 0 0 10px;
    color: rgba(213, 189, 130, 0.56);
    font-size: 0.62rem;
    letter-spacing: 0.26em;
}

.legal-panel-heading h2 {
    margin: 0;
    color: var(--gold);
    font-size: clamp(1.5rem, 3.4vw, 2.35rem);
    font-weight: 500;
    letter-spacing: 0.1em;
}

.legal-panel-heading > p:last-child {
    margin: 17px auto 0;
    color: rgba(243, 238, 226, 0.64);
    font-size: 0.82rem;
    line-height: 1.9;
}

.legal-document::before,
.legal-document::after {
    content: "◆";
    position: absolute;
    color: var(--gold);
    font-size: 0.65rem;
}

.legal-document::before {
    top: 13px;
    left: 15px;
}

.legal-document::after {
    right: 15px;
    bottom: 13px;
}

.legal-draft-label {
    margin: 0 0 42px;
    padding: 12px 16px;
    border: 1px solid rgba(193, 0, 0, 0.28);
    color: rgba(255, 220, 220, 0.72);
    background: rgba(92, 0, 7, 0.18);
    font-size: 0.7rem;
    text-align: center;
    letter-spacing: 0.12em;
}

.legal-section {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 20px;
    padding: 34px 0;
    border-top: 1px solid rgba(213, 189, 130, 0.13);
}

.legal-section:first-of-type {
    border-top: 0;
}

.legal-section-number {
    margin: 3px 0 0;
    color: rgba(213, 189, 130, 0.44);
    font-size: 0.72rem;
    letter-spacing: 0.15em;
}

.legal-section h2,
.legal-section h3 {
    margin: 0 0 20px;
    color: var(--gold);
    font-size: clamp(1.05rem, 2.1vw, 1.35rem);
    font-weight: 500;
    letter-spacing: 0.11em;
}

@keyframes legal-panel-reveal {
    from { opacity: 0; filter: blur(5px); transform: translateY(12px); }
    to { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.legal-section p,
.legal-section li {
    color: rgba(243, 238, 226, 0.73);
    font-size: 0.85rem;
    line-height: 2;
}

.legal-section p {
    margin: 0 0 15px;
}

.legal-section ul {
    display: grid;
    gap: 8px;
    margin: 16px 0 0;
    padding-left: 1.4em;
}

.legal-updated {
    margin: 40px 0 0;
    color: rgba(243, 238, 226, 0.42);
    font-size: 0.7rem;
    text-align: right;
}

.legal-navigation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    margin-top: 48px;
}

.legal-navigation a {
    color: rgba(243, 238, 226, 0.72);
    font-size: 0.74rem;
    text-decoration: none;
    letter-spacing: 0.08em;
}

.legal-navigation a:hover,
.legal-navigation a:focus-visible {
    color: var(--gold);
}

.legal-footer {
    padding: 25px;
    color: rgba(243, 238, 226, 0.34);
    font-size: 0.65rem;
    text-align: center;
}

body.status-page {
    height: 100%;
    overflow: hidden;
}

.status-main {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: calc(var(--header-height) + 35px) 20px 50px;
    text-align: center;
    overflow: hidden;
}

.status-emblems {
    width: clamp(310px, 52vw, 720px);
    opacity: 0.22;
}

.status-message {
    position: relative;
    z-index: 1;
    width: min(100%, 720px);
}

.status-code {
    margin: 0 0 16px;
    color: var(--gold);
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    letter-spacing: 0.38em;
}

.status-message h1 {
    margin: 0;
    font-size: clamp(2.2rem, 6vw, 5.2rem);
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: 0.1em;
}

.status-copy {
    margin: 30px 0 0;
    color: rgba(243, 238, 226, 0.76);
    font-size: clamp(0.92rem, 1.7vw, 1.12rem);
    line-height: 2;
    letter-spacing: 0.08em;
}

.status-subcopy {
    margin: 15px 0 0;
    color: rgba(243, 238, 226, 0.48);
    font-size: 0.75rem;
    line-height: 1.9;
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-top: 38px;
}

.status-button {
    display: inline-grid;
    place-items: center;
    min-width: 190px;
    min-height: 54px;
    padding: 12px 24px;
    border: 1px solid rgba(213, 189, 130, 0.45);
    color: var(--gold);
    background: rgba(5, 17, 20, 0.76);
    font-size: 0.78rem;
    text-decoration: none;
    letter-spacing: 0.12em;
    transition: border-color 0.35s, background 0.35s, transform 0.35s;
}

.status-button:hover,
.status-button:focus-visible {
    border-color: var(--gold);
    background: rgba(20, 42, 45, 0.9);
    transform: translateY(-3px);
}

.status-button-primary {
    border-color: rgba(193, 0, 0, 0.7);
    color: #f3dedb;
}

.maintenance-page .status-emblems {
    filter: sepia(0.18) hue-rotate(238deg) drop-shadow(0 0 28px rgba(140, 79, 180, 0.2));
}

.status-copyright {
    position: fixed;
    right: 18px;
    bottom: 12px;
    margin: 0;
    color: rgba(243, 238, 226, 0.3);
    font-size: 0.62rem;
}

@keyframes document-emblem {
    to { transform: rotate(1turn); }
}

@media (max-width: 700px) {
    .legal-main {
        width: min(100% - 28px, 1040px);
    }

    .legal-section {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .legal-section-number {
        margin-bottom: 5px;
    }

    .legal-tabs {
        top: calc(var(--header-height) + 7px);
        gap: 4px;
        margin-right: -7px;
        margin-left: -7px;
        padding: 5px;
    }

    .legal-tab {
        min-height: 62px;
        padding: 8px 4px;
    }

    .legal-tab small {
        display: none;
    }

    .legal-tab span {
        margin: 0;
        font-size: 0.66rem;
        line-height: 1.5;
    }

    .legal-navigation {
        display: grid;
        gap: 17px;
        text-align: center;
    }

    .status-actions,
    .status-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .legal-emblem img,
    .status-emblems img {
        animation: none;
    }
}
