/* Custom styles to complement Tailwind CSS */

/* Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #87A96B, #6B8E50);
    z-index: 9999;
    transition: width 0.1s ease-out;
    opacity: 0;
    pointer-events: none;
}

.reading-progress-bar.visible {
    opacity: 1;
}

/* Search Styles */
.search-container {
    position: relative;
    flex-shrink: 0;
}

.search-input {
    font-family: 'Inter', sans-serif;
    font-size: 0.813rem;
    padding: 0.5rem 1rem;
    border: 1px solid #E5E5E5;
    border-radius: 20px;
    background: transparent;
    color: #333333;
    width: 140px;
    transition: width 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #87A96B;
    background: #FDFBF7;
    width: 200px;
}

.search-input::placeholder {
    color: #333333;
    opacity: 0.4;
}

@media (max-width: 640px) {
    .search-input {
        width: 100%;
        max-width: 200px;
    }
    .search-input:focus {
        width: 100%;
        max-width: 200px;
    }
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #FDFBF7;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #E5E5E5;
    transition: background-color 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: rgba(135, 169, 107, 0.1);
}

.search-result-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.938rem;
    font-weight: 500;
    color: #333333;
    margin-bottom: 0.25rem;
}

.search-result-summary {
    font-family: 'Inter', sans-serif;
    font-size: 0.813rem;
    color: #333333;
    opacity: 0.6;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #333333;
    opacity: 0.5;
}

/* Tags Styles */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.tag-pill {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(135, 169, 107, 0.15);
    color: #5A7A4A;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tag-pill:hover {
    background: rgba(135, 169, 107, 0.3);
    color: #3D5232;
}

.tag-pill.active {
    background: #87A96B;
    color: #FDFBF7;
}

/* Post card tags */
.post-card .tags-container {
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Table of Contents Styles */
.toc-container {
    margin-top: 3rem;
    padding: 1.5rem;
    background: rgba(245, 245, 245, 0.5);
    border-radius: 8px;
    border: 1px solid #E5E5E5;
}

.toc-container.hidden {
    display: none;
}

.toc-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #333333;
    opacity: 0.6;
    margin-bottom: 1rem;
}

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

.toc-nav li {
    margin-bottom: 0.5rem;
}

.toc-nav li.toc-h3 {
    padding-left: 1rem;
}

.toc-nav a {
    font-family: 'Inter', sans-serif;
    font-size: 0.938rem;
    color: #333333;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.15s ease, color 0.15s ease;
    display: block;
    line-height: 1.5;
}

.toc-nav a:hover {
    opacity: 1;
    color: #87A96B;
}

/* Related Posts Styles */
.related-posts-container {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #E5E5E5;
}

.related-posts-container.hidden {
    display: none;
}

.related-posts-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #333333;
    opacity: 0.6;
    margin-bottom: 1.5rem;
}

.related-posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.related-post-card {
    padding: 1rem;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.related-post-card:hover {
    border-color: #87A96B;
    background-color: rgba(135, 169, 107, 0.05);
}

.related-post-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.related-post-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: #333333;
    opacity: 0.5;
}

/* Page transitions */
.page {
    display: none !important;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page.active {
    display: block !important;
    opacity: 1;
}

.page.hidden {
    display: none !important;
    opacity: 0;
}

/* Ensure Tailwind hidden class doesn't interfere with page visibility */
.hidden.page.active {
    display: block !important;
    opacity: 1;
}


/* Word Cloud Styles - Random Cloud Layout */
#word-cloud {
    position: relative;
    width: 100%;
    min-height: 300px;
}

@media (min-width: 768px) {
    #word-cloud {
        min-height: 360px;
    }
}

.word-cloud-item {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    user-select: none;
    font-family: 'Playfair Display', Georgia, serif;
    line-height: 1.2;
    white-space: nowrap;
    color: #333333;
}

.word-cloud-item:hover {
    color: #87A96B;
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1 !important;
}

/* Post Card Styles - Editorial */
.post-card {
    padding: 0;
    border-bottom: 1px solid rgba(229, 229, 229, 0.6);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    padding-bottom: 2.5rem;
}

.post-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.post-card:hover {
    transform: translateX(4px);
}

.post-card:hover h3 {
    color: #87A96B;
}

/* Serif title - large and bold */
.post-card h3 {
    font-family: 'Playfair Display', 'Noto Serif SC', Georgia, 'SimSun', 'STSong', serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.5rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

/* Sans-serif excerpt - clean and readable */
.post-card .post-excerpt {
    font-family: 'Inter', sans-serif;
    font-size: 0.938rem;
    color: #333333;
    opacity: 0.55;
    line-height: 1.7;
    margin-bottom: 0.75rem;
    font-weight: 400;
}

/* Date - small and subtle */
.post-card .post-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: #333333;
    opacity: 0.35;
    font-weight: 400;
    letter-spacing: 0.03em;
}

/* Section label - subtle accent */
.post-card .post-section {
    font-family: 'Inter', sans-serif;
    font-size: 0.688rem;
    color: #87A96B;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.5rem;
    font-weight: 500;
    opacity: 0.85;
}

/* Section Card Styles */
.section-card {
    padding: 2.5rem 0;
    border-bottom: 1px solid #E5E5E5;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.section-card:hover {
    padding-left: 1rem;
}

.section-card h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-card p {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: #333333;
    opacity: 0.6;
    line-height: 1.8;
}

/* Post Article Styles - Modern Readable Layout */
.post-article {
    font-family: 'Inter', sans-serif;
    color: #333333;
}

/* Post Header */
.post-article .post-header {
    margin-bottom: 3rem;
}

.post-article .post-section-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: #87A96B;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    font-weight: 600;
}

.post-article .post-title {
    font-family: 'Playfair Display', 'Noto Serif SC', Georgia, 'SimSun', 'STSong', serif;
    font-size: 3rem;
    font-weight: 700;
    color: #333333;
    margin-bottom: 1.5rem;
    line-height: 1.4;
    letter-spacing: 0;
}

.post-article .post-meta {
    font-family: 'Inter', sans-serif;
    font-size: 0.938rem;
    color: #333333;
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
}

.post-article .post-reading-time {
    opacity: 0.5;
}

/* Post Body - Typography */
.post-article .post-body {
    font-size: 1.125rem; /* 18px */
    line-height: 1.75;
    color: #333333;
}

.post-article .post-body p {
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* Heading 1 - Largest, bold serif */
.post-article .post-body h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #333333;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Heading 2 - Large serif */
.post-article .post-body h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 600;
    color: #333333;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

/* Heading 3 - Medium serif (different from h2) */
.post-article .post-body h3 {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 1.625rem;
    font-weight: 700;
    color: #333333;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Heading 4 - Sans-serif transition */
.post-article .post-body h4 {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333333;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

/* Heading 5 - Smaller sans-serif */
.post-article .post-body h5 {
    font-family: 'Inter', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: #333333;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Heading 6 - Smallest sans-serif */
.post-article .post-body h6 {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #333333;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Links */
.post-article .post-body a {
    color: #333333;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: opacity 0.2s ease;
}

.post-article .post-body a:hover {
    opacity: 0.7;
}

/* Lists */
.post-article .post-body ul,
.post-article .post-body ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-article .post-body ul {
    list-style-type: disc;
}

.post-article .post-body ol {
    list-style-type: decimal;
}

.post-article .post-body li {
    margin-bottom: 0.5rem;
    line-height: 1.75;
}

.post-article .post-body li > ul,
.post-article .post-body li > ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Blockquotes */
.post-article .post-body blockquote {
    border-left: 4px solid #E5E5E5;
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: #666666;
    font-size: 1.063rem;
    line-height: 1.75;
}

.post-article .post-body blockquote p {
    margin-bottom: 0;
}

.post-article .post-body blockquote p:last-child {
    margin-bottom: 0;
}

/* Code Blocks */
.post-article .post-body pre {
    background-color: #f5f5f5;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    padding: 1.25rem;
    margin: 2rem 0;
    overflow-x: auto;
    font-size: 0.938rem;
    line-height: 1.6;
}

.post-article .post-body pre code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    background: none;
    padding: 0;
    border: none;
    font-size: inherit;
    color: #333333;
}

/* Inline Code */
.post-article .post-body code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.938rem;
    background-color: #f5f5f5;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    color: #333333;
}

.post-article .post-body pre code {
    background: none;
    padding: 0;
}

/* Images */
.post-article .post-images {
    margin: 2.5rem 0;
}

.post-article .post-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    display: block;
}

/* Inline images in post body (from markdown) */
.post-article .post-body img,
.post-article .post-body .post-body-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 2rem auto;
    display: block;
}

/* Horizontal Rules */
.post-article .post-body hr {
    border: none;
    border-top: 1px solid #E5E5E5;
    margin: 2.5rem 0;
}

/* Strong and Emphasis */
.post-article .post-body strong {
    font-weight: 600;
    color: #333333;
}

.post-article .post-body em {
    font-style: italic;
}

/* Post Navigation */
.post-nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.post-nav-link {
    display: block;
    padding: 1.5rem;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    text-decoration: none;
    color: #333333;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.post-nav-link:hover {
    border-color: #333333;
    background-color: #fafafa;
}

.post-nav-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666666;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.post-nav-title {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: #333333;
    line-height: 1.5;
}

.post-nav-next {
    text-align: right;
}

/* Introduction Content - Matches Post Article Styling */
/* Uses .post-article and .post-body classes - inherits all styles from post styling */

/* Move introduction title higher but with some space */
#introduction-content-display .post-body h1:first-child,
#introduction-content-display .post-body h2:first-child {
    margin-top: 0.5rem;
}

/* Multi-line clamp utility (Tailwind CDN doesn't guarantee line-clamp plugin) */
.line-clamp-4 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

/* Gallery Card Styles - Flip Card */
.gallery-card-container {
    perspective: 1000px;
}

.gallery-card-inner {
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.gallery-card-container.flipped .gallery-card-inner {
    transform: rotateY(180deg);
}

.gallery-card-front,
.gallery-card-back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.gallery-card-front {
    position: relative;
}

.gallery-card-back {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: rotateY(180deg);
}

.gallery-card-container:hover .gallery-card-inner {
    transform: translateY(-4px);
}

.gallery-card-container.flipped:hover .gallery-card-inner {
    transform: rotateY(180deg) translateY(-4px);
}

.gallery-card-front h3,
.gallery-card-back h3 {
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .gallery-card-front h3,
    .gallery-card-back h3 {
        font-size: 1rem;
    }
}

.gallery-comment {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.8rem;
    font-style: italic;
    font-weight: 400;
    color: rgba(51, 51, 51, 0.65);
    line-height: 1.7;
    letter-spacing: 0.01em;
    text-align: center;
    padding: 0 0.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 6rem 2rem;
    color: #333333;
    opacity: 0.4;
    font-family: 'Inter', sans-serif;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 4rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #333333;
    background: transparent;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #333333;
    color: #FDFBF7;
    border-color: #333333;
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #333333;
    color: #FDFBF7;
    border-color: #333333;
}

/* Navigation Active State */
.nav-link {
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.nav-link.active {
    color: #333333;
    border-bottom: 2px solid #87A96B;
}

.nav-link:hover {
    border-bottom: 2px solid #E5E5E5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .post-card h3 {
        font-size: 1.5rem;
    }

    .section-card h3 {
        font-size: 1.5rem;
    }

    .post-article .post-title {
        font-size: 2rem;
    }

    .post-article .post-body h1 {
        font-size: 1.75rem;
    }

    .post-article .post-body h2 {
        font-size: 1.5rem;
    }

    .post-article .post-body h3 {
        font-size: 1.375rem;
    }

    .post-article .post-body h4 {
        font-size: 1.125rem;
    }

    .post-article .post-body h5 {
        font-size: 1rem;
    }

    .post-article .post-body h6 {
        font-size: 0.938rem;
    }

    .post-article .post-body {
        font-size: 1.063rem; /* 17px on mobile */
    }

    .post-nav-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .post-nav-next {
        text-align: left;
    }

    /* Mobile header adjustments */
    .nav-link {
        font-size: 0.75rem;
        letter-spacing: 0.08em;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .post-card h3 {
        font-size: 1.375rem;
    }

    .post-card .post-excerpt {
        font-size: 0.875rem;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
