/* ==========================================================================
   OJS 3.5 Health Sciences Theme Custom Layout - Borderless Grid
   ========================================================================== */

/* 1. Expand Content Wrapper to Full Width */
.page-site .col-md-8 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

/* 2. Responsive Grid System (1 Column Mobile, 4 Columns Desktop) */
.site-journals-list {
    display: grid !important;
    grid-template-columns: repeat(1, 1fr) !important; /* 1 columns on Mobile */
    gap: 20px 20px !important; /* REDUCED to 20px vertical gap, 20px horizontal gap */
    align-items: flex-start; /* Aligns items to the top without stretching heights */
    padding: 0 !important;
}

@media (min-width: 992px) {
    .site-journals-list {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 columns on Desktop */
        gap: 20px 30px !important; /* REDUCED to 20px vertical gap, 30px horizontal gap */
    }
}

/* 3. Borderless Journal Items (Side-by-Side Layout) */
.site-journal {
    display: flex !important;
    flex-direction: row !important; 
    align-items: flex-start; 
    gap: 15px; 
    height: 100%;
    margin-bottom: 0 !important; /* THIS FIXES THE VERTICAL SPACING ISSUE */
    background-color: transparent !important; 
    border: none !important; 
    padding: 0 !important; 
    box-shadow: none !important; 
}

/* 4. Journal Thumbnail */
/* Base setting for mobile */
.site-journal-img {
    display: block !important; /* Forces the link container to wrap the image properly */
    flex: 0 0 25%; 
    max-width: 25%;
    margin-bottom: 0 !important; 
}

.site-journal-img img {
    width: 100%; 
    height: auto !important; 
    aspect-ratio: 1 / 1.4; /* This forces a tall, portrait aspect ratio (standard journal size) */
    object-fit: cover; 
    border-radius: 4px; 
    box-shadow: 0 3px 8px rgba(0,0,0,0.1); 
}

/* Desktop override */
@media (min-width: 992px) {
    .site-journal-img {
        flex: 0 0 35% !important; /* Gives the image almost half the card width on desktop */
        max-width: 35% !important;
    }
    
    .site-journal-img img {
        min-height: 200px !important; /* Absolutely forces the height on desktop */
    }
}

/* 5. Journal Text Formatting (3/4 Width on the right) */
.site-journal-body {
    flex: 1; /* Takes the remaining 75% of the space */ 
    display: flex; 
    flex-direction: column; 
    padding: 0 !important; 
    min-width: 0; /* Prevents text from pushing past the container */ 
    
    /* Applies a modern, highly legible system font stack */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Journal Title Upgrades */
.site-journal-title {
    font-size: 1.35rem; /* Made the title significantly bigger */
    font-weight: 700; /* Makes the title bold */
    line-height: 1.3; /* Slightly increased line spacing */
    margin-top: 0; 
    margin-bottom: 10px;
}

/* The Animated Underline Effect for the Title Link */
.site-journal-title a {
    color: #1a202c; /* Strong, dark text color */
    text-decoration: none !important; /* Removes the ugly default browser underline */
    
    /* Creates the custom underline */
    background-image: linear-gradient(#0275d8, #0275d8); /* Uses your theme's blue color */
    background-position: 0% 100%; /* Positions it at the bottom left */
    background-repeat: no-repeat;
    background-size: 100% 2px; /* 100% width, 2px thickness */
    
    /* Controls the smooth sliding animation */
    transition: background-size 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), color 0.3s ease;
}

/* How the underline behaves on hover and click */
.site-journal-title a:hover, 
.site-journal-title a:active,
.site-journal-title a:focus {
    background-size: 0% 2px; /* Shrinks the underline down to 0% */
    background-position: 100% 100%; /* Forces it to slide out to the right */
    color: #0275d8; /* Changes the text color to blue on hover */
    outline: none;
}

/* Journal Description Upgrades */
.site-journal-description {
    display: -webkit-box; 
    -webkit-line-clamp: 6; /* Limits description to 6 lines */ 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-bottom: 15px; 
    color: #4a5568; 
    font-size: 0.95rem; /* Increased font size slightly */
    line-height: 1.65; /* Increased line space drastically for better readability */
}

.site-journal-description p {
    display: inline; 
    margin: 0; 
}

/* 6. Align Action Buttons (Horizontal 50/50 Split) */
.site-journal .links {
    margin-top: auto; 
    display: grid !important;
    grid-template-columns: 1fr 1fr; /* Creates two equal-width columns */
    gap: 10px; /* Space between the two buttons */
    width: 100%;
}

.site-journal .links .btn {
    width: 100%;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.85rem;
    white-space: normal; /* Ensures text wraps neatly if the screen is narrow */
}

/* ==========================================================================
   7. Premium Hero Banner (Site About Section)
   ========================================================================== */

/* Base setting for mobile: Tighter spacing so it doesn't feel empty */
.page-content {
    background: transparent !important; 
    border: none !important; 
    box-shadow: none !important; 
    padding: 30px 0 20px 0 !important; /* Drastically reduced bottom padding for mobile */
    margin-bottom: 10px !important; /* Reduced bottom margin */
    text-align: center; 
}

/* Desktop override: Restores the massive whitespace for large screens */
@media (min-width: 768px) {
    .page-content {
        padding: 40px 0 60px 0 !important; /* Brings back the 60px bottom padding */
        margin-bottom: 20px !important; 
    }
}

/* Remove default OJS borders and margins */
.site-about {
    border-bottom: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Add a professional blue accent line above the text (Desktop Only) */
/* Base setting for mobile: Hides the line completely */
.site-about::before {
    content: '';
    display: none !important; 
    width: 80px;
    height: 4px;
    background-color: #0275d8; /* Uses your theme's blue */
    margin: 0 auto 30px auto;
    border-radius: 2px;
}

/* Desktop override: Brings the line back for wider screens */
@media (min-width: 768px) {
    .site-about::before {
        display: block !important;
    }
}

/* Transform the typography to look like Nature/Science */
/* Base setting for mobile */
.site-about p {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.2rem !important; /* Smaller, readable size for mobile phones */
    font-weight: 300 !important; /* Light, elegant font weight */
    line-height: 1.6 !important; 
    color: #2d3748 !important; /* Deep, sophisticated grey-blue */
    margin: 0 auto !important;
    max-width: 900px; /* Keeps the text from stretching too wide on massive screens */
    
    /* Overrides the previous clamp/truncation so the text fully displays */
    display: block !important;
    overflow: visible !important;
    -webkit-line-clamp: unset !important;
}

/* Desktop override: Scales the text back up for larger screens */
@media (min-width: 768px) {
    .site-about p {
        font-size: 1.6rem !important; /* The massive, confident text size for desktop */
        line-height: 1.7 !important; /* Slightly increased line height for the larger text */
    }
}

/* 8. Hide OJS / PKP Footer Brand Logo */
.site-footer .footer-brand-image,
.site-footer .col-md-2[role="complementary"] {
    display: none !important;
}

/* 9. White Background for Footer and Text Color Adjustments */
.site-footer {
    background-color: #ffffff !important;
    color: #333333 !important;
}

/* 10. Container-width border above the footer widgets */
.site-footer .site-footer-sidebar {
    border-top: 1px solid #e2e8f0 !important;
    padding-top: 30px !important; /* Adds some breathing room between the line and 'About science' */
    margin-top: 20px !important; 
}

/* Ensure headings in the footer are dark */
.site-footer h2,
.site-footer .title {
    color: #222222 !important;
}

/* Ensure all paragraphs, bold text, and general content are dark */
.site-footer p,
.site-footer strong,
.site-footer em,
.site-footer .content {
    color: #4a5568 !important;
}

/* Update link colors in the footer so they are visible */
.site-footer a {
    color: #0275d8 !important;
}

.site-footer a:hover {
    color: #014c8c !important;
    text-decoration: underline;
}

/* Add a separating line above the copyright section in the footer */
.site-footer > .site-footer-content {
    border-top: 1px solid #e2e8f0 !important;
    padding-top: 25px !important; /* Adds breathing room below the line */
    margin-top: 20px !important;  /* Adds breathing room above the line */
}

/* ==========================================================================
   11. Custom 4-Column Footer (Bootstrap Override Method)
   ========================================================================== */

/* 1. Target the exact Bootstrap column holding your text and remove its restrictions */
.site-footer > .container.site-footer-content > .row > .col-md.site-footer-content {
    display: block !important; 
    align-self: flex-start !important; /* CRITICAL: Removes Bootstrap's vertical centering */
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

/* 2. Apply the multi-column layout on Desktop */
@media (min-width: 992px) {
    .site-footer > .container.site-footer-content > .row > .col-md.site-footer-content {
        column-count: 4 !important;
        column-gap: 40px !important;
    }
}

/* 3. Stop content from breaking/slicing awkwardly across columns */
.site-footer > .container.site-footer-content > .row > .col-md.site-footer-content > * {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
}

/* 4. Style the text, headings, and links */
.site-footer-content strong {
    display: block;
    font-size: 1.05rem;
    color: #222222 !important;
    margin-bottom: 8px;
    break-after: avoid !important; /* Prevents the heading from separating from its list */
}

.site-footer-content ul {
    list-style: none !important;
    padding: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 25px !important;
}

.site-footer-content ul li {
    margin-bottom: 10px;
}

.site-footer-content ul li a {
    color: #4a5568 !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-footer-content ul li a:hover {
    color: #0275d8 !important; 
    text-decoration: underline;
}

/* ==========================================================================
   12. Custom Announcement Feature Card (Above Grid)
   ========================================================================== */

/* The main container for the announcement */
.custom-announcement-card {
    display: flex;
    flex-direction: column; /* Stacks image on top of text for mobile */
    background-color: #f8fafc; /* A very soft, professional blue/gray tint */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 30px;
    margin-bottom: 40px; /* Space between the announcement and the journal grid */
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease;
}

.custom-announcement-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

/* Desktop override: Places text on left, image on right */
@media (min-width: 768px) {
    .custom-announcement-card {
        flex-direction: row; /* Side-by-side layout */
        align-items: stretch;
    }
}

/* The text section of the announcement */
.announcement-content {
    flex: 1; /* Takes up the remaining space on the left */
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

/* The little 'Latest News' badge */
.announcement-badge {
    background-color: #0275d8;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 15px;
}

/* Typography for the announcement */
.announcement-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-top: 0;
    margin-bottom: 12px;
    line-height: 1.3;
}

.announcement-text {
    font-size: 0.95rem;
    color: #4a5568;
    margin-bottom: 25px;
    line-height: 1.6;
}

/* Ensure the button doesn't stretch */
.announcement-btn {
    margin-top: auto;
    padding: 8px 20px;
    font-weight: 600;
}

/* The image section on the right */
.announcement-image {
    flex: 0 0 100%; /* Full width on mobile */
}

@media (min-width: 768px) {
    .announcement-image {
        flex: 0 0 40%; /* Image takes up exactly 40% of the card on desktop */
        max-width: 40%;
    }
}

/* Forces the image to fill its container beautifully without distorting */
.announcement-image img {
    width: 100%;
    height: 100%;
    min-height: 250px;
    object-fit: cover;
    display: block;
}

/* ==========================================================================
   13. Aggressive Bottom Spacing Removal (Grid to Footer)
   ========================================================================== */

/* 1. Target the global OJS page wrappers */
.pkp_structure_main,
.page-site,
.page {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* 2. Target the Bootstrap rows and columns holding the grid */
.page-site > .row,
.page-site .col-md-8 {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* 3. Ensure the grid container itself has no trailing space */
.site-journals {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* 4. Remove any hidden top margin from the main footer block */
.site-footer {
    margin-top: 0 !important;
}