/*
Theme Name: JandanBrutal
Description: A Brutalist theme inspired by Jandan.com, focusing on raw content and voting.
Author: Antigravity
Version: 1.0
*/

:root {
    --shadow: none;
    --brutal-border: 1px solid #ccc;
    /* Lighter, thinner border */
    --brutal-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --mono-font: 'Courier New', Courier, monospace;
}

.brutal-shadow {
    --shadow: 4px 4px 0 #eee;
    /* Softer shadow */
}

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

body {
    margin: 0;
    padding: 0;
    background: #fff;
    color: #000;
    font-family: var(--brutal-font);
    font-weight: 700;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    /* Mobile viewport fix */
}

a {
    color: #000;
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

a:hover {
    background: #FFFE00;
    /* Vibrant Brutalist Yellow */
    color: #000;
    text-decoration: none;
}

/* Layout */
.container {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Header */
#header {
    margin-bottom: 60px;
    border-bottom: var(--brutal-border);
    padding-bottom: 20px;
}

.site-name {
    font-size: 32px;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: -1px;
    overflow-wrap: anywhere;
    /* Smart breaking */
}

.site-name a {
    color: #000;
    text-decoration: none;
}

.site-description {
    font-family: var(--mono-font);
    font-weight: 400;
    margin: 10px 0 0;
    font-size: 14px;
}

/* Post Card */
.card {
    border: var(--brutal-border);
    margin-bottom: 30px;
    padding: 10px;
    /* Reduced from 15px */
    box-shadow: var(--shadow);
    background: #fff;
    position: relative;
}

/* Meta Data */
.meta {
    font-family: var(--mono-font);
    font-weight: 400;
    font-size: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    /* Reduced from 8px */
    color: #666;
}

/* Content - Image Only Rule */
.post-content {
    margin-bottom: 0;
    line-height: 0;
    font-size: 0;
}

.post-content img {
    display: block;
    max-width: 100%;
    height: auto;
    /* Removed min-height and gray background to prevent gray bars */
    background: transparent;
    border: none;
    margin: 0 auto;
    pointer-events: auto;
    /* Enable clicks */
    cursor: zoom-in;
    /* Indicate clickable */
}

/* Fallback Image Style */
.post-content img.broken {
    padding: 20px;
    object-fit: contain;
    border: 3px dashed #000;
    background: #fff;
    width: 100%;
    font-size: 14px;
    /* Restore font size for broken text */
    line-height: 1.5;
}

.post-content a img {
    pointer-events: auto;
}

.post-content p {
    margin: 0;
    font-size: 16px;
    /* Restore font size for text */
    line-height: 1.5;
    margin-top: 10px;
}

/* Focus Mode */
.post-content img.focused {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 98vw;
    max-height: 98vh;
    z-index: 1000;
    border: 5px solid #fff;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.9);
    cursor: zoom-out;
}

/* Vote Block */
.vote-block {
    display: flex;
    gap: 16px;
    font-family: var(--mono-font);
    font-weight: 400;
    margin-top: 5px;
    /* Unified to 5px */
}

.vote-btn {
    background: transparent;
    border: none;
    color: #666;
    padding: 2px 5px;
    /* Reduced vertical padding from 5px to 2px */
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    border-radius: 0;
    transition: transform 0.1s;
    line-height: 1;
    /* Tight line height */
}

/* Jandan Style Colors */
.vote-btn[data-type="oo"] {
    color: #E53935;
    /* Jandan Red */
}

.vote-btn[data-type="xx"] {
    color: #1E88E5;
    /* Jandan Blue */
}

.vote-btn:hover {
    background: transparent;
    text-decoration: none;
    /* No underline */
    opacity: 0.8;
}

.vote-btn:active {
    transform: scale(0.95);
    background: transparent;
    box-shadow: none;
}

.vote-btn.voted {
    background: transparent;
    color: inherit;
    /* Keep color */
    opacity: 0.5;
    cursor: default;
    text-decoration: none;
}

.vote-error {
    color: #FF0000;
    font-size: 12px;
    margin-left: 10px;
    display: none;
}

/* Footer */
#footer {
    border-top: var(--brutal-border);
    padding: 40px 0;
    text-align: center;
    font-family: var(--mono-font);
    font-size: 12px;
}

/* ... (skipping unchanged content) ... */

/* Brutal Toast Notification */
.brutal-toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    padding: 10px 20px;
    font-family: var(--brutal-font);
    font-weight: 700;
    font-size: 14px;
    border: 1px solid #ccc;
    /* Match card border */
    box-shadow: 2px 2px 0 #eee;
    /* Match card shadow */
    z-index: 99999;
    animation: toast-in 0.3s ease-out;
}

/* Responsive & Mobile Optimization (Phase 3) */
@media (max-width: 600px) {

    /* 1. Brutalist Fallback: Prevent horizontal scroll (Safer) */
    img,
    video,
    iframe,
    table,
    pre {
        max-width: 100%;
    }

    * {
        box-sizing: border-box;
    }

    img {
        height: auto;
    }

    /* ... (unchanged) ... */

    @media (max-width: 600px) {
        #back-to-top {
            bottom: 20px;
            right: 20px;
            left: auto;
            /* Force right alignment */
            width: 36px;
            height: 36px;
            line-height: 34px;
            font-size: 28px;
            /* High visibility on mobile */
        }
    }

    /* 2. Layout Adjustments */
    .container {
        width: 100%;
        padding: 0 16px;
        margin: 20px auto;
    }

    #header {
        margin-bottom: 30px;
    }

    .site-name {
        font-size: 24px;
        /* Note: overflow-wrap handled globally */
    }

    /* 3. Card & Image Rules */
    .card {
        margin-bottom: 30px;
        /* Vertical: 0, Horizontal: 6px */
        padding: 0 6px !important;
        box-shadow: 2px 2px 0 #eee !important;
        /* Use Flexbox to eliminate whitespace between divs */
        display: flex;
        flex-direction: column;
    }

    /* Prevent long images from taking over screen */
    .card img {
        max-height: 85vh;
        object-fit: contain;
        width: 100%;
        display: block;
        margin: 0;
        /* No margin at all */
    }

    /* Compact Meta */
    .meta {
        padding: 8px 0 0 0;
        /* Zero bottom padding */
        margin-bottom: 0;
        border-bottom: 1px solid #eee;
    }



    /* 5. Vote Block: Static (Natural Flow) */
    .vote-block {
        display: flex;
        gap: 15px;
        margin-top: 5px !important;
        /* Unified to 5px */
        padding-top: 5px;
        border-top: 1px solid #eee;
        /* Separator */
    }

    .vote-btn {
        flex: 1;
        /* Equal width */
        padding: 4px 0;
        /* Reduced from 8px for extreme compactness */
        /* Larger touch target */
        font-size: 16px;
        /* Prevent iOS zoom */
        width: 100%;
        line-height: 1;
        /* Tighter line height */
    }

    /* Spacing between multiple images in one post (Fallback for non-grid) */
    .post-content img+img {
        margin-top: 10px !important;
    }



    /* Tighter spacing for image content on mobile */
    .post-content {
        margin-bottom: 0 !important;
        /* Force Zero margin */
        line-height: 0 !important;
        /* Fix ghost space */
        font-size: 0 !important;
        /* Kill all inline whitespace size */
    }

    .post-content img {
        vertical-align: bottom;
        /* Crucial for removing descent space */
    }
}

/* Grid Layout (Multi-Image) - Global */
.img-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    margin-top: 5px;
}

.grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f0f0f0;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    pointer-events: auto;
    cursor: zoom-in;
    transition: opacity 0.2s;
}

.grid-item img:not(.focused):hover {
    opacity: 0.9;
}

/* Focus Counter (Overlay) */
#focus-counter {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 15px;
    border-radius: 20px;
    font-family: var(--mono-font);
    font-size: 14px;
    z-index: 2000;
    /* Above image */
    pointer-events: none;
    display: none;
    backdrop-filter: blur(5px);
}

/* Stable Focus Background */
#focus-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    /* Pure Black, No Transparency */
    z-index: 999;
    /* Below image, Above content */
    display: none;
    cursor: zoom-out;
    /* Optional: subtle fade in */
    animation: fade-in 0.2s ease-out forwards;
}

/* Focus Slider Track */
#focus-track {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    /* Mobile Viewport Fix: Use dvh if available, else 100vh or bottom:0 */
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* Smooth snap */
}

#focus-track.anim-enter {
    animation: track-enter 0.25s cubic-bezier(0.2, 0, 0, 1) forwards;
}

@keyframes track-enter {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#focus-track.no-anim {
    transition: none;
}

.focus-slide {
    width: 100vw;
    height: 100%;
    /* Inherit track height (100dvh) */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.focus-slide img {
    max-width: 100vw;
    max-height: 100%;
    /* Fit within container */
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    /* Ensure visibility */
}

/* Hide Original Image when Focused (Optional, but good for perf) */
img.focused-placeholder {
    opacity: 0;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}



/* Brutal Toast Notification */
.brutal-toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    padding: 10px 20px;
    font-family: var(--brutal-font);
    font-weight: 700;
    font-size: 14px;
    border: 1px solid #ccc;
    /* Match card border */
    box-shadow: 2px 2px 0 #eee;
    /* Match card shadow */
    z-index: 99999;
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Back to Top Button */
/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #ccc;
    /* Match card border */
    box-shadow: 2px 2px 0 #eee;
    /* Match card shadow */
    color: #000;
    /* Flexbox for centering SVG */
    display: flex;
    justify-content: center;
    align-items: center;

    cursor: pointer;
    z-index: 900;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: all 0.3s ease;
}

#back-to-top svg {
    width: 24px;
    height: 24px;
    display: block;
}

#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#back-to-top:hover {
    border-color: #999;
    box-shadow: 2px 2px 0 #ccc;
    /* Darker shadow on hover */
    color: #000;
}

@media (max-width: 600px) {

    /* Back to Top Mobile */
    #back-to-top {
        bottom: 20px;
        right: 20px;
        left: auto;
        /* Prevent left drift */
        width: 36px;
        height: 36px;
    }
}
