/* ===================================
   PAGE TEMPLATE - RIVERSIDE STYLE WITH ALL FEATURES
   Three-column layout: TOC | Content | CTA Sidebar
   =================================== */

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dark-mode-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dark-mode-toggle .sun-icon,
.dark-mode-toggle .moon-icon {
    color: #495057;
    transition: opacity 0.2s ease;
}

.dark-mode-toggle .moon-icon {
    display: none;
}

/* Dark mode active state */
body.dark-mode .dark-mode-toggle {
    background: #2d3748;
}

body.dark-mode .dark-mode-toggle .sun-icon {
    display: none;
}

body.dark-mode .dark-mode-toggle .moon-icon {
    display: block;
    color: #f7fafc;
}

/* Search Toggle */
.search-toggle {
    position: fixed;
    top: 20px;
    right: 80px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #495057;
}

.search-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #3d81f6 0%, #3d81f6 100%);
    z-index: 9999;
    transition: width 0.1s ease;
}

/* Riverside Header */
.riverside-header {
    background: #f8f9fa;
    color: #212529;
    padding: 2rem 0 3rem 0;
    position: relative;
    border-bottom: 1px solid #e9ecef;
}

.riverside-header__container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Breadcrumbs */
.riverside-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.breadcrumb-link {
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb-link:hover {
    color: #3d81f6;
}

.breadcrumb-separator {
    color: #adb5bd;
}

.breadcrumb-current {
    color: #212529;
    font-weight: 500;
}

/* Header Content Layout */
.riverside-header__content {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
}

.riverside-header__main {
    flex: 1;
    max-width: 600px;
}

/* Page Title */
.riverside-title {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 1.5rem 0;
    color: #212529;
}

/* Page Subtitle */
.riverside-subtitle {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #6c757d;
    margin-bottom: 2rem;
}

/* Meta Information */
.riverside-meta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.riverside-author-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.riverside-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e9ecef;
}

.riverside-author-details {
    display: flex;
    flex-direction: column;
}

.riverside-author-name {
    font-weight: 600;
    color: #212529;
    font-size: 0.9375rem;
}

.riverside-author-title {
    font-size: 0.8125rem;
    color: #6c757d;
}

.riverside-dates {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.riverside-date-separator {
    color: #adb5bd;
}

/* Featured Image */
.riverside-featured-image {
    flex-shrink: 0;
    width: 400px;
    height: 250px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.riverside-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile TOC Slider */
.mobile-toc-slider {
    display: none;
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
    position: relative; /* Use relative positioning by default */
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    width: 100%;
    margin: 0;
}

.mobile-toc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.mobile-toc-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.5rem;
}

.mobile-toc-scroll::-webkit-scrollbar {
    display: none;
}

.mobile-toc-item {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mobile-toc-item:hover {
    background: #e9ecef;
    color: #495057;
    text-decoration: none;
}

.mobile-toc-item.active {
    background: #3d81f6;
    color: white;
    border-color: #3d81f6;
}

/* Show mobile TOC on smaller screens */
@media (max-width: 1024px) {
    .mobile-toc-slider {
        display: block;
        top: 0; /* Reset to top for mobile */
        position: relative; /* Change from sticky to relative on mobile */
        z-index: 999;
    }
}

@media (max-width: 768px) {
    .mobile-toc-slider {
        top: 0;
        position: relative;
        margin-top: 0;
        padding-top: 1rem;
    }
}

/* Three-Column Content Wrapper */
.riverside-content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    gap: 2rem;
    align-items: start;
}

/* Table of Contents (Left Sidebar) */
.table-of-contents {
    position: sticky;
    top: 2rem;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.toc-header {
    margin-bottom: 1rem;
}

.toc-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #212529;
}

.toc-nav {
    font-size: 0.875rem;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
}

.toc-item--level-2 {
    margin-left: 0;
}

.toc-item--level-3 {
    margin-left: 1rem;
}

.toc-item--level-4 {
    margin-left: 2rem;
}

.toc-link {
    display: block;
    padding: 0.5rem 0;
    color: #495057;
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.75rem;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.toc-link:hover {
    color: #3d81f6;
    border-left-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.toc-link.active {
    color: #3d81f6;
    border-left-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    font-weight: 600;
}

/* Content Container */
.riverside-content-container {
    display: contents;
}

/* Main Content */
.riverside-content {
    min-width: 0;
}

.riverside-content-inner {
    font-size: 1.125rem;
    line-height: 1.7;
    color: #212529;
}

.riverside-content-inner h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem 0;
    color: #212529;
    scroll-margin-top: 2rem;
}

.riverside-content-inner h3 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem 0;
    color: #212529;
    scroll-margin-top: 2rem;
}

.riverside-content-inner h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem 0;
    color: #212529;
    scroll-margin-top: 2rem;
}

.riverside-content-inner p {
    margin-bottom: 1.5rem;
    color: #212529;
}

.riverside-content-inner ul,
.riverside-content-inner ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    color: #212529;
}

.riverside-content-inner li {
    margin-bottom: 0.5rem;
    color: #212529;
}

.riverside-content-inner blockquote {
    border-left: 4px solid #667eea;
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: #6c757d;
}

.riverside-content-inner img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.riverside-content-inner code {
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e83e8c;
}

.riverside-content-inner pre {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.riverside-content-inner pre code {
    background: none;
    padding: 0;
    color: #212529;
}

/* Persistent Sidebar (Right) */
.riverside-sidebar {
    position: sticky;
    top: 2rem;
}

.riverside-cta-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    color: #212529;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.riverside-cta-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 1rem 0;
    color: #212529;
}

.riverside-cta-description {
    color: #6c757d;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.riverside-cta-button {
    display: block;
    width: 100%;
    background: #22c55d;
    color: white;
    text-align: center;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease;
    margin-bottom: 2rem;
}

.riverside-cta-button:hover {
    background: #16a34a;
    text-decoration: none;
    color: white;
}

/* Subtle Share Buttons */
.riverside-share {
    border-top: 1px solid #e9ecef;
    padding-top: 1.5rem;
}

.riverside-share-label {
    display: block;
    font-size: 0.8125rem;
    color: #3d81f6;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.riverside-share-buttons {
    display: flex;
    gap: 0.5rem;
}

.riverside-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f8f9fa;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    cursor: pointer;
}

.riverside-share-btn:hover {
    background: #3d81f6;
    color: white;
    border-color: #3d81f6;
    transform: translateY(-1px);
}

/* Newsletter Section */
.riverside-newsletter {
    background: #f8f9fa;
    padding: 3rem 0;
    margin: 3rem 0;
}

.riverside-newsletter__container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.riverside-newsletter__icon {
    background: linear-gradient(135deg, #22c55d 0%, #3d81f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.riverside-newsletter__title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: #212529;
}

.riverside-newsletter__description {
    color: #6c757d;
    margin-bottom: 2rem;
    font-size: 1.125rem;
}

.riverside-newsletter__form {
    display: flex;
    gap: 0.75rem;
    max-width: 400px;
    margin: 0 auto;
}

.riverside-newsletter__input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
}

.riverside-newsletter__input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.riverside-newsletter__button {
    background: #212529;
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.riverside-newsletter__button:hover {
    background: #495057;
}

/* Author Box - Bottom */
.riverside-author-box {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem auto;
    max-width: 800px;
    position: relative;
}

.riverside-author-box__container {
    margin: 0 1.5rem;
}

.riverside-author-box__content {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.riverside-author-box__avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid #e9ecef;
}

.riverside-author-box__info {
    flex: 1;
}

.riverside-author-box__name {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: #212529;
}

.riverside-author-box__bio {
    line-height: 1.6;
    color: #495057;
    margin: 0;
}

/* Related Articles */
.riverside-related {
    margin: 4rem 0;
}

.riverside-related__container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.riverside-related__title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 3rem 0;
    color: #212529;
}

.riverside-related__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.riverside-related__card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.riverside-related__card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.riverside-related__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.riverside-related__image {
    height: 200px;
    overflow: hidden;
}

.riverside-related__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.riverside-related__content {
    padding: 1.5rem;
}

.riverside-related__card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: #212529;
    line-height: 1.3;
}

.riverside-related__excerpt {
    color: #6c757d;
    line-height: 1.5;
    margin: 0;
}

/* Mobile Responsiveness */
@media (max-width: 1200px) {
    .riverside-content-wrapper {
        grid-template-columns: 240px minmax(0, 1fr) 280px;
        gap: 1.5rem;
        max-width: 1200px;
    }
    
    .table-of-contents {
        padding: 1rem;
    }
    
    .riverside-cta-card {
        padding: 1.5rem;
    }
}

@media (max-width: 1024px) {
    .riverside-content-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
        max-width: 800px;
    }
    
    .table-of-contents {
        display: none;
    }
    
    .mobile-toc {
        display: block;
    }
    
    .riverside-sidebar {
        position: static;
        order: -1;
        max-width: 400px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .riverside-header {
        padding: 1.5rem 0 2rem 0;
    }
    
    .riverside-header__container {
        padding: 0 1rem;
    }
    
    .riverside-header__content {
        flex-direction: column;
        gap: 2rem;
    }
    
    .riverside-featured-image {
        width: 100%;
        height: 200px;
        order: -1;
    }
    
    .riverside-title {
        font-size: 2rem;
    }
    
    .riverside-subtitle {
        font-size: 1.125rem;
    }
    
    .riverside-content-wrapper {
        padding: 2rem 1rem;
    }
    
    .riverside-content-inner {
        font-size: 1rem;
    }
    
    .riverside-author-box__content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .riverside-author-box__avatar {
        margin: 0 auto;
    }
    
    .riverside-newsletter__form {
        flex-direction: column;
    }
    
    .riverside-related__grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-toc-list {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .riverside-header {
        padding: 1rem 0 1.5rem 0;
    }
    
    .riverside-title {
        font-size: 1.75rem;
    }
    
    .riverside-author-box {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
    
    .riverside-author-box__container {
        margin: 0;
    }
}

/* Dark Mode Support - Minimal overrides only */
@media (prefers-color-scheme: dark) {
    /* Force TOC to stay light even in dark mode */
    .table-of-contents {
        background: white !important;
        border-color: #e9ecef !important;
    }
    
    .toc-header h3 {
        color: #212529 !important;
    }
    
    .toc-link {
        color: #495057 !important;
    }
    
    .toc-link:hover {
        color: #3d81f6 !important;
        background: rgba(102, 126, 234, 0.05) !important;
    }
    
    .toc-link.active {
        color: #3d81f6 !important;
        background: rgba(102, 126, 234, 0.1) !important;
    }
}

/* Print Styles */
@media print {
    .riverside-sidebar,
    .riverside-newsletter,
    .table-of-contents,
    .mobile-toc,
    .reading-progress-bar {
        display: none;
    }
    
    .riverside-header {
        background: white;
        color: black;
    }
    
    .riverside-title,
    .riverside-author-name {
        color: black;
    }
    
    .riverside-content-wrapper {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
}

