/**
* Castory — mobile optimization (BuddyBoss standard: 768px / 480px)
 */

/* ——— profile BuddyBoss ——— */
@media (max-width: 768px) {
    .bb-profile-content .castory-profile-wrap,
    .bb-profile-content .castory-profile-stats,
    .item-body .castory-manage-wrap {
        padding-left: 0;
        padding-right: 0;
    }

    .castory-manage-wrap {
        padding: 12px 12px max(32px, env(safe-area-inset-bottom));
    }

    .castory-manage-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
        padding-bottom: 14px;
    }

    .castory-manage-header__actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .castory-manage-header__actions .castory-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .castory-manage-stats {
        flex-direction: row;
        justify-content: space-around;
        padding: 12px 14px;
        gap: 10px;
    }

    .castory-manage-stat {
        flex: 1 1 0;
        min-width: 0;
    }

    .castory-manage-stat__value {
        font-size: 1.25rem;
    }

    .castory-manage-tabs {
        gap: 6px;
    }

    .castory-manage-tab {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    .castory-episode-item {
        flex-wrap: wrap;
        gap: 10px;
    }

    .castory-episode-item__actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px solid var(--castory-border, #2d3748);
    }

    .castory-episode-item__actions .castory-btn {
        min-height: 40px;
    }

    /* Activity cards */
    .castory-activity-card {
        max-width: none;
    }

    /* Feed episode in profile tabs */
    .castory-feed-episode {
        flex-direction: row;
        padding: 12px;
        gap: 12px;
    }

    .castory-feed-episode__thumb {
        width: 64px;
        height: 64px;
    }

    .castory-following-podcasts.cast-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .castory-manage-wrap {
        padding: 10px 10px max(28px, env(safe-area-inset-bottom));
    }

    .castory-manage-header h1 {
        font-size: 1.15rem;
    }

    .castory-manage-tab {
        flex: 1 1 100%;
    }

    .castory-manage-stats {
        flex-direction: column;
        align-items: stretch;
    }

    .castory-manage-stat {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: right;
        padding: 6px 0;
        border-bottom: 1px solid var(--castory-border, #2d3748);
    }

    .castory-manage-stat:last-child {
        border-bottom: none;
    }

    .castory-manage-stat__value {
        font-size: 1.1rem;
    }

    .castory-manage-stat__label {
        font-size: 0.78rem;
    }

    .castory-activity-card__thumb {
        width: 56px;
        height: 56px;
    }

    .castory-feed-episode {
        flex-direction: column;
    }

    .castory-feed-episode__thumb {
        width: 100%;
        height: 120px;
    }
}

/* ——— forms (podcast + Episode) ——— */
@media (max-width: 768px) {
    .castory-form-grid {
        grid-template-columns: 1fr;
    }

    .castory-form-grid .castory-field--upload {
        grid-column: 1 / -1;
    }

    .castory-form-grid .castory-field-row--meta {
        grid-template-columns: 1fr;
    }

    .castory-modal-overlay .castory-modal {
        width: 100%;
        max-width: none;
        min-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    .castory-modal-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .castory-modal-footer .castory-btn,
    .castory-modal-footer .castory-btn-submit {
        flex: 1 1 100%;
        max-width: none;
        min-height: 44px;
    }

    .castory-episode-screen__panel {
        transform: translate3d(0, 100%, 0);
        box-shadow: none;
    }

    html[dir="rtl"] .castory-episode-screen__panel {
        transform: translate3d(0, 100%, 0);
    }

    .castory-episode-screen.is-active .castory-episode-screen__panel {
        transform: translate3d(0, 0, 0);
    }

    .castory-episode-screen__actions {
        flex-direction: column-reverse;
    }

    .castory-episode-screen__footer .castory-btn-submit,
    .castory-episode-screen__footer .castory-btn--ghost {
        width: 100%;
        min-height: 44px;
    }

    .castory-episode-screen__header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }

    .castory-episode-screen__body {
        padding: 0 16px;
    }

    .castory-episode-screen__footer {
        padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    }

    .castory-upload-zone {
        min-height: 100px;
    }

    .castory-upload-zone__pick {
        min-height: 40px;
    }
}

/* ——— tab profile Castory ——— */
@media (max-width: 768px) {
    .castory-profile-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 16px;
        margin-bottom: 16px;
    }

    .castory-profile-header h3 {
        font-size: 1.2rem;
    }

    #open-castory-modal {
        width: 100%;
        min-height: 44px;
    }

    .castory-profile-list {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .castory-profile-list .podcast-thumb {
        height: 160px;
    }

    .castory-profile-card-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .castory-profile-card-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .castory-profile-card-actions .castory-btn,
    .castory-profile-card-actions a {
        flex: 1 1 calc(50% - 4px);
        min-height: 40px;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .castory-profile-list .podcast-thumb {
        height: 140px;
    }

    .castory-profile-card-actions .castory-btn,
    .castory-profile-card-actions a {
        flex: 1 1 100%;
    }
}

/* ——— page single podcast ——— */
@media (max-width: 768px) {
    .castbox-page {
        padding-left: 12px;
        padding-right: 12px;
    }
}
