/* ===============================
   TODAY STORY RANDOMIZER (optimized)
   =============================== */

.story-randomizer-wrapper {
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: center;
    margin: 20px auto;
}

/* --- Filter bar --- */
.story-randomizer-filters {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: flex-start;
}

.story-randomizer-filters .filter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 0px;
    padding: 10px 20px;
}

.story-randomizer-filters label {
    text-align: left;
    white-space: nowrap;
    font-weight: bold;
    font-size: 16px;
    color: #222;
}

.story-randomizer-filters select {
    flex-shrink: 0;
    width: 320px;
    min-width: 280px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 15px;
    background-color: #F7F6C4;
}

/* Spin button desktop */
.story-randomizer-spin-btn {
    display: inline-block;
    background: #1B72B6 !important;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: bold;
    width: 250px;
    border-radius: 50px;
    padding: 10px 20px;
    transition: all 0.25s ease;
    margin-top: 8px;
    margin-left: 10px;
    align-self: flex-start;
}

.story-randomizer-spin-btn:hover {
    background: #11A89E !important;
    transform: scale(1.05);
}

/* --- Placeholder / Loader --- */
.story-placeholder,
.story-randomizer-result .error {
    color: #555;
    font-style: italic;
    margin-top: 10px;
}

.loading {
    color: #888;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%,100% { opacity:0.4; }
    50% { opacity:1; }
}

.story-loader {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.story-loader.active { display:flex; }
.story-loader .spinner {
    width: 50px;
    height: 50px;
    border: 6px solid #ddd;
    border-top-color: #f43f5e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Card area === */
.story-randomizer-cards-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 220px;
    perspective: 1200px; /* tăng cảm giác 3D */
}

/* --- Flip Card --- */
.story-card {
    width: 300px;
    height: 200px;
    max-width: 100%;
    min-height: 200px;
    background-color: #F3E1B9;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15); /* frame nổi */
    padding: 16px;
    text-align: center;
    transform-style: preserve-3d;
    transition: transform 0.6s, box-shadow 0.3s;
    cursor: pointer;
    position: relative;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.story-card:hover {
    transform: translateY(-6px) rotateX(2deg) rotateY(2deg);
    box-shadow: 0 12px 28px rgba(0,0,0,0.25);
}

/* Front */
.story-card .story-front {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
    backface-visibility: hidden;
}

.story-card .story-front p {
    margin: 0;
    font-style: italic;
    color: #555;
}

/* Back */
.story-card .story-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    transform: rotateY(180deg);
    text-align: left;
}

.story-card.flipped { transform: rotateY(180deg); }

/* Title, Category, Type */
.story-title {
    font-size: 20px;
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.story-category {
    display: inline-block;
    margin-top: 10px;
    margin-bottom: 8px;
    font-weight: normal;
}
.story-category .category-prefix { font-weight: bold; margin-right: 4px; }

.story-type-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}
.type-prefix { font-weight: bold; margin-right: 4px; }
.story-type-pill {
    display: inline-block;
    background-color: #7cb342;
    color: #fff;
    border-radius: 6px;
    padding: 0 6px;
    font-weight: bold;
}

/* Type color mapping */
.type-humor { background: #f9a825; }
.type-inspiration { background: #1e88e5; }
.type-lesson { background: #43a047; }
.type-warning { background: #e53935; }
.type-case { background: #8e24aa; }
.type-quote { background: #6d4c41; }
.type-personal { background: #fb8c00; }
.type-tip { background: #00acc1; }
.type-strategy { background: #3949ab; }
.type-thinking { background: #7cb342; }
.type-default { background: #7cb342; }

.story-type-pill {
  opacity: 0.6; /* 0.0–1.0, càng nhỏ càng mờ */
}

/* === Responsive === */
@media screen and (max-width: 768px) {
    .story-card .story-back .story-title { font-size: 22px; }
    .story-card .story-back .story-category { font-size: 16px; }
    .story-card .story-back .story-type-wrapper { font-size: 16px; }
    .story-card { width: 99%; }
}



.story-card .story-back p:last-child {
    margin-top: 10px;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 16px;
    color: #1B72B6;  /* màu nổi bật */
    cursor: pointer;
    text-align: center; 
}
