/* Stories: feed estilo Instagram. Usa tokens de theme.css e componentes de ui.css. */

/* ============================ feed / trilho ============================ */
.stories-page { padding-block: 20px 56px; }

.stories-rail {
    margin-top: 8px;
    padding: 18px 16px;
    border-radius: var(--radius-lg, 18px);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow, 0 1px 2px rgba(0,0,0,.04));
}

.stories-circles {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.stories-circles::-webkit-scrollbar { height: 6px; }
.stories-circles::-webkit-scrollbar-thumb { background: var(--border-strong, var(--border)); border-radius: 99px; }

.story-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 80px;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--text);
    text-decoration: none;
    scroll-snap-align: start;
    -webkit-tap-highlight-color: transparent;
}

/* anel gradiente */
.story-circle-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    padding: 3px;
    display: grid;
    place-items: center;
    background: var(--border-strong, var(--border));
    transition: transform .18s ease, box-shadow .18s ease;
}

.story-circle--new .story-circle-ring {
    background: conic-gradient(from 210deg, var(--accent), #f0883e, #e9568a, #8b5cf6, var(--accent));
    box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}

.story-circle--seen .story-circle-ring { background: var(--border-strong, var(--border)); }

.story-circle:hover .story-circle-ring,
.story-circle:focus-visible .story-circle-ring { transform: translateY(-2px) scale(1.03); }
.story-circle:focus-visible { outline: none; }
.story-circle:focus-visible .story-circle-ring { box-shadow: 0 0 0 3px var(--focus-ring, color-mix(in srgb, var(--accent) 45%, transparent)); }

.story-circle:active .story-circle-ring { transform: scale(.96); }

/* avatar dentro do anel */
.story-circle-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
    border: 3px solid var(--surface);
    overflow: hidden;
    background: var(--surface);
}
.story-circle-avatar .avatar {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50%;
    font-size: 1.3rem;
}
.story-circle-avatar .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* círculo "criar story" */
.story-circle--add .story-circle-ring { background: var(--border); }
.story-circle-add-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent-soft, color-mix(in srgb, var(--accent) 16%, var(--surface)));
    color: var(--accent);
    border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.story-circle-add-inner svg { width: 24px; height: 24px; }

.story-circle-name {
    font-size: .78rem;
    font-weight: 600;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: var(--text-soft, var(--text));
}

.stories-empty-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 6px;
    font-size: .9rem;
}
.stories-empty-hint svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ============================ modal viewer ============================ */
body.stories-no-scroll { overflow: hidden; }

.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity .2s ease;
}
.story-viewer[hidden] { display: none; }
.story-viewer.is-open { opacity: 1; }

.story-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 12, .92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.story-viewer-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: min(88vh, 760px);
    display: flex;
    flex-direction: column;
    background: #0d0d12;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 70px -20px rgba(0, 0, 0, .8);
    transform: scale(.96);
    transition: transform .22s cubic-bezier(.2, .8, .3, 1);
}
.story-viewer.is-open .story-viewer-content { transform: scale(1); }

/* progresso segmentado */
.story-viewer-progress {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    z-index: 4;
    display: flex;
    gap: 4px;
}
.story-progress-bar {
    flex: 1;
    height: 3px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .28);
    overflow: hidden;
}
.story-progress-fill {
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 99px;
}
.story-progress-bar.is-done .story-progress-fill { width: 100% !important; transition: none; }

/* header */
.story-viewer-header {
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #fff;
}
.story-viewer-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    border: 1.5px solid rgba(255, 255, 255, .5);
}
.story-viewer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.story-viewer-meta { display: grid; gap: 1px; min-width: 0; }
.story-viewer-username { font-weight: 700; font-size: .92rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.story-viewer-time { font-size: .76rem; color: rgba(255, 255, 255, .75); text-shadow: 0 1px 3px rgba(0,0,0,.4); }

.story-viewer-close {
    margin-left: auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}
.story-viewer-close:hover { background: rgba(255, 255, 255, .25); }
.story-viewer-close svg { width: 20px; height: 20px; }

/* palco (mídia + zonas de toque + setas) */
.story-viewer-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    background: #000;
}
.story-viewer-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.story-viewer-media img,
.story-viewer-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.story-viewer-media.is-text {
    padding: 32px 26px;
    background: linear-gradient(145deg, var(--accent), #8b5cf6);
}
.story-text-content {
    color: #fff;
    font-size: 1.5rem;
    line-height: 1.4;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    word-break: break-word;
}
.story-link-chip {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    padding: 9px 18px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .95);
    color: #111;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 20px -6px rgba(0, 0, 0, .5);
}

/* zonas de toque (metade esquerda/direita) */
.story-tap {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    z-index: 2;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.story-tap--prev { left: 0; }
.story-tap--next { right: 0; width: 65%; }

/* setas visíveis (desktop) */
.story-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, background .15s ease;
}
.story-viewer-stage:hover .story-nav { opacity: 1; }
.story-nav:hover { background: rgba(255, 255, 255, .3); }
.story-nav svg { width: 22px; height: 22px; }
.story-nav--prev { left: 10px; }
.story-nav--next { right: 10px; }

/* botão denunciar no header */
.story-viewer-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}
.story-viewer-icon:hover { background: rgba(239, 68, 68, .85); }
.story-viewer-icon svg { width: 18px; height: 18px; }

/* footer / responder */
.story-viewer-footer {
    padding: 10px 14px 12px;
    background: #0d0d12;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

/* barra de reações rápidas */
.story-react-bar {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 10px;
}
.story-react-emoji {
    border: 0;
    background: rgba(255, 255, 255, .08);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
}
.story-react-emoji:hover { transform: scale(1.18); background: rgba(255, 255, 255, .16); }
.story-react-emoji.is-active { transform: scale(1.4); }
.story-reply-form { display: flex; gap: 8px; align-items: center; }
.story-reply-form .input {
    flex: 1;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
    border-radius: 99px;
    padding: 10px 16px;
}
.story-reply-form .input::placeholder { color: rgba(255, 255, 255, .55); }
.story-reply-form .input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, .12);
}
.story-reply-form .btn { flex-shrink: 0; border-radius: 50%; width: 40px; height: 40px; padding: 0; }
.story-reply-form .btn svg { width: 18px; height: 18px; }

/* ============================ criar story ============================ */
.story-create-panel { margin-bottom: 24px; }

.story-create-form {
    display: grid;
    gap: 18px;
    max-width: 560px;
    padding: 22px;
}
.story-create-form .form-group { display: grid; gap: 8px; }
.story-create-form .form-label { font-weight: 600; font-size: .88rem; color: var(--text); }

/* seletor de tipo */
.story-create-form .btn-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.story-type-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.story-type-btn svg { width: 18px; height: 18px; }

/* preview da mídia */
.story-preview {
    margin-top: 6px;
    border-radius: var(--radius, 12px);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
    aspect-ratio: 9 / 16;
    max-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-preview[hidden] { display: none; }
.story-preview img,
.story-preview video { width: 100%; height: 100%; object-fit: contain; }

/* swatches de cor */
.story-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.story-color-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 2px var(--surface);
    transition: transform .12s ease, border-color .12s ease;
}
.story-color-swatch:hover { transform: scale(1.1); }
.story-color-swatch--active {
    border-color: var(--accent);
    transform: scale(1.12);
}

.story-create-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}
.story-create-form .form-actions .btn svg { width: 18px; height: 18px; }

/* ============================ responsivo ============================ */
@media (max-width: 640px) {
    .stories-rail { padding: 14px 12px; border-radius: 14px; }
    .stories-circles { gap: 14px; }
    .story-circle { width: 72px; }
    .story-circle-ring { width: 64px; height: 64px; }
    .story-circle-name { font-size: .72rem; }
    .story-viewer { padding: 0; }
    .story-viewer-content { max-width: 100%; height: 100%; border-radius: 0; }
    .story-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .story-circle-ring,
    .story-viewer,
    .story-viewer-content { transition: none; }
}

/* ===================== quem visualizou (dono) ===================== */
.story-owner-views {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 0;
    background: rgba(255, 255, 255, .06);
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: background .15s ease;
}
.story-owner-views:hover { background: rgba(255, 255, 255, .12); }
.story-owner-views svg { width: 18px; height: 18px; }

.story-viewers-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    max-height: 60%;
    display: flex;
    flex-direction: column;
    background: #15151c;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .5);
    animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.story-viewers-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
}
.story-viewers-close {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer;
}
.story-viewers-close svg { width: 18px; height: 18px; }
.story-viewers-list { overflow-y: auto; padding: 8px 8px 16px; }
.story-viewer-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 10px; border-radius: 10px;
}
.story-viewer-row:hover { background: rgba(255, 255, 255, .05); }
.story-viewer-row-av { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }
.story-viewer-row-av img { width: 100%; height: 100%; object-fit: cover; }
.story-viewer-row-meta { display: grid; gap: 1px; }
.story-viewer-row-meta strong { color: #fff; font-size: .9rem; }
.story-viewer-row-meta small { color: rgba(255, 255, 255, .55); font-size: .76rem; }
.story-viewers-empty { padding: 28px 16px; text-align: center; color: rgba(255, 255, 255, .6); font-size: .9rem; }

/* ===================== modal de denúncia (Instagram) ===================== */
.story-report-modal {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.story-report-modal[hidden] { display: none; }
.story-report-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.story-report-sheet {
    position: relative;
    width: 100%;
    max-height: 82%;
    overflow-y: auto;
    background: var(--surface, #fff);
    color: var(--text, #15151c);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 8px 0 20px;
    animation: sheet-up .25s cubic-bezier(.2,.8,.3,1);
}
.story-report-grab { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong, #ccc); margin: 8px auto 4px; }
.story-report-head {
    display: flex; align-items: center; justify-content: center; position: relative;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
}
.story-report-x {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; display: grid; place-items: center;
    border: 0; border-radius: 50%; background: transparent; color: var(--text-soft, #666); cursor: pointer;
}
.story-report-x svg { width: 20px; height: 20px; }
.story-report-intro { padding: 16px; margin: 0; font-weight: 600; }
.story-report-reasons { list-style: none; margin: 0; padding: 0; }
.story-report-reason {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 16px; border: 0; background: none;
    border-bottom: 1px solid var(--border);
    color: var(--text); font-size: .95rem; text-align: left; cursor: pointer;
}
.story-report-reason:hover { background: var(--hover, rgba(0,0,0,.03)); }
.story-report-reason svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

.story-report-step { padding: 0; }
#report-step-confirm, #report-step-done { padding: 28px 24px; text-align: center; }
.story-report-confirm-icon, .story-report-done-icon {
    width: 64px; height: 64px; margin: 0 auto 16px;
    display: grid; place-items: center; border-radius: 50%;
}
.story-report-confirm-icon { background: var(--danger-soft, #fde8e8); color: var(--danger, #e03131); }
.story-report-done-icon { background: var(--success-soft, #e7f6ec); color: var(--success, #1a7f37); }
.story-report-confirm-icon svg, .story-report-done-icon svg { width: 30px; height: 30px; }
#report-step-confirm h3, #report-step-done h3 { margin: 0 0 8px; font-size: 1.15rem; }
.story-report-confirm-text, #report-step-done p { color: var(--text-soft, #555); margin: 0 0 22px; font-size: .92rem; }
.story-report-actions { display: flex; gap: 10px; }
.story-report-actions .btn { flex: 1; justify-content: center; }
#report-step-done .btn { width: 100%; }
