/* Horizontal story-rings strip — Instagram style */
.story-rings {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--s-3) var(--s-4);
    scrollbar-width: thin;
    scrollbar-color: var(--border-input, var(--border-default)) transparent;
}

.story-rings::-webkit-scrollbar {
    height: 6px;
}

.story-rings::-webkit-scrollbar-thumb {
    background: var(--border-input, var(--border-default));
    border-radius: 3px;
}

.story-rings:empty,
.story-rings[data-loaded="true"]:empty {
    display: none;
}

.story-ring {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-1);
    width: 78px;
    cursor: pointer;
    user-select: none;
}

/* Outer gradient ring (saffron→maroon for unviewed; muted for viewed/own) */
.story-ring__avatar-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, var(--saffron) 0%, var(--maroon) 100%);
    transition: transform var(--duration-fast) ease;
}

.story-ring:hover .story-ring__avatar-wrap {
    transform: scale(1.04);
}

.story-ring--viewed .story-ring__avatar-wrap,
.story-ring--own:not(.story-ring--has-unviewed) .story-ring__avatar-wrap {
    background: linear-gradient(135deg, var(--border-default) 0%, var(--border-strong) 100%);
}

.story-ring__avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--bg-primary, var(--surface-1));
    object-fit: cover;
    background: var(--bg-light, var(--surface-2));
    display: block;
}

.story-ring__name {
    font-size: var(--t-caption);
    font-weight: 500;
    color: var(--text-secondary, var(--text-secondary));
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 76px;
    line-height: 1.2;
}

/* "Your story" placeholder — first card with a + when own user has none */
.story-ring--add .story-ring__avatar-wrap {
    background: var(--bg-light, var(--surface-2));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid color-mix(in srgb, var(--saffron) 40%, transparent);
}

.story-ring--add .story-ring__plus {
    font-size: var(--t-display-sm);
    color: var(--brand-dark, var(--saffron));
    line-height: 1;
}

/* Compose modal */
/* ─── Glimpse compose modal ───────────────────────────────────────
 *
 * Polished upload sheet with drag-drop dropzone, live preview, caption
 * + character counter, and a brand-orange Share CTA. Matches the
 * platform's tokenised look so it sits beside the rings strip on the
 * home page without feeling foreign.
 */
.glimpse-compose-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: glimpse-compose-fade var(--duration-fast) ease-out;
}
@keyframes glimpse-compose-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
body.glimpse-compose-open { overflow: hidden; }

.glimpse-compose-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
}

.glimpse-compose-card {
    position: relative;
    background: var(--bg-primary, #fff);
    border-radius: var(--radius-lg, 14px);
    width: min(460px, 94vw);
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.30);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-5);
    animation: glimpse-compose-pop var(--duration-fast) ease-out;
}
@keyframes glimpse-compose-pop {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.glimpse-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.glimpse-compose-title {
    margin: 0;
    font-family: var(--font-primary);
    font-size: var(--t-title-md, 20px);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.glimpse-compose-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    border: 0;
    cursor: pointer;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) ease;
}
.glimpse-compose-close:hover { background: var(--bg-tertiary, rgba(0,0,0,0.08)); }

.glimpse-compose-subtitle {
    margin: 0;
    color: var(--text-tertiary);
    font-family: var(--font-primary);
    font-size: var(--t-body-sm);
    line-height: 1.5;
}

.glimpse-compose-dropzone {
    position: relative;
    display: block;
    cursor: pointer;
    border: 2px dashed var(--border-subtle, rgba(0, 0, 0, 0.18));
    border-radius: var(--radius-md, 12px);
    background: var(--bg-light, #FFF8F0);
    overflow: hidden;
    transition: border-color var(--duration-fast) ease,
                background var(--duration-fast) ease;
    min-height: 220px;
}
.glimpse-compose-dropzone:hover,
.glimpse-compose-dropzone:focus-within,
.glimpse-compose-dropzone.is-dragging {
    border-color: var(--brand-primary, #FF7A1A);
    background: color-mix(in srgb, var(--brand-primary, #FF7A1A) 6%, transparent);
}
.glimpse-compose-dropzone__inner {
    padding: var(--s-7) var(--s-4);
    text-align: center;
    color: var(--text-secondary);
    font-family: var(--font-primary);
}
.glimpse-compose-dropzone__icon {
    width: 44px; height: 44px;
    color: var(--brand-primary, #FF7A1A);
    margin-bottom: var(--s-3);
}
.glimpse-compose-dropzone__title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.glimpse-compose-dropzone__hint {
    font-size: var(--t-body-sm);
    color: var(--text-tertiary);
}
.glimpse-compose-dropzone__preview {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    background: #0a0a0a;
    overflow: hidden;
}
.glimpse-compose-dropzone__preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.glimpse-compose-replace {
    position: absolute;
    top: var(--s-2);
    right: var(--s-2);
    border: 0;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font: inherit;
    font-size: var(--t-body-sm);
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-pill, 999px);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--duration-fast) ease;
}
.glimpse-compose-replace:hover { background: rgba(0, 0, 0, 0.85); }

.glimpse-compose-field {
    position: relative;
}
.glimpse-compose-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
    border-radius: var(--radius-sm, 8px);
    padding: var(--s-2) var(--s-3) calc(var(--s-2) + 16px);
    font: inherit;
    font-family: var(--font-primary);
    font-size: var(--t-body-md);
    color: var(--text-primary);
    resize: vertical;
    min-height: 64px;
    background: var(--bg-primary);
    transition: border-color var(--duration-fast) ease,
                box-shadow var(--duration-fast) ease;
}
.glimpse-compose-field textarea:focus {
    outline: none;
    border-color: var(--brand-primary, #FF7A1A);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #FF7A1A) 18%, transparent);
}
.glimpse-compose-counter {
    position: absolute;
    bottom: 6px;
    right: 12px;
    color: var(--text-tertiary);
    font-size: var(--t-body-xs, 12px);
    pointer-events: none;
}

.glimpse-compose-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    padding-top: var(--s-2);
}
.glimpse-compose-cancel,
.glimpse-compose-submit {
    appearance: none;
    border: 0;
    padding: 10px var(--s-5);
    border-radius: var(--radius-pill, 999px);
    font: inherit;
    font-family: var(--font-primary);
    font-size: var(--t-body-md);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration-fast) ease,
                color var(--duration-fast) ease,
                opacity var(--duration-fast) ease;
}
.glimpse-compose-cancel {
    background: transparent;
    color: var(--text-secondary);
}
.glimpse-compose-cancel:hover {
    background: var(--bg-tertiary, rgba(0, 0, 0, 0.06));
    color: var(--text-primary);
}
.glimpse-compose-submit {
    background: var(--brand-primary, #FF7A1A);
    color: #fff;
    min-width: 100px;
}
.glimpse-compose-submit:hover { background: var(--brand-primary-dark, #E66B0F); }
.glimpse-compose-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ─── Glimpse grid (Explore › Glimpses chip + Profile › My Glimpses)
 *
 * Flat responsive grid rendered by `window.devalayStories.loadGrid`.
 * Each tile is a single glimpse with a soft author overlay so users
 * can see at a glance who shared what. Tap → opens the existing full-
 * screen viewer (the one the rings strip uses on the home feed).
 */
.glimpse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--s-3);
    margin-top: var(--s-3);
}
.glimpse-grid--full { grid-column: 1 / -1; }

.glimpse-grid__loading,
.glimpse-grid__empty {
    grid-column: 1 / -1;
    padding: var(--s-7) var(--s-4);
    text-align: center;
    color: var(--text-tertiary);
    font-family: var(--font-primary);
}

.glimpse-tile {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: var(--bg-light, #FFF8F0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform var(--duration-fast) ease,
                box-shadow var(--duration-fast) ease;
    display: block;
}
.glimpse-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.glimpse-tile__media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.glimpse-tile__overlay {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: var(--s-2) var(--s-3);
    display: flex;
    align-items: center;
    gap: var(--s-2);
    /* Subtle gradient — keeps the glimpse media as the hero. */
    background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 100%);
    color: #fff;
    font-family: var(--font-primary);
    font-size: var(--t-body-sm);
}
.glimpse-tile__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.9);
    flex-shrink: 0;
}
.glimpse-tile__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.glimpse-tile__caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: var(--s-3) var(--s-3) var(--s-2);
    background: linear-gradient(0deg, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
    color: #fff;
    font-family: var(--font-primary);
    font-size: var(--t-body-sm);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 480px) {
    .glimpse-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
