/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #000;
    /* Dark mode by default for premium feel */
    color: #fff;
    font-size: 14px;
    overscroll-behavior-y: none;
    /* Prevent bounce */
}

a {
    text-decoration: none;
    color: inherit;
}

/* Utils */
.container {
    max-width: 450px;
    /* Mobile width constraint for desktop view consistency */
    margin: 0 auto;
    background-color: #000;
    min-height: 100vh;
    position: relative;
    border-left: 1px solid #333;
    border-right: 1px solid #333;
}

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 60px;
    /* Increased slightly for touch */
    background-color: #000;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #262626;
}

.logo {
    font-family: 'Instagram Sans', 'Billabong', cursive;
    /* Fallback to cursive if custom font fails */
    font-size: 28px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.top-nav i {
    font-size: 24px;
    color: #fff;
    cursor: pointer;
}

.top-nav .actions {
    display: flex;
    gap: 20px;
}

/* Stories */
.stories-container {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid #1c1c1c;
    /* Subtler border */
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.stories-container::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.story {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.story-ring {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    padding: 2px;
    /* Ring width */
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-ring-none {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-ring img,
.story-ring-none img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #000;
    /* Gap between ring and image */
    object-fit: cover;
}

.add-story-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background-color: #0095f6;
    /* Instagram Blue */
    border: 2px solid #000;
    /* Match background */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.add-story-btn i {
    font-size: 10px;
}

.story-username {
    font-size: 11px;
    color: #f5f5f5;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Feed Posts */
.post {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #1c1c1c;
    padding-bottom: 16px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    position: relative;
    z-index: 10;
    background-color: #000;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.username-loc {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 600;
    font-size: 13px;
}

.location {
    font-size: 11px;
    color: #a8a8a8;
}

.options-icon {
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

/* Post Content (Embed) */
.post-content {
    width: 100%;
    aspect-ratio: 4/5;
    /* Standard Instagram portrait ratio */
    background-color: #121212;
    position: relative;
    overflow: hidden;
}

.supersplat-embed {
    width: 100%;
    height: calc(100% + 50px);
    border: none;
    display: block;
    margin-top: -50px;
}

.overlay-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    pointer-events: none;
    /* Let clicks pass through to embed */
    backdrop-filter: blur(4px);
}

/* Reel Styles */
.reel-container {
    width: 100%;
    aspect-ratio: 4/5;
    /* Instagram feed crops 9:16 reels to 4:5 */
    background-color: #000;
    position: relative;
    overflow: hidden;
}

.reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
    /* Tapping toggles sound like instagram */
}

.mute-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    z-index: 10;
}

/* Carousel Styles */
.carousel-container {
    width: 100%;
    aspect-ratio: 5/4;
    position: relative;
    overflow: hidden;
    background-color: #121212;
}

.carousel-container-square {
    width: 100%;
    aspect-ratio: 1/1;
    position: relative;
    overflow: hidden;
    background-color: #121212;
}

.carousel-track {
    display: flex;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
    -webkit-overflow-scrolling: touch;
}

.carousel-track::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.carousel-slide {
    min-width: 100%;
    height: 100%;
    scroll-snap-align: center;
    position: relative;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Post Actions */
.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 6px;
    position: relative;
    /* For absolutely positioning the dots */
}

.left-actions,
.right-actions {
    display: flex;
    gap: 16px;
}

.post-actions i {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.1s;
}

.post-actions i:active {
    transform: scale(0.9);
    color: #888;
}

.fa-heart:hover {
    color: #ff3b30;
    /* Instagram red hover roughly */
}

/* Carousel Indicators (Dots) */
.carousel-indicators {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #a8a8a8;
    opacity: 0.5;
    transition: background-color 0.2s, opacity 0.2s, transform 0.2s;
}

.dot.active {
    background-color: #0095f6;
    /* Instagram Blue */
    opacity: 1;
    transform: scale(1.1);
}

/* Post Details */
.post-likes {
    padding: 0 12px;
    font-size: 13px;
    margin-bottom: 6px;
}

.post-caption {
    padding: 0 12px;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.post-time {
    padding: 0 12px;
    font-size: 10px;
    color: #a8a8a8;
    margin-top: 4px;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 55px;
    /* Standard tab bar height */
    position: -webkit-sticky;
    /* Fallback for older iOS Chrome */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    /* Center without transform for better iOS compat */
    width: 100%;
    max-width: 450px;
    /* Match container */
    background-color: #000;
    border-top: 1px solid #1c1c1c;
    z-index: 1000;
    /* Increased z-index */
    padding-bottom: env(safe-area-inset-bottom);
    padding-bottom: constant(safe-area-inset-bottom);
    /* Older iOS fallback */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Force GPU layer on iOS Chrome */
}

.nav-item {
    cursor: pointer;
    color: #fff;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.nav-item.active {
    opacity: 1;
}

.nav-item i {
    font-size: 24px;
}

.nav-profile-pic {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #fff;
}

/* Large screen adjustments */
@media (min-width: 480px) {
    body {
        background-color: #fafafa;
        color: #000;
    }

    .container {
        /* Encapsulate everything in the phone-sized container */
        background-color: #000;
        color: #fff;
        margin: 20px auto;
        border-radius: 30px;
        height: 850px;
        overflow-y: scroll;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
        max-height: 90vh;
        /* Hide scroll bar for the container itself */
        scrollbar-width: none;
    }

    .container::-webkit-scrollbar {
        display: none;
    }

    /* Fix fixed positioning relative to container for desktop view */
    /* .bottom-nav uses base fixed styles which now handle centering */

    .top-nav {
        position: sticky;
        top: 0;
        border-radius: 30px 30px 0 0;
    }
}