/* ===========================================
   Stories — index grid, detail, recorder form
   =========================================== */

/* Filters */
.stories-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    max-width: var(--auth-content-max-width);
    margin-left: auto;
    margin-right: auto;
    padding: 0 var(--auth-content-padding);
}

.stories-filter-select-wrapper {
    position: relative;
    max-width: 280px;
}

.stories-filter-select-wrapper .mdi-chevron-down {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-light);
}

.stories-filter-select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    font-size: 14px;
    color: var(--text);
    appearance: none;
    cursor: pointer;
}

.stories-filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===========================================
   Story Card (Index Grid Item)
   =========================================== */

.stories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: var(--auth-content-max-width);
    margin: 0 auto;
    padding: 0 var(--auth-content-padding);
}

.story-card {
    position: relative;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s, box-shadow 0.2s;
}

.story-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.story-card-media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--background);
    overflow: hidden;
}

.story-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Kind-tinted gradient backdrop when there is no thumbnail */
.story-card-media--audio {
    background: linear-gradient(135deg, var(--primary-soft) 0%, #FED7AA 100%);
}

.story-card-media--video {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
}

.story-card-media--text {
    background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
}

.story-card-kind-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.story-card-duration {
    font-size: 12px;
    font-weight: 600;
}

.story-card-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.story-card-play .mdi {
    font-size: 48px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.story-card-content {
    padding: 14px 16px 16px;
}

.story-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.story-card-prompt {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 12px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.story-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.story-card-storyteller {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.story-card-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.story-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-card-avatar .avatar-initials {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
}

.story-card-storyteller-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-card-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.story-card-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.story-card-stat .mdi {
    font-size: 14px;
}

/* ===========================================
   Story Detail
   =========================================== */

.story-audio-player audio {
    width: 100%;
}

.story-audio-duration {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.story-video-player video {
    width: 100%;
    max-height: 480px;
    border-radius: 12px;
    background: black;
}

.story-prompt-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--primary-soft);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.story-prompt-block .mdi {
    font-size: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.story-prompt-text {
    margin: 0;
    font-size: 15px;
    font-style: italic;
    color: var(--text);
}

.story-body {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
}

.story-transcript {
    color: var(--text-secondary);
}

.story-photos-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.story-photos-gallery .gallery-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
}

.story-photos-gallery .gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-storyteller-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.story-storyteller-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.story-storyteller-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-storyteller-avatar .avatar-initials {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
}

.story-storyteller-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ===========================================
   Story Form — selected prompt + recorder
   =========================================== */

.story-selected-prompt {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--primary-soft);
    border-radius: 12px;
    padding: 12px 16px;
}

.story-selected-prompt--visible {
    display: flex;
}

.story-selected-prompt .mdi-lightbulb-outline {
    color: var(--primary);
    flex-shrink: 0;
}

.story-selected-prompt-text {
    flex: 1;
    font-size: 14px;
    font-style: italic;
    color: var(--text);
}

.story-selected-prompt-clear {
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.story-selected-prompt-clear:hover {
    color: var(--text);
}

.story-recorder {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 16px;
}

.story-recorder-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.story-recorder-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--primary);
    border-radius: 24px;
    background: white;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.story-recorder-btn:hover {
    background: var(--primary-soft);
}

.story-recorder-btn--secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}

.story-recorder-btn--secondary:hover {
    background: var(--background);
}

.story-recorder-btn--stop {
    border-color: #D32F2F;
    background: #D32F2F;
    color: white;
}

.story-recorder-btn--stop:hover {
    background: #B71C1C;
}

.story-recorder-live {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.story-recorder-live video {
    width: 100%;
    max-height: 320px;
    border-radius: 12px;
    background: black;
}

.story-recorder-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.story-recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #D32F2F;
    animation: story-recording-pulse 1.2s ease-in-out infinite;
}

@keyframes story-recording-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.story-recorder-live-actions {
    display: flex;
    gap: 10px;
}

.story-recorder-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.story-recorder-preview audio {
    width: 100%;
}

.story-recorder-preview video {
    width: 100%;
    max-height: 320px;
    border-radius: 12px;
    background: black;
}

.story-recorder-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.story-recorder-filename {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-recorder-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: #D32F2F;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

/* Existing recording in the edit form */
.existing-media-item--recording {
    width: 100%;
    max-width: 480px;
}

.existing-media-item--recording audio,
.existing-media-item--recording video {
    width: 100%;
    border-radius: 12px;
}

/* ===========================================
   Responsive
   =========================================== */

@media (max-width: 900px) {
    .stories-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .story-photos-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stories-grid {
        grid-template-columns: 1fr;
    }

    .stories-filters {
        padding: 0 var(--auth-content-padding-mobile);
    }

    .stories-filter-select-wrapper {
        max-width: 100%;
    }

    .story-recorder-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .story-recorder-btn {
        justify-content: center;
    }
}
