/* KREDA SafeCase – Spatial / 3D Layer
   Ergänzt site.css, premium.css und experience.css.
   Bleibt monochrom, ernsthaft, schul-tauglich.
   Alle Effekte respektieren prefers-reduced-motion. */

:root {
    --sp-depth-1: 8px;
    --sp-depth-2: 18px;
    --sp-depth-3: 32px;
    --sp-depth-4: 56px;
    --sp-tilt-x: 0deg;
    --sp-tilt-y: 0deg;
    --sp-mouse-x: 0;
    --sp-mouse-y: 0;
}

/* ——— 3D-Hero (WebGL-Buehne, Klassenzimmer-Welt) ——— */
.hero3d {
    position: relative;
    isolation: isolate;
    min-height: clamp(640px, 92vh, 940px);
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #f3f3f4 65%, #e9e9ec 100%);
    color: var(--ink, #1d1d1f);
    perspective: 1600px;
}

/* Kompakte Variante für Unterseiten */
.hero3d.hero3d--page {
    min-height: clamp(520px, 80vh, 760px);
}

.hero3d__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
    pointer-events: none;
}

/* Sanfter Vignetten-Verlauf, der den Text vom 3D-Hintergrund trennt */
.hero3d__overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(80% 60% at 18% 30%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 65%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.0) 30%, rgba(255, 255, 255, 0.65) 100%);
}

/* Subtiles Tafel-Linien-Pattern als Hintergrundebene (für Schul-Stimmung).
   Wird hinter dem WebGL-Canvas leicht durchscheinen, falls Canvas dezent ist. */
.hero3d::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
    background-size: 96px 96px, 96px 96px;
    background-position: -1px -1px;
    mask-image: radial-gradient(85% 75% at 50% 35%, #000 60%, transparent 100%);
    -webkit-mask-image: radial-gradient(85% 75% at 50% 35%, #000 60%, transparent 100%);
    opacity: 0.7;
}

.hero3d__inner {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
    padding: clamp(5rem, 11vh, 8rem) 24px clamp(4rem, 8vh, 6rem);
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
    transform-style: preserve-3d;
}

.hero3d__kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #424245;
    background: rgba(255, 255, 255, 0.78);
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-bottom: 1.25rem;
    transform: translate3d(var(--p-x, 0), var(--p-y, 0), 30px);
}

.hero3d__kicker::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #1d1d1f;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06);
}

.hero3d__title {
    margin: 0;
    font-size: clamp(2.8rem, 8.2vw, 6.2rem);
    line-height: 0.98;
    letter-spacing: -0.045em;
    font-weight: 600;
    color: #1d1d1f;
    max-width: 14ch;
    transform-style: preserve-3d;
}

.hero3d__title-line {
    display: block;
    transform: translate3d(0, 0, var(--depth, 0px));
    will-change: transform;
}

.hero3d__title-line.is-dim {
    color: #86868b;
}

.hero3d__title-line.is-accent {
    color: #1d1d1f;
    position: relative;
}

.hero3d__title-line.is-accent::after {
    content: "";
    display: block;
    width: 0;
    height: 4px;
    margin-top: 0.35rem;
    background: linear-gradient(90deg, #1d1d1f, #1d1d1f 60%, transparent);
    border-radius: 2px;
    transition: width 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 0.4s;
}

.hero3d.is-in .hero3d__title-line.is-accent::after {
    width: 56%;
}

.hero3d__lead {
    margin: 1.5rem 0 2rem;
    font-size: clamp(1.05rem, 1.4vw, 1.3rem);
    line-height: 1.5;
    color: #424245;
    max-width: 36em;
    transform: translate3d(var(--p-x, 0), var(--p-y, 0), 20px);
}

.hero3d__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    transform: translate3d(var(--p-x, 0), var(--p-y, 0), 40px);
}

.hero3d__actions .ex-btn--primary {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

/* Schwebende Geräte-Karte (Bild des SafeCase) mit 3D-Tilt */
.hero3d__device {
    position: relative;
    aspect-ratio: 4 / 5;
    max-width: 460px;
    width: 100%;
    margin-left: auto;
    transform-style: preserve-3d;
    perspective: 1200px;
}

.hero3d__device-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 28px;
    overflow: hidden;
    background: #f0f0f2;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.18),
        0 6px 16px rgba(0, 0, 0, 0.08),
        0 1px 0 rgba(255, 255, 255, 0.6) inset;
    transform: rotateX(var(--sp-tilt-x, 0deg)) rotateY(var(--sp-tilt-y, 0deg)) translate3d(0, 0, 0);
    transition: transform 0.18s ease;
    will-change: transform;
}

.hero3d__device-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.06);
}

.hero3d__device-inner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 35%, rgba(0, 0, 0, 0.22) 100%);
    pointer-events: none;
}

.hero3d__device-tag {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    color: #1d1d1f;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    max-width: 70%;
    transform: translateZ(60px);
}

.hero3d__device-tag strong {
    display: block;
    color: #1d1d1f;
    margin-bottom: 2px;
    font-weight: 600;
}

/* Schwebende Mini-Karten neben Hero — geben Tiefe und „Schule"-Bezug */
.hero3d__chip {
    position: absolute;
    z-index: 4;
    background: rgba(255, 255, 255, 0.94);
    color: #1d1d1f;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
    will-change: transform;
}

.hero3d__chip strong {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.hero3d__chip--a {
    top: 12%;
    right: 6%;
    transform: translate3d(var(--p-x-strong, 0), var(--p-y-strong, 0), 70px);
}

.hero3d__chip--b {
    bottom: 14%;
    left: 4%;
    transform: translate3d(calc(var(--p-x-strong, 0) * -1), calc(var(--p-y-strong, 0) * -1), 50px);
}

.hero3d__scroll {
    position: absolute;
    left: 50%;
    bottom: 28px;
    z-index: 3;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    letter-spacing: 0.18em;
    color: #6e6e73;
    font-weight: 500;
    text-transform: uppercase;
}

.hero3d__scroll::before {
    content: "";
    width: 1px;
    height: 26px;
    background: #1d1d1f;
    opacity: 0.4;
    animation: heroScrollLine 2.4s ease-in-out infinite;
}

@keyframes heroScrollLine {
    0% { transform: scaleY(0.2); transform-origin: 50% 0; opacity: 0.1; }
    50% { transform: scaleY(1); opacity: 0.6; }
    100% { transform: scaleY(0.2); transform-origin: 50% 100%; opacity: 0.1; }
}

/* ——— Globale Tilt-Karten ——— */
[data-tilt] {
    transform-style: preserve-3d;
    will-change: transform;
    transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-tilt]:hover {
    transition: transform 0.08s linear;
}

[data-tilt] > * {
    transform-style: preserve-3d;
}

[data-tilt-depth] {
    transform: translateZ(var(--tilt-depth, 24px));
}

/* Bento-Karten bekommen Tiefe */
.ex-bento {
    perspective: 1400px;
}

.ex-bento__cell {
    transform: translateZ(0);
    transition: transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.5s ease;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.ex-bento__cell.is-in-view {
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
}

.ex-bento__cell:hover {
    transform: translateZ(12px);
    box-shadow: 0 32px 60px rgba(0, 0, 0, 0.14), 0 6px 14px rgba(0, 0, 0, 0.06);
}

.ex-bento__cell.is-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120% 80% at 30% 0%, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0) 60%);
    z-index: 1;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* Sticky-Story 3D-Boost */
.ex-sticky__media {
    transform-style: preserve-3d;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.16);
}

.ex-sticky__media::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.18) 0%, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.18) 100%);
}

/* Numbers section: subtiler Tafel-Hintergrund */
.ex-numbers {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.ex-numbers::before {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: 0;
    background-image:
        radial-gradient(60% 50% at 50% 30%, rgba(255, 255, 255, 0.06), transparent 70%),
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.06) 0,
            rgba(255, 255, 255, 0.06) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.05) 0,
            rgba(255, 255, 255, 0.05) 1px,
            transparent 1px,
            transparent 80px
        );
    pointer-events: none;
    mask-image: radial-gradient(80% 80% at 50% 50%, #000 35%, transparent 100%);
    -webkit-mask-image: radial-gradient(80% 80% at 50% 50%, #000 35%, transparent 100%);
}

.ex-numbers > * {
    position: relative;
    z-index: 1;
}

/* Schwebende Schul-Glyphen (subtil), site-weit über mehrere Sektionen */
.spatial-glyph-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
    opacity: 0.6;
}

.spatial-glyph {
    position: absolute;
    color: rgba(0, 0, 0, 0.05);
    width: 80px;
    height: 80px;
    transform: translate3d(var(--gx, 0), var(--gy, 0), 0) rotate(var(--gr, 0deg));
    will-change: transform;
}

.spatial-glyph svg {
    width: 100%;
    height: 100%;
    display: block;
}

.spatial-glyph--small { width: 48px; height: 48px; }
.spatial-glyph--large { width: 120px; height: 120px; }

/* Final CTA: 3D-Tafel mit Kreide-Schimmer */
.ex-final {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.ex-final::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(120% 80% at 20% 0%, rgba(255, 255, 255, 0.10), transparent 55%),
        radial-gradient(80% 60% at 80% 100%, rgba(255, 255, 255, 0.05), transparent 70%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.045) 0, rgba(255,255,255,0.045) 1px, transparent 1px, transparent 60px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 60px);
    pointer-events: none;
    z-index: 0;
}

.ex-final > * {
    position: relative;
    z-index: 1;
}

/* Headlines mit subtilem 3D-Schatten („Druckletter-Effekt") */
.ex-h1,
.ex-h2,
.hero3d__title,
.ex-hero__title,
.ex-final__title {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* Word-Rotate hochwertiger */
.word-rotate {
    background: linear-gradient(180deg, #1d1d1f 0%, #424245 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    border-bottom: 3px solid #1d1d1f;
}

/* Ex-Hero (alte) bekommt nun 3D-Tilt-Stage */
.ex-hero__stage-inner {
    transform: scale(var(--stage-scale, 0.96)) rotateX(var(--sp-tilt-x, 0deg)) rotateY(var(--sp-tilt-y, 0deg));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Compact-cards (Schul-Seite) bekommen sanften Tilt */
.compact-card,
.metric-box,
.problem-card {
    transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.4s ease;
    will-change: transform;
}

.compact-card:hover,
.metric-box:hover,
.problem-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

/* Page-Hero (Unterseiten) bekommt subtilen schwebenden Schul-Hintergrund */
body.page-hero-bright .page-hero {
    position: relative;
    overflow: hidden;
}

body.page-hero-bright .page-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
    background-size: 80px 80px, 80px 80px;
    mask-image: radial-gradient(70% 70% at 50% 30%, #000 50%, transparent 100%);
    -webkit-mask-image: radial-gradient(70% 70% at 50% 30%, #000 50%, transparent 100%);
    opacity: 0.55;
    pointer-events: none;
}

body.page-hero-bright .page-hero .container {
    position: relative;
    z-index: 1;
}

/* Hero-Bilder auf Unterseiten heben + 3D-Tilt */
.page-hero-grid,
.panel-split {
    perspective: 1400px;
}

.hero-image-frame,
.hero-product-card {
    transform-style: preserve-3d;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.10), 0 4px 14px rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    transform: rotateX(var(--sp-tilt-x, 0deg)) rotateY(var(--sp-tilt-y, 0deg));
    transition: transform 0.18s ease, box-shadow 0.4s ease;
    will-change: transform;
}

.hero-image-frame:hover,
.hero-product-card:hover {
    box-shadow: 0 36px 80px rgba(0, 0, 0, 0.16), 0 6px 18px rgba(0, 0, 0, 0.08);
}

/* Eigene Marquee leicht 3D */
.ex-marquee {
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04) inset, 0 -1px 0 rgba(0, 0, 0, 0.04) inset;
}

/* Counter-Numbers leicht heben */
.ex-numbers__value {
    text-shadow: 0 0 28px rgba(255, 255, 255, 0.04);
}

/* ——— Responsiv ——— */
@media (max-width: 1100px) {
    .hero3d__inner {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        padding-top: clamp(4rem, 9vh, 5.5rem);
    }

    .hero3d__device {
        margin: 0 auto;
        max-width: 380px;
    }

    .hero3d__chip--a {
        top: 6%;
        right: 4%;
    }

    .hero3d__chip--b {
        bottom: 4%;
        left: 4%;
    }
}

@media (max-width: 720px) {
    .hero3d {
        min-height: 760px;
    }

    .hero3d__chip {
        font-size: 11px;
        padding: 9px 11px;
    }

    .hero3d__chip--a,
    .hero3d__chip--b {
        position: static;
        transform: none;
        display: inline-block;
        margin: 6px 6px 0 0;
        max-width: none;
    }

    .hero3d__device-tag {
        max-width: 80%;
        font-size: 11px;
    }
}

/* ——— Reduced Motion / WebGL aus ——— */
@media (prefers-reduced-motion: reduce) {
    .hero3d__title-line,
    .hero3d__lead,
    .hero3d__actions,
    .hero3d__kicker,
    .hero3d__chip {
        transform: none !important;
    }

    .hero3d__device-inner {
        transform: none !important;
    }

    .ex-bento__cell:hover,
    .compact-card:hover,
    .metric-box:hover,
    .problem-card:hover {
        transform: none !important;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04) !important;
    }

    .hero3d__scroll::before {
        animation: none;
    }
}

.hero3d.no-webgl .hero3d__canvas {
    display: none;
}

.hero3d.no-webgl::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(60% 50% at 30% 30%, rgba(0, 0, 0, 0.05), transparent 70%),
        radial-gradient(50% 40% at 80% 60%, rgba(0, 0, 0, 0.04), transparent 70%);
    pointer-events: none;
}
