/*
 * LEG-001d / dev.224
 * Canonical owner: legal documents, legal footer and cookie-consent presentation.
 * Cross-component contract: app.css owns the auth/account viewport and consumes
 * --st-legal-footer-height; this file owns the exact fixed-footer height.
 * No duplicate viewport override and no permanent cascade-force workaround lives here.
 */

body.auth-page {
    --st-legal-footer-height: 44px;
}

body.auth-page .auth-panel-wrap {
    height: 100%;
    min-height: 0;
    max-height: 100%;
}

/* Entry/auth panels keep their accepted dimensions. Only overflow becomes
 * internally scrollable when viewport height is too small. Scrollbars stay
 * visually hidden while wheel/touch/keyboard scrolling remains available. */
body.auth-page .auth-screen:not(.account-panel-screen) .auth-panel {
    box-sizing: border-box;
    max-height: min(72dvh, 100%);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.auth-page .auth-screen:not(.account-panel-screen) .auth-panel::-webkit-scrollbar,
.legal-document__body::-webkit-scrollbar,
.cookie-settings__panel::-webkit-scrollbar,
.legal-footer-links--auth::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Legal document screen */
.legal-auth-screen__logo {
    width: min(320px, 30vw);
    margin-bottom: 10px;
}

.legal-auth-screen__content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: stretch;
    box-sizing: border-box;
}

.legal-document {
    width: min(920px, calc(100vw - 40px));
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0 auto 8px;
    border: 1px solid rgba(171, 112, 255, 0.24);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(20, 14, 29, 0.91), rgba(11, 8, 18, 0.93));
    box-shadow: 0 24px 58px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.025) inset;
    backdrop-filter: blur(7px);
    overflow: hidden;
}

.legal-document__header {
    flex: 0 0 auto;
    padding: 20px 24px 15px;
    border-bottom: 1px solid rgba(171, 112, 255, 0.12);
}

.legal-document__topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 11px;
}

.legal-document__back {
    color: #d8c5ee;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.legal-document__back:hover {
    text-decoration: underline;
}

.legal-document__tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.legal-document__tab {
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #aaa0b8;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.legal-document__tab:hover {
    color: #eadbfa;
    text-decoration: none;
}

.legal-document__tab.is-active {
    border-color: rgba(171, 112, 255, 0.18);
    background: rgba(171, 112, 255, 0.09);
    color: #eadbfa;
}

.legal-document__eyebrow {
    display: block;
    margin: 0 0 5px;
    color: #caa6ff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.legal-document h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(25px, 3vw, 34px);
    font-weight: 600;
    line-height: 1.08;
}

.legal-document__title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.legal-document__lead {
    margin: 9px 0 0;
    color: #c8bfd3;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
}

.legal-document__meta {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: flex-end;
    color: #9e94ad;
    font-size: 11.5px;
    font-weight: 400;
}

.legal-document__meta span {
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.legal-document__body {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 22px 24px 32px;
    color: #d2cadc;
    font-size: 14.5px;
    font-weight: 400;
    line-height: 1.72;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: contain;
}

.legal-document__section,
.legal-document__paragraph {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

.legal-document__section {
    margin-top: 23px;
    margin-bottom: 8px;
}

.legal-document__section:first-child {
    margin-top: 0;
}

.legal-document__section h2 {
    margin: 0;
    color: #f2ebf8;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
}

.legal-document__paragraph {
    margin-top: 0;
    margin-bottom: 12px;
}

.legal-document__paragraph--note {
    padding: 11px 13px;
    border-left: 2px solid rgba(171, 112, 255, 0.52);
    border-radius: 0 10px 10px 0;
    background: rgba(171, 112, 255, 0.055);
    color: #cfc4da;
}

.legal-document__cookie-action {
    max-width: 760px;
    margin: 18px auto 0;
}

/* Shared legal action button. Explicit width:auto neutralises the old public
 * global button width without creating a second global button component. */
.legal-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 36px;
    box-sizing: border-box;
    padding: 8px 11px;
    border: 1px solid rgba(171, 112, 255, 0.22);
    border-radius: 9px;
    background: rgba(171, 112, 255, 0.08);
    color: #e7dbf4;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
}

.legal-action-button:hover {
    border-color: rgba(187, 139, 255, 0.35);
    background: rgba(171, 112, 255, 0.13);
}

.legal-action-button.is-primary {
    border-color: rgba(187, 139, 255, 0.35);
    background: rgba(124, 76, 190, 0.48);
    color: #fff;
}

/* Registration legal consent block */
.auth-legal-consents {
    display: grid;
    gap: 8px;
    margin: 1px 0 3px;
    padding: 10px 11px;
    border: 1px solid rgba(171, 112, 255, 0.12);
    border-radius: 13px;
    background: rgba(8, 6, 14, 0.34);
}

.auth-legal-consent {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    color: #cfc6db;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.42;
}

.auth-legal-consent input {
    width: 14px;
    height: 14px;
    min-height: 0;
    margin: 2px 0 0;
    accent-color: #9a66df;
    flex: 0 0 auto;
}

.auth-legal-consent a {
    color: #f0d8ff;
    font-weight: 500;
    text-decoration: none;
}

.auth-legal-consent a:hover {
    text-decoration: underline;
}

/* Cookie consent banner */
.cookie-consent {
    position: fixed;
    z-index: 10000;
    left: 18px;
    right: 18px;
    bottom: calc(var(--st-legal-footer-height, 44px) + 14px);
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    width: min(920px, calc(100% - 36px));
    box-sizing: border-box;
    margin: 0 auto;
    padding: 15px 17px;
    border: 1px solid rgba(171, 112, 255, 0.25);
    border-radius: 15px;
    background: rgba(10, 8, 18, 0.95);
    box-shadow: 0 16px 46px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(9px);
}

.cookie-consent[hidden] {
    display: none;
}

.cookie-consent__copy {
    min-width: 0;
}

.cookie-consent__copy strong {
    display: block;
    margin-bottom: 4px;
    color: #f2ecf8;
    font-size: 14px;
    font-weight: 600;
}

.cookie-consent__copy p {
    max-width: 620px;
    margin: 0 0 4px;
    color: #c7becf;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
}

.cookie-consent__copy a {
    color: #f0d8ff;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.cookie-consent__copy a:hover {
    text-decoration: underline;
}

.cookie-consent__actions {
    display: flex;
    gap: 7px;
    flex-shrink: 0;
}

/* Cookie settings modal */
.cookie-settings {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: clamp(10px, 2.5vw, 20px);
    overflow-x: hidden;
    overflow-y: auto;
    background: rgba(5, 4, 8, 0.64);
    backdrop-filter: blur(4px);
    overscroll-behavior: contain;
}

.cookie-settings[hidden] {
    display: none;
}

.cookie-settings__panel {
    width: min(500px, 100%);
    max-height: calc(100dvh - 20px);
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
    border: 1px solid rgba(171, 112, 255, 0.28);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(21, 15, 31, 0.97), rgba(12, 9, 19, 0.98));
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.54);
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: contain;
}

.cookie-settings__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.cookie-settings__top > div {
    min-width: 0;
}

.cookie-settings__top h2 {
    margin: 0;
    color: #fff;
    font-size: 22px;
    font-weight: 600;
}

.cookie-settings__top p {
    margin: 5px 0 0;
    color: #bfb5c9;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
}

.cookie-settings__close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    box-sizing: border-box;
    flex: 0 0 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.035);
    color: #d9d1e1;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.cookie-settings__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.cookie-settings__row > div {
    min-width: 0;
}

.cookie-settings__row strong {
    display: block;
    color: #eee7f5;
    font-size: 13px;
    font-weight: 600;
}

.cookie-settings__row span {
    display: block;
    margin-top: 3px;
    color: #a99faf;
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.4;
}

.cookie-settings__state {
    flex: 0 0 auto;
    margin: 0;
    padding: 5px 8px;
    border: 1px solid rgba(171, 112, 255, 0.18);
    border-radius: 999px;
    background: rgba(171, 112, 255, 0.07);
    color: #d7c5ec;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.cookie-settings__switch {
    position: relative;
    width: 38px;
    height: 22px;
    min-width: 38px;
    min-height: 22px;
    flex: 0 0 38px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #3c3545;
    cursor: pointer;
}

.cookie-settings__switch span {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    margin: 0;
    border-radius: 50%;
    background: #bdb6c5;
    transition: left 0.15s ease, background 0.15s ease;
}

.cookie-settings__switch.is-on {
    background: #7650a8;
}

.cookie-settings__switch.is-on span {
    left: 19px;
    background: #f3ebfb;
}

.cookie-settings__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 15px;
}

/* Fixed legal footer */
.legal-footer-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
    font-size: 0.85rem;
}

.legal-footer-links--auth {
    position: fixed;
    z-index: 10005;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--st-legal-footer-height, 44px);
    min-height: var(--st-legal-footer-height, 44px);
    box-sizing: border-box;
    margin: 0;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: nowrap;
    border-top: 1px solid rgba(171, 112, 255, 0.14);
    background: rgba(8, 6, 13, 0.91);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.legal-footer-links--auth a,
.legal-footer-links--auth button {
    position: relative;
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 14px;
    border: 0;
    background: transparent;
    color: #cbbdd9;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

.legal-footer-links--auth a:hover,
.legal-footer-links--auth button:hover {
    color: #f0d8ff;
    text-decoration: none;
}

.legal-footer-links--auth a + a::before,
.legal-footer-links--auth button::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 1px;
    height: 12px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
}

/* Tablet and stacked auth layout */
@media (max-width: 1100px) {
    body.auth-page .auth-screen:not(.account-panel-screen) .auth-panel {
        max-height: 100%;
    }
}

/* Mobile */
@media (max-width: 720px) {
    body.auth-page {
        --st-legal-footer-height: 42px;
    }

    .legal-auth-screen__logo {
        width: min(280px, 66vw);
        margin-bottom: 7px;
    }

    .legal-document {
        width: 100%;
        border-radius: 16px;
    }

    .legal-document__header {
        padding: 15px 15px 11px;
    }

    .legal-document__topline {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .legal-document__title-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 9px;
    }

    .legal-document__meta {
        justify-content: flex-start;
    }

    .legal-document__body {
        padding: 16px 15px 24px;
        font-size: 13.5px;
        line-height: 1.65;
    }

    .legal-document__tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .legal-document__tabs::-webkit-scrollbar {
        display: none;
    }

    .cookie-consent {
        left: 10px;
        right: 10px;
        bottom: calc(var(--st-legal-footer-height) + 10px);
        width: calc(100% - 20px);
        padding: 13px;
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .cookie-consent__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .cookie-consent__actions .legal-action-button:last-child {
        grid-column: 1 / -1;
    }

    .legal-action-button {
        width: 100%;
    }

    .cookie-settings {
        padding: 10px;
    }

    .cookie-settings__panel {
        width: 100%;
        max-height: calc(100dvh - 20px);
        padding: 16px;
        border-radius: 17px;
    }

    .cookie-settings__top {
        gap: 10px;
    }

    .cookie-settings__top h2 {
        font-size: 20px;
    }

    .cookie-settings__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .legal-footer-links--auth {
        justify-content: flex-start;
        padding: 5px 4px;
    }

    .legal-footer-links--auth a,
    .legal-footer-links--auth button {
        padding: 4px;
        font-size: 10.5px;
    }
}

/* Very small/short phones: keep controls usable without enlarging the footer. */
@media (max-width: 420px) {
    .cookie-settings__row {
        gap: 10px;
    }

    .cookie-settings__actions {
        grid-template-columns: 1fr;
    }

    .cookie-settings__top p {
        font-size: 12px;
    }
}

@media (max-height: 720px) and (min-width: 721px) {
    body.auth-page .auth-screen:not(.account-panel-screen) .auth-panel {
        max-height: 100%;
    }
}
