/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #fafafa;
    color: #262626;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Header */
header {
    background: #fff;
    border-bottom: 1px solid #dbdbdb;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    gap: 16px;
}

.logo {
    text-decoration: none;
    color: inherit;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: #262626;
    line-height: 1.2;
}

nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: #262626;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 20px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

nav a:hover {
    background: #f0f0f0;
}

nav a.active {
    background: #0095f6;
    color: #fff;
    font-weight: 600;
}

/* Hamburger Menu Button */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background: #262626;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Main Feed */
main {
    padding: 20px 0;
    flex: 1;
}

.feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 100%;
    overflow: hidden;
}

/* Post Card */
.post {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    max-width: 100%;
    width: 100%;
}

.post:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.post-header {
    padding: 14px 16px;
    border-bottom: 1px solid #efefef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.platform-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.platform-telegram {
    background: linear-gradient(135deg, #0088cc, #29b6f6);
}

.platform-twitter {
    background: linear-gradient(135deg, #1da1f2, #1e88e5);
}

.platform-instagram {
    background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.post-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 13px;
    color: #8e8e8e;
    min-width: 0;
    overflow: hidden;
}

.author {
    font-weight: 600;
    color: #262626;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.date {
    font-size: 12px;
}

/* Post Content - STRICT OVERFLOW CONTROL */
.post-content {
    padding: 16px;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.post-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #262626;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

.post-body {
    font-size: 15px;
    line-height: 1.7;
    color: #262626;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.post-body p {
    margin-bottom: 12px;
    max-width: 100%;
}

.post-body p:last-child {
    margin-bottom: 0;
}

/* ==================== MEDIA ELEMENTS - FORCE CONTAINMENT ==================== */

/* All images - force max-width with !important */
.post-body img,
.post-content img,
.post img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
    object-fit: contain;
    box-sizing: border-box;
}

/* All videos */
.post-body video,
.post-content video,
.post video {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
    box-sizing: border-box;
}

/* Iframes (YouTube, etc.) */
.post-body iframe,
.post-content iframe,
.post iframe {
    max-width: 100% !important;
    width: 100% !important;
    height: auto;
    min-height: 200px;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
    border: none;
    box-sizing: border-box;
}

/* Embedded objects */
.post-body embed,
.post-body object,
.post-content embed,
.post-content object {
    max-width: 100% !important;
    width: 100% !important;
    height: auto;
    box-sizing: border-box;
}

/* Any element with inline width/height - override */
.post-body [width],
.post-body [height],
.post-content [width],
.post-content [height],
.post [width],
.post [height] {
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box;
}

/* Force all descendants to respect container */
.post-body *,
.post-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Links */
.post-body a {
    color: #0095f6;
    word-break: break-all;
    overflow-wrap: break-word;
}

.post-body a:hover {
    color: #00376b;
    text-decoration: underline;
}

/* ==================== END MEDIA ELEMENTS ==================== */

.post-footer {
    padding: 14px 16px;
    border-top: 1px solid #efefef;
    background: #fafafa;
}

.source-link {
    color: #0095f6;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}

.source-link:hover {
    color: #00376b;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    flex-wrap: wrap;
}

.pagination .btn {
    padding: 10px 20px;
    background: #0095f6;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pagination .btn:hover {
    background: #0081d5;
    transform: translateY(-1px);
}

.pagination .btn:active {
    transform: translateY(0);
}

.page-info {
    font-size: 14px;
    color: #8e8e8e;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    color: #8e8e8e;
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 20px;
    color: #262626;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
}

/* Footer */
footer {
    background: #fff;
    border-top: 1px solid #dbdbdb;
    padding: 24px 0;
    margin-top: auto;
}

footer .container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.copyright {
    color: #8e8e8e;
    font-size: 13px;
    text-align: center;
}

.heart {
    color: #e74c3c;
}

/* ==================== MOBILE STYLES ==================== */

@media (max-width: 640px) {
    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 12px;
        max-width: 100%;
        overflow-x: hidden;
    }

    header .container {
        padding: 10px 12px;
    }

    .logo h1 {
        font-size: 20px;
    }

    /* Show hamburger menu */
    .menu-toggle {
        display: flex;
    }

    /* Hide nav by default on mobile */
    header nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 75%;
        max-width: 280px;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        padding: 80px 24px 24px;
        gap: 8px;
        transition: right 0.3s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,0.15);
        z-index: 100;
    }

    header nav.active {
        right: 0;
    }

    header nav a {
        padding: 14px 20px;
        font-size: 16px;
        border-radius: 8px;
        text-align: left;
        color: #262626;
    }

    header nav a.active {
        background: #0095f6;
        color: #fff;
    }

    /* Overlay when menu is open */
    header nav.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.4);
        z-index: -1;
    }

    main {
        padding: 16px 0;
        overflow-x: hidden;
    }

    .feed {
        gap: 12px;
        overflow-x: hidden;
    }

    .post {
        border-radius: 8px;
        overflow: hidden;
        max-width: 100%;
    }

    .post-header {
        padding: 12px;
        flex-wrap: wrap;
    }

    .platform-badge {
        padding: 4px 10px;
        font-size: 10px;
    }

    .post-meta {
        flex-direction: row;
        gap: 8px;
        align-items: center;
        font-size: 12px;
    }

    .author {
        max-width: 140px;
    }

    .post-content {
        padding: 12px;
        overflow: hidden;
        max-width: 100%;
    }

    .post-title {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .post-body {
        font-size: 14px;
        line-height: 1.6;
        overflow: hidden;
        max-width: 100%;
    }

    /* MOBILE: Force all media to stay inside container */
    .post-body img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        border-radius: 6px;
        margin: 10px 0;
    }

    .post-body video {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        border-radius: 6px;
        margin: 10px 0;
    }

    .post-body iframe {
        max-width: 100% !important;
        width: 100% !important;
        min-height: 180px;
        border-radius: 6px;
        margin: 10px 0;
    }

    .post-footer {
        padding: 12px;
    }

    .source-link {
        font-size: 13px;
    }

    .pagination {
        padding: 12px;
        gap: 12px;
        border-radius: 8px;
        margin: 16px 0;
    }

    .pagination .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .empty-state {
        padding: 40px 20px;
        border-radius: 8px;
    }

    .empty-state svg {
        width: 48px;
        height: 48px;
    }

    .empty-state h2 {
        font-size: 18px;
    }

    footer {
        padding: 16px 0;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .logo h1 {
        font-size: 18px;
    }

    .pagination {
        flex-direction: column;
    }

    .pagination .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Focus styles */
a:focus,
button:focus {
    outline: 2px solid #0095f6;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Print styles */
@media print {
    header,
    footer,
    .pagination,
    .menu-toggle {
        display: none;
    }

    .post {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 20px;
    }

    .container {
        max-width: 100%;
    }
}
