/* ===== Designed-card renderer (shared: preview + topic carousel) ===== */
.designed-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    aspect-ratio: var(--dc-aspect, 620 / 880);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    perspective: 1600px;
    margin: 0 auto;
}

.dcr-faces {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .6s;
}
.designed-card.flipped .dcr-faces { transform: rotateY(180deg); }

.dcr-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    border-radius: 14px;
}
.dcr-face-back { transform: rotateY(180deg); }

/* Reliably hide the inactive face. Iframes (e.g. YouTube) break the 3D
   rendering context so backface-visibility alone lets the back bleed over
   the front — so we also toggle visibility + z-index, switching at mid-flip
   (0.3s of the 0.6s animation) so the flip still looks right. */
.dcr-face-front { z-index: 2; }
.dcr-face-back {
    z-index: 1;
    visibility: hidden;
    transition: visibility 0s linear .3s;
}
.designed-card.flipped .dcr-face-front {
    z-index: 1;
    visibility: hidden;
    transition: visibility 0s linear .3s;
}
.designed-card.flipped .dcr-face-back {
    z-index: 2;
    visibility: visible;
}

.dcr-band {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px 10px;
    font-weight: 600;
    overflow: hidden;
}

.dcr-body {
    position: relative;
    flex: 1 1 auto;
    overflow: hidden;
}

/* positioned elements */
.dcr-el { position: absolute; box-sizing: border-box; overflow: hidden; }
.dcr-el img,
.dcr-el video,
.dcr-el iframe { width: 100%; height: 100%; display: block; border: 0; }
.dcr-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 4px;
    white-space: pre-wrap;   /* honour line breaks from the designer */
    word-break: break-word;
    line-height: 1.2;
}
.dcr-audio {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; padding: 6px; background: rgba(0,0,0,.04);
}
.dcr-audio audio { width: 100%; }
.dcr-audio-title { font-weight: 600; text-align: center; }

/* link / button element */
.dcr-link-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    border-radius: 8px;
    padding: 4px 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
    word-break: break-word;
}
.dcr-link-btn:hover { filter: brightness(1.08); color: inherit; }

/* ---- Designed cards inside the staff-deck UI ---- */
/* Builder thumbnails (search results / working set / current deck) */
.deck-designed-thumb .designed-card {
    width: auto;
    height: 100%;
    max-width: 100%;
    box-shadow: none;
    border-radius: 10px;
}
/* Deck show carousel */
.carousel-card .designed-card {
    width: auto;
    height: 100%;
    max-width: 100%;
    margin: 0 auto;
}
/* Builder fullscreen enlarge */
.dcr-fullscreen .designed-card {
    max-width: none;
    width: auto;
    height: 90vh;
}

/* corner buttons */
.dcr-corner-btn {
    position: absolute;
    z-index: 100;
    width: 38px; height: 38px;
    border: none; border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    transition: background .2s, transform .2s;
}
.dcr-corner-btn:hover { background: rgba(0, 0, 0, .8); transform: scale(1.08); }
/* Read-aloud button: green + pulse while speaking */
.dcr-read-btn.dcr-reading {
    background: #198754;
    animation: dcr-read-pulse 1.1s ease-in-out infinite;
}
@keyframes dcr-read-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, .6); }
    50% { box-shadow: 0 0 0 6px rgba(25, 135, 84, 0); }
}
.corner-top-left { top: 10px; left: 10px; }
.corner-top-right { top: 10px; right: 10px; }
.corner-bottom-left { bottom: 10px; left: 10px; }
.corner-bottom-right { bottom: 10px; right: 10px; }

/* voice picker: small secondary button sitting beside the read-aloud button */
.dcr-voice-btn {
    left: 54px; bottom: 12px;
    width: 34px; height: 34px;
    font-size: 13px;
}
.dcr-voice-menu {
    position: absolute;
    z-index: 120;
    left: 10px; bottom: 54px;
    width: 220px; max-width: calc(100% - 20px);
    max-height: 240px; overflow-y: auto;
    background: #fff; color: #212529;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
    padding: 6px;
}
.dcr-voice-label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    color: #6c757d; padding: 4px 8px 6px;
}
.dcr-voice-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; border: none; background: transparent;
    text-align: left; cursor: pointer;
    padding: 7px 8px; border-radius: 7px;
    font-size: 13px; color: #212529;
}
.dcr-voice-item:hover { background: #f1f3f5; }
.dcr-voice-item.is-active { background: #e7f1ff; color: #0d6efd; font-weight: 600; }
.dcr-voice-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcr-voice-tag { flex: 0 0 auto; font-size: 11px; color: #6c757d; }
.dcr-voice-item.is-active .dcr-voice-tag { color: #0d6efd; }
.dcr-voice-empty { padding: 10px 8px; font-size: 13px; color: #6c757d; }

/* enlarge overlay */
.dcr-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.dcr-overlay .designed-card {
    max-width: min(90vw, 620px);
    height: min(90vh, 880px);
    width: auto;
    aspect-ratio: var(--dc-aspect, 620 / 880);
}
.dcr-overlay-close {
    position: fixed;
    top: 18px; right: 22px;
    z-index: 2100;
    width: 46px; height: 46px;
    border: none; border-radius: 50%;
    background: #fff; color: #222;
    font-size: 20px; cursor: pointer;
}
