/* ========================================
   JOURNAL PAGE STYLES
   ======================================== */

/* Variables */
:root {
    --primary-teal: #2DBEC1;
    --primary-teal-light: #4DCACF;
    --primary-teal-dark: #1A9B9F;
    --secondary-beige: #F4E7D6;
    --secondary-beige-dark: #E8D5C0;
    --accent-coral: #FF6B6B;
    --accent-sage: #95A99C;
    --text-dark: #2C3E50;
    --text-medium: #546E7A;
    --text-light: #78909C;
    --background-white: #FFFFFF;
    --background-cream: #FEFCF8;
    --shadow-light: 0 2px 20px rgba(45, 190, 193, 0.1);
    --shadow-medium: 0 8px 30px rgba(45, 190, 193, 0.15);
    --shadow-heavy: 0 15px 50px rgba(45, 190, 193, 0.2);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--background-cream);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   HERO SECTION
   ======================================== */

.journal-hero {
    position: relative;
    min-height: 40vh;
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--primary-teal-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: 80px; /* Account for header */
}

.journal-hero__content {
    position: relative;
    z-index: 3;
    text-align: center;
    color: white;
    max-width: 600px;
    padding: 20px;
}

.journal-hero__title {
    font-family: 'Cormorant', serif;
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 500;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 1s ease-out 0.3s forwards;
}

.journal-hero__subtitle {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 400;
    opacity: 0.9;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 1s ease-out 0.6s forwards;
}

/* Wave SVG and Floating Books */
.wave-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    z-index: 1;
    pointer-events: none;
}

.wave-path {
    opacity: 0.8;
}

.wave-path-1 {
    animation: waveFlow1 8s ease-in-out infinite;
}

.wave-path-2 {
    animation: waveFlow2 10s ease-in-out infinite;
    animation-delay: -2s;
}

.wave-path-3 {
    animation: waveFlow3 12s ease-in-out infinite;
    animation-delay: -4s;
}

.floating-books {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.floating-wave-book {
    position: absolute;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    animation: bookFloat 6s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(45, 190, 193, 0.3);
}

/* Books positioned along the wave paths */
.book-wave-1 {
    left: 15%;
    top: 30%;
    animation-delay: 0s;
    font-size: 1.4rem;
}

.book-wave-2 {
    left: 50%;
    top: 25%;
    animation-delay: -2s;
    font-size: 1rem;
}

.book-wave-3 {
    left: 80%;
    top: 35%;
    animation-delay: -4s;
    font-size: 1.3rem;
}

/* Books in Wave Path 2 */
.book-wave-4 {
    left: 10%;
    top: 50%;
    animation-delay: -1s;
    font-size: 1.1rem;
}

.book-wave-5 {
    left: 60%;
    top: 45%;
    animation-delay: -3s;
    font-size: 1.5rem;
}

.book-wave-6 {
    left: 90%;
    top: 55%;
    animation-delay: -5s;
    font-size: 0.9rem;
}

/* Books in Wave Path 3 */
.book-wave-7 {
    left: 25%;
    top: 70%;
    animation-delay: -2.5s;
    font-size: 1.2rem;
}

.book-wave-8 {
    left: 70%;
    top: 75%;
    animation-delay: -4.5s;
    font-size: 1.6rem;
}

/* Wave Flow Animations for SVG paths */
@keyframes waveFlow1 {
    0%, 100% {
        transform: translateX(0px) translateY(0px);
        opacity: 0.8;
    }
    25% {
        transform: translateX(-5px) translateY(-3px);
        opacity: 0.9;
    }
    50% {
        transform: translateX(8px) translateY(-2px);
        opacity: 0.7;
    }
    75% {
        transform: translateX(-3px) translateY(-5px);
        opacity: 0.85;
    }
}

@keyframes waveFlow2 {
    0%, 100% {
        transform: translateX(0px) translateY(0px);
        opacity: 0.8;
    }
    33% {
        transform: translateX(6px) translateY(3px);
        opacity: 0.6;
    }
    66% {
        transform: translateX(-4px) translateY(-4px);
        opacity: 0.9;
    }
}

@keyframes waveFlow3 {
    0%, 100% {
        transform: translateX(0px) translateY(0px);
        opacity: 0.8;
    }
    40% {
        transform: translateX(-6px) translateY(2px);
        opacity: 0.7;
    }
    80% {
        transform: translateX(4px) translateY(-3px);
        opacity: 0.85;
    }
}

/* Book Floating Animation */
@keyframes bookFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg) scale(1);
        opacity: 0.15;
    }
    25% {
        transform: translateY(-8px) rotate(5deg) scale(1.1);
        opacity: 0.25;
    }
    50% {
        transform: translateY(-15px) rotate(-3deg) scale(0.95);
        opacity: 0.3;
    }
    75% {
        transform: translateY(-5px) rotate(2deg) scale(1.05);
        opacity: 0.2;
    }
}

@keyframes floatingWave {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.1;
    }
    25% {
        transform: translateY(-15px) rotate(5deg);
        opacity: 0.2;
    }
    50% {
        transform: translateY(-25px) rotate(-3deg);
        opacity: 0.15;
    }
    75% {
        transform: translateY(-10px) rotate(2deg);
        opacity: 0.18;
    }
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   FILTER NAVIGATION
   ======================================== */

.journal-filters {
    background: var(--background-white);
    padding: 2rem 0;
    border-bottom: 1px solid rgba(45, 190, 193, 0.1);
    position: sticky;
    top: 80px;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.filter-nav {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-btn {
    background: transparent;
    border: 2px solid var(--primary-teal);
    color: var(--primary-teal);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-teal);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* ========================================
   JOURNAL CONTENT
   ======================================== */

.journal-content {
    padding: 4rem 0;
}

.journal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 3rem;
    margin-bottom: 4rem;
    justify-content: center; /* Center items when there are fewer than full width */
}

/* When there's only one non-featured item, limit its width */
.journal-grid:has(.journal-article:only-child:not(.featured)) {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Better handling for single featured article */
.journal-grid:has(.journal-article.featured:only-child) .journal-article.featured {
    max-width: 1000px;
    margin: 0 auto;
}

/* Better layout for few items (2-3 articles) */
.journal-grid.few-items {
    justify-content: center;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

/* Article Cards */
.journal-article {
    background: var(--background-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
    opacity: 0;
    transform: translateY(30px);
}

.journal-article.visible {
    opacity: 1;
    transform: translateY(0);
}

.journal-article:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-heavy);
}

.article-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.journal-article:hover .article-image img {
    transform: scale(1.05);
}

.article-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--primary-teal);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-read-time {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-dark);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.article-content {
    padding: 2rem;
}

.article-title {
    font-family: 'Cormorant', serif;
    font-size: 1.6rem;
    font-weight: 500;
    margin-bottom: 1rem;
    line-height: 1.3;
    color: var(--text-dark);
}

.article-excerpt {
    color: var(--text-medium);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(45, 190, 193, 0.1);
}

.article-date {
    color: var(--text-light);
    font-size: 0.9rem;
}

.article-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-medium);
    font-size: 0.9rem;
    font-weight: 500;
}

.article-author::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary-teal);
    border-radius: 50%;
}

/* Featured Article */
.journal-article.featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    max-width: 100%;
}

/* Better layout for single featured articles */
.journal-grid.single-item .journal-article.featured {
    max-width: 900px;
    margin: 0 auto;
}

/* Better layout for single regular articles */
.journal-grid.single-item .journal-article:not(.featured) {
    max-width: 500px;
    margin: 0 auto;
}

.journal-article.featured .article-image {
    height: 400px;
}

.journal-article.featured .article-content {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.journal-article.featured .article-title {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.journal-article.featured .article-excerpt {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* ========================================
   LOAD MORE BUTTON
   ======================================== */

.load-more-container {
    text-align: center;
}

.load-more-btn {
    background: linear-gradient(135deg, var(--primary-teal), var(--primary-teal-light));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Montserrat', sans-serif;
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   ARTICLE MODAL
   ======================================== */

.article-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.article-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background-white);
    border-radius: var(--border-radius);
    max-width: 800px;
    width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(45, 190, 193, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: var(--transition);
    font-size: 1.1rem;
    color: var(--text-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-close:hover {
    background: var(--primary-teal);
    color: white;
    border-color: var(--primary-teal);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(45, 190, 193, 0.3);
}

.modal-body {
    padding: 3.5rem 2.5rem 2.5rem 2.5rem; /* Reduced top padding since close button is smaller and higher */
}

.modal-header {
    margin-bottom: 2rem;
    padding-right: 4rem; /* Increased padding to give more space for close button */
}

.modal-header h1 {
    font-family: 'Cormorant', serif;
    font-size: 2.5rem;
    margin: 0 0 1.5rem 0;
    color: var(--text-dark);
    line-height: 1.2;
    order: 1; /* Ensure title comes first */
}

.modal-header .article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0;
    border: none;
    margin: 0;
    order: 2; /* Meta comes after title */
    max-width: calc(100% - 1rem); /* Ensure meta doesn't get too close to close button */
}

.modal-header .article-meta > * {
    margin: 0;
    padding: 0.4rem 0.8rem;
    background: var(--secondary-beige);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-medium);
    font-weight: 500;
    white-space: nowrap;
}

.modal-header .article-category {
    background: var(--primary-teal);
    color: white;
    font-weight: 600;
}

.modal-header .article-read-time {
    background: rgba(149, 169, 156, 0.2);
    color: var(--accent-sage);
}

.modal-header .article-date {
    background: rgba(255, 107, 107, 0.1);
    color: var(--accent-coral);
}

.modal-header .article-author {
    background: var(--background-cream);
    color: var(--text-dark);
    font-style: italic;
}

.modal-image {
    margin-bottom: 2rem;
}

.modal-image img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.modal-content-text {
    line-height: 1.8;
}

.modal-content-text p {
    margin-bottom: 1.5rem;
    color: var(--text-medium);
}

.modal-content-text h2, .modal-content-text h3 {
    font-family: 'Cormorant', serif;
    color: var(--text-dark);
    margin: 2rem 0 1rem;
}

.modal-content-text h2 {
    font-size: 2rem;
}

.modal-content-text h3 {
    font-size: 1.6rem;
}

.modal-body p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    color: var(--text-medium);
}

.modal-body h2, .modal-body h3 {
    font-family: 'Cormorant', serif;
    color: var(--text-dark);
    margin: 2rem 0 1rem;
}

.modal-body h2 {
    font-size: 2rem;
}

.modal-body h3 {
    font-size: 1.6rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .journal-hero {
        min-height: 35vh;
        margin-top: 60px;
    }
    
    .journal-hero__content {
        padding: 15px;
    }
    
    .floating-wave-book {
        font-size: 1rem;
    }
    
    .book-wave-1, .book-wave-5 {
        font-size: 1.2rem;
    }
    
    .book-wave-8 {
        font-size: 1.3rem;
    }
    
    .wave-path {
        transform: scale(0.8);
    }
    
    .journal-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Mobile single item improvements */
    .journal-grid.single-item .journal-article.featured {
        max-width: 100%;
    }
    
    .journal-grid.single-item .journal-article:not(.featured) {
        max-width: 100%;
    }
    
    .journal-article.featured {
        grid-template-columns: 1fr;
    }
    
    .journal-article.featured .article-image {
        height: 250px;
    }
    
    .journal-article.featured .article-content {
        padding: 2rem;
    }
    
    .journal-article.featured .article-title {
        font-size: 2rem;
    }
    
    .filter-nav {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .form-group {
        flex-direction: column;
    }
    
    .newsletter-btn {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
    }
    
    .modal-body {
        padding: 3.5rem 1.5rem 2rem 1.5rem; /* Better mobile padding */
    }
    
    .modal-header {
        padding-right: 2.5rem; /* Less padding on mobile */
    }
    
    .modal-header h1 {
        font-size: 2rem;
    }
    
    .modal-header .article-meta {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.4rem;
    }
    
    .modal-header .article-meta > * {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    
    .modal-image img {
        height: 250px; /* Smaller on mobile */
    }
    
    .modal-close {
        width: 35px;
        height: 35px;
        top: 0.75rem;
        right: 0.75rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .journal-hero__content {
        padding: 20px 15px;
    }
    
    .article-content {
        padding: 1.5rem;
    }
    
    .journal-article.featured .article-content {
        padding: 1.5rem;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wave::before {
        animation: none;
    }
}

/* Focus states for keyboard navigation */
.filter-btn:focus,
.load-more-btn:focus,
.modal-close:focus {
    outline: 2px solid var(--primary-teal);
    outline-offset: 2px;
}

.journal-article:focus {
    outline: 2px solid var(--primary-teal);
    outline-offset: 4px;
}

/* Modal responsive improvements */
@media (max-width: 768px) {
    .modal-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 3rem 1.5rem 1.5rem 1.5rem;
    }
    
    .modal-header {
        padding-right: 3.5rem;
    }
    
    .modal-header .article-meta {
        max-width: calc(100% - 0.5rem);
    }
}
