:root {
    --main-bg: #242424;
    --main-fg: #f0f0f0;
    --accent: #2563eb;
    --like: #db2777;
    --comment: #059669;
    --github: #181717;
    --youtube: #FF0000;
    --steam: #1b2838;
    --discord: #7289da;
    --bluesky: #3E5BFF;
    --post-bg: #fff;
    --post-border: #000;
    --avatar-bg: #f0f0f0;
    --avatar-border: #000;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-heavy: rgba(0, 0, 0, 1);
    --shadow-mid: rgba(0, 0, 0, 0.05);
    --header-shadow1: #ffffff52;
    --header-shadow2: #000;
}

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--main-bg);
    font-family: monospace;
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h20v20H0V0zm2 2v16h16V2H2z' fill='%23000000' fill-opacity='0.05'/%3E%3C/svg%3E");
    overflow-x: hidden;
}

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

.bg-pattern {
    position: fixed;
    inset: 0;
    opacity: 0.05;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.container {
    max-width: 1560px; /* increased by 30% from 1200px */
    width: 100%;
    margin: 0 auto;
    padding: 2rem 0 2rem 0;
    position: relative;
    z-index: 1;
    padding-top: 160px; /* increased from 100px */
    box-sizing: border-box;
    overflow: visible; /* ensure expanded content is visible */
}

header {
    text-align: center;
    margin-bottom: 80px;
    color: var(--main-fg);
    font-size: 20px;
    padding-top: 2rem; /* add extra space above header */
    overflow: visible;
}

h1 {
    transition: all 0.3s ease;
    text-shadow: 2px 2px 0 var(--header-shadow1), 3px 3px 0 var(--header-shadow2);
    margin-bottom: 0.5rem;
    transform-origin: center;
    cursor: pointer;
    position: relative;
    display: inline-block;
}

.social-links {
    margin-top: 1rem;
    font-size: 1rem;
}

.social-links a {
    margin: 0 10px;
    color: var(--main-fg);
    text-decoration: none;
    font-weight: bold;
    font-size: 2rem;
    display: inline-block;
}

.social-links a:hover {
    transform: scale(1.1);
    transition: transform 0.3s ease;
    text-shadow: 0 0 3px white;
}

.social-links a:hover.fa-github,
.social-links a:hover .fab.fa-github {
    color: var(--github) !important;
}

.social-links a:hover.fa-youtube,
.social-links a:hover .fab.fa-youtube {
    color: var(--youtube) !important;
}

.social-links a:hover.fa-steam,
.social-links a:hover .fab.fa-steam {
    color: var(--steam) !important;
}

.social-links a:hover.fa-discord,
.social-links a:hover .fab.fa-discord {
    color: var(--discord) !important;
}

.social-links a:hover.fa-bluesky,
.social-links a:hover .fa-brands.fa-bluesky {
    color: var(--bluesky) !important;
}

#posts {
    max-width: 1560px; /* increased by 30% from 1200px */
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-left: 80px;  /* Increase left padding to balance the negative margin */
    padding-right: 40px;
    box-sizing: border-box;
    text-align: left;
    min-height: 0; /* Prevent flex container from causing jumps */
    /* Add stable height to prevent jumps */
    contain: layout style;
}

.masonry-col {
    flex: 1 1 0;
    min-width: 320px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap so negative margins overlap */
    transition: none; /* Prevent transitions during layout changes */
    will-change: auto; /* Prevent unnecessary layer promotion */
    /* Prevent reflow during resize */
}

@media (max-width: 799px) {
    #posts {
        flex-direction: column;
        gap: 0;
        transition: none; /* Prevent transitions during layout changes */
        /* Remove the min-height that was causing issues */
        min-height: auto;
        margin-top: 2rem; /* Add top margin to push posts below header */
        margin-right: 0px;
        margin-left:0px;
        padding-right: 0; /* Remove right padding on mobile */
    }
    .masonry-col {
        min-width: 0;
        width: 100%;
        /* Hide overflow columns on mobile */
    }
    .masonry-col:not(:first-child) {
        display: none;
    }
    
    /* Ensure posts don't have excessive negative margins on mobile */
    .post {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }
}

.post {
    background: var(--post-bg);
    /* Add post-it note lines: slightly darker than background, full width, spaced ~32px apart */
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 27px,
            rgba(0,0,0,0.04) 27px,
            rgba(0,0,0,0.04) 29px,
            transparent 29px,
            transparent 32px
        );
    background-size: 100% 32px;
    background-repeat: repeat;
    padding: 2rem 1.5rem;
    margin-bottom: -0.2rem;
    margin-top: -0.2rem;
    margin-left: -40px;
    margin-right: -40px;
    border: 1.8px solid var(--post-border);
    position: relative; /* Add back for z-index to work */
    box-shadow: 3px 7px 4px var(--shadow-light);
    transition: transform 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55), 
                box-shadow 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55),
                opacity 0.2s ease;
    display: inline-block;
    width: 100%;
    min-width: 320px;
    break-inside: avoid;
    z-index: 1;
    
    /* Dynamic rotation based on height */
    --post-height: 300px; /* Default fallback */
    --min-rotation: 0.5deg; /* Minimum rotation for tall posts */
    --max-rotation: 3deg; /* Maximum rotation for short posts */
    --rotation-factor: clamp(var(--min-rotation), calc(var(--max-rotation) - (var(--post-height) - 200px) * 0.005), var(--max-rotation));
    
    /* Apply rotation with random direction */
    transform: rotate(var(--rotation-factor));
}

.post::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 0;
    width: 100%;
    height: 55px; /* Keep existing height */
    background-color: rgba(0, 0, 0, 0.05); /* Keep existing background color */
    z-index: 0; /* Ensure it's behind the post content but above the post background lines */
    border-radius: 25%; /* Add radius to top-left corner */
    filter: blur(5px); /* Add a slight blur to soften the edges */
}

/* Remove these alternate rotation rules, JS now handles rotation and color */
/*
.post:nth-child(odd) {
    transform: rotate(calc(-1 * var(--rotation-factor)));
}
.post:nth-child(even) {
    transform: rotate(var(--rotation-factor));
}
*/

.post:hover {
    /* Remove transform here, JS will handle */
    box-shadow: 6px 6px 30px var(--shadow-heavy);
    z-index: 100;
}

.post-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    margin: -2rem -1.5rem 1.25rem -1.5rem; /* stretch to post edge, extra space below */
    padding: 0.75rem 1.5rem 0.75rem 1.5rem;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--avatar-bg);
    border: 2px solid var(--avatar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transform: rotate(-2deg);
    box-shadow: 2px 2px 0 var(--avatar-border);
}

.post-content {
    text-shadow: 1px 1px 0 #fff;
}

/* Ensure image containers can hold positioned tape */
.image-placeholder,
.image-placeholder img {
    position: relative;
}

/* Force relative positioning on image links (containers) */
a:has(.image-placeholder) {
    position: relative !important;
    display: block !important;
}

/* JavaScript-generated tape styling */
.tape {
    position: absolute;
    background: rgba(255, 248, 220, 0.9);
    border: 0.5px solid rgba(0, 0, 0, 0.18);
    z-index: 100;
    pointer-events: none;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    background-image: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.3) 25%, 
        transparent 25%, 
        transparent 75%, 
        rgba(255, 255, 255, 0.3) 75%);
    background-size: 3px 3px;
    /* Zig-zag mask on top/bottom (long) sides, subtle and thin */
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg width='100' height='20' viewBox='0 0 100 20' xmlns='http://www.w3.org/2000/svg'><polygon points='0,0 100,0 100,20 0,20' fill='white'/><polyline points='0,0 5,8 10,0 15,8 20,0 25,8 30,0 35,8 40,0 45,8 50,0 55,8 60,0 65,8 70,0 75,8 80,0 85,8 90,0 95,8 100,0' fill='none' stroke='white' stroke-width='1'/><polyline points='0,20 5,12 10,20 15,12 20,20 25,12 30,20 35,12 40,20 45,12 50,20 55,12 60,20 65,12 70,20 75,12 80,20 85,12 90,20 95,12 100,20' fill='none' stroke='white' stroke-width='1'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg width='100' height='20' viewBox='0 0 100 20' xmlns='http://www.w3.org/2000/svg'><polygon points='0,0 100,0 100,20 0,20' fill='white'/><polyline points='0,0 5,8 10,0 15,8 20,0 25,8 30,0 35,8 40,0 45,8 50,0 55,8 60,0 65,8 70,0 75,8 80,0 85,8 90,0 95,8 100,0' fill='none' stroke='white' stroke-width='1'/><polyline points='0,20 5,12 10,20 15,12 20,20 25,12 30,20 35,12 40,20 45,12 50,20 55,12 60,20 65,12 70,20 75,12 80,20 85,12 90,20 95,12 100,20' fill='none' stroke='white' stroke-width='1'/></svg>");
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.post-actions {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

.action-btn {
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.action-btn.like {
    color: var(--like);
    transform: rotate(-1deg);
}

.action-btn.repost {
    color: var(--accent);
    transform: rotate(1deg);
}

.action-btn.comment {
    color: var(--comment);
    transform: rotate(-0.5deg);
}

.avatar-img {
    width: 250px;
    margin: 20px auto;
    display: block;
}

.post:hover {
    /* Remove transform here, JS will handle */
    box-shadow: 6px 6px 30px var(--shadow-heavy);
    z-index: 100;
}

.subtext {
    margin-bottom: 30px;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px) translateY(5px);
    }

    50% {
        transform: translateX(5px) translateY(-5px);
    }

    75% {
        transform: translateX(-5px) translateY(-5px);
    }
}

h1:hover {
    animation:
        wildSpin 3s ease-in-out,
        rainbow 3s linear,
        shake 0.5s ease-in-out infinite;
}

social-links a {
    position: relative;
}

social-links a::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.3rem;
    border-radius: 0.3rem;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

social-links a:hover::after {
    opacity: 1;
}

.project-links {
    margin-top: 2rem;
    font-size: 1rem;
}

.project-links a {
    display: inline-block;
    margin: 0.5rem 0;
    padding: 0.5rem 1rem;
    background: var(--post-bg);
    color: var(--main-bg);
    text-decoration: none;
    font-weight: bold;
    border-radius: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.project-links a:hover {
    background: var(--accent);
    color: var(--post-bg);
}

footer {
    text-align: center;
    margin-top: 3rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--main-fg);
}

footer a {
    color: var(--main-fg);
    text-decoration: underline;
}

footer a:hover {
    color: var(--accent);
}

.hashtag {
    color: #222;
    /* Remove text rotation/skew, only background is "sloppy" */
    background: none;
    border-radius: 6px 12px 8px 10px / 10px 8px 12px 6px;
    padding: 0 6px 2px 6px;
    font-weight: 500;
    cursor: pointer;
    box-shadow:
        0 2px 8px 0 rgba(255, 248, 154, 0.18),
        0 1px 0 0 rgba(255, 248, 154, 0.25);
    display: inline-block;
    margin: 0 2px;
    position: relative;
    z-index: 1;
}
.hashtag::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: -3px;
    right: -3px;
    top: 2px;
    bottom: 2px;
    /* Default fallback color, will be overridden inline by JS */
    background: linear-gradient(
        4deg,
        var(--hashtag-bg, #fff89a) 0%,
        var(--hashtag-bg, #fff89a) 100%
    );
    opacity: 0.7;
    border-radius: 8px 14px 10px 12px / 12px 10px 14px 8px;
    transform: rotate(-2deg) skewX(-2deg);
    pointer-events: none;
}

.mention {
    color: #388e3c;
    background: #e8f5e9;
    border-radius: 4px;
    color: #388e3c;
    background: #e8f5e9;
    border-radius: 4px;
    padding: 0 4px;
    font-weight: 500;    cursor: pointer;
}

/* Video center play button styling */
.video-center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: auto;
}

.video-center-play::before {
    content: "▶";
    color: white;
    font-size: 24px;
    margin-left: 4px; /* Slight offset to center the triangle visually */
}

.video-center-play:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-center-play:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Video embed container and video styling */
.video-embed-container {
    position: relative;
}

.video-embed {
    width: 100%;
    max-height: 60vh;
    margin: 1.5rem 0 12px 0;
    background: #000;
    border-radius: 8px;
}

/* Shadowbox modal styling */
.shadowbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.0);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
    transition: background 0.35s cubic-bezier(.5,1.5,.5,1);
}

.shadowbox-modal.visible {
    background: rgba(0,0,0,0.7);
}

.shadowbox-post {
    transform: translateY(100vh) scale(0.98);
    max-width: 75vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    z-index: 10001;
    cursor: default;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(.5,1.5,.5,1), transform 0.5s cubic-bezier(.5,1.5,.5,1);
}

.shadowbox-post.visible {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
}

.shadowbox-image {
    max-width: 90vw !important;
    max-height: 80vh !important;
    width: auto !important;
    object-fit: contain !important;
    display: block !important;
    margin: 24px auto !important;
    opacity: 1 !important;
}

.shadowbox-close {
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 2rem;
    background: rgba(0,0,0,0.2);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10002;
    transition: background 0.2s;
}

.shadowbox-close:hover {
    background: rgba(0,0,0,0.5);
}

/* Post header avatar image styling */
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Post metadata styling */
.post-author {
    font-weight: bold;
}

.post-date {
    font-size: 0.875rem;
    color: #666;
}

/* Image placeholder styling */
.image-placeholder {
    width: 100%;
    margin-top: 1.5rem;
    border: 4px solid var(--post-border);
    background: var(--avatar-bg);
    text-align: center;
    transform: rotate(0deg);
    box-shadow: 4px 4px 0 var(--post-border);
    display: block;
}

/* Post animation for loading */
@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateY(50px) rotate(var(--post-rotation, 0deg));
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(var(--post-rotation, 0deg));
    }
}

.post.loading {
    opacity: 0;
    transform: translateY(50px) rotate(var(--post-rotation, 0deg));
    animation: slideUpFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Loading indicator and view more button styles */
.loading-posts, .view-more-posts {
    text-align: center;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--post-bg);
    border: 2px solid var(--post-border);
    box-shadow: 3px 3px 0 var(--shadow-light);
    max-width: 400px;
    transform: rotate(-1deg);
    color: #666;
    font-family: inherit;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.view-more-posts {
    cursor: pointer;
    text-decoration: none;
    display: block;
    clear: both;
    margin-top: 3rem;
}

.view-more-posts:hover {
    transform: rotate(-1deg) scale(1.05);
    box-shadow: 6px 6px 0 var(--shadow-light);
    color: var(--bluesky);
}

.loading-posts::before, .view-more-posts::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 0;
    width: 100%;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.05);
    z-index: 0;
    border-radius: 25%;
    filter: blur(3px);
}

.loading-posts-content, .view-more-posts-content {
    position: relative;
    z-index: 1;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}