.flipbox-container {
    perspective: 2000px;
    background: transparent;
    width: 100%;
    margin-bottom: var(--weyel-space-8, 64px);
}

.flipbox {
    position: relative;
    width: 100%;
    height: 480px;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

/* Flip animation: CSS-Hover (Desktop) + is-flipped (Touch & Click-Modus) */
.flipbox-container.trigger-hover:hover .flipbox,
.flipbox-container.trigger-click.is-flipped .flipbox,
.flipbox-container.trigger-hover.is-flipped .flipbox {
    transform: rotateY(180deg);
}

.flipbox-front, .flipbox-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    border-radius: var(--weyel-radius-lg, 16px);
    overflow: hidden;
}

/* FRONT SIDE */
.flipbox-front {
    background-color: #ffffff;
    z-index: 2;
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
    /* Force front position in 3D space */
    transform: rotateY(0deg);
}

.flipbox-container:hover .flipbox-front {
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
}

.flipbox-front-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0; /* Remove padding to let image touch edges */
}

.flipbox-image-wrap {
    width: 100%;
    height: 300px; /* Fixed height for consistent look */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Essential for the crop */
    background: #fcfcfc;
}

.flipbox-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* This performs the CSS crop */
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.flipbox-container:hover .flipbox-image-wrap img {
    transform: scale(1.1);
}

.flipbox-front-title-wrap {
    margin-top: auto;
    padding: 30px 20px;
    text-align: center;
    background: #fff;
    z-index: 2;
}

.flipbox-front-overtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--weyel-color-blue, #0768b1); /* Default CI color, can be refined */
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 5px;
}

.flipbox-front-title {
    font-weight: 700;
    font-size: 20px;
    color: var(--weyel-color-text, #494043);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Color Overrides for Overtitle (matching the card color) */
.color-blue .flipbox-front-overtitle { color: var(--weyel-color-blue, #0768b1); }
.color-green .flipbox-front-overtitle { color: var(--weyel-color-green, #52ae32); }
.color-red .flipbox-front-overtitle { color: var(--weyel-color-red, #e62243); }
.color-dark .flipbox-front-overtitle { color: var(--weyel-color-text, #494043); }

/* BACK SIDE */
.flipbox-back {
    transform: rotateY(180deg);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
    text-align: center;
    color: #ffffff;
}

.flipbox-back-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.flipbox-back-text {
    font-size: 16px;
    line-height: 1.7;
    font-weight: 400;
}

/* CTA-Button auf der Rückseite */
.flipbox-back-link {
    display: inline-block;
    margin-top: 28px;
    padding: 11px 30px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 30px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    position: relative;
    z-index: 10;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.flipbox-back-link:hover,
.flipbox-back-link:focus {
    background-color: #fff;
    border-color: #fff;
    outline: none;
}

.color-blue .flipbox-back-link:hover,
.color-blue .flipbox-back-link:focus { color: var(--weyel-color-blue, #0768b1); }

.color-green .flipbox-back-link:hover,
.color-green .flipbox-back-link:focus { color: var(--weyel-color-green, #52ae32); }

.color-red .flipbox-back-link:hover,
.color-red .flipbox-back-link:focus { color: var(--weyel-color-red, #e62243); }

.color-dark .flipbox-back-link:hover,
.color-dark .flipbox-back-link:focus { color: var(--weyel-color-text, #494043); }

/* Color Variations & Border Mapping */
.color-blue .flipbox-back { background-color: var(--weyel-color-blue, #0768b1); }
.color-blue .flipbox-front { border-bottom: 5px solid var(--weyel-color-blue, #0768b1); }

.color-green .flipbox-back { background-color: var(--weyel-color-green, #52ae32); }
.color-green .flipbox-front { border-bottom: 5px solid var(--weyel-color-green, #52ae32); }

.color-red .flipbox-back { background-color: var(--weyel-color-red, #e62243); }
.color-red .flipbox-front { border-bottom: 5px solid var(--weyel-color-red, #e62243); }

.color-dark .flipbox-back { background-color: var(--weyel-color-text, #494043); }
.color-dark .flipbox-front { border-bottom: 5px solid var(--weyel-color-text, #494043); }

/* Editor Styling */
.flipbox-editor-wrapper {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 12px;
}

.flipbox-editor-wrapper .flipbox-front,
.flipbox-editor-wrapper .flipbox-back {
    position: relative;
    transform: none;
    height: auto;
    min-height: 480px;
    backface-visibility: visible !important;
    overflow-y: auto; /* Allow scrolling during edit if text is very long */
}

.flipbox-image-wrap .placeholder {
    width: 100%;
    height: 150px;
    background: #eee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}
