/**
 * Invest Hub Blog Single Post - Dark Style
 * Extracted from template-blog-single.php
 */

/* ============================================
   BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: visible;
    max-width: 100vw;
}

body {
    max-width: 100vw;
}

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #16161e;
    --bg-tertiary: #1e1e28;
    --bg-card: #1a1a24;
    --bg-content: #13131a;
    --accent: #22c55e;
    --accent-glow: rgba(34, 197, 94, 0.3);
    --accent-purple: #a855f7;
    --text-primary: #f0f0f5;
    --text-secondary: #b8b8c4;
    --text-body: #c8c8d4;
    --text-muted: #888899;
    --border-color: rgba(255,255,255,0.08);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary) !important;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

/* Override WordPress default heading colors */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

/* Block inline styles from posts that try to change body/page background */
.ih-post-content style {
    display: none !important;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(34, 197, 94, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 30%, rgba(168, 85, 247, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* NOTE: Header, Navigation, and Mobile Menu styles are centralized in common.css */

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */
.ih-main {
    padding: 120px 40px 80px;
    max-width: 1300px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 40px;
    align-items: start;
}

.ih-article-wrapper {
    max-width: 900px;
    min-width: 0; /* Prevent grid blowout */
}

/* ============================================
   SIDEBAR - STICKY
   ============================================ */
.ih-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 100px !important;
    align-self: start !important;
    height: fit-content !important;
    max-height: calc(100vh - 120px);
}

.ih-sidebar-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 28px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.ih-sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ih-sidebar-title .live-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ih-portfolio-stat {
    margin-bottom: 20px;
}

.ih-portfolio-stat:last-child {
    margin-bottom: 0;
}

.ih-portfolio-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ih-portfolio-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.ih-portfolio-value.positive {
    color: #22c55e;
}

.ih-portfolio-value.negative {
    color: #ef4444;
}

.ih-portfolio-change {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.ih-sidebar-cta {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    display: block;
    text-align: center;
    transition: all 0.3s;
}

.ih-sidebar-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(34, 197, 94, 0.35);
}

.ih-sidebar-cta-member {
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
}

.ih-sidebar-cta-member:hover {
    box-shadow: 0 12px 30px rgba(168, 85, 247, 0.35);
}

.ih-sidebar-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
}

@media (max-width: 1100px) {
    .ih-main {
        grid-template-columns: 1fr;
        max-width: 900px;
    }

    .ih-sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .ih-sidebar-card {
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .ih-sidebar {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   SINGLE POST HEADER
   ============================================ */
.ih-post-header {
    margin-bottom: 40px;
}

.ih-post-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 24px;
    transition: color 0.2s;
}

.ih-post-back:hover {
    color: var(--accent);
}

.ih-post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.ih-post-category {
    background: var(--accent);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ih-post-locked-badge {
    background: var(--accent-purple);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ih-post-title {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #fff 0%, #e4e4e7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ih-post-featured {
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 0 auto 32px;
    display: block;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* ============================================
   POST CONTENT - LIGHT BACKGROUND
   ============================================ */
.ih-post-content {
    font-size: 18px;
    line-height: 1.85;
    color: #2d2d2d;
    background: #ffffff;
    padding: 56px 64px;
    border-radius: 24px;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 40px rgba(0,0,0,0.3);
    overflow-x: auto;
    max-width: 100%;
}

.ih-post-content h1,
.ih-post-content h2,
.ih-post-content h3,
.ih-post-content h4,
.ih-post-content h5,
.ih-post-content h6 {
    color: #1a1a1a !important;
    margin: 48px 0 20px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.ih-post-content h1 { font-size: 32px; }
.ih-post-content h2 { font-size: 26px; border-bottom: 1px solid #e5e5e5; padding-bottom: 12px; color: #1a1a1a !important; }
.ih-post-content h3 { font-size: 22px; color: #2a2a2a !important; }
.ih-post-content h4 { font-size: 19px; color: #333 !important; }

/* Force dark text on headings that have inline styles from Gutenberg */
.ih-post-content h1[style*="color"],
.ih-post-content h2[style*="color"],
.ih-post-content h3[style*="color"],
.ih-post-content h4[style*="color"],
.ih-post-content h5[style*="color"],
.ih-post-content h6[style*="color"] {
    color: #1a1a1a !important;
}

/* Also handle gradient text headings */
.ih-post-content h1[style*="background"],
.ih-post-content h2[style*="background"],
.ih-post-content h3[style*="background"],
.ih-post-content h4[style*="background"] {
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    -webkit-text-fill-color: #1a1a1a !important;
    color: #1a1a1a !important;
}

.ih-post-content p {
    margin-bottom: 24px;
    color: #3d3d3d;
}

.ih-post-content a {
    color: #16a34a;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ih-post-content a:hover {
    color: #15803d;
}

.ih-post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Make content images fill the container width */
.ih-post-content > p > img,
.ih-post-content > img {
    width: 100%;
    height: auto;
}

/* Base styles for image blocks */
.ih-post-content figure,
.ih-post-content .wp-block-image {
    margin: 24px 0;
    max-width: 100%;
}

/* Float LEFT - highest priority with !important for alignleft */
.ih-post-content figure.alignleft,
.ih-post-content .wp-block-image.alignleft {
    float: left !important;
    margin: 8px 32px 20px 0 !important;
    max-width: 40% !important;
    clear: left;
}

/* Float RIGHT */
.ih-post-content figure.alignright,
.ih-post-content .wp-block-image.alignright {
    float: right !important;
    margin: 8px 0 20px 32px !important;
    max-width: 40% !important;
    clear: right;
}

/* Center - no float */
.ih-post-content figure.aligncenter,
.ih-post-content .wp-block-image.aligncenter {
    display: block;
    margin: 32px auto;
    text-align: center;
    float: none !important;
    max-width: 100%;
}

/* Full width without alignment - no float */
.ih-post-content .wp-block-image.size-full:not(.alignleft):not(.alignright):not(.is-resized),
.ih-post-content .wp-block-image.size-large:not(.alignleft):not(.alignright) {
    float: none;
    max-width: 100%;
    margin: 32px 0;
}

/* Resized images respect their alignment */
.ih-post-content .wp-block-image.is-resized img {
    width: auto;
    height: auto;
}

/* Clear floats before headings */
.ih-post-content h1,
.ih-post-content h2,
.ih-post-content h3,
.ih-post-content h4 {
    clear: both;
}

/* Clearfix for content */
.ih-post-content::after {
    content: "";
    display: table;
    clear: both;
}

.ih-post-content figcaption {
    text-align: center;
    font-size: 14px;
    color: #888;
    margin-top: 12px;
}

.ih-post-content ul,
.ih-post-content ol {
    margin: 24px 0;
    padding-left: 28px;
    color: #3d3d3d;
}

.ih-post-content li {
    margin-bottom: 12px;
}

.ih-post-content blockquote {
    border-left: 4px solid #22c55e;
    padding: 24px 28px;
    margin: 32px 0;
    background: #f8faf8;
    border-radius: 0 16px 16px 0;
    font-style: italic;
    color: #4a4a4a;
    font-size: 17px;
}

.ih-post-content strong,
.ih-post-content b {
    color: #1a1a1a;
    font-weight: 600;
}

.ih-post-content em,
.ih-post-content i {
    color: #4a4a4a;
}

.ih-post-content code {
    background: #f4f4f5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    color: #d63384;
}

.ih-post-content pre {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    margin: 24px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.ih-post-content hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 48px 0;
}

/* ============================================
   TABLES - RESPONSIVE
   ============================================ */
.ih-post-content figure.wp-block-table,
.ih-post-content .wp-block-table {
    margin: 24px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.ih-post-content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
}

.ih-post-content th,
.ih-post-content td {
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    text-align: left;
    color: #3d3d3d;
    white-space: normal;
    word-break: break-word;
}

.ih-post-content th {
    background: #f8f8f8;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 12px;
}

.ih-post-content td {
    background: #fff;
}

.ih-post-content tr:nth-child(even) td {
    background: #fafafa;
}

/* ============================================
   PORTFOLIO SECTION OVERRIDES
   ============================================ */
.ih-post-content .pf-section {
    background: transparent !important;
    margin: 32px 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    color: #2d2d2d !important;
}

.ih-post-content .pf-section h2,
.ih-post-content .pf-section .pf-title {
    color: #1a1a1a !important;
    font-size: 24px !important;
    margin-bottom: 8px !important;
}

.ih-post-content .pf-section .pf-subtitle,
.ih-post-content .pf-section .pf-date {
    color: #6b7280 !important;
}

.ih-post-content .pf-stats {
    margin: 24px 0 !important;
}

.ih-post-content .pf-chip {
    background: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
}

.ih-post-content .pf-table-wrapper {
    margin: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

/* Default images - centered, no float */
.ih-post-content img:not(.ih-post-featured):not(.ih-author-avatar) {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 24px auto;
}

/* Figures and image blocks - centered */
.ih-post-content figure,
.ih-post-content .wp-block-image {
    margin: 24px 0;
    text-align: center;
    clear: both;
}

.ih-post-content figure img,
.ih-post-content .wp-block-image img {
    max-width: 100%;
    margin: 0 auto;
    display: block;
}

/* Content images - full width, clickable */
.ih-post-content p > img {
    max-width: 100%;
    margin: 24px auto;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ih-post-content p > img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Lightbox overlay */
.ih-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.ih-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.ih-lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    cursor: default;
}

.ih-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ih-lightbox-close:hover {
    opacity: 1;
}

/* Embedded content styling */
.ih-post-content iframe {
    max-width: 100%;
    border-radius: 12px;
    margin: 24px 0;
}

/* Custom HTML blocks in content */
.ih-post-content > div[style*="background"] {
    border-radius: 12px;
    margin: 24px 0;
}

/* ============================================
   LOCKED CONTENT
   ============================================ */
.ih-locked-content {
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 48px 36px;
    text-align: center;
    margin: 48px 0;
    position: relative;
    overflow: hidden;
}

.ih-locked-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(34, 197, 94, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.ih-locked-icon {
    font-size: 56px;
    margin-bottom: 20px;
    position: relative;
    opacity: 0.9;
}

.ih-locked-content h3 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #2d2d2d !important;
    position: relative;
}

.ih-locked-content p {
    color: #555 !important;
    margin-bottom: 28px;
    font-size: 15px;
    line-height: 1.7;
    position: relative;
}

.ih-btn-unlock {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff !important;
    padding: 14px 32px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.ih-btn-unlock:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
    color: #ffffff !important;
}

/* ============================================
   RELATED POSTS
   ============================================ */
.ih-related {
    margin-top: 80px;
    padding-top: 60px;
    border-top: 1px solid var(--border-color);
}

.ih-related h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 32px;
}

.ih-related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.ih-related-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

.ih-related-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.ih-related-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.ih-related-card-content {
    padding: 20px;
}

.ih-related-card h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

/* ============================================
   FOOTER
   ============================================ */
.ih-footer {
    padding: 40px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    position: relative;
    z-index: 1;
    margin-top: 80px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .ih-header {
        padding: 16px 20px;
    }

    .ih-nav {
        display: none;
    }

    .ih-main {
        padding: 100px 20px 60px;
    }

    .ih-post-title {
        font-size: 28px;
    }

    .ih-post-content {
        font-size: 16px;
        padding: 24px;
        border-radius: 16px;
        overflow-x: hidden;
    }

    /* Tables - horizontal scroll on mobile */
    .ih-post-content figure.wp-block-table,
    .ih-post-content .wp-block-table {
        margin-left: -24px;
        margin-right: -24px;
        padding: 0 24px;
        width: calc(100% + 48px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ih-post-content table {
        min-width: 500px;
        font-size: 12px;
    }

    .ih-post-content th,
    .ih-post-content td {
        padding: 6px 8px;
        white-space: nowrap;
    }

    /* Hint for scrollable tables */
    .ih-post-content figure.wp-block-table::after,
    .ih-post-content .wp-block-table::after {
        content: '← прокрутите →';
        display: block;
        text-align: center;
        font-size: 11px;
        color: #888;
        padding: 8px 0 0;
    }

    /* Fix inline grid layouts on mobile (e.g., stats blocks with 3 columns) */
    .ih-post-content div[style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr 1fr !important;
        font-size: 14px !important;
    }

    .ih-post-content div[style*="grid-template-columns: repeat(3"] > div {
        font-size: 14px !important;
    }

    .ih-post-content div[style*="grid-template-columns: repeat(3"] div[style*="font-size: 24px"] {
        font-size: 20px !important;
    }

    .ih-locked-content {
        padding: 40px 24px;
    }

    .ih-locked-content h3 {
        font-size: 22px;
    }

    .ih-related-grid {
        grid-template-columns: 1fr;
    }
}
