/* ShadowUI: automatische Anpassung an Handy, Tablet und Desktop (alle Seiten). */

:root {
    --ss-viewport-app-height: 100dvh;
    --ss-viewport-shell-height: calc(var(--ss-viewport-app-height) - env(safe-area-inset-top, 0px));
    --ss-viewport-pad-x: clamp(10px, 2.2vw, 28px);
    --ss-viewport-pad-y: clamp(8px, 1.4vw, 18px);
    --ss-viewport-pad-left-shell: clamp(12px, 2.4vw, 30px);
    --ss-viewport-pad-bottom-shell: max(80px, calc(68px + env(safe-area-inset-bottom, 0px)));
    --ss-viewport-content-max: min(100%, 1680px);
    --ss-viewport-touch: 44px;
    --ss-viewport-gap: clamp(8px, 1.4vw, 16px);
}

body.ss-shell-body {
    min-height: var(--ss-viewport-app-height);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

/* Legacy-Seiten mit Navbar (ohne App-Shell) */
body:not(.ss-shell-body) main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-inline: var(--ss-viewport-pad-x);
    padding-bottom: max(72px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

body:not(.ss-shell-body) .flash-stack,
body:not(.ss-shell-body) .maintenance-banner,
body:not(.ss-shell-body) .ad-slot {
    width: min(1180px, calc(100% - (var(--ss-viewport-pad-x) * 2)));
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
}

/* Support-Hilfe (eigenes Layout) */
.ss-support-standalone {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.ss-support-standalone main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-inline: var(--ss-viewport-pad-x);
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.ss-support-standalone :is(.max-w-6xl, .max-w-5xl, .max-w-2xl) {
    width: 100%;
    max-width: min(72rem, 100%);
    margin-inline: auto;
    padding-inline: var(--ss-viewport-pad-x);
    box-sizing: border-box;
}

/* === Unified Shell: volle Breite, keine horizontalen Überläufe === */
body.ss-shell-body .su-shell,
body.ss-shell-body .su-main,
body.ss-shell-body .su-content,
body.ss-shell-body .su-content-grid,
body.ss-shell-body .su-content-main,
body.ss-shell-body .su-shell-page-view {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

body.ss-shell-body .su-shell-page-view,
body.ss-shell-body .su-content-main {
    width: 100%;
}

body.ss-shell-body .su-content {
    padding-top: var(--ss-viewport-pad-y);
    padding-right: var(--ss-viewport-pad-x);
    padding-bottom: var(--ss-viewport-pad-bottom-shell);
    padding-left: var(--ss-viewport-pad-left-shell);
}

body.ss-shell-body .su-content > :not(script):not(style) {
    max-width: 100%;
    min-width: 0;
}

body.ss-shell-body :where(h1, h2, h3, h4, p, li, span, strong, label, a, button) {
    overflow-wrap: anywhere;
    word-break: break-word;
}

body.ss-shell-body img,
body.ss-shell-body video,
body.ss-shell-body canvas,
body.ss-shell-body iframe,
body.ss-shell-body svg {
    max-width: 100%;
    height: auto;
}

body.ss-shell-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Vollflächige App-Seiten (Feed, Live, Upload, Cast, Studio) */
body.ss-shell-body:is(
    .ss-feed-body,
    .ss-live-body,
    .ss-live-viewer-page,
    .ss-live-feed-page,
    .ss-shell-live-mode-active,
    .upload-body,
    .shadow-cast-body,
    .shadow-match-body,
    .live-studio-body,
    .ss-mobile-live-body
) .su-content {
    padding: 0;
    overflow: hidden;
}

body.ss-shell-body.upload-body .su-content {
    padding: var(--ss-viewport-pad-y) var(--ss-viewport-pad-x);
    padding-bottom: var(--ss-viewport-pad-bottom-shell);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Inhalts-Container: nutzen verfügbare Shell-Breite */
body.ss-shell-body :is(
    .saas-landing,
    .search-shell,
    .community-shell,
    .contact-shell,
    .ads-shell,
    .admin-shell,
    .stats-shell,
    .pulse-shell,
    .upload-shell,
    .my-profile-shell,
    .pp-shell,
    .creator-shell,
    .ticket-dashboard-shell,
    .ticket-center-shell,
    .subscription-grid,
    .date-match-shell,
    .feed-post-page,
    .feed-stats-page,
    .lm-body,
    .infrastructure-body,
    .onboarding-body,
    .verification-body,
    .user-stats-desktop-body,
    .user-stats-mobile-body,
    .shadow-events-body,
    .ss-legal-body .legal-shell,
    .ss-support-shell-page .support-page-shell
) {
    width: 100%;
    max-width: var(--ss-viewport-content-max);
    margin-inline: auto;
    min-width: 0;
    box-sizing: border-box;
}

body.ss-shell-body .home-top-grid,
body.ss-shell-body .hero-section,
body.ss-shell-body .brand-entry-strip {
    min-width: 0;
}

/* Typische Mehrspalten-Layouts stapeln sich auf schmalen Viewports */
@media (max-width: 1080px) {
    body.ss-shell-body .su-content {
        padding-left: clamp(10px, 2vw, 20px);
        padding-right: clamp(10px, 2vw, 16px);
    }

    body.ss-shell-body :is(
        .feature-grid,
        .quote-grid,
        .platform-suite-grid,
        .stats-grid,
        .members-grid,
        .subscription-grid,
        .monetization-option-grid,
        .growth-control-grid
    ) {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    }
}

@media (max-width: 760px) {
    body.ss-shell-body .su-content {
        padding-bottom: var(--ss-viewport-pad-bottom-shell);
    }

    body.ss-shell-body .saas-landing {
        width: 100%;
        max-width: 100%;
        margin-inline: 0;
    }

    body.ss-shell-body :is(
        .hero-section,
        .home-top-grid,
        .world-cup-banner,
        .brand-entry-strip
    ) {
        grid-template-columns: minmax(0, 1fr);
    }

    body.ss-shell-body :is(
        .feature-grid,
        .quote-grid,
        .platform-suite-grid,
        .stats-grid,
        .members-grid
    ) {
        grid-template-columns: minmax(0, 1fr);
    }

    body.ss-shell-body :is(
        button,
        .neon-btn,
        .neon-button,
        .su-link,
        .su-bottom-nav__item,
        input[type="submit"],
        input[type="button"]
    ):not(.su-link__icon) {
        min-height: var(--ss-viewport-touch);
    }
}

@media (max-width: 480px) {
    body.ss-shell-body .su-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    body.ss-shell-body .su-topbar {
        padding-inline: 10px;
    }
}

/* Ultrawide: etwas mehr Luft, Inhalt bleibt lesbar */
@media (min-width: 1600px) {
    body.ss-shell-body .su-content {
        padding-left: clamp(18px, 1.8vw, 36px);
        padding-right: clamp(16px, 1.6vw, 32px);
    }

    :root {
        --ss-viewport-content-max: min(100%, 1760px);
    }
}

/* Kurze Displays (z. B. Querformat auf dem Handy) */
@media (max-height: 720px) and (min-width: 761px) {
    body.ss-shell-body .hero-copy h1 {
        font-size: clamp(1.45rem, 2.4vw, 2.1rem);
    }

    body.ss-shell-body .hero-intro {
        font-size: 0.94rem;
        line-height: 1.45;
    }
}

/* === Shadow Cast: Studio füllt Viewport === */
body.shadow-cast-body.ss-shell-body {
    overflow: hidden;
}

body.shadow-cast-body.ss-shell-body > main,
body.shadow-cast-body.ss-shell-body .su-shell,
body.shadow-cast-body.ss-shell-body .su-main,
body.shadow-cast-body.ss-shell-body .su-content,
body.shadow-cast-body.ss-shell-body .su-content-grid,
body.shadow-cast-body.ss-shell-body .su-content-main,
body.shadow-cast-body.ss-shell-body .su-shell-page-view {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.shadow-cast-body.ss-shell-body .su-sidebar,
body.shadow-cast-body.ss-shell-body .su-topbar,
body.shadow-cast-body.ss-shell-body .su-bottom-nav,
body.shadow-cast-body.ss-shell-body .ss-mobile-bottom-nav,
body.shadow-cast-body.ss-shell-body .ss-mobile-top-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.shadow-cast-body.ss-shell-body .su-shell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
}

body.shadow-cast-body .shadow-cast-shell {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    min-height: 0;
    padding: clamp(6px, 0.9vw, 12px);
    gap: clamp(6px, 0.9vw, 10px);
}

body.shadow-cast-body .shadow-cast-topbar,
body.shadow-cast-body .shadow-cast-hero {
    padding: clamp(6px, 0.9vw, 10px);
    gap: clamp(6px, 0.8vw, 10px);
}

body.shadow-cast-body .shadow-cast-topbar__brand h1,
body.shadow-cast-body .shadow-cast-hero h1 {
    font-size: clamp(1rem, 1.6vw, 1.35rem);
}

body.shadow-cast-body .shadow-cast-grid {
    grid-template-columns: minmax(min(100%, 220px), 280px) minmax(0, 1fr);
    min-height: 0;
    height: 100%;
}

body.shadow-cast-body .shadow-cast-grid--quad {
    grid-template-columns: minmax(0, 1fr) !important;
}

body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) {
    grid-template-columns: minmax(0, 0.36fr) minmax(0, 1.64fr);
    min-height: 0;
    height: 100%;
}

body.shadow-cast-body .shadow-cast-stage--matrix {
    grid-template-columns: minmax(248px, 0.28fr) minmax(0, 1fr) minmax(0, 0.42fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "filters tiktok webcam";
}

body.shadow-cast-body .shadow-cast-shell--studio .shadow-cast-stage.shadow-cast-stage--matrix {
    grid-template-columns: minmax(248px, 0.28fr) minmax(0, 1fr) minmax(0, 0.42fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    grid-template-areas: "filters tiktok webcam" !important;
}

body.shadow-cast-body .shadow-cast-source-stack {
    grid-template-rows: minmax(0, 1fr) minmax(120px, 0.38fr);
    min-height: 0;
    height: 100%;
}

body.shadow-cast-body .shadow-cast-camera {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

body.shadow-cast-body .shadow-cast-camera__frame,
body.shadow-cast-body .shadow-cast-source__frame {
    width: 100%;
    max-width: none;
    max-height: 100%;
    min-height: 0;
    justify-self: stretch;
}

body.shadow-cast-body .shadow-cast-control .shadow-cast-step-list {
    display: none;
}

@media (max-width: 1180px) {
    body.shadow-cast-body .shadow-cast-grid,
    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix),
    body.shadow-cast-body .shadow-cast-hero {
        grid-template-columns: minmax(0, 1fr);
    }

    body.shadow-cast-body.ss-shell-body .su-content {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body.shadow-cast-body .shadow-cast-shell {
        height: auto;
        min-height: 100dvh;
        max-height: none;
        overflow: visible;
    }

    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) .shadow-cast-camera {
        order: -1;
    }

    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) .shadow-cast-camera__frame {
        width: 100%;
        max-width: none;
        max-height: min(56dvh, 520px);
        margin-inline: auto;
    }

    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) .shadow-cast-source__frame[data-shadow-cast-source-orientation="portrait"],
    body.shadow-cast-body .shadow-cast-stage:not(.shadow-cast-stage--matrix) .shadow-cast-source__frame[data-shadow-cast-source-orientation="square"] {
        width: 100%;
        max-width: min(100%, 420px);
        margin-inline: auto;
    }

    body.shadow-cast-body .shadow-cast-stage.shadow-cast-stage--matrix {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(42dvh, 1fr) minmax(34dvh, 0.82fr);
        grid-template-areas:
            "filters"
            "tiktok"
            "webcam";
        height: auto;
        max-height: none;
        overflow: visible;
    }

    body.shadow-cast-body .shadow-cast-stage--matrix > .shadow-cast-stage__filters {
        max-height: min(52dvh, 520px);
    }

    body.shadow-cast-body .shadow-cast-effects-stack {
        margin-top: auto;
    }
}

@media (max-width: 820px) {
    body.shadow-cast-body.ss-shell-body .shadow-cast-shell {
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 520px) {
    body.shadow-cast-body .shadow-cast-status-meta {
        display: none;
    }

    body.shadow-cast-body .shadow-cast-effect-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.shadow-cast-body .shadow-cast-actions {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    body.ss-shell-body *,
    body.shadow-cast-body * {
        scroll-behavior: auto !important;
    }
}

/* Shadow Cast: Admin-Navigation wieder sichtbar (Desktop + Mobile) */
body.shadow-cast-body.ss-shell-body .su-shell {
    grid-template-columns: var(--su-sidebar-width, clamp(11.75rem, 13.2vw, 14rem)) minmax(0, 1fr) !important;
}

body.shadow-cast-body.ss-shell-body .su-sidebar,
body.shadow-cast-body.ss-shell-body .su-topbar {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

body.shadow-cast-body.ss-shell-body .su-bottom-nav,
body.shadow-cast-body.ss-shell-body .ss-mobile-bottom-nav,
body.shadow-cast-body.ss-shell-body .ss-mobile-top-nav {
    visibility: visible !important;
    pointer-events: auto !important;
}

@media (max-width: 980px) {
    body.shadow-cast-body.ss-shell-body .su-shell {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body.shadow-cast-body.ss-shell-body .su-sidebar {
        display: none !important;
    }

    body.shadow-cast-body.ss-shell-body .ss-mobile-bottom-nav {
        display: block !important;
    }
}
