/* ═══════════════════════════════════════════════════════════════
   public/css/stories-reels.css — Stories (24h) + Reels
   Fichier séparé (pas d'ajout dans matrix.css) — réutilise uniquement
   les tokens déjà définis dans matrix.css:root (aucune nouvelle
   variable custom).
   ═══════════════════════════════════════════════════════════════ */

/* ─── STORIES : bandeau "grandes cartes" (façon Facebook) ───────── */
.stories-tray-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.stories-tray {
    display: flex;
    gap: .6rem;
    padding: .1rem .1rem .3rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}
.stories-tray::-webkit-scrollbar { display: none; }

.story-card {
    position: relative;
    width: 112px;
    height: 198px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    padding: 0;
    scroll-snap-align: start;
    transition: transform .15s ease, border-color .15s ease;
}
.story-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-bright);
}

.story-card-media {
    position: absolute;
    inset: 0;
}
.story-card-media img,
.story-card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-card-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 55%, rgba(0,0,0,.8) 100%);
}

.story-card-avatar-ring {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    padding: 2.5px;
    background: var(--text-muted);
}
.story-card-avatar-ring.unseen {
    background: linear-gradient(135deg, var(--green-bright), var(--green-medium), var(--green-bright));
    box-shadow: 0 0 6px rgba(0,255,65,.5);
}
.story-card-avatar-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 1.5px solid var(--bg-card);
}

.story-card-name {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    color: #fff;
    font-size: .74rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Carte "Créer une story" */
.story-card-add-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
}
.story-card-add-bg-avatar { filter: blur(1px) brightness(.7); }
.story-card-add-btn {
    position: absolute;
    left: 50%;
    /* Assez haut pour laisser un espace clair au-dessus du libellé
       (bottom:8px ci-dessous) — avant, les deux se chevauchaient. */
    bottom: 48px;
    transform: translate(-50%, 50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--green-bright);
    color: #000;
    font-weight: 900;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--bg-card);
    box-shadow: var(--shadow-bright);
}
.story-card-add-label {
    position: absolute;
    bottom: 8px;
    left: 6px;
    right: 6px;
    text-align: center;
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
}

/* Flèches de défilement (desktop uniquement) */
.stories-tray-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
    z-index: 2;
}
.stories-tray-nav-next { right: -4px; }
.stories-tray-nav-prev { left: -4px; }

@media (max-width: 768px) {
    .story-card { width: 92px; height: 168px; }
    .stories-tray-nav { display: none; }
}

/* ─── STORIES : visionneuse plein écran ─────────────────────────── */
.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 6000; /* au-dessus de #mx-lightbox (5000) */
    background: #000;
    display: flex;
    flex-direction: column;
    touch-action: none;
}

.story-progress-bar {
    display: flex;
    gap: 4px;
    padding: .6rem .6rem 0;
}
.story-progress-seg {
    flex: 1;
    height: 2.5px;
    background: rgba(255,255,255,.3);
    border-radius: 2px;
    overflow: hidden;
}
.story-progress-seg > i {
    display: block;
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 2px;
}
.story-progress-seg.done > i { width: 100%; transition: none; }
.story-progress-seg.active > i { transition: width linear; }

.story-viewer-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .9rem;
    color: #fff;
    font-family: var(--font-mono);
}
.story-viewer-header .avatar-sm { border-color: rgba(255,255,255,.3); }
.story-viewer-header .story-time { color: rgba(255,255,255,.6); font-size: .72rem; }
.story-viewer-close {
    margin-left: auto;
    background: none; border: none; color: #fff;
    font-size: 1.4rem; cursor: pointer; padding: .2rem .5rem;
}

.story-viewer-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.story-viewer-media img,
.story-viewer-media video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.story-media-pending {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    height: 100%;
    color: var(--text-muted, #999);
    font-family: var(--font-mono);
    font-size: .85rem;
    text-align: center;
}
.story-pending-icon { font-size: 2rem; }

.story-tap-prev, .story-tap-next {
    position: absolute;
    top: 0; bottom: 0;
    width: 32%;
    z-index: 1;
}
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; width: 68%; }

.story-viewer-caption {
    position: absolute;
    left: 0; right: 0; bottom: 4.5rem;
    text-align: center;
    color: #fff;
    font-family: var(--font-mono);
    font-size: .9rem;
    padding: 0 1.2rem;
    text-shadow: 0 1px 4px rgba(0,0,0,.8);
    pointer-events: none;
}

.story-viewer-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem .9rem calc(.8rem + env(safe-area-inset-bottom));
}
.story-reply-input {
    flex: 1;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 999px;
    padding: .55rem 1rem;
    color: #fff;
    font-family: var(--font-mono);
    font-size: .82rem;
    cursor: pointer;
}
.story-viewer-actions button {
    background: none; border: none; color: #fff;
    font-size: 1.3rem; cursor: pointer;
}

.story-viewers-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    max-height: 60%;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    padding: 1rem;
    overflow-y: auto;
}

/* ─── STORIES : choix du type à la création (photo / texte) ─────── */
.story-choice-modal {
    position: fixed;
    inset: 0;
    z-index: 6100;
    background: rgba(0,0,0,.8);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.story-choice-close {
    position: absolute;
    top: 1rem; left: 1rem;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}
.story-choice-cards {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}
.story-choice-card {
    width: 220px;
    height: 320px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 1.5rem;
    text-align: center;
    transition: transform .15s ease;
}
.story-choice-card:hover { transform: translateY(-4px); }
.story-choice-card-photo { background: linear-gradient(160deg, #6a82fb, #3ad1e0); }
.story-choice-card-text  { background: linear-gradient(160deg, #b06ab3, #e2378d); }
.story-choice-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

@media (max-width: 600px) {
    .story-choice-card { width: 44vw; height: 62vw; }
}

/* ─── STORIES : éditeur de story texte (fond dégradé + texte) ───── */
.story-text-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 6100;
    background: #000;
    display: none;
    flex-direction: row;
}
.story-text-editor-panel {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}
.story-text-editor-panel-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text-primary);
    font-weight: 700;
}
.story-text-editor-close {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}
.story-text-bg-label {
    font-family: var(--font-mono);
    font-size: .75rem;
    color: var(--text-muted);
}
.story-text-bg-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .5rem;
}
.story-text-bg-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.story-text-bg-swatch.active {
    border-color: var(--green-bright);
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--green-bright);
}
.story-text-font-select {
    width: 100%;
    padding: .5rem .7rem;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .85rem;
    cursor: pointer;
}
.story-text-font-select:focus {
    outline: none;
    border-color: var(--green-bright);
}
.story-text-font-select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.story-text-color-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .4rem;
}
.story-text-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    padding: 0;
}
.story-text-color-swatch.active {
    border-color: var(--green-bright);
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--green-bright);
}

.story-text-gif-btn {
    width: 100%;
    padding: .5rem;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .78rem;
    cursor: pointer;
    text-align: center;
}
.story-text-gif-btn:hover { border-color: var(--green-dim); color: var(--green-bright); }
.story-text-gif-panel {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.story-text-gif-search {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .8rem;
    padding: .45rem .6rem;
    outline: none;
}
.story-text-gif-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .3rem;
    max-height: 220px;
    overflow-y: auto;
}
.story-text-gif-results img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}
.story-text-gif-hint {
    grid-column: 1/-1;
    text-align: center;
    color: var(--text-muted);
    font-size: .72rem;
    padding: .75rem;
}

.story-text-editor-actions {
    margin-top: auto;
    display: flex;
    gap: .5rem;
}
.story-text-editor-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
}
.story-text-editor-preview-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
}
.story-text-editor-preview {
    position: relative;
    width: min(360px, 80vw);
    aspect-ratio: 9/16;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.story-text-editor-gif-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-text-gif-remove {
    position: absolute;
    top: .6rem; right: .6rem;
    z-index: 2;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    cursor: pointer;
    font-size: .85rem;
    align-items: center;
    justify-content: center;
}
.story-text-editor-input {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: #fff;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.story-text-editor-input::placeholder { color: rgba(255,255,255,.7); }

@media (max-width: 768px) {
    .story-text-editor-modal { flex-direction: column; overflow-y: auto; }
    .story-text-editor-panel { width: 100%; height: auto; max-height: 55vh; border-right: none; border-bottom: 1px solid var(--border); }
    .story-text-editor-preview-wrap { height: auto; flex: 1 1 auto; min-height: 220px; padding: 1rem 0; }
    .story-text-editor-preview { max-height: 40vh; }
    .story-text-editor-actions { margin-top: 0; }
}

/* ─── Aperçu de story dans une bulle de chat (story-message-preview.js) ─── */
.story-msg-preview {
    width: 160px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    margin-bottom: .3rem;
}
.story-msg-preview-media {
    width: 100%;
    aspect-ratio: 9/16;
    background: #000;
}
.story-msg-preview-media img,
.story-msg-preview-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.story-msg-preview-label {
    font-family: var(--font-mono);
    font-size: .65rem;
    color: var(--text-secondary);
    padding: .3rem .5rem;
}
.story-msg-preview-expired {
    width: 160px;
    padding: 1.2rem .5rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: .3rem;
}
.story-msg-preview-text {
    font-size: .85rem;
}

/* ─── CARTE "REELS" DANS LE FEED (vitrine, façon Facebook) ──────────── */
.fb-reels-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
}
.fb-reels-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}
.fb-reels-card-title {
    font-family: var(--font-display);
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.fb-reels-card-more {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.2rem;
    line-height: 1;
    padding: .2rem .5rem;
    border-radius: 50%;
    transition: background .15s, color .15s;
}
.fb-reels-card-more:hover { background: var(--bg-elevated); color: var(--text-primary); }

.fb-reels-tray-wrap { position: relative; }
.fb-reels-tray {
    display: flex;
    gap: .6rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}
.fb-reels-tray::-webkit-scrollbar { display: none; }

.reel-thumb-card {
    position: relative;
    width: 132px;
    height: 234px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
    cursor: pointer;
    text-decoration: none;
    scroll-snap-align: start;
    transition: transform .15s ease, border-color .15s ease;
    display: block;
}
.reel-thumb-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-bright);
}
.reel-thumb-media { position: absolute; inset: 0; }
.reel-thumb-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.reel-thumb-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,.35) 100%);
}
.reel-thumb-menu {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,.4);
    border: none;
    color: #fff;
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.reel-thumb-author {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .reel-thumb-card { width: 108px; height: 192px; }
    .fb-reels-tray-wrap .stories-tray-nav { display: none; }
}

/* ─── REELS ──────────────────────────────────────────────────────── */
.reels-wrap {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    z-index: 4000;
    background: #000;
}
body.reels-open { overflow: hidden; }

.reel-item {
    position: relative;
    height: 100vh;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}
.reel-video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.reel-close-btn {
    position: fixed;
    top: calc(.9rem + env(safe-area-inset-top));
    left: .9rem;
    z-index: 4100;
    background: rgba(0,0,0,.5);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.reel-overlay-bottom {
    position: absolute;
    left: 0; right: 76px; bottom: 0;
    padding: 1rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
    color: #fff;
    background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
    font-family: var(--font-mono);
}
.reel-overlay-bottom .reel-author { font-weight: 700; margin-bottom: .3rem; text-decoration: none; color: #fff; }
.reel-overlay-bottom .reel-caption { font-size: .85rem; color: rgba(255,255,255,.9); }

.reel-overlay-right {
    position: absolute;
    right: .6rem; bottom: 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
}
.reel-action-btn {
    background: none;
    border: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    font-size: 1.6rem;
    cursor: pointer;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.reel-action-btn.active { color: var(--green-bright); }
.reel-count {
    font-family: var(--font-mono);
    font-size: .68rem;
    color: rgba(255,255,255,.85);
}

.reel-comments-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 65%;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    z-index: 4200;
    padding: 1rem;
    overflow-y: auto;
}

.reel-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 4100;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--green-bright);
    color: #000;
    border: none;
    font-size: 1.6rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: var(--shadow-bright);
}

.reel-composer-modal {
    position: fixed;
    inset: 0;
    z-index: 4300;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.reel-composer-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}
.reel-cam-preview {
    width: 100%;
    aspect-ratio: 9/16;
    max-height: 55vh;
    background: #000;
    border-radius: var(--radius);
    object-fit: cover;
}
.reel-rec-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #ef4444;
    display: inline-block;
    animation: pulse 1s ease-in-out infinite;
}
.reel-rec-timer {
    font-family: var(--font-mono);
    font-size: .85rem;
    color: var(--text-primary);
}
