/* Text Page Specific Styles - Clean version without sidebar conflicts */

/* Fade in animations for text content */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide scrollbar but maintain scroll functionality */
html {
    overflow-x: hidden;
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

html::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

body {
    overflow-x: hidden;
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

body::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

/* CRITICAL FIX: Force scroll unlock for text pages */
body.textpage-body {
    overflow-y: auto !important;
    height: auto !important;
}

body.textpage-body.scroll-locked {
    overflow-y: auto !important;
    height: auto !important;
}

/* Override default main positioning for text pages - HIGHER SPECIFICITY */
body.textpage-body main,
.textpage-body main {
    margin-left: var(--sidebar-width, 80px) !important;
    padding: 0 !important;
    height: auto !important;
    overflow-y: visible !important;
    width: calc(100vw - var(--sidebar-width, 80px)) !important;
    box-sizing: border-box !important;
    min-height: 100vh !important;
}

/* Force main to be scrollable on text pages - HIGHER SPECIFICITY */
body.textpage-body main,
.textpage-body main {
    overflow-y: visible !important;
    height: auto !important;
}

body.textpage-body.scroll-locked main,
.textpage-body.scroll-locked main {
    overflow-y: visible !important;
    height: auto !important;
}

/* Main content container - positioned to work with sidebar with responsive scaling */
body.textpage-body .main-content,
.textpage-body .main-content {
    max-width: clamp(650px, 65vw, 900px);
    margin: clamp(40px, 6vw, 80px) auto clamp(80px, 12vw, 160px) auto;
    padding: clamp(30px, 4vw, 60px);
    line-height: 1.75;
    font-size: clamp(16px, 1.1vw + 0.5rem, 20px);
    color: #2c2c2c;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    width: calc(100% - clamp(120px, 15vw, 200px));
    box-sizing: border-box;
    margin-left: clamp(120px, 12vw, 200px) !important;
    margin-right: clamp(40px, 8vw, 120px) !important;
}

/* Page Header Styles with responsive scaling */
.page-header {
    margin-bottom: clamp(36px, 5vw, 64px);
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.2s forwards;
}

/* Title styling with responsive scaling */
.page-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.2rem, 3.5vw + 1rem, 4.5rem);
    font-weight: 300;
    color: #1a1a1a;
    margin-bottom: clamp(6px, 1vw, 12px);
    line-height: 1.3;
    letter-spacing: -0.02em;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.3s forwards;
}

/* Subtitle/meta information with responsive scaling */
.page-subtitle {
    font-size: clamp(15px, 1.2vw + 0.4rem, 20px);
    color: #555;
    margin-bottom: clamp(12px, 1.5vw, 20px);
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.5;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.4s forwards;
}

/* Date styling with responsive scaling */
.page-date {
    font-size: clamp(12px, 1vw + 0.3rem, 16px);
    color: #888;
    margin-bottom: 0;
    font-weight: 300;
    display: block;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.5s forwards;
}

/* Page Content Container */
.page-content {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.6s forwards;
}

/* Paragraph styling with responsive scaling */
.main-content p {
    margin-bottom: clamp(20px, 2.5vw, 32px);
    text-align: left;
    font-size: clamp(16px, 1.1vw + 0.5rem, 20px);
    line-height: 1.75;
    color: #2c2c2c;
    word-wrap: break-word;
}

.page-content p:first-child {
    margin-top: 0;
}

.page-content p:last-child {
    margin-bottom: 0;
}

/* Text selection styling */
.main-content ::selection {
    background-color: rgba(0, 0, 0, 0.1);
    color: inherit;
}

/* Focus styles for accessibility */
.main-content:focus {
    outline: none;
}

/* Large Desktop optimizations (1440px and up) */
@media (min-width: 1440px) {
    body.textpage-body .main-content,
    .textpage-body .main-content {
        max-width: clamp(750px, 55vw, 1000px);
        margin-left: clamp(150px, 10vw, 220px) !important;
        margin-right: clamp(60px, 6vw, 120px) !important;
        padding: clamp(50px, 4vw, 80px);
    }
}

/* Ultra-wide screens (1920px and up) */
@media (min-width: 1920px) {
    body.textpage-body .main-content,
    .textpage-body .main-content {
        max-width: clamp(850px, 50vw, 1200px);
        margin-left: clamp(180px, 12vw, 300px) !important;
        margin-right: clamp(80px, 8vw, 200px) !important;
    }
}

/* Responsive adjustments for text pages - HIGHER SPECIFICITY */
@media (max-width: 1439px) and (min-width: 1025px) {
    body.textpage-body main,
    .textpage-body main {
        margin-left: var(--sidebar-width, 80px) !important;
        width: calc(100vw - var(--sidebar-width, 80px)) !important;
    }
    
    body.textpage-body .main-content,
    .textpage-body .main-content {
        margin-left: clamp(140px, 11vw, 180px) !important;
        margin-right: clamp(50px, 6vw, 100px) !important;
        width: calc(100% - clamp(190px, 17vw, 280px));
    }
}

@media (max-width: 1024px) {
    body.textpage-body main,
    .textpage-body main {
        margin-left: var(--sidebar-width, 60px) !important;
        width: calc(100vw - var(--sidebar-width, 60px)) !important;
    }
    
    body.textpage-body .main-content,
    .textpage-body .main-content {
        margin-left: clamp(100px, 10vw, 140px) !important;
        margin-right: clamp(30px, 4vw, 60px) !important;
        width: calc(100% - clamp(130px, 14vw, 200px));
        font-size: clamp(15px, 1.2vw + 0.5rem, 18px);
    }
    
    .page-title {
        font-size: clamp(2rem, 4vw + 0.5rem, 3.8rem);
    }
    
    .main-content p {
        font-size: clamp(15px, 1.2vw + 0.5rem, 18px);
        margin-bottom: clamp(18px, 2.2vw, 28px);
    }
}

@media (max-width: 768px) {
    body.textpage-body main,
    .textpage-body main {
        margin-left: var(--sidebar-width, 50px) !important;
        width: calc(100vw - var(--sidebar-width, 50px)) !important;
    }
    
    body.textpage-body .main-content,
    .textpage-body .main-content {
        max-width: clamp(500px, 85vw, 650px);
        width: calc(100% - clamp(80px, 12vw, 120px));
        margin: clamp(30px, 4vw, 50px) auto clamp(60px, 8vw, 100px) clamp(70px, 10vw, 110px) !important;
        padding: clamp(20px, 3vw, 35px) clamp(18px, 2.5vw, 30px);
        font-size: clamp(14px, 2vw + 0.6rem, 16px);
    }
    
    .page-header {
        margin-bottom: clamp(28px, 4vw, 42px);
    }
    
    .page-title {
        font-size: clamp(1.8rem, 5vw + 0.5rem, 2.4rem);
        margin-bottom: clamp(4px, 0.8vw, 8px);
    }
    
    .page-subtitle {
        font-size: clamp(13px, 2.2vw + 0.4rem, 16px);
        margin-bottom: clamp(10px, 1.5vw, 15px);
    }
    
    .page-date {
        font-size: clamp(11px, 1.8vw + 0.3rem, 14px);
        margin-bottom: 0;
    }
    
    .page-content p {
        font-size: clamp(14px, 2vw + 0.6rem, 16px);
        line-height: 1.7;
        margin-bottom: clamp(16px, 2vw, 24px);
    }
}

@media (max-width: 480px) {
    body.textpage-body main,
    .textpage-body main {
        margin-left: var(--sidebar-width, 45px) !important;
        width: calc(100vw - var(--sidebar-width, 45px)) !important;
    }
    
    body.textpage-body .main-content,
    .textpage-body .main-content {
        width: calc(100% - clamp(60px, 8vw, 85px));
        margin: clamp(20px, 3vw, 35px) auto clamp(40px, 6vw, 70px) clamp(55px, 8vw, 75px) !important;
        padding: clamp(15px, 2.5vw, 25px);
        font-size: clamp(13px, 2.5vw + 0.5rem, 15px);
    }
    
    .page-header {
        margin-bottom: clamp(20px, 3vw, 32px);
    }
    
    .page-title {
        font-size: clamp(1.5rem, 6vw + 0.5rem, 2rem);
    }
    
    .page-subtitle {
        font-size: clamp(12px, 2.5vw + 0.3rem, 15px);
    }
    
    .page-content p {
        font-size: clamp(13px, 2.5vw + 0.5rem, 15px);
        line-height: 1.65;
        margin-bottom: clamp(14px, 2vw, 20px);
    }
}

@media (max-width: 360px) {
    body.textpage-body main,
    .textpage-body main {
        margin-left: var(--sidebar-width, 40px) !important;
        width: calc(100vw - var(--sidebar-width, 40px)) !important;
    }
    
    body.textpage-body .main-content,
    .textpage-body .main-content {
        margin-left: clamp(45px, 6vw, 65px) !important;
        margin-right: clamp(15px, 2vw, 25px) !important;
        width: calc(100% - clamp(60px, 8vw, 90px));
    }
}

/* Print styles */
@media print {
    .main-content {
        max-width: none;
        padding: 0;
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }
    
    .page-title {
        font-size: 18pt;
        margin-bottom: 12pt;
    }
    
    .page-subtitle,
    .page-date {
        font-size: 10pt;
    }
    
    .page-content p {
        margin-bottom: 12pt;
        font-size: 12pt;
        line-height: 1.6;
    }
    
    /* Hide animations in print */
    .page-header,
    .page-title,
    .page-subtitle,
    .page-date,
    .page-content {
        animation: none !important;
        opacity: 1 !important;
    }
    
    /* Remove left margins in print for better use of space */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}