/**
 * FUTURES READING MODE
 *
 * Clean, professional reading experience for transmissions.
 * Overrides acidburn post-view styling on futures.html only.
 * Header retains the acidburn aesthetic; everything below is for reading.
 *
 * Two modes: dark (default) and light (toggled via .light-reading class).
 * Both use warm, high-contrast, acidburn-inspired palettes.
 */

/* ═══════════════════════════════════════════════════════════════
   READING FONTS
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,300;1,8..60,400&family=Inter:wght@400;500;600&display=swap');

/* ═══════════════════════════════════════════════════════════════
   DARK MODE VARIABLES (default)
   ═══════════════════════════════════════════════════════════════ */

.post-view {
    --rv-bg: #13121a;
    --rv-text: #ddd8d0;
    --rv-text-secondary: #b0a99e;
    --rv-heading: #efe8df;
    --rv-h2: #c9a0e0;
    --rv-accent: #a0ddb8;
    --rv-accent-dim: rgba(160, 221, 184, 0.25);
    --rv-quote-text: #c0b8ad;
    --rv-quote-border: #5a3a72;
    --rv-meta: #9a90a8;
    --rv-tag-text: #b0a8c0;
    --rv-tag-bg: rgba(160, 130, 200, 0.1);
    --rv-tag-border: rgba(160, 130, 200, 0.25);
    --rv-rule: #3a3040;
    --rv-link: #a0ddb8;
    --rv-link-hover: #c8f0d8;
    --rv-code-bg: rgba(255, 255, 255, 0.06);
    --rv-code-text: #a0ddb8;
    --rv-pre-bg: rgba(0, 0, 0, 0.35);
    --rv-pre-border: #2e2838;
    --rv-back: #9a90a8;
    --rv-back-hover: #ddd8d0;
    --rv-toggle-bg: rgba(255, 255, 255, 0.06);
    --rv-toggle-border: rgba(160, 130, 200, 0.3);
    --rv-toggle-text: #9a90a8;
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT MODE VARIABLES
   ═══════════════════════════════════════════════════════════════ */

body.light-reading .post-view {
    --rv-bg: #f5f0e8;
    --rv-text: #2e2a26; /* Deep dark brown/black */
    --rv-text-secondary: #4a443c;
    --rv-heading: #1a1816;
    --rv-h2: #4a1868;
    --rv-accent: #1a7a40;
    --rv-accent-dim: rgba(26, 122, 64, 0.15);
    --rv-quote-text: #3a3530;
    --rv-quote-border: #7a50a0;
    --rv-meta: #4a4040;
    --rv-tag-text: #2e1a48;
    --rv-tag-bg: rgba(90, 50, 130, 0.12);
    --rv-tag-border: rgba(90, 50, 130, 0.35);
    --rv-rule: #b0a89e;
    --rv-link: #1a7a40;
    --rv-link-hover: #0e5a2c;
    --rv-code-bg: rgba(0, 0, 0, 0.08);
    --rv-code-text: #1a7a40;
    --rv-pre-bg: rgba(0, 0, 0, 0.06);
    --rv-pre-border: #b0a89e;
    --rv-back: #3a3030;
    --rv-back-hover: #000000;
    --rv-toggle-bg: rgba(0, 0, 0, 0.08);
    --rv-toggle-border: rgba(130, 90, 170, 0.35);
    --rv-toggle-text: #3a3030;
}

/* Light mode header — inherits window card from acidburn.css, just override inner panel + text */
body.light-reading .header-bar::after {
    background: #fdfaf5;
}

body.light-reading .header-bar .header-brand,
body.light-reading .header-bar .header-post-title {
    color: #bf00ff;
    text-shadow: none;
}

body.light-reading .header-bar .header-stat-value {
    color: #bf00ff;
    text-shadow: none;
}

body.light-reading .header-bar .header-stat-label {
    color: rgba(0,0,0,0.6);
}

/* ═══════════════════════════════════════════════════════════════
   DISABLE GLITCH & SCANLINES ON THIS PAGE
   ═══════════════════════════════════════════════════════════════ */

body.glitch {
    animation: none !important;
}

/* Kill scanline/moire overlay when reading a post */
body:has(.post-view.active)::after {
    display: none !important;
}

/* Fix container padding and prevent double scrolling when reading */
body:has(.post-view.active) {
    overflow: hidden;
}

body:has(.post-view.active) .main-content {
    padding-top: 50px !important;
    padding-bottom: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    /* Clip any grid-item overflow (e.g. when a post's title/content pushes
       .post-view wider than its grid column). Without this, body scrollWidth
       grows past the viewport and mobile browsers show horizontal scroll. */
    overflow-x: hidden;
}

@media (max-width: 600px) {
    body:has(.post-view.active) .main-content {
        padding-top: 44px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATED TRANSITIONS — smooth flow between index and posts
   ═══════════════════════════════════════════════════════════════ */

.main-content {
    display: grid;
    /* minmax(0, 1fr) — the 0 minimum lets the column shrink below its
       items' min-content, so long non-wrapping text in a post can't
       push the grid (and therefore the body) wider than the viewport. */
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

.index-view, .post-view {
    grid-column: 1;
    grid-row: 1;
    /* Force grid items to the grid cell width. Without explicit width:100%
       and min-width:0, chromium sizes the flex-container post-view by its
       min-content, which for a post with long non-wrapping text (or wide
       default padding before breakpoints resolve) ends up wider than the
       viewport — expanding the body to ~516px on a 375px phone. */
    width: 100%;
    min-width: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.5s;
}

.index-view.hidden {
    display: block !important; /* Override display: none to allow transition */
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
    visibility: hidden;
}

.post-view {
    display: flex !important; /* Always flex layout, controlled by opacity */
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
    visibility: hidden;
}

.post-view.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0.1s; /* Slight delay for post coming in */
}

/* Ensure header content transitions smoothly too */
.header-brand, .header-post-title {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════
   ADAPTIVE HEADER — keep acidburn vibe, show post info
   ═══════════════════════════════════════════════════════════════ */

.header-content-wrapper {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-width: 0;
}

.header-brand {
    /* Inherit from acidburn.css, ensure it's on top of textures */
    position: relative;
    z-index: 10;
    white-space: nowrap;
}

.header-post-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 2px 2px 0px #000, 0 0 10px rgba(0,255,255,0.5);
    -webkit-text-stroke: 1.5px #000;
    letter-spacing: 1px;
    opacity: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 1px solid rgba(0,0,0,0.3);
    padding-left: 1.5rem;
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    .header-post-title {
        display: none; /* Hide title on very small screens to fit INDEX */
    }
}

/* ════╗═══════════════════════════════════════════════════════════╗═══════════════════════════════════════╗
   POST VIEW — FIXED HEIGHT WITH INTERNAL SCROLL
   ════╝═══════════════════════════════════════════════════════════╗═══════════════════════════════════════╗ */

.post-view {
    background: #12121a; /* Smooth dark gray for the box */
    background-image: none; /* No grid inside the reader */
    border: 3px solid transparent;
    border-image: linear-gradient(135deg, var(--purple), var(--cyan), var(--purple)) 1;
    backdrop-filter: blur(10px);
    max-width: calc(900px - var(--space-md) * 2);
    margin: 0 auto;
    border-radius: 2px;
    transition: background 0.3s ease, color 0.3s ease, opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
    position: relative;
    /* Height and margin adjustments to fit screen perfectly */
    margin-top: 2rem;
    height: calc(100vh - 50px - 4rem);
    display: flex; /* Always flex layout, animation handled by opacity/visibility */
    flex-direction: column;
    overflow: hidden;
    z-index: 500;
}

body.light-reading .post-view {
    background: #fdfaf5;
    background-image: none;
    border-image: linear-gradient(135deg, #bf00ff, #00ffff, #bf00ff) 1;
}

@media (max-width: 600px) {
    .post-view {
        margin-top: 1rem;
        height: calc(100vh - 44px - 2rem);
        height: calc(100dvh - 44px - 2rem); /* Use dynamic viewport height if supported */
    }
}

/* Internal layout: Meta stays at top, content scrolls */
.post-view-meta {
    flex-shrink: 0;
    padding: 2rem 5rem 1.5rem; /* Reduced top padding, match 5rem side padding */
    margin-bottom: 0;
    border-bottom: 1px solid var(--rv-rule);
    transition: border-color 0.3s ease;
}

.post-view-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--rv-heading);
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--rv-accent-dim);
}

/* Close button inside box */
.post-close-btn {
    position: absolute;
    top: 0.75rem; /* Nudged up due to reduced padding */
    left: 5rem; /* Aligned with new padding */
    z-index: 1000;
    background: none;
    border: none;
    color: var(--rv-meta);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.post-close-btn:hover {
    color: var(--rv-accent);
    text-shadow: 0 0 10px var(--rv-accent-dim);
}

/* Share/copy-link button — mirrors close button on the right */
.post-share-btn {
    position: absolute;
    top: 0.75rem;
    right: 2rem;
    z-index: 1000;
    background: none;
    border: none;
    color: var(--rv-meta);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.post-share-btn:hover {
    color: var(--rv-accent);
    text-shadow: 0 0 10px var(--rv-accent-dim);
}

.post-share-btn.copied {
    color: var(--rv-accent);
}

/* Toggle moved inside post-view */
.reading-mode-toggle {
    position: absolute;
    top: 1rem;
    right: 2rem;
    z-index: 1000;
    background: var(--rv-toggle-bg);
    border: 1px solid var(--rv-toggle-border);
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reading-mode-toggle:hover {
    background: var(--rv-accent-dim);
    border-color: var(--rv-accent);
}

.reading-mode-toggle .mode-icon {
    width: 24px;
    height: 24px;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 0 5px var(--rv-accent-dim));
}

.reading-mode-toggle:hover .mode-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px var(--rv-accent));
}

.post-view.light-reading .reading-mode-toggle .mode-icon {
    filter: none;
}

@media (max-width: 600px) {
    .reading-mode-toggle {
        top: 1rem;
        right: 1rem;
        padding: 0.3rem 0.6rem;
        height: 32px;
    }
}

/* When active, post-content scrolls */
.post-view.active .post-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--rv-rule) transparent;
    padding: 0 5rem 3rem; /* Pushed out padding on both sides */
}

/* Hide scrollbar but keep functionality */
.post-view.active .post-content::-webkit-scrollbar {
    width: 8px;
}

.post-view.active .post-content::-webkit-scrollbar-track {
    background: transparent;
}

.post-view.active .post-content::-webkit-scrollbar-thumb {
    background-color: var(--rv-rule);
    border-radius: 4px;
}

/* Larger screens: bigger scrollbar */
@media (min-width: 1200px) {
    .post-view.active .post-content::-webkit-scrollbar {
        width: 12px;
    }

    .post-view.active .post-content::-webkit-scrollbar-thumb {
        background-color: var(--rv-rule);
    }

    .post-view.active .post-content {
        padding: 3.5rem 4rem;
    }
}

@media (min-width: 1600px) {
    .post-view.active .post-content {
        padding: 4rem 5rem;
    }
}

/* Ensure content wraps properly at all widths */
.post-content {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Hide any leftover post-back button (now in reading bar) */
.post-back {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════
   POST META (date, tags)
   ═══════════════════════════════════════════════════════════════ */

.post-view-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--rv-meta);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
}

.post-view-tags .post-tag {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--rv-tag-text);
    background: var(--rv-tag-bg);
    border: 1px solid var(--rv-tag-border);
    padding: 0.25rem 0.65rem;
    border-radius: 3px;
    text-shadow: none;
    animation: none;
    transition: all 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════
   POST CONTENT — READING TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════ */

.post-content {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.15rem;
    font-optical-sizing: auto;
    line-height: 1.85;
    color: var(--rv-text);
    font-weight: 400;
    transition: color 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.post-content h1 {
    font-family: 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--rv-heading);
    text-shadow: none;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
    line-height: 1.25;
    transition: color 0.3s ease;
}

.post-content h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--rv-h2);
    text-shadow: none;
    margin: 3rem 0 1.25rem;
    padding-left: 0;
    border-left: none;
    letter-spacing: -0.01em;
    transition: color 0.3s ease;
}

.post-content h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--rv-text-secondary);
    text-shadow: none;
    margin: 2rem 0 1rem;
    transition: color 0.3s ease;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content ul,
.post-content ol {
    margin: 1.5rem 0;
    padding-left: 1.5rem;
}

.post-content li {
    color: var(--rv-text);
    margin-bottom: 0.6rem;
    transition: color 0.3s ease;
}

.post-content em {
    font-style: italic;
    color: var(--rv-text-secondary);
    transition: color 0.3s ease;
}

.post-content strong {
    color: var(--rv-heading);
    font-weight: 600;
    text-shadow: none;
    transition: color 0.3s ease;
}

.post-content blockquote {
    border-left: 3px solid var(--rv-quote-border);
    padding-left: 1.5rem;
    margin: 2rem 0;
    color: var(--rv-quote-text);
    font-style: italic;
    transition: all 0.3s ease;
    max-width: 100%;
    overflow-x: hidden;
}

.post-content code {
    max-width: 100%;
    overflow-wrap: break-word;
}

.post-content code {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9em;
    background: var(--rv-code-bg);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--rv-code-text);
    transition: all 0.3s ease;
}

.post-content pre {
    background: var(--rv-pre-bg);
    border: 1px solid var(--rv-pre-border);
    padding: 1.25rem;
    margin: 2rem 0;
    border-radius: 4px;
    overflow-x: auto;
    overflow-y: hidden; /* Fix vertical scroll on code blocks */
    transition: all 0.3s ease;
}

.post-content pre code {
    background: none;
    padding: 0;
    display: block;
}

.post-content hr {
    border: none;
    height: 1px;
    background: var(--rv-rule);
    margin: 3rem auto;
    max-width: 100px;
    transition: background 0.3s ease;
}

.post-content a {
    color: var(--rv-link);
    text-decoration: none;
    border-bottom: 1px solid var(--rv-accent-dim);
    transition: all 0.2s ease;
}

.post-content a:hover {
    color: var(--rv-link-hover);
    border-color: var(--rv-link-hover);
}

/* ═══════════════════════════════════════════════════════════════
   HIDE BLACK HOLE WHEN READING
   ═══════════════════════════════════════════════════════════════ */

body:has(.post-view.active) #blackhole-container {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

body:has(.post-view.active) .static-bg {
    display: block !important;
    opacity: 1;
}

/* Light mode background */
body:has(.post-view.active.light-reading) .static-bg {
    background: #f5f0e8 !important;
    background-image: 
        linear-gradient(rgba(191, 0, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(191, 0, 255, 0.05) 1px, transparent 1px) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TAG FILTER STRIP
   ═══════════════════════════════════════════════════════════════ */

#tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
}

.tag-filter-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: rgba(0, 255, 255, 0.6);
    background: rgba(5, 5, 18, 0.92);
    border: 1px solid rgba(0, 255, 255, 0.2);
    padding: 0.25rem 0.65rem;
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    letter-spacing: 0.03em;
}

.tag-filter-btn:hover {
    color: #00ffff;
    border-color: rgba(0, 255, 255, 0.5);
}

.tag-filter-btn.active {
    color: #00ffff;
    background: rgba(5, 5, 18, 0.92);
    border-color: #00ffff;
}

/* Light mode tag filter overrides */
body.light-reading .tag-filter-btn {
    background: #e8e2d8;
    color: #5a5050;
    border-color: #d0c8be;
}

body.light-reading .tag-filter-btn:hover {
    background: #dfd8cf;
    color: #1a1816;
    border-color: #bf00ff;
}

body.light-reading .tag-filter-btn.active {
    background: #dfd8cf;
    color: #bf00ff;
    border-color: #bf00ff;
    box-shadow: 0 0 10px rgba(191, 0, 255, 0.1);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — FULLSCREEN & WIDESCREEN COMFORT
   ═══════════════════════════════════════════════════════════════ */

/* Wider screens: more generous padding, keep readable line width */
@media (min-width: 1200px) {
    .post-view.active .post-content {
        padding: 3.5rem 4rem;
    }
}

@media (min-width: 1600px) {
    .post-view.active .post-content {
        padding: 4rem 5rem;
    }
}

@media (max-width: 768px) {
    .post-view.active .post-content {
        padding: 1.5rem 1rem;
    }

    .post-view-meta {
        padding: 1.5rem 1rem 1rem;
    }

    .post-view-title {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .post-view-tags {
        display: none; /* Hide tags on mobile to save vertical space */
    }

    .post-close-btn {
        left: 1rem;
        top: 0.5rem;
    }

    .post-share-btn {
        right: 1rem;
        top: 0.5rem;
    }

    .post-content {
        font-size: 1.05rem;
        line-height: 1.75;
    }

    .post-content h1 {
        font-size: 1.6rem;
    }
}
