/* Public Story Viewer — immersive 9:16 canvas. Scoped to .story-viewer-* only. */

.story-viewer-body {
    margin: 0;
    background: #020617;
    color: #f8fafc;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    overflow: hidden;
}

.story-viewer {
    --story-viewer-ink: #f8fafc;
    --story-viewer-muted: rgba(248, 250, 252, 0.72);
    --story-viewer-dark: #020617;
    --story-viewer-frame: #0f172a;
    --story-viewer-accent: #2563eb;
    --story-viewer-safe-top: max(12px, env(safe-area-inset-top, 0px));
    --story-viewer-safe-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    --story-viewer-safe-x: max(12px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));

    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background: var(--story-viewer-dark);
    overflow: hidden;
}

.story-viewer-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(100%, calc((100dvh - 24px) * 9 / 16));
    max-width: 420px;
    height: min(100dvh, calc(100vw * 16 / 9));
    max-height: 100dvh;
    aspect-ratio: 9 / 16;
    background: var(--story-viewer-frame);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.story-viewer-progress {
    position: absolute;
    top: var(--story-viewer-safe-top);
    left: var(--story-viewer-safe-x);
    right: var(--story-viewer-safe-x);
    z-index: 5;
    display: flex;
    gap: 4px;
}

.story-viewer-progress-track {
    flex: 1 1 0;
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
}

.story-viewer-progress-fill {
    display: block;
    width: 0%;
    height: 100%;
    background: #fff;
    transform-origin: left center;
}

.story-viewer-header {
    position: absolute;
    top: calc(var(--story-viewer-safe-top) + 14px);
    left: var(--story-viewer-safe-x);
    right: var(--story-viewer-safe-x);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.story-viewer-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.story-viewer-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--story-viewer-accent);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 700;
}

.story-viewer-identity-copy {
    min-width: 0;
}

.story-viewer-author,
.story-viewer-title,
.story-viewer-category {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 8px rgba(2, 6, 23, 0.7);
}

.story-viewer-author {
    font-size: 0.8125rem;
    font-weight: 700;
}

.story-viewer-title,
.story-viewer-category {
    font-size: 0.75rem;
    color: var(--story-viewer-muted);
}

.story-viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.story-viewer-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.35);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

.story-viewer-icon-btn:hover {
    background: rgba(15, 23, 42, 0.55);
}

.story-viewer-icon-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.story-viewer-icon-btn svg {
    width: 20px;
    height: 20px;
}

.story-viewer-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.story-viewer-canvas {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.story-viewer-slide {
    position: absolute;
    inset: 0;
}

.story-viewer-media {
    position: absolute;
    inset: 0;
    background: #000;
}

.story-viewer-image,
.story-viewer-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.story-viewer-video-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    background: rgba(15, 23, 42, 0.28);
    font-size: 0.8125rem;
    font-weight: 650;
}

.story-viewer-video-fallback svg {
    width: 40px;
    height: 40px;
}

.story-viewer-copy {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: calc(var(--story-viewer-safe-bottom) + 28px);
    z-index: 1;
    max-height: 38%;
    margin: 0;
    overflow: auto;
    color: #fff;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 10px rgba(2, 6, 23, 0.8);
}

.story-viewer-hit {
    position: absolute;
    top: 84px;
    bottom: 0;
    z-index: 2;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.story-viewer-hit--prev {
    left: 0;
    width: 34%;
}

.story-viewer-hit--next {
    right: 0;
    width: 66%;
}

.story-viewer-hit:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.story-viewer-end {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 24px;
    background: rgba(2, 6, 23, 0.78);
    text-align: center;
}

.story-viewer-end[hidden],
.story-viewer-slide[hidden],
.story-viewer-canvas[hidden],
.story-viewer-icon-btn[hidden],
.story-viewer-icon-btn svg[hidden] {
    display: none !important;
}

.story-viewer-end-kicker {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--story-viewer-muted);
}

.story-viewer-end h2 {
    margin: 0 0 16px;
    font-size: 1.5rem;
    font-weight: 700;
}

.story-viewer-end-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.story-viewer-btn {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.story-viewer-btn--ghost {
    background: transparent;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.story-viewer-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.story-viewer-toast {
    position: absolute;
    left: 50%;
    bottom: calc(18px + var(--story-viewer-safe-bottom));
    z-index: 6;
    margin: 0;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 650;
    transform: translateX(-50%);
    pointer-events: none;
}

.story-viewer-toast[hidden] {
    display: none !important;
}

@media (max-width: 720px) {
    .story-viewer-frame {
        width: 100%;
        height: 100dvh;
        max-width: none;
        max-height: none;
        aspect-ratio: auto;
        border-radius: 0;
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-viewer-progress-fill {
        transition: none;
    }
}
